Skip to content

Commit

Permalink
Codeoptimierungen Spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
Nic12345678 committed Jul 12, 2024
1 parent 7f6ba66 commit 2b26d3a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class WahltagRepositoryTest {
private WahltagRepository repository;

@AfterEach
void tearDown() throws Exception {
void tearDown() {
repository.deleteAll();
}

Expand Down Expand Up @@ -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);
}
Expand All @@ -83,7 +83,6 @@ private List<Wahltag> 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<Wahltag> myModifiableList = Arrays.asList(wahltag4, wahltag1, wahltag3, wahltag2);
return myModifiableList;
return Arrays.asList(wahltag4, wahltag1, wahltag3, wahltag2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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))));
Expand All @@ -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))));
Expand All @@ -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");
Expand All @@ -152,12 +152,12 @@ void loadFromRemoteFirstAndThanUpdateRepository() throws Exception {
val expectedResponseBody_1 = dtoMapper.fromListOfWahltagModelToListOfWahltagDTO(
modelMapper.fromWahltagEntityToWahltagModelList((List<Wahltag>) 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);

Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -66,18 +65,14 @@ private List<Wahltag> 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<WahltagModel> createWahltagModelList() {
val wahltag1 = new WahltagModel("identifikatorWahltag1", LocalDate.now().minusMonths(2), "beschreibungWahltag1", "nummerWahltag1");
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,15 @@ private List<Wahltag> 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<WahltagModel> createWahltagModelList(String pIndex) {
val wahltag1 = new WahltagModel(pIndex + "_identifikatorWahltag1", LocalDate.now().minusMonths(2), "beschreibungWahltag1", "nummerWahltag1");
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);
}
}
}

0 comments on commit 2b26d3a

Please sign in to comment.