From 2b26d3a4806996cd7a2675a19ec4421bd8b027a4 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Fri, 12 Jul 2024 18:17:11 +0200 Subject: [PATCH] Codeoptimierungen Spotless --- .../domain/WahltagRepositoryTest.java | 9 ++++----- .../wahltage/WahltageControllerIntegrationTest.java | 13 ++++++------- .../services/wahltag/WahltagModelMapperTest.java | 9 ++------- .../services/wahltag/WahltageServiceTest.java | 8 ++------ 4 files changed, 14 insertions(+), 25 deletions(-) diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/WahltagRepositoryTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/WahltagRepositoryTest.java index a6e19c9eb..5fd114d4d 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/WahltagRepositoryTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/WahltagRepositoryTest.java @@ -32,7 +32,7 @@ class WahltagRepositoryTest { private WahltagRepository repository; @AfterEach - void tearDown() throws Exception { + void tearDown() { repository.deleteAll(); } @@ -71,8 +71,8 @@ void findAllByOrderByWahltagAsc() { wahltageToSave.sort( Comparator - .comparing((Wahltag w) -> w.getWahltag()) - .thenComparing((Wahltag w) -> w.getWahltag())); + .comparing(Wahltag::getWahltag) + .thenComparing(Wahltag::getWahltag)); Assertions.assertThat(wahltageToSave).isEqualTo(foundWahltage); } @@ -83,7 +83,6 @@ private List createWahltagList(String pIndex) { val wahltag3 = new Wahltag(pIndex + "_identifikatorWahltag3", LocalDate.now().plusMonths(1), "beschreibungWahltag3", "nummerWahltag3"); val wahltag2 = new Wahltag(pIndex + "_identifikatorWahltag2", LocalDate.now().minusMonths(1), "beschreibungWahltag2", "nummerWahltag2"); - List myModifiableList = Arrays.asList(wahltag4, wahltag1, wahltag3, wahltag2); - return myModifiableList; + return Arrays.asList(wahltag4, wahltag1, wahltag3, wahltag2); } } diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageControllerIntegrationTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageControllerIntegrationTest.java index 9933490d3..4f786d365 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageControllerIntegrationTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageControllerIntegrationTest.java @@ -92,7 +92,7 @@ void loadedFromExternal() throws Exception { String requestDate = LocalDate.now().minusMonths(3).toString(); - val eaiWahltage = createClientWahltageDTO(LocalDate.now().minusMonths(3), false); + val eaiWahltage = createClientWahltageDTO(false); WireMock.stubFor(WireMock.get("/wahldaten/wahltage?includingSince=" + requestDate) .willReturn(WireMock.aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()) .withBody(objectMapper.writeValueAsBytes(eaiWahltage)))); @@ -115,7 +115,7 @@ void externalDataIsPersisted() throws Exception { String requestDate = LocalDate.now().minusMonths(3).toString(); - val eaiWahltage = createClientWahltageDTO(LocalDate.now().minusMonths(3), false); + val eaiWahltage = createClientWahltageDTO(false); WireMock.stubFor(WireMock.get("/wahldaten/wahltage?includingSince=" + requestDate) .willReturn(WireMock.aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()) .withBody(objectMapper.writeValueAsBytes(eaiWahltage)))); @@ -138,7 +138,7 @@ void externalDataIsPersisted() throws Exception { void loadFromRemoteFirstAndThanUpdateRepository() throws Exception { val entitiesToFindInRepository = modelMapper .fromWahltagModelToWahltagEntityList(wahltageClientMapper - .fromRemoteClientWahltageDTOtoListOfWahltagModel(createClientWahltageDTO(LocalDate.now().minusMonths(3), true))); + .fromRemoteClientWahltageDTOtoListOfWahltagModel(createClientWahltageDTO(true))); val savedEntitiesInRepository_1 = wahltagRepository.saveAll(entitiesToFindInRepository); val request = MockMvcRequestBuilders.get("/businessActions/wahltage"); @@ -152,12 +152,12 @@ void loadFromRemoteFirstAndThanUpdateRepository() throws Exception { val expectedResponseBody_1 = dtoMapper.fromListOfWahltagModelToListOfWahltagDTO( modelMapper.fromWahltagEntityToWahltagModelList((List) savedEntitiesInRepository_1)); - Assertions.assertThat(new ArrayList(Arrays.asList(responseBodyAsListOfDTOs))) + Assertions.assertThat(new ArrayList<>(Arrays.asList(responseBodyAsListOfDTOs))) .usingRecursiveComparison().ignoringCollectionOrder() .ignoringFields("beschreibung") .isEqualTo(expectedResponseBody_1); - Assertions.assertThat(new ArrayList(Arrays.asList(responseBodyAsListOfDTOs))) + Assertions.assertThat(new ArrayList<>(Arrays.asList(responseBodyAsListOfDTOs))) .usingRecursiveComparison().ignoringCollectionOrder() .isNotEqualTo(expectedResponseBody_1); @@ -187,8 +187,7 @@ void technischeWlsExceptionWhenNoExternalDataFound() throws Exception { } } - private de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO createClientWahltageDTO(LocalDate sinceTag, - boolean differentAsInDummyClient) { + private de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO createClientWahltageDTO(boolean differentAsInDummyClient) { val clientWahltageDTO = new de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO(); diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModelMapperTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModelMapperTest.java index cc6243ad0..9b76730f1 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModelMapperTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModelMapperTest.java @@ -1,6 +1,5 @@ package de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag; -import static org.junit.jupiter.api.Assertions.*; import de.muenchen.oss.wahllokalsystem.basisdatenservice.domain.Wahltag; import java.time.LocalDate; import java.util.List; @@ -66,9 +65,7 @@ private List createWahltagList() { val wahltag2 = new Wahltag("identifikatorWahltag2", LocalDate.now().minusMonths(1), "beschreibungWahltag2", "nummerWahltag2"); val wahltag3 = new Wahltag("identifikatorWahltag3", LocalDate.now().plusMonths(1), "beschreibungWahltag3", "nummerWahltag3"); - val wahltagEntities = List.of(wahltag1, wahltag2, wahltag3); - - return wahltagEntities; + return List.of(wahltag1, wahltag2, wahltag3); } private List createWahltagModelList() { @@ -76,8 +73,6 @@ private List createWahltagModelList() { val wahltag2 = new WahltagModel("identifikatorWahltag2", LocalDate.now().minusMonths(1), "beschreibungWahltag2", "nummerWahltag2"); val wahltag3 = new WahltagModel("identifikatorWahltag3", LocalDate.now().plusMonths(1), "beschreibungWahltag3", "nummerWahltag3"); - val wahltagModels = List.of(wahltag1, wahltag2, wahltag3); - - return wahltagModels; + return List.of(wahltag1, wahltag2, wahltag3); } } diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageServiceTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageServiceTest.java index eb280b87d..dec8f060b 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageServiceTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageServiceTest.java @@ -53,9 +53,7 @@ private List createWahltagList(String pIndex) { val wahltag2 = new Wahltag(pIndex + "_identifikatorWahltag2", LocalDate.now().minusMonths(1), "beschreibungWahltag2", "nummerWahltag2"); val wahltag3 = new Wahltag(pIndex + "_identifikatorWahltag3", LocalDate.now().plusMonths(1), "beschreibungWahltag3", "nummerWahltag3"); - val wahltagEntities = List.of(wahltag1, wahltag2, wahltag3); - - return wahltagEntities; + return List.of(wahltag1, wahltag2, wahltag3); } private List createWahltagModelList(String pIndex) { @@ -63,9 +61,7 @@ private List createWahltagModelList(String pIndex) { val wahltag2 = new WahltagModel(pIndex + "_identifikatorWahltag2", LocalDate.now().minusMonths(1), "beschreibungWahltag2", "nummerWahltag2"); val wahltag3 = new WahltagModel(pIndex + "_identifikatorWahltag3", LocalDate.now().plusMonths(1), "beschreibungWahltag3", "nummerWahltag3"); - val wahltagModels = List.of(wahltag1, wahltag2, wahltag3); - - return wahltagModels; + return List.of(wahltag1, wahltag2, wahltag3); } } }