Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Test
- public void testGetShiftForClockinBefore () {
- ScheduleManager manager = new ScheduleManager(getShifts());
- Calendar cal = getCal(2018, 10, 1, 9, 0);
- Schedule sc = manager.getShiftForClockIn(cal.getTime());
- Assert.assertEquals("1", sc.getShiftId());
- }
- @Test
- public void testGetShiftForClockinDuringFirst () {
- ScheduleManager manager = new ScheduleManager(getShifts());
- Calendar cal = getCal(2018, 10, 1, 11, 0);
- Schedule sc = manager.getShiftForClockIn(cal.getTime());
- Assert.assertEquals("1", sc.getShiftId());
- }
- @Test
- public void testGetShiftForClockinStartFirst () {
- ScheduleManager manager = new ScheduleManager(getShifts());
- Calendar cal = getCal(2018, 10, 1, 10, 0);
- Schedule sc = manager.getShiftForClockIn(cal.getTime());
- Assert.assertEquals("1", sc.getShiftId());
- }
- @Test
- public void testGetShiftForClockinEndFirst () {
- ScheduleManager manager = new ScheduleManager(getShifts());
- Calendar cal = getCal(2018, 10, 1, 14, 0);
- Schedule sc = manager.getShiftForClockIn(cal.getTime());
- Assert.assertEquals("1", sc.getShiftId());
- }
- @Test
- public void testGetShiftForClockinBetween () {
- ScheduleManager manager = new ScheduleManager(getShifts());
- Calendar cal = getCal(2018, 10, 1, 14, 30);
- Schedule sc = manager.getShiftForClockIn(cal.getTime());
- Assert.assertEquals("2", sc.getShiftId());
- }
- @Test
- public void testGetShiftForClockinAfterSecond () {
- ScheduleManager manager = new ScheduleManager(getShifts());
- Calendar cal = getCal(2018, 10, 1, 20, 0);
- Schedule sc = manager.getShiftForClockIn(cal.getTime());
- Assert.assertEquals("2", sc.getShiftId());
- }
- @Test
- public void testCanClockinNoShiftAllowed () {
- PolicyManager policyManager = new PolicyManager(getConfig(true, true, 15, true, 15));
- Calendar cal = getCal(2018, 10, 1, 20, 0);
- ClockInRestrictionReason reason = policyManager.canClockIn(null, cal.getTime());
- Assert.assertEquals(ClockInRestrictionReason.None, reason);
- }
- @Test
- public void testCanClockinNoShiftNotAllowed () {
- PolicyManager policyManager = new PolicyManager(getConfig(false, true, 15, true, 15));
- Calendar cal = getCal(2018, 10, 1, 20, 0);
- ClockInRestrictionReason reason = policyManager.canClockIn(null, cal.getTime());
- Assert.assertEquals(ClockInRestrictionReason.NoShift, reason);
- }
- @Test
- public void testCanClockinTooEearlyAllowed () {
- PolicyManager policyManager = new PolicyManager(getConfig(true, true, 15, true, 15));
- Calendar cal = getCal(2018, 10, 1, 9, 25);
- ClockInRestrictionReason reason = policyManager.canClockIn(getShift("1", 2018, 10, 1, 10, 0, 60 * 4), cal.getTime());
- Assert.assertEquals(ClockInRestrictionReason.None, reason);
- }
- @Test
- public void testCanClockinTooEearlyBoundryNotAllowed () {
- PolicyManager policyManager = new PolicyManager(getConfig(true, false, 15, true, 15));
- Calendar cal = getCal(2018, 10, 1, 9, 45);
- ClockInRestrictionReason reason = policyManager.canClockIn(getShift("1", 2018, 10, 1, 10, 0, 60 * 4), cal.getTime());
- Assert.assertEquals(ClockInRestrictionReason.None, reason);
- }
- @Test
- public void testCanClockinTooEearlyNotAllowed () {
- PolicyManager policyManager = new PolicyManager(getConfig(true, false, 15, true, 15));
- Calendar cal = getCal(2018, 10, 1, 9, 40);
- ClockInRestrictionReason reason = policyManager.canClockIn(getShift("1", 2018, 10, 1, 10, 0, 60 * 4), cal.getTime());
- Assert.assertEquals(ClockInRestrictionReason.TooEarly, reason);
- }
- @Test
- public void testCanClockinTooLateAllowed () {
- PolicyManager policyManager = new PolicyManager(getConfig(true, true, 15, true, 15));
- Calendar cal = getCal(2018, 10, 1, 10, 35);
- ClockInRestrictionReason reason = policyManager.canClockIn(getShift("1", 2018, 10, 1, 10, 0, 60 * 4), cal.getTime());
- Assert.assertEquals(ClockInRestrictionReason.None, reason);
- }
- @Test
- public void testCanClockinTooLateBoundryNotAllowed () {
- PolicyManager policyManager = new PolicyManager(getConfig(true, true, 15, false, 15));
- Calendar cal = getCal(2018, 10, 1, 10, 15);
- ClockInRestrictionReason reason = policyManager.canClockIn(getShift("1", 2018, 10, 1, 10, 0, 60 * 4), cal.getTime());
- Assert.assertEquals(ClockInRestrictionReason.None, reason);
- }
- @Test
- public void testCanClockinTooLateNotAllowed () {
- PolicyManager policyManager = new PolicyManager(getConfig(true, true, 15, false, 15));
- Calendar cal = getCal(2018, 10, 1, 10, 20);
- ClockInRestrictionReason reason = policyManager.canClockIn(getShift("1", 2018, 10, 1, 10, 0, 60 * 4), cal.getTime());
- Assert.assertEquals(ClockInRestrictionReason.TooLate, reason);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement