Added current config getter

This commit is contained in:
Filip Izydorczyk 2020-12-12 13:33:11 +01:00
parent 5a1108e1bf
commit e02523b4f4
2 changed files with 18 additions and 6 deletions

View File

@ -5,13 +5,10 @@ import com.plannaplan.models.FileData;
import com.plannaplan.repositories.AppConfigRepository; import com.plannaplan.repositories.AppConfigRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.security.DrbgParameters.Reseed;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.stream.Collector;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.plannaplan.configutils.*; import com.plannaplan.configutils.*;
@ -34,7 +31,7 @@ public class ConfiguratorService {
/** /**
* methoid to config system * methoid to config system
* *
* @param data ConfigData containng system congis * @param data ConfigData containng system configs
*/ */
public void config(ConfigData data) { public void config(ConfigData data) {
FileReader reader = new FileReader(data.getFilestream()); FileReader reader = new FileReader(data.getFilestream());

View File

@ -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.request.MockMvcRequestBuilders.multipart;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; 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 static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.*;
import java.io.InputStream; import java.io.InputStream;
import java.sql.Date;
import com.plannaplan.entities.AppConfig;
import com.plannaplan.entities.User; import com.plannaplan.entities.User;
import com.plannaplan.services.ConfiguratorService;
import com.plannaplan.services.UserService; import com.plannaplan.services.UserService;
import com.plannaplan.types.UserRoles; import com.plannaplan.types.UserRoles;
@ -36,6 +39,8 @@ public class ConfigControllerTest extends AbstractControllerTest {
@Autowired @Autowired
private UserService service; private UserService service;
@Autowired
private ConfiguratorService configService;
@Test @Test
public void shouldReturnNoAuthorized() throws Exception { 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(FIRST_TOUR_END, "14.12.2020").param(SECOND_TOUR_START, "16.12.2020")
.param(SECOND_TOUR_END, "20.12.2020").header("Authorization", "Bearer " + token)) .param(SECOND_TOUR_END, "20.12.2020").header("Authorization", "Bearer " + token))
.andExpect(status().isOk()); .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 @Test