Advertisement
Guest User

Tests

a guest
Nov 21st, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.04 KB | None | 0 0
  1.     @Test
  2.     public void testGetShiftForClockinBefore () {
  3.         ScheduleManager manager = new ScheduleManager(getShifts());
  4.         Calendar cal = getCal(2018, 10, 1, 9, 0);
  5.         Schedule sc = manager.getShiftForClockIn(cal.getTime());
  6.         Assert.assertEquals("1", sc.getShiftId());
  7.     }
  8.  
  9.     @Test
  10.     public void testGetShiftForClockinDuringFirst () {
  11.         ScheduleManager manager = new ScheduleManager(getShifts());
  12.         Calendar cal = getCal(2018, 10, 1, 11, 0);
  13.         Schedule sc = manager.getShiftForClockIn(cal.getTime());
  14.         Assert.assertEquals("1", sc.getShiftId());
  15.     }
  16.  
  17.     @Test
  18.     public void testGetShiftForClockinStartFirst () {
  19.         ScheduleManager manager = new ScheduleManager(getShifts());
  20.         Calendar cal = getCal(2018, 10, 1, 10, 0);
  21.         Schedule sc = manager.getShiftForClockIn(cal.getTime());
  22.         Assert.assertEquals("1", sc.getShiftId());
  23.     }
  24.  
  25.     @Test
  26.     public void testGetShiftForClockinEndFirst () {
  27.         ScheduleManager manager = new ScheduleManager(getShifts());
  28.         Calendar cal = getCal(2018, 10, 1, 14, 0);
  29.         Schedule sc = manager.getShiftForClockIn(cal.getTime());
  30.         Assert.assertEquals("1", sc.getShiftId());
  31.     }
  32.  
  33.     @Test
  34.     public void testGetShiftForClockinBetween () {
  35.         ScheduleManager manager = new ScheduleManager(getShifts());
  36.         Calendar cal = getCal(2018, 10, 1, 14, 30);
  37.         Schedule sc = manager.getShiftForClockIn(cal.getTime());
  38.         Assert.assertEquals("2", sc.getShiftId());
  39.     }
  40.  
  41.     @Test
  42.     public void testGetShiftForClockinAfterSecond () {
  43.         ScheduleManager manager = new ScheduleManager(getShifts());
  44.         Calendar cal = getCal(2018, 10, 1, 20, 0);
  45.         Schedule sc = manager.getShiftForClockIn(cal.getTime());
  46.         Assert.assertEquals("2", sc.getShiftId());
  47.     }
  48.  
  49.     @Test
  50.     public void testCanClockinNoShiftAllowed () {
  51.         PolicyManager policyManager = new PolicyManager(getConfig(true, true, 15, true, 15));
  52.         Calendar cal = getCal(2018, 10, 1, 20, 0);
  53.         ClockInRestrictionReason reason = policyManager.canClockIn(null, cal.getTime());
  54.         Assert.assertEquals(ClockInRestrictionReason.None, reason);
  55.     }
  56.  
  57.     @Test
  58.     public void testCanClockinNoShiftNotAllowed () {
  59.         PolicyManager policyManager = new PolicyManager(getConfig(false, true, 15, true, 15));
  60.         Calendar cal = getCal(2018, 10, 1, 20, 0);
  61.         ClockInRestrictionReason reason = policyManager.canClockIn(null, cal.getTime());
  62.         Assert.assertEquals(ClockInRestrictionReason.NoShift, reason);
  63.     }
  64.  
  65.     @Test
  66.     public void testCanClockinTooEearlyAllowed () {
  67.         PolicyManager policyManager = new PolicyManager(getConfig(true, true, 15, true, 15));
  68.         Calendar cal = getCal(2018, 10, 1, 9, 25);
  69.         ClockInRestrictionReason reason = policyManager.canClockIn(getShift("1", 2018, 10, 1, 10, 0, 60 * 4), cal.getTime());
  70.         Assert.assertEquals(ClockInRestrictionReason.None, reason);
  71.     }
  72.  
  73.     @Test
  74.     public void testCanClockinTooEearlyBoundryNotAllowed () {
  75.         PolicyManager policyManager = new PolicyManager(getConfig(true, false, 15, true, 15));
  76.         Calendar cal = getCal(2018, 10, 1, 9, 45);
  77.         ClockInRestrictionReason reason = policyManager.canClockIn(getShift("1", 2018, 10, 1, 10, 0, 60 * 4), cal.getTime());
  78.         Assert.assertEquals(ClockInRestrictionReason.None, reason);
  79.     }
  80.  
  81.     @Test
  82.     public void testCanClockinTooEearlyNotAllowed () {
  83.         PolicyManager policyManager = new PolicyManager(getConfig(true, false, 15, true, 15));
  84.         Calendar cal = getCal(2018, 10, 1, 9, 40);
  85.         ClockInRestrictionReason reason = policyManager.canClockIn(getShift("1", 2018, 10, 1, 10, 0, 60 * 4), cal.getTime());
  86.         Assert.assertEquals(ClockInRestrictionReason.TooEarly, reason);
  87.     }
  88.  
  89.     @Test
  90.     public void testCanClockinTooLateAllowed () {
  91.         PolicyManager policyManager = new PolicyManager(getConfig(true, true, 15, true, 15));
  92.         Calendar cal = getCal(2018, 10, 1, 10, 35);
  93.         ClockInRestrictionReason reason = policyManager.canClockIn(getShift("1", 2018, 10, 1, 10, 0, 60 * 4), cal.getTime());
  94.         Assert.assertEquals(ClockInRestrictionReason.None, reason);
  95.     }
  96.  
  97.     @Test
  98.     public void testCanClockinTooLateBoundryNotAllowed () {
  99.         PolicyManager policyManager = new PolicyManager(getConfig(true, true, 15, false, 15));
  100.         Calendar cal = getCal(2018, 10, 1, 10, 15);
  101.         ClockInRestrictionReason reason = policyManager.canClockIn(getShift("1", 2018, 10, 1, 10, 0, 60 * 4), cal.getTime());
  102.         Assert.assertEquals(ClockInRestrictionReason.None, reason);
  103.     }
  104.  
  105.     @Test
  106.     public void testCanClockinTooLateNotAllowed () {
  107.         PolicyManager policyManager = new PolicyManager(getConfig(true, true, 15, false, 15));
  108.         Calendar cal = getCal(2018, 10, 1, 10, 20);
  109.         ClockInRestrictionReason reason = policyManager.canClockIn(getShift("1", 2018, 10, 1, 10, 0, 60 * 4), cal.getTime());
  110.         Assert.assertEquals(ClockInRestrictionReason.TooLate, reason);
  111.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement