From 98bfcddd3dc78e4e719c713d25be71be887893bf Mon Sep 17 00:00:00 2001 From: larsk21 <57503246+larsk21@users.noreply.github.com> Date: Fri, 17 Jul 2020 18:38:50 +0200 Subject: [PATCH] remove LocalDate.now() from tests --- src/test/java/data/EntryArithmeticTest.java | 18 +++++++------- .../java/data/TimeSheetArithmeticTest.java | 24 ++++++++++--------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/test/java/data/EntryArithmeticTest.java b/src/test/java/data/EntryArithmeticTest.java index 546db52..78b1490 100644 --- a/src/test/java/data/EntryArithmeticTest.java +++ b/src/test/java/data/EntryArithmeticTest.java @@ -8,14 +8,14 @@ public class EntryArithmeticTest { - private static LocalDate DATE_NOW = LocalDate.now(); - + private static final LocalDate DATE = LocalDate.of(2020, 5, 17); + @Test public void testGetWorkingTime1() { TimeSpan start = new TimeSpan(14, 0); TimeSpan end = new TimeSpan(18, 0); TimeSpan pause = new TimeSpan(0, 30); - Entry entry = new Entry("Test", DATE_NOW, start, end, pause, false); + Entry entry = new Entry("Test", DATE, start, end, pause, false); TimeSpan workingTime = entry.getWorkingTime(); assertEquals(workingTime.getHour(), 3); @@ -27,7 +27,7 @@ public void testGetWorkingTime2() { TimeSpan start = new TimeSpan(17, 0); TimeSpan end = new TimeSpan(20, 30); TimeSpan pause = new TimeSpan(0, 0); - Entry entry = new Entry("Test", DATE_NOW, start, end, pause, false); + Entry entry = new Entry("Test", DATE, start, end, pause, false); TimeSpan workingTime = entry.getWorkingTime(); assertEquals(workingTime.getHour(), 3); @@ -39,7 +39,7 @@ public void testGetWorkingTime3() { TimeSpan start = new TimeSpan(12, 30); TimeSpan end = new TimeSpan(21, 0); TimeSpan pause = new TimeSpan(0, 30); - Entry entry = new Entry("Test", DATE_NOW, start, end, pause, false); + Entry entry = new Entry("Test", DATE, start, end, pause, false); TimeSpan workingTime = entry.getWorkingTime(); assertEquals(workingTime.getHour(), 8); @@ -51,7 +51,7 @@ public void testGetWorkingTime4() { TimeSpan start = new TimeSpan(13, 0); TimeSpan end = new TimeSpan(21, 25); TimeSpan pause = new TimeSpan(0, 30); - Entry entry = new Entry("Test", DATE_NOW, start, end, pause, false); + Entry entry = new Entry("Test", DATE, start, end, pause, false); TimeSpan workingTime = entry.getWorkingTime(); assertEquals(workingTime.getHour(), 7); @@ -63,7 +63,7 @@ public void testGetWorkingTime5() { TimeSpan start = new TimeSpan(19, 30); TimeSpan end = new TimeSpan(20, 0); TimeSpan pause = new TimeSpan(0, 0); - Entry entry = new Entry("Test", DATE_NOW, start, end, pause, false); + Entry entry = new Entry("Test", DATE, start, end, pause, false); TimeSpan workingTime = entry.getWorkingTime(); assertEquals(workingTime.getHour(), 0); @@ -75,7 +75,7 @@ public void testGetWorkingTime6() { TimeSpan start = new TimeSpan(13, 0); TimeSpan end = new TimeSpan(23, 0); TimeSpan pause = new TimeSpan(5, 0); - Entry entry = new Entry("Test", DATE_NOW, start, end, pause, false); + Entry entry = new Entry("Test", DATE, start, end, pause, false); TimeSpan workingTime = entry.getWorkingTime(); assertEquals(workingTime.getHour(), 5); @@ -87,7 +87,7 @@ public void testGetWorkingTimeVacation() { TimeSpan start = new TimeSpan(9, 0); TimeSpan end = new TimeSpan(12, 0); TimeSpan pause = new TimeSpan(0, 0); - Entry entry = new Entry("Test", DATE_NOW, start, end, pause, true); + Entry entry = new Entry("Test", DATE, start, end, pause, true); TimeSpan workingTime = entry.getWorkingTime(); assertEquals(workingTime.getHour(), 3); diff --git a/src/test/java/data/TimeSheetArithmeticTest.java b/src/test/java/data/TimeSheetArithmeticTest.java index b8227dd..a091407 100644 --- a/src/test/java/data/TimeSheetArithmeticTest.java +++ b/src/test/java/data/TimeSheetArithmeticTest.java @@ -10,19 +10,21 @@ public class TimeSheetArithmeticTest { + private static final LocalDate DATE = LocalDate.of(2020, 5, 17); + @Test public void testGetTotalWorkTime() { Employee employee = new Employee("Moritz Gstür", 1234567); Profession profession = new Profession("Fakultät für Informatik", WorkingArea.UB, new TimeSpan(40, 0), 10.31); TimeSpan zeroTs = new TimeSpan(0, 0); Entry[] entries = new Entry[7]; - entries[0] = new Entry("Test1", LocalDate.now(), new TimeSpan(10, 0), new TimeSpan(18, 30), new TimeSpan(3, 15), false); - entries[1] = new Entry("Test2", LocalDate.now(), new TimeSpan(12, 0), new TimeSpan(16, 30), new TimeSpan(0, 0), false); - entries[2] = new Entry("Test3", LocalDate.now(), new TimeSpan(10, 0), new TimeSpan(12, 0), new TimeSpan(0, 15), false); - entries[3] = new Entry("Test4", LocalDate.now(), new TimeSpan(15, 0), new TimeSpan(16, 30), new TimeSpan(0, 0), false); - entries[4] = new Entry("Test5", LocalDate.now(), new TimeSpan(20, 0), new TimeSpan(20, 30), new TimeSpan(0, 0), false); - entries[5] = new Entry("Test6", LocalDate.now(), new TimeSpan(9, 30), new TimeSpan(18, 30), new TimeSpan(1, 0), false); - entries[6] = new Entry("Test7", LocalDate.now(), new TimeSpan(9, 0), new TimeSpan(12, 0), new TimeSpan(0, 0), true); + entries[0] = new Entry("Test1", DATE, new TimeSpan(10, 0), new TimeSpan(18, 30), new TimeSpan(3, 15), false); + entries[1] = new Entry("Test2", DATE, new TimeSpan(12, 0), new TimeSpan(16, 30), new TimeSpan(0, 0), false); + entries[2] = new Entry("Test3", DATE, new TimeSpan(10, 0), new TimeSpan(12, 0), new TimeSpan(0, 15), false); + entries[3] = new Entry("Test4", DATE, new TimeSpan(15, 0), new TimeSpan(16, 30), new TimeSpan(0, 0), false); + entries[4] = new Entry("Test5", DATE, new TimeSpan(20, 0), new TimeSpan(20, 30), new TimeSpan(0, 0), false); + entries[5] = new Entry("Test6", DATE, new TimeSpan(9, 30), new TimeSpan(18, 30), new TimeSpan(1, 0), false); + entries[6] = new Entry("Test7", DATE, new TimeSpan(9, 0), new TimeSpan(12, 0), new TimeSpan(0, 0), true); TimeSheet timeSheet = new TimeSheet(employee, profession, YearMonth.of(2019, Month.NOVEMBER), entries, zeroTs, zeroTs); assertEquals(timeSheet.getTotalWorkTime(), new TimeSpan(21, 30)); @@ -34,10 +36,10 @@ public void testGetTotalVacationTime() { Profession profession = new Profession("Fakultät für Informatik", WorkingArea.UB, new TimeSpan(40, 0), 10.31); TimeSpan zeroTs = new TimeSpan(0, 0); Entry[] entries = new Entry[4]; - entries[0] = new Entry("Test1", LocalDate.now(), new TimeSpan(10, 0), new TimeSpan(18, 30), new TimeSpan(3, 15), false); - entries[1] = new Entry("Test2", LocalDate.now(), new TimeSpan(12, 0), new TimeSpan(16, 30), new TimeSpan(0, 0), true); - entries[2] = new Entry("Test3", LocalDate.now(), new TimeSpan(10, 0), new TimeSpan(12, 0), new TimeSpan(0, 0), true); - entries[3] = new Entry("Test4", LocalDate.now(), new TimeSpan(15, 0), new TimeSpan(16, 30), new TimeSpan(0, 0), true); + entries[0] = new Entry("Test1", DATE, new TimeSpan(10, 0), new TimeSpan(18, 30), new TimeSpan(3, 15), false); + entries[1] = new Entry("Test2", DATE, new TimeSpan(12, 0), new TimeSpan(16, 30), new TimeSpan(0, 0), true); + entries[2] = new Entry("Test3", DATE, new TimeSpan(10, 0), new TimeSpan(12, 0), new TimeSpan(0, 0), true); + entries[3] = new Entry("Test4", DATE, new TimeSpan(15, 0), new TimeSpan(16, 30), new TimeSpan(0, 0), true); TimeSheet timeSheet = new TimeSheet(employee, profession, YearMonth.of(2019, Month.NOVEMBER), entries, zeroTs, zeroTs); assertEquals(timeSheet.getTotalVacationTime(), new TimeSpan(8, 0));