From e02523b4f41654aadc37eefda054dff006e1173e Mon Sep 17 00:00:00 2001 From: Filip Izydorczyk Date: Sat, 12 Dec 2020 13:33:11 +0100 Subject: [PATCH] Added current config getter --- .../services/ConfiguratorService.java | 5 +---- .../controllers/ConfigControllerTest.java | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/buisnesslogic/src/main/java/com/plannaplan/services/ConfiguratorService.java b/buisnesslogic/src/main/java/com/plannaplan/services/ConfiguratorService.java index d98a6c5..8f550f4 100755 --- a/buisnesslogic/src/main/java/com/plannaplan/services/ConfiguratorService.java +++ b/buisnesslogic/src/main/java/com/plannaplan/services/ConfiguratorService.java @@ -5,13 +5,10 @@ import com.plannaplan.models.FileData; import com.plannaplan.repositories.AppConfigRepository; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Sort; import org.springframework.stereotype.Component; -import java.security.DrbgParameters.Reseed; import java.util.Comparator; import java.util.List; -import java.util.stream.Collector; import java.util.stream.Collectors; import com.plannaplan.configutils.*; @@ -34,7 +31,7 @@ public class ConfiguratorService { /** * methoid to config system * - * @param data ConfigData containng system congis + * @param data ConfigData containng system configs */ public void config(ConfigData data) { FileReader reader = new FileReader(data.getFilestream()); diff --git a/restservice/src/test/java/com/plannaplan/controllers/ConfigControllerTest.java b/restservice/src/test/java/com/plannaplan/controllers/ConfigControllerTest.java index 517f674..b6a2e95 100755 --- a/restservice/src/test/java/com/plannaplan/controllers/ConfigControllerTest.java +++ b/restservice/src/test/java/com/plannaplan/controllers/ConfigControllerTest.java @@ -2,12 +2,15 @@ package com.plannaplan.controllers; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.multipart; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.*; import java.io.InputStream; +import java.sql.Date; +import com.plannaplan.entities.AppConfig; import com.plannaplan.entities.User; +import com.plannaplan.services.ConfiguratorService; import com.plannaplan.services.UserService; import com.plannaplan.types.UserRoles; @@ -36,6 +39,8 @@ public class ConfigControllerTest extends AbstractControllerTest { @Autowired private UserService service; + @Autowired + private ConfiguratorService configService; @Test public void shouldReturnNoAuthorized() throws Exception { @@ -78,7 +83,17 @@ public class ConfigControllerTest extends AbstractControllerTest { .param(FIRST_TOUR_END, "14.12.2020").param(SECOND_TOUR_START, "16.12.2020") .param(SECOND_TOUR_END, "20.12.2020").header("Authorization", "Bearer " + token)) .andExpect(status().isOk()); - assertFalse(true); + + final AppConfig config = this.configService.getCurrentConfig(); + assertTrue(config.getFirstTourStart().compareTo(Date.valueOf("2020-12-12")) == 0, + "Date in database is wrong. Perhabs database has wrong timezone set."); + assertTrue(config.getFirstTourEnd().compareTo(Date.valueOf("2020-12-14")) == 0, + "Date in database is wrong. Perhabs database has wrong timezone set."); + assertTrue(config.getSecondTourStart().compareTo(Date.valueOf("2020-12-16")) == 0, + "Date in database is wrong. Perhabs database has wrong timezone set."); + assertTrue(config.getSecondTourEnd().compareTo(Date.valueOf("2020-12-20")) == 0, + "Date in database is wrong. Perhabs database has wrong timezone set."); + // yyyy-mm-dd } @Test