From 68100e1ae1d607f849b5a0309340522186a6df49 Mon Sep 17 00:00:00 2001 From: Marcus Fihlon Date: Tue, 26 Mar 2024 16:25:31 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20complete=20refactor=20and?= =?UTF-8?q?=20redesign=20to=20fit=20perfectly=20on=20FullHD=20monitors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcus Fihlon --- .../swiss/fihlon/apus/service/ConferenceService.java | 8 ++++---- .../swiss/fihlon/apus/service/ConferenceServiceTest.java | 9 ++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/swiss/fihlon/apus/service/ConferenceService.java b/src/main/java/swiss/fihlon/apus/service/ConferenceService.java index d3e0c86..af3446e 100644 --- a/src/main/java/swiss/fihlon/apus/service/ConferenceService.java +++ b/src/main/java/swiss/fihlon/apus/service/ConferenceService.java @@ -17,8 +17,6 @@ */ package swiss.fihlon.apus.service; -import org.apache.commons.lang3.RandomStringUtils; -import org.apache.commons.lang3.RandomUtils; import org.springframework.stereotype.Service; import swiss.fihlon.apus.conference.Session; @@ -81,8 +79,7 @@ private List generateSampleData() { LocalDateTime startDate = LocalDateTime.now() .truncatedTo(ChronoUnit.SECONDS) - .withSecond(0) - .minusMinutes(5); + .withSecond(0); while (startDate.getMinute() % 5 != 0) { startDate = startDate.minusMinutes(1); } @@ -98,6 +95,9 @@ private List generateSampleData() { final String title = "Test Session #" + index; final String speaker = "Speaker #" + (counter + 1); sampleData.add(new Session(id, startDate, endDate, room, title, speaker)); + if (sampleData.size() >= sampleDataSize) { + break; + } } startDate = startDate.plusMinutes(sampleDuration); } diff --git a/src/test/java/swiss/fihlon/apus/service/ConferenceServiceTest.java b/src/test/java/swiss/fihlon/apus/service/ConferenceServiceTest.java index d783537..4c7f50a 100644 --- a/src/test/java/swiss/fihlon/apus/service/ConferenceServiceTest.java +++ b/src/test/java/swiss/fihlon/apus/service/ConferenceServiceTest.java @@ -26,8 +26,11 @@ class ConferenceServiceTest { @Test void displaySampleData() { final ConferenceService conferenceService = new ConferenceService(); - assertEquals(5, conferenceService.getRunningSessions().size()); - assertEquals(5, conferenceService.getNextSessions().size()); - assertEquals(90, conferenceService.getFutureSessions().size()); + final var runningSessions = conferenceService.getRunningSessions(); + assertEquals(15, runningSessions.size()); + final var nextSessions = conferenceService.getNextSessions(); + assertEquals(15, nextSessions.size()); + final var futureSessions = conferenceService.getFutureSessions(); + assertEquals(85, futureSessions.size()); } }