From 4f43a9d30658021f412bf3583b646c75ebedad65 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Tue, 9 Jul 2024 18:06:56 +0200 Subject: [PATCH 01/51] getWahltage, first implementation, without Tests --- .../clients/DummyClientImpl.java | 19 ++++++- .../clients/WahltageClientImpl.java | 44 +++++++++++++++ .../clients/WahltageClientMapper.java | 26 +++++++++ ...pl.java => WahlvorschlaegeClientImpl.java} | 2 +- .../basisdatenservice/domain/Wahltag.java | 55 +++++++++++++++++++ .../domain/WahltagRepository.java | 52 ++++++++++++++++++ .../rest/wahltage/WahltagDTO.java | 12 ++++ .../rest/wahltage/WahltageController.java | 44 +++++++++++++++ .../rest/wahltage/WahltageDTOMapper.java | 10 ++++ .../services/wahltag/WahltagModel.java | 14 +++++ .../services/wahltag/WahltagModelMapper.java | 20 +++++++ .../services/wahltag/WahltageClient.java | 20 +++++++ .../services/wahltag/WahltageModel.java | 13 +++++ .../services/wahltag/WahltageService.java | 32 +++++++++++ .../h2/V2_0__createWahltagTable.sql | 10 ++++ .../oracle/V2_0__createWahltagTable.sql | 10 ++++ ...ava => WahlvorschlaegeClientImplTest.java} | 4 +- .../src/test/resources/wahltage.http | 22 ++++++++ 18 files changed, 405 insertions(+), 4 deletions(-) create mode 100644 wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImpl.java create mode 100644 wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapper.java rename wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/{ClientImpl.java => WahlvorschlaegeClientImpl.java} (96%) create mode 100644 wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java create mode 100644 wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/WahltagRepository.java create mode 100644 wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltagDTO.java create mode 100644 wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java create mode 100644 wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageDTOMapper.java create mode 100644 wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModel.java create mode 100644 wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModelMapper.java create mode 100644 wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageClient.java create mode 100644 wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageModel.java create mode 100644 wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageService.java create mode 100644 wls-basisdaten-service/src/main/resources/db/migrations/h2/V2_0__createWahltagTable.sql create mode 100644 wls-basisdaten-service/src/main/resources/db/migrations/oracle/V2_0__createWahltagTable.sql rename wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/{ClientImplTest.java => WahlvorschlaegeClientImplTest.java} (97%) create mode 100644 wls-basisdaten-service/src/test/resources/wahltage.http diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/DummyClientImpl.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/DummyClientImpl.java index 5b2e10b6e..f1230f4ee 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/DummyClientImpl.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/DummyClientImpl.java @@ -1,11 +1,18 @@ package de.muenchen.oss.wahllokalsystem.basisdatenservice.clients; import de.muenchen.oss.wahllokalsystem.basisdatenservice.configuration.Profiles; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.exception.ExceptionConstants; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltagModel; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltageClient; import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahlvorschlag.KandidatModel; import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahlvorschlag.WahlvorschlaegeClient; import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahlvorschlag.WahlvorschlaegeModel; import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahlvorschlag.WahlvorschlagModel; +import de.muenchen.oss.wahllokalsystem.wls.common.exception.WlsException; import de.muenchen.oss.wahllokalsystem.wls.common.security.domain.BezirkUndWahlID; +import java.time.LocalDate; +import java.util.List; import java.util.Set; import java.util.UUID; import org.springframework.context.annotation.Profile; @@ -13,7 +20,7 @@ @Component @Profile(Profiles.DUMMY_CLIENTS) -public class DummyClientImpl implements WahlvorschlaegeClient { +public class DummyClientImpl implements WahlvorschlaegeClient, WahltageClient { @Override public WahlvorschlaegeModel getWahlvorschlaege(BezirkUndWahlID bezirkUndWahlID) { @@ -25,4 +32,14 @@ public WahlvorschlaegeModel getWahlvorschlaege(BezirkUndWahlID bezirkUndWahlID) Set.of(new KandidatModel(UUID.randomUUID().toString(), "kandidat21", 1L, true, 1L, true), new KandidatModel(UUID.randomUUID().toString(), "kandidat22", 2L, false, 1L, false))))); } + + @Override + public List getWahltage(LocalDate tag) { + return List.of( + new WahltagModel("wahltagID4", LocalDate.now().plusMonths(2), "Beschreibung Wahltag 4", "3"), + new WahltagModel("wahltagID1", LocalDate.now().minusMonths(2), "Beschreibung Wahltag 1", "0"), + new WahltagModel("wahltagID3", LocalDate.now().plusMonths(1), "Beschreibung Wahltag 3", "2"), + new WahltagModel("wahltagID2", LocalDate.now().minusMonths(1), "Beschreibung Wahltag 2", "1") + ); + } } diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImpl.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImpl.java new file mode 100644 index 000000000..ec299a424 --- /dev/null +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImpl.java @@ -0,0 +1,44 @@ +package de.muenchen.oss.wahllokalsystem.basisdatenservice.clients; + +import de.muenchen.oss.wahllokalsystem.basisdatenservice.configuration.Profiles; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.client.WahldatenControllerApi; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.exception.ExceptionConstants; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltagModel; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltageClient; +import de.muenchen.oss.wahllokalsystem.wls.common.exception.WlsException; +import de.muenchen.oss.wahllokalsystem.wls.common.exception.util.ExceptionFactory; +import java.time.LocalDate; +import java.util.List; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Profile; +import org.springframework.stereotype.Component; + +@Component +@Profile(Profiles.NOT + Profiles.DUMMY_CLIENTS) +@RequiredArgsConstructor +@Slf4j +public class WahltageClientImpl implements WahltageClient { + + private final ExceptionFactory exceptionFactory; + + private final WahldatenControllerApi wahldatenControllerApi; + private final WahltageClientMapper wahltageClientMapper; + + @Override + public List getWahltage(LocalDate tag) throws WlsException { + + final WahltageDTO wahltageDTO; + try { + wahltageDTO = wahldatenControllerApi.loadWahltageSinceIncluding(tag); + } catch (final Exception exception) { + log.info("exception on loadwahltage from external", exception); + throw exceptionFactory.createTechnischeWlsException(ExceptionConstants.FAILED_COMMUNICATION_WITH_EAI); + } + if (wahltageDTO == null) { + throw exceptionFactory.createFachlicheWlsException(ExceptionConstants.NULL_FROM_CLIENT); + } + return wahltageClientMapper.fromRemoteClientWahltageDTOtoListOfWahltagModel(wahltageDTO); + } +} diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapper.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapper.java new file mode 100644 index 000000000..35bcec5f7 --- /dev/null +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapper.java @@ -0,0 +1,26 @@ +package de.muenchen.oss.wahllokalsystem.basisdatenservice.clients; + +import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltagDTO; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltagModel; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltageModel; +import java.util.List; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; + +@Mapper +public interface WahltageClientMapper { + + List fromListOfRemoteWahltagDTOtoListOfWahltagModel(List wahltagDTOList); + + @Mapping(target = "wahltagModels", source = "wahltage") + WahltageModel toWahltageModel(WahltageDTO wahltageDTO); + + @Mapping(target = "wahltagID", source = "identifikator") + @Mapping(target = "wahltag", source = "tag") + WahltagModel toWahltagModel(WahltagDTO wahltagDTO); + + default List fromRemoteClientWahltageDTOtoListOfWahltagModel(WahltageDTO wahltageDTO) { + return wahltageDTO.getWahltage().stream().map(this::toWahltagModel).toList(); + } +} diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/ClientImpl.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahlvorschlaegeClientImpl.java similarity index 96% rename from wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/ClientImpl.java rename to wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahlvorschlaegeClientImpl.java index bdb6fa859..6c347d937 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/ClientImpl.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahlvorschlaegeClientImpl.java @@ -17,7 +17,7 @@ @Profile(Profiles.NOT + Profiles.DUMMY_CLIENTS) @RequiredArgsConstructor @Slf4j -public class ClientImpl implements WahlvorschlaegeClient { +public class WahlvorschlaegeClientImpl implements WahlvorschlaegeClient { private final ExceptionFactory exceptionFactory; diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java new file mode 100644 index 000000000..b90742d56 --- /dev/null +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java @@ -0,0 +1,55 @@ +package de.muenchen.oss.wahllokalsystem.basisdatenservice.domain; + +import static java.sql.Types.VARCHAR; +import jakarta.persistence.Embeddable; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.validation.constraints.NotNull; +import java.time.LocalDate; +import java.util.UUID; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import org.apache.commons.lang3.builder.EqualsExclude; +import org.hibernate.annotations.JdbcTypeCode; +import org.hibernate.annotations.NaturalId; +import org.hibernate.annotations.UuidGenerator; + +@Entity +@Data +@EqualsAndHashCode +@NoArgsConstructor +@AllArgsConstructor +public class Wahltag { + + @Id + @GeneratedValue(generator = "uuid") + @UuidGenerator + @JdbcTypeCode(VARCHAR) + @EqualsExclude + private UUID id; + + @NaturalId + @NotNull + @ToString.Include + private String wahltagID; + + @NotNull + @ToString.Include + private LocalDate wahltag; + + @NotNull + @ToString.Include + private String beschreibung; + + @NotNull + @ToString.Include + private String nummer; +} diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/WahltagRepository.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/WahltagRepository.java new file mode 100644 index 000000000..6080d256d --- /dev/null +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/WahltagRepository.java @@ -0,0 +1,52 @@ +package de.muenchen.oss.wahllokalsystem.basisdatenservice.domain; + +import java.util.List; +import java.util.UUID; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.CachePut; +import org.springframework.data.repository.CrudRepository; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.transaction.annotation.Transactional; + +@PreAuthorize("hasAuthority('Basisdaten_READ_Wahltag')") +@Transactional +public interface WahltagRepository extends CrudRepository { + + String CACHE = "WAHLTAG_CACHE"; + + @Override + @CachePut(value = CACHE, key = "#p0.wahltagID") + @PreAuthorize("hasAuthority('Basisdaten_WRITE_Wahltag')") + S save(S entity); + + @Override + @PreAuthorize("hasAuthority('Basisdaten_WRITE_Wahltag')") + Iterable saveAll(Iterable entities ); + + @Override + @CacheEvict(value = CACHE, key = "#p0") + @PreAuthorize("hasAuthority('Basisdaten_DELETE_Wahltag')") + void deleteById(UUID id); + + @Override + @CacheEvict(value = CACHE, key = "#p0.wahltagID") + @PreAuthorize("hasAuthority('Basisdaten_DELETE_Wahltag')") + void delete(Wahltag entity); + + @Override + @CacheEvict(value = CACHE, allEntries = true) + @PreAuthorize("hasAuthority('Basisdaten_DELETE_Wahltag')") + void deleteAllById(Iterable strings); + + @Override + @CacheEvict(value = CACHE, allEntries = true) + @PreAuthorize("hasAuthority('Basisdaten_DELETE_Wahltag')") + void deleteAll(Iterable entities); + + @Override + @CacheEvict(value = CACHE, allEntries = true) + @PreAuthorize("hasAuthority('Basisdaten_DELETE_Wahltag')") + void deleteAll(); + + List findAllByOrderByWahltagAsc(); +} diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltagDTO.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltagDTO.java new file mode 100644 index 000000000..693d80398 --- /dev/null +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltagDTO.java @@ -0,0 +1,12 @@ +package de.muenchen.oss.wahllokalsystem.basisdatenservice.rest.wahltage; + +import jakarta.validation.constraints.NotNull; +import java.time.LocalDate; +import lombok.Builder; + +@Builder +public record WahltagDTO(@NotNull String wahltagID, + @NotNull LocalDate wahltag, + @NotNull String beschreibung, + @NotNull String nummer) { +} diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java new file mode 100644 index 000000000..eb891059f --- /dev/null +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java @@ -0,0 +1,44 @@ +package de.muenchen.oss.wahllokalsystem.basisdatenservice.rest.wahltage; + +import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltageService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import java.util.List; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/businessActions/wahltage") +@RequiredArgsConstructor +@Slf4j +public class WahltageController { + + private final WahltageService wahltageService; + private final WahltageDTOMapper wahltageDTOMapper; + + @Operation(description = "Laden der Liste der Wahltage, bei denen das Datum bis 3 Monate in die Vergangenheit reicht") + @ApiResponses( + value = { + @ApiResponse( + responseCode = "200", description = "OK", + content = { @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema( implementation = WahltagDTO.class))) } + ) + } + ) + @GetMapping + public ResponseEntity> getWahltage() { + return new ResponseEntity<>( + wahltageDTOMapper.fromListOfWahltagModelToListOfWahltagDTO(wahltageService.getWahltage()), + HttpStatus.OK + ); + } +} diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageDTOMapper.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageDTOMapper.java new file mode 100644 index 000000000..352efb744 --- /dev/null +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageDTOMapper.java @@ -0,0 +1,10 @@ +package de.muenchen.oss.wahllokalsystem.basisdatenservice.rest.wahltage; + +import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltagModel; +import java.util.List; +import org.mapstruct.Mapper; + +@Mapper +public interface WahltageDTOMapper { + List fromListOfWahltagModelToListOfWahltagDTO(List wahltage); +} diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModel.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModel.java new file mode 100644 index 000000000..0271f6646 --- /dev/null +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModel.java @@ -0,0 +1,14 @@ +package de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag; + +import jakarta.validation.constraints.NotNull; +import java.time.LocalDate; +import lombok.Builder; + +@Builder +public record WahltagModel(@NotNull String wahltagID, + @NotNull LocalDate wahltag, + @NotNull String beschreibung, + @NotNull String nummer +) { + +} diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModelMapper.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModelMapper.java new file mode 100644 index 000000000..9dde6699a --- /dev/null +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModelMapper.java @@ -0,0 +1,20 @@ +package de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag; + +import de.muenchen.oss.wahllokalsystem.basisdatenservice.domain.Wahltag; +import java.util.List; +import org.mapstruct.CollectionMappingStrategy; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; + +@Mapper(collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED) +public interface WahltagModelMapper { + + @Mapping(target = "id", ignore = true) + Wahltag toEntity(WahltagModel wahltagModel); + + WahltagModel toModel(Wahltag entity); + + List fromWahltagEntityToWahltagModelList(List entities); + + List fromWahltagModelToWahltagEntityList(List entities); +} diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageClient.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageClient.java new file mode 100644 index 000000000..1ea8398ee --- /dev/null +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageClient.java @@ -0,0 +1,20 @@ +package de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag; + +import de.muenchen.oss.wahllokalsystem.wls.common.exception.WlsException; +import java.time.LocalDate; +import java.util.List; + +public interface WahltageClient { + + /** + * @param tag The Request Tag - Reference for requested Wahltage + * @return List + * @throws WlsException + * {@link de.muenchen.oss.wahllokalsystem.wls.common.exception.FachlicheWlsException} if + * return would be null + * {@link de.muenchen.oss.wahllokalsystem.wls.common.exception.TechnischeWlsException} + * if there were trouble during communication + */ + List getWahltage(LocalDate tag) throws WlsException; + +} diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageModel.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageModel.java new file mode 100644 index 000000000..4b5b2c00b --- /dev/null +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageModel.java @@ -0,0 +1,13 @@ +package de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag; + +import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahlvorschlag.WahlvorschlagModel; +import de.muenchen.oss.wahllokalsystem.wls.common.security.domain.BezirkUndWahlID; +import jakarta.validation.constraints.NotNull; +import java.util.List; +import java.util.Set; +import lombok.Builder; + +@Builder +public record WahltageModel(@NotNull List wahltagModels) { + +} diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageService.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageService.java new file mode 100644 index 000000000..6d2d1ca64 --- /dev/null +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageService.java @@ -0,0 +1,32 @@ +package de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag; + +import de.muenchen.oss.wahllokalsystem.basisdatenservice.domain.WahltagRepository; +import java.time.LocalDate; +import java.util.List; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +@Slf4j +public class WahltageService { + + private final WahltagRepository wahltagRepository; + + private final WahltagModelMapper wahltagModelMapper; + + private final WahltageClient wahltageClient; + + @PreAuthorize( + "hasAuthority('Basisdaten_BUSINESSACTION_GetWahltage')" + ) + public List getWahltage() { + log.info("#getWahltage"); + List wahltage = wahltageClient.getWahltage(LocalDate.now().minusMonths(3)); + wahltagRepository.saveAll(wahltagModelMapper.fromWahltagModelToWahltagEntityList(wahltage)); + return wahltagModelMapper.fromWahltagEntityToWahltagModelList(wahltagRepository.findAllByOrderByWahltagAsc()); + } +} diff --git a/wls-basisdaten-service/src/main/resources/db/migrations/h2/V2_0__createWahltagTable.sql b/wls-basisdaten-service/src/main/resources/db/migrations/h2/V2_0__createWahltagTable.sql new file mode 100644 index 000000000..8c7078480 --- /dev/null +++ b/wls-basisdaten-service/src/main/resources/db/migrations/h2/V2_0__createWahltagTable.sql @@ -0,0 +1,10 @@ +CREATE TABLE wahltag +( + id VARCHAR(255) NOT NULL, + wahltagID VARCHAR(1024) NOT NULL, + wahltag TIMESTAMP NOT NULL, + beschreibung VARCHAR(1024) NOT NULL, + nummer VARCHAR(1024), + + PRIMARY KEY (id) +); \ No newline at end of file diff --git a/wls-basisdaten-service/src/main/resources/db/migrations/oracle/V2_0__createWahltagTable.sql b/wls-basisdaten-service/src/main/resources/db/migrations/oracle/V2_0__createWahltagTable.sql new file mode 100644 index 000000000..8c7078480 --- /dev/null +++ b/wls-basisdaten-service/src/main/resources/db/migrations/oracle/V2_0__createWahltagTable.sql @@ -0,0 +1,10 @@ +CREATE TABLE wahltag +( + id VARCHAR(255) NOT NULL, + wahltagID VARCHAR(1024) NOT NULL, + wahltag TIMESTAMP NOT NULL, + beschreibung VARCHAR(1024) NOT NULL, + nummer VARCHAR(1024), + + PRIMARY KEY (id) +); \ No newline at end of file diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/ClientImplTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahlvorschlaegeClientImplTest.java similarity index 97% rename from wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/ClientImplTest.java rename to wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahlvorschlaegeClientImplTest.java index fa4982b75..ea66ac33a 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/ClientImplTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahlvorschlaegeClientImplTest.java @@ -21,7 +21,7 @@ import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -class ClientImplTest { +class WahlvorschlaegeClientImplTest { @Mock ExceptionFactory exceptionFactory; @@ -33,7 +33,7 @@ class ClientImplTest { WahlvorschlaegeClientMapper wahlvorschlaegeClientMapper; @InjectMocks - ClientImpl unitUnderTest; + WahlvorschlaegeClientImpl unitUnderTest; @Nested class GetWahlvorschlaege { diff --git a/wls-basisdaten-service/src/test/resources/wahltage.http b/wls-basisdaten-service/src/test/resources/wahltage.http new file mode 100644 index 000000000..6cac6bd5b --- /dev/null +++ b/wls-basisdaten-service/src/test/resources/wahltage.http @@ -0,0 +1,22 @@ +### Get token wls_all +POST {{ SSO_URL }}/auth/realms/wls_realm/protocol/openid-connect/token +Content-Type: application/x-www-form-urlencoded + +password = test & +grant_type = password & +client_secret = top-secret & +client_id = wls & +username = wls_all + +> {% + client.global.set("auth_token", response.body.access_token); + client.global.set("token_type", response.body.token_type); +%} + +### get userinfo with auth_token +GET {{ SSO_URL }}/auth/realms/wls_realm/protocol/openid-connect/userinfo +Authorization: {{ token_type }} {{ auth_token }} + +### Get Basisdaten - working with dummy.client +GET {{ WLS_BASISDATEN_SERVICE_URL }}/businessActions/wahltage +Authorization: {{ token_type }} {{ auth_token }} \ No newline at end of file From c7405627f7fe73c90ebc60a8c3c5576913750241 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Thu, 11 Jul 2024 12:48:06 +0200 Subject: [PATCH 02/51] First Tests --- .../clients/WahltageClientMapper.java | 2 - .../clients/DummyClientImplTest.java | 11 + .../clients/WahltageClientImplTest.java | 67 ++++++ .../clients/WahltageClientMapperTest.java | 161 +++++++++++++ .../SecurityConfigurationTest.java | 25 +- .../WahltageControllerIntegrationTest.java | 215 ++++++++++++++++++ .../basisdatenservice/utils/Authorities.java | 20 ++ 7 files changed, 497 insertions(+), 4 deletions(-) create mode 100644 wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImplTest.java create mode 100644 wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapperTest.java create mode 100644 wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageControllerIntegrationTest.java diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapper.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapper.java index 35bcec5f7..633f0c3ff 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapper.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapper.java @@ -11,8 +11,6 @@ @Mapper public interface WahltageClientMapper { - List fromListOfRemoteWahltagDTOtoListOfWahltagModel(List wahltagDTOList); - @Mapping(target = "wahltagModels", source = "wahltage") WahltageModel toWahltageModel(WahltageDTO wahltageDTO); diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/DummyClientImplTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/DummyClientImplTest.java index b39c42dd2..7eaf7a40d 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/DummyClientImplTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/DummyClientImplTest.java @@ -1,6 +1,7 @@ package de.muenchen.oss.wahllokalsystem.basisdatenservice.clients; import de.muenchen.oss.wahllokalsystem.wls.common.security.domain.BezirkUndWahlID; +import java.time.LocalDate; import lombok.val; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Nested; @@ -20,4 +21,14 @@ void resultIsANonNullObject() { Assertions.assertThat(result).hasNoNullFieldsOrProperties(); } } + + @Nested + class GetWahltage { + + @Test + void resultIsAnArrayWithPositiveSize() { + val result = unitUnderTest.getWahltage(LocalDate.now().minusMonths(3)); + Assertions.assertThat(result).size().isPositive(); + } + } } diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImplTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImplTest.java new file mode 100644 index 000000000..9f3c21ae4 --- /dev/null +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImplTest.java @@ -0,0 +1,67 @@ +package de.muenchen.oss.wahllokalsystem.basisdatenservice.clients; + +import static org.mockito.ArgumentMatchers.any; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.client.WahldatenControllerApi; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.exception.ExceptionConstants; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltagModel; +import de.muenchen.oss.wahllokalsystem.wls.common.exception.FachlicheWlsException; +import de.muenchen.oss.wahllokalsystem.wls.common.exception.util.ExceptionFactory; +import java.time.LocalDate; +import java.util.List; +import lombok.val; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class WahltageClientImplTest { + + @Mock + ExceptionFactory exceptionFactory; + + @Mock + WahldatenControllerApi wahldatenControllerApi; + + @Mock + WahltageClientMapper wahltageClientMapper; + + @InjectMocks + WahltageClientImpl unitUnderTest; + + @Nested + class GetWahltage { + + @Test + void clientResponseIsMapped() { + val testDate = LocalDate.now().minusMonths(3); + + val mockedClientResponse = new WahltageDTO(); + val mockedMappedClientResponse = List.of(WahltagModel.builder().build()) ; + + Mockito.when(wahldatenControllerApi.loadWahltageSinceIncluding(testDate)) + .thenReturn(mockedClientResponse); + Mockito.when(wahltageClientMapper.fromRemoteClientWahltageDTOtoListOfWahltagModel(mockedClientResponse)) + .thenReturn(mockedMappedClientResponse); + + val result = unitUnderTest.getWahltage(testDate); + + Assertions.assertThat(result).isSameAs(mockedMappedClientResponse); + } + + @Test + void exceptionWhenClientResponseIsNull() { + val mockedWlsException = FachlicheWlsException.withCode("").buildWithMessage(""); + + Mockito.when(wahldatenControllerApi.loadWahltageSinceIncluding(any())).thenReturn(null); + Mockito.when(exceptionFactory.createFachlicheWlsException(ExceptionConstants.NULL_FROM_CLIENT)).thenReturn(mockedWlsException); + + Assertions.assertThatException().isThrownBy(() -> unitUnderTest.getWahltage(LocalDate.now())).isSameAs(mockedWlsException); + } + } +} diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapperTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapperTest.java new file mode 100644 index 000000000..aed543379 --- /dev/null +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapperTest.java @@ -0,0 +1,161 @@ +package de.muenchen.oss.wahllokalsystem.basisdatenservice.clients; + +import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltagDTO; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltagModel; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltageModel; +import java.time.LocalDate; +import java.util.List; +import java.util.Set; +import lombok.val; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.mapstruct.factory.Mappers; + +class WahltageClientMapperTest { + + private final WahltageClientMapper unitUnderTest = Mappers.getMapper(WahltageClientMapper.class); + + @Nested + class ToWahltageModel { + + @Test + void isMapped() { + val dtoToMap = new WahltageDTO(); + + val wahltag1 = new WahltagDTO(); + wahltag1.setIdentifikator("identifikatorWahltag1"); + wahltag1.setBeschreibung("beschreibungWahltag1"); + wahltag1.setNummer("nummerWahltag1"); + wahltag1.setTag(LocalDate.now().minusMonths(2)); + + val wahltag2 = new WahltagDTO(); + wahltag2.setIdentifikator("identifikatorWahltag2"); + wahltag2.setBeschreibung("beschreibungWahltag2"); + wahltag2.setNummer("nummerWahltag2"); + wahltag2.setTag(LocalDate.now().minusMonths(1)); + + val wahltag3 = new WahltagDTO(); + wahltag3.setIdentifikator("identifikatorWahltag3"); + wahltag3.setBeschreibung("beschreibungWahltag3"); + wahltag3.setNummer("nummerWahltag3"); + wahltag3.setTag(LocalDate.now().plusMonths(1)); + + dtoToMap.setWahltage(Set.of( + wahltag3, wahltag2, wahltag1 + )); + + Assertions.assertThat(dtoToMap).hasNoNullFieldsOrProperties(); + Assertions.assertThat(dtoToMap.getWahltage()).size().isPositive(); + + val result = unitUnderTest.toWahltageModel(dtoToMap); + + val expectedWahltage = List.of( + new WahltagModel("identifikatorWahltag1", + LocalDate.now().minusMonths(2), + "beschreibungWahltag1", + "nummerWahltag1" + ), + new WahltagModel("identifikatorWahltag2", + LocalDate.now().minusMonths(1), + "beschreibungWahltag2", + "nummerWahltag2" + ), + new WahltagModel("identifikatorWahltag3", + LocalDate.now().plusMonths(1), + "beschreibungWahltag3", + "nummerWahltag3" + ) + ); + + val expectedResult = new WahltageModel(expectedWahltage); + + Assertions.assertThat(result.wahltagModels()).containsExactlyInAnyOrderElementsOf(expectedResult.wahltagModels()); + } + + } + + @Nested + class ToWahltagModel { + + @Test + void isMapped() { + val dtoToMap = new WahltagDTO(); + dtoToMap.setIdentifikator("identifikatorWahltag1"); + dtoToMap.setBeschreibung("beschreibungWahltag1"); + dtoToMap.setNummer("nummerWahltag1"); + dtoToMap.setTag(LocalDate.now().minusMonths(2)); + + Assertions.assertThat(dtoToMap).hasNoNullFieldsOrProperties(); + + val result = unitUnderTest.toWahltagModel(dtoToMap); + + val expectedWahltag = new WahltagModel( + "identifikatorWahltag1", + LocalDate.now().minusMonths(2), + "beschreibungWahltag1", + "nummerWahltag1" + ); + + Assertions.assertThat(result).usingRecursiveComparison().isEqualTo(expectedWahltag); + } + + } + + @Nested + class FromRemoteClientWahltageDTOtoListOfWahltagModel { + + @Test + void isMapped() { + val dtoToMap = new WahltageDTO(); + + val wahltag1 = new WahltagDTO(); + wahltag1.setIdentifikator("identifikatorWahltag1"); + wahltag1.setBeschreibung("beschreibungWahltag1"); + wahltag1.setNummer("nummerWahltag1"); + wahltag1.setTag(LocalDate.now().minusMonths(2)); + + val wahltag2 = new WahltagDTO(); + wahltag2.setIdentifikator("identifikatorWahltag2"); + wahltag2.setBeschreibung("beschreibungWahltag2"); + wahltag2.setNummer("nummerWahltag2"); + wahltag2.setTag(LocalDate.now().minusMonths(1)); + + val wahltag3 = new WahltagDTO(); + wahltag3.setIdentifikator("identifikatorWahltag3"); + wahltag3.setBeschreibung("beschreibungWahltag3"); + wahltag3.setNummer("nummerWahltag3"); + wahltag3.setTag(LocalDate.now().plusMonths(1)); + + dtoToMap.setWahltage(Set.of( + wahltag1, wahltag2, wahltag3 + )); + + Assertions.assertThat(dtoToMap).hasNoNullFieldsOrProperties(); + Assertions.assertThat(dtoToMap.getWahltage()).size().isPositive(); + + val result = unitUnderTest.fromRemoteClientWahltageDTOtoListOfWahltagModel(dtoToMap); + + val expectedWahltage = List.of( + new WahltagModel("identifikatorWahltag1", + LocalDate.now().minusMonths(2), + "beschreibungWahltag1", + "nummerWahltag1" + ), + new WahltagModel("identifikatorWahltag2", + LocalDate.now().minusMonths(1), + "beschreibungWahltag2", + "nummerWahltag2" + ), + new WahltagModel("identifikatorWahltag3", + LocalDate.now().plusMonths(1), + "beschreibungWahltag3", + "nummerWahltag3" + ) + ); + + Assertions.assertThat(result).containsExactlyInAnyOrderElementsOf(expectedWahltage); + } + } +} diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/configuration/SecurityConfigurationTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/configuration/SecurityConfigurationTest.java index 2aa68c8cd..f1d37ee7c 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/configuration/SecurityConfigurationTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/configuration/SecurityConfigurationTest.java @@ -5,6 +5,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import de.muenchen.oss.wahllokalsystem.basisdatenservice.MicroServiceApplication; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltageService; import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahlvorschlag.WahlvorschlaegeService; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -30,6 +31,9 @@ class SecurityConfigurationTest { @MockBean WahlvorschlaegeService wahlvorschlaegeService; + @MockBean + WahltageService wahltageService; + @Test void accessSecuredResourceRootThenUnauthorized() throws Exception { api.perform(get("/")) @@ -77,15 +81,32 @@ class Wahlvorschlaege { @Test @WithAnonymousUser - void accessGetWahlvorstaendeUnauthorizedThenUnauthorized() throws Exception { + void accessGetWahlvorschlaegeUnauthorizedThenUnauthorized() throws Exception { api.perform(get("/businessActions/wahlvorschlaege/wahlID/wahlbezirkID")).andExpect(status().isUnauthorized()); } @Test @WithMockUser - void accessGetWahlvorstaendeUnauthorizedThenOk() throws Exception { + void accessGetWahlvorschlaegeUnauthorizedThenOk() throws Exception { api.perform(get("/businessActions/wahlvorschlaege/wahlID/wahlbezirkID")).andExpect(status().isOk()); } } + @Nested + class Wahltage { + + @Test + @WithAnonymousUser + void accessGetWahltageUnauthorizedThenUnauthorized() throws Exception { + api.perform(get("/businessActions/wahltage")).andExpect(status().isUnauthorized()); + } + + @Test + @WithMockUser + void accessGetWahltageUnauthorizedThenOk() throws Exception { + api.perform(get("/businessActions/wahltage")).andExpect(status().isOk()); + } + + } + } 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 new file mode 100644 index 000000000..2159ce349 --- /dev/null +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageControllerIntegrationTest.java @@ -0,0 +1,215 @@ +package de.muenchen.oss.wahllokalsystem.basisdatenservice.rest.wahltage; + +import static de.muenchen.oss.wahllokalsystem.basisdatenservice.TestConstants.SPRING_NO_SECURITY_PROFILE; +import static de.muenchen.oss.wahllokalsystem.basisdatenservice.TestConstants.SPRING_TEST_PROFILE; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.github.tomakehurst.wiremock.client.WireMock; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.MicroServiceApplication; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.clients.WahltageClientMapper; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.clients.WahltageClientMapper; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.domain.KandidatRepository; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.domain.Wahltag; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.domain.WahltagRepository; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.domain.WahlvorschlagRepository; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltagDTO; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.exception.ExceptionConstants; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltagModelMapper; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.utils.Authorities; +import de.muenchen.oss.wahllokalsystem.wls.common.exception.rest.model.WlsExceptionCategory; +import de.muenchen.oss.wahllokalsystem.wls.common.exception.rest.model.WlsExceptionDTO; +import de.muenchen.oss.wahllokalsystem.wls.common.testing.SecurityUtils; +import java.time.LocalDate; +import java.util.List; +import java.util.Set; +import lombok.val; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.SpyBean; +import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; +import org.springframework.http.HttpStatus; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.transaction.annotation.Transactional; + +@SpringBootTest(classes = MicroServiceApplication.class, webEnvironment = SpringBootTest.WebEnvironment.MOCK) +@AutoConfigureMockMvc +@AutoConfigureWireMock +@ActiveProfiles(profiles = { SPRING_TEST_PROFILE, SPRING_NO_SECURITY_PROFILE }) +public class WahltageControllerIntegrationTest { + + @Value("${service.info.oid}") + String serviceID; + + @Autowired + MockMvc api; + + @Autowired + ObjectMapper objectMapper; + + @Autowired + WahltageDTOMapper dtoMapper; + + @Autowired + WahltagModelMapper modelMapper; + + @Autowired + WahltageClientMapper wahltageClientMapper; + + @Autowired + WahltagRepository wahltagRepository; + + @Autowired + WahlvorschlagRepository wahlvorschlagRepository; + + @Autowired + KandidatRepository kandidatRepository; + + @AfterEach + void tearDown() { + SecurityUtils.runWith(Authorities.ALL_AUTHORITIES_DELETE_WAHLTAGE); + wahltagRepository.deleteAll(); + } + + @BeforeEach + void setup() { + WireMock.resetAllRequests(); + } + + @Nested + class GetWahltage { + + @Test + void loadedFromExternal() throws Exception { + + String requestDate = LocalDate.now().minusMonths(3).toString(); + + val eaiWahltage = createClientWahltageDTO(LocalDate.now().minusMonths(3)); + WireMock.stubFor(WireMock.get("/wahldaten/wahltage?includingAfter=" + requestDate) + .willReturn(WireMock.aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()) + .withBody(objectMapper.writeValueAsBytes(eaiWahltage)))); + + val request = MockMvcRequestBuilders.get("/businessActions/wahltage"); + + val responseFromController = api.perform(request).andExpect(status().isOk()).andReturn(); + val responseBodyAsDTO = objectMapper.readValue(responseFromController.getResponse().getContentAsString(), de.muenchen.oss.wahllokalsystem.basisdatenservice.rest.wahltage.WahltagDTO[].class); + + val expectedResponseBody = dtoMapper.fromListOfWahltagModelToListOfWahltagDTO(wahltageClientMapper.fromRemoteClientWahltageDTOtoListOfWahltagModel(eaiWahltage)); + + Assertions.assertThat(responseBodyAsDTO).containsExactlyInAnyOrderElementsOf(expectedResponseBody); + } + + @Test + @Transactional + void externalDataIsPersisted() throws Exception { + + String requestDate = LocalDate.now().minusMonths(3).toString(); + + val eaiWahltage = createClientWahltageDTO(LocalDate.now().minusMonths(3)); + WireMock.stubFor(WireMock.get("/wahldaten/wahltage?includingAfter=" + requestDate) + .willReturn(WireMock.aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()) + .withBody(objectMapper.writeValueAsBytes(eaiWahltage)))); + + val request = MockMvcRequestBuilders.get("/businessActions/wahltage"); + + api.perform(request).andExpect(status().isOk()); + + val dataFromRepo = wahltagRepository.findAllByOrderByWahltagAsc(); + + val expectedListOfData = modelMapper.fromWahltagModelToWahltagEntityList( + wahltageClientMapper.fromRemoteClientWahltageDTOtoListOfWahltagModel(eaiWahltage) + ); + + Assertions.assertThat(dataFromRepo) + .usingRecursiveComparison().ignoringCollectionOrder() + .ignoringFields("id") + .isEqualTo(expectedListOfData); + } + + @Test + void loadFromRepository() throws Exception { + + val entitiesToFind = modelMapper + .fromWahltagModelToWahltagEntityList(wahltageClientMapper + .fromRemoteClientWahltageDTOtoListOfWahltagModel(createClientWahltageDTO(LocalDate.now().minusMonths(3)))); + //val savedEntities = wahltagRepository.saveAll(entitiesToFind); + + + val request = MockMvcRequestBuilders.get("/businessActions/wahltage"); + + //val responseFromController = api.perform(request).andExpect(status().isOk()).andReturn(); + + + + // beim lesen wird im service auch gespeichert und wegen uuid wird doppelt gespeichert. + + val response = api.perform(request).andExpect(status().isOk()).andReturn(); + val responseBodyAsListOfDTOs = objectMapper.readValue(response.getResponse().getContentAsString(), de.muenchen.oss.wahllokalsystem.basisdatenservice.rest.wahltage.WahltagDTO[].class); + + val expectedResponseBody = dtoMapper.fromListOfWahltagModelToListOfWahltagDTO( + modelMapper.fromWahltagEntityToWahltagModelList(entitiesToFind) + ); + + Assertions.assertThat(responseBodyAsListOfDTOs).containsExactlyInAnyOrderElementsOf(expectedResponseBody); + //WireMock.verify(0, WireMock.anyRequestedFor(WireMock.anyUrl())); + } + + @Test + void technischeWlsExceptionWhenNoExternalDataFound() throws Exception { + + String requestDate = LocalDate.now().minusMonths(3).toString(); + + WireMock.stubFor(WireMock.get("/wahldaten/wahltage?includingAfter=" + requestDate) + .willReturn(WireMock.aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.NOT_FOUND.value()))); + + val request = MockMvcRequestBuilders.get("/businessActions/wahltage"); + + val response = api.perform(request).andExpect(status().isInternalServerError()).andReturn(); + val responseBodyAsWlsExceptionDTO = objectMapper.readValue(response.getResponse().getContentAsString(), WlsExceptionDTO.class); + + val expectedWlsExceptionDTO = new WlsExceptionDTO(WlsExceptionCategory.T, + ExceptionConstants.FAILED_COMMUNICATION_WITH_EAI.code(), serviceID, + ExceptionConstants.FAILED_COMMUNICATION_WITH_EAI.message()); + Assertions.assertThat(responseBodyAsWlsExceptionDTO).isEqualTo(expectedWlsExceptionDTO); + } + } + + private de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO createClientWahltageDTO(LocalDate sinceTag) { + + val clientWahltageDTO = new de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO(); + + val wahltag1 = new de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltagDTO(); + wahltag1.setIdentifikator("identifikatorWahltag1"); + wahltag1.setBeschreibung("beschreibungWahltag1"); + wahltag1.setNummer("nummerWahltag1"); + wahltag1.setTag(LocalDate.now().minusMonths(2)); + + val wahltag2 = new de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltagDTO(); + wahltag2.setIdentifikator("identifikatorWahltag2"); + wahltag2.setBeschreibung("beschreibungWahltag2"); + wahltag2.setNummer("nummerWahltag2"); + wahltag2.setTag(LocalDate.now().minusMonths(1)); + + val wahltag3 = new WahltagDTO(); + wahltag3.setIdentifikator("identifikatorWahltag3"); + wahltag3.setBeschreibung("beschreibungWahltag3"); + wahltag3.setNummer("nummerWahltag3"); + wahltag3.setTag(LocalDate.now().plusMonths(1)); + + + + val wahltage = Set.of(wahltag1, wahltag2, wahltag3); + clientWahltageDTO.setWahltage(wahltage); + + return clientWahltageDTO; + } + +} diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/utils/Authorities.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/utils/Authorities.java index e5f3b74d3..257a26849 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/utils/Authorities.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/utils/Authorities.java @@ -7,6 +7,7 @@ public class Authorities { public static final String SERVICE_GET_WAHLVORSCHLAEGE = "Basisdaten_BUSINESSACTION_GetWahlvorschlaege"; + public static final String SERVICE_GET_WAHLTAGE = "Basisdaten_BUSINESSACTION_GetWahltage"; public static final String REPOSITORY_READ_WAHLVORSCHLAEGE = "Basisdaten_READ_WLSWahlvorschlaege"; public static final String REPOSITORY_DELETE_WAHLVORSCHLAEGE = "Basisdaten_DELETE_WLSWahlvorschlaege"; @@ -20,6 +21,10 @@ public class Authorities { public static final String REPOSITORY_WRITE_KANDIDAT = "Basisdaten_WRITE_Kandidat"; public static final String REPOSITORY_DELETE_KANDIDAT = "Basisdaten_DELETE_Kandidat"; + public static final String REPOSITORY_READ_WAHLTAG = "Basisdaten_READ_Wahltag"; + public static final String REPOSITORY_DELETE_WAHLTAG = "Basisdaten_DELETE_Wahltag"; + public static final String REPOSITORY_WRITE_WAHLTAG = "Basisdaten_WRITE_Wahltag"; + public static final String[] ALL_AUTHORITIES_GET_WAHLVORSCHLAEGE = new String[] { SERVICE_GET_WAHLVORSCHLAEGE, REPOSITORY_READ_WAHLVORSCHLAEGE, @@ -37,4 +42,19 @@ public class Authorities { REPOSITORY_DELETE_WAHLVORSCHLAEGE }; + public static final String[] ALL_AUTHORITIES_GET_WAHLTAGE = new String[] { + SERVICE_GET_WAHLTAGE, + REPOSITORY_READ_WAHLTAG, + REPOSITORY_WRITE_WAHLTAG + }; + public static final String[] ALL_AUTHORITIES_SET_WAHLTAGE = new String[] { + SERVICE_GET_WAHLTAGE, + REPOSITORY_READ_WAHLTAG, + REPOSITORY_WRITE_WAHLTAG + }; + + public static final String[] ALL_AUTHORITIES_DELETE_WAHLTAGE = new String[] { + REPOSITORY_DELETE_WAHLTAG + }; + } From 900037564630d93c56b013fb0958e6f7854ec908 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Thu, 11 Jul 2024 16:34:07 +0200 Subject: [PATCH 03/51] Entity mit Client wahltagID als Id ohne UUID --- .../clients/DummyClientImpl.java | 3 +- .../basisdatenservice/domain/Wahltag.java | 40 +++++++++---------- .../h2/V2_0__createWahltagTable.sql | 5 +-- .../oracle/V2_0__createWahltagTable.sql | 5 +-- 4 files changed, 24 insertions(+), 29 deletions(-) diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/DummyClientImpl.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/DummyClientImpl.java index f1230f4ee..2b588a0ff 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/DummyClientImpl.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/DummyClientImpl.java @@ -39,7 +39,6 @@ public List getWahltage(LocalDate tag) { new WahltagModel("wahltagID4", LocalDate.now().plusMonths(2), "Beschreibung Wahltag 4", "3"), new WahltagModel("wahltagID1", LocalDate.now().minusMonths(2), "Beschreibung Wahltag 1", "0"), new WahltagModel("wahltagID3", LocalDate.now().plusMonths(1), "Beschreibung Wahltag 3", "2"), - new WahltagModel("wahltagID2", LocalDate.now().minusMonths(1), "Beschreibung Wahltag 2", "1") - ); + new WahltagModel("wahltagID2", LocalDate.now().minusMonths(1), "Beschreibung Wahltag 2", "1")); } } diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java index b90742d56..59ec94881 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java @@ -1,55 +1,53 @@ package de.muenchen.oss.wahllokalsystem.basisdatenservice.domain; -import static java.sql.Types.VARCHAR; -import jakarta.persistence.Embeddable; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer; +import jakarta.persistence.Column; import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; import jakarta.persistence.Id; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; import java.time.LocalDate; -import java.util.UUID; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; -import lombok.Getter; import lombok.NoArgsConstructor; -import lombok.Setter; import lombok.ToString; -import org.apache.commons.lang3.builder.EqualsExclude; -import org.hibernate.annotations.JdbcTypeCode; -import org.hibernate.annotations.NaturalId; -import org.hibernate.annotations.UuidGenerator; +import org.springframework.stereotype.Indexed; @Entity +@Indexed @Data @EqualsAndHashCode @NoArgsConstructor @AllArgsConstructor +@Table(name = "Wahltag") public class Wahltag { @Id - @GeneratedValue(generator = "uuid") - @UuidGenerator - @JdbcTypeCode(VARCHAR) - @EqualsExclude - private UUID id; - - @NaturalId + @Column(name = "wahltagID") @NotNull + @Size(max = 1024) @ToString.Include private String wahltagID; + @Column(name = "wahltag") + @JsonDeserialize(using = LocalDateDeserializer.class) + @JsonSerialize(using = LocalDateSerializer.class) @NotNull @ToString.Include private LocalDate wahltag; - @NotNull + @Column(name = "beschreibung") + @Size(max = 1024) @ToString.Include private String beschreibung; - @NotNull + @Column(name = "nummer") + @Size(max = 1024) @ToString.Include private String nummer; } diff --git a/wls-basisdaten-service/src/main/resources/db/migrations/h2/V2_0__createWahltagTable.sql b/wls-basisdaten-service/src/main/resources/db/migrations/h2/V2_0__createWahltagTable.sql index 8c7078480..932b92471 100644 --- a/wls-basisdaten-service/src/main/resources/db/migrations/h2/V2_0__createWahltagTable.sql +++ b/wls-basisdaten-service/src/main/resources/db/migrations/h2/V2_0__createWahltagTable.sql @@ -1,10 +1,9 @@ CREATE TABLE wahltag ( - id VARCHAR(255) NOT NULL, wahltagID VARCHAR(1024) NOT NULL, wahltag TIMESTAMP NOT NULL, - beschreibung VARCHAR(1024) NOT NULL, + beschreibung VARCHAR(1024), nummer VARCHAR(1024), - PRIMARY KEY (id) + PRIMARY KEY (wahltagID) ); \ No newline at end of file diff --git a/wls-basisdaten-service/src/main/resources/db/migrations/oracle/V2_0__createWahltagTable.sql b/wls-basisdaten-service/src/main/resources/db/migrations/oracle/V2_0__createWahltagTable.sql index 8c7078480..932b92471 100644 --- a/wls-basisdaten-service/src/main/resources/db/migrations/oracle/V2_0__createWahltagTable.sql +++ b/wls-basisdaten-service/src/main/resources/db/migrations/oracle/V2_0__createWahltagTable.sql @@ -1,10 +1,9 @@ CREATE TABLE wahltag ( - id VARCHAR(255) NOT NULL, wahltagID VARCHAR(1024) NOT NULL, wahltag TIMESTAMP NOT NULL, - beschreibung VARCHAR(1024) NOT NULL, + beschreibung VARCHAR(1024), nummer VARCHAR(1024), - PRIMARY KEY (id) + PRIMARY KEY (wahltagID) ); \ No newline at end of file From 2f2cb26152725b8ee2cdd5b172fca4586ca0307f Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Thu, 11 Jul 2024 16:35:59 +0200 Subject: [PATCH 04/51] Tetsts bis auf service-tests --- .../clients/DummyClientImpl.java | 3 - .../domain/WahltagRepository.java | 21 +++--- .../rest/wahltage/WahltagDTO.java | 4 +- .../rest/wahltage/WahltageController.java | 7 +- .../services/wahltag/WahltagModel.java | 4 +- .../services/wahltag/WahltagModelMapper.java | 5 +- .../clients/WahltageClientImplTest.java | 2 +- .../clients/WahltageClientMapperTest.java | 51 ++++++--------- .../WahltageControllerIntegrationTest.java | 64 ++++++++++--------- .../rest/wahltage/WahltageControllerTest.java | 52 +++++++++++++++ .../rest/wahltage/WahltageDTOMapperTest.java | 56 ++++++++++++++++ 11 files changed, 183 insertions(+), 86 deletions(-) create mode 100644 wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageControllerTest.java create mode 100644 wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageDTOMapperTest.java diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/DummyClientImpl.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/DummyClientImpl.java index 2b588a0ff..649647902 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/DummyClientImpl.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/DummyClientImpl.java @@ -1,15 +1,12 @@ package de.muenchen.oss.wahllokalsystem.basisdatenservice.clients; import de.muenchen.oss.wahllokalsystem.basisdatenservice.configuration.Profiles; -import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO; -import de.muenchen.oss.wahllokalsystem.basisdatenservice.exception.ExceptionConstants; import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltagModel; import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltageClient; import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahlvorschlag.KandidatModel; import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahlvorschlag.WahlvorschlaegeClient; import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahlvorschlag.WahlvorschlaegeModel; import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahlvorschlag.WahlvorschlagModel; -import de.muenchen.oss.wahllokalsystem.wls.common.exception.WlsException; import de.muenchen.oss.wahllokalsystem.wls.common.security.domain.BezirkUndWahlID; import java.time.LocalDate; import java.util.List; diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/WahltagRepository.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/WahltagRepository.java index 6080d256d..4e3c248de 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/WahltagRepository.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/WahltagRepository.java @@ -1,19 +1,27 @@ package de.muenchen.oss.wahllokalsystem.basisdatenservice.domain; import java.util.List; -import java.util.UUID; +import java.util.Optional; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CachePut; +import org.springframework.cache.annotation.Cacheable; import org.springframework.data.repository.CrudRepository; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.transaction.annotation.Transactional; @PreAuthorize("hasAuthority('Basisdaten_READ_Wahltag')") @Transactional -public interface WahltagRepository extends CrudRepository { +public interface WahltagRepository extends CrudRepository { String CACHE = "WAHLTAG_CACHE"; + @Override + List findAll(); + + @Override + @Cacheable(value = CACHE, key = "#p0") + Optional findById(String wahltagID); + @Override @CachePut(value = CACHE, key = "#p0.wahltagID") @PreAuthorize("hasAuthority('Basisdaten_WRITE_Wahltag')") @@ -21,23 +29,18 @@ public interface WahltagRepository extends CrudRepository { @Override @PreAuthorize("hasAuthority('Basisdaten_WRITE_Wahltag')") - Iterable saveAll(Iterable entities ); + Iterable saveAll(Iterable entities); @Override @CacheEvict(value = CACHE, key = "#p0") @PreAuthorize("hasAuthority('Basisdaten_DELETE_Wahltag')") - void deleteById(UUID id); + void deleteById(String wahltagID); @Override @CacheEvict(value = CACHE, key = "#p0.wahltagID") @PreAuthorize("hasAuthority('Basisdaten_DELETE_Wahltag')") void delete(Wahltag entity); - @Override - @CacheEvict(value = CACHE, allEntries = true) - @PreAuthorize("hasAuthority('Basisdaten_DELETE_Wahltag')") - void deleteAllById(Iterable strings); - @Override @CacheEvict(value = CACHE, allEntries = true) @PreAuthorize("hasAuthority('Basisdaten_DELETE_Wahltag')") diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltagDTO.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltagDTO.java index 693d80398..6c1c00511 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltagDTO.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltagDTO.java @@ -7,6 +7,6 @@ @Builder public record WahltagDTO(@NotNull String wahltagID, @NotNull LocalDate wahltag, - @NotNull String beschreibung, - @NotNull String nummer) { + String beschreibung, + String nummer) { } diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java index eb891059f..42af14315 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java @@ -30,15 +30,14 @@ public class WahltageController { value = { @ApiResponse( responseCode = "200", description = "OK", - content = { @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema( implementation = WahltagDTO.class))) } + content = { @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = WahltagDTO.class))) } ) } ) @GetMapping public ResponseEntity> getWahltage() { return new ResponseEntity<>( - wahltageDTOMapper.fromListOfWahltagModelToListOfWahltagDTO(wahltageService.getWahltage()), - HttpStatus.OK - ); + wahltageDTOMapper.fromListOfWahltagModelToListOfWahltagDTO(wahltageService.getWahltage()), + HttpStatus.OK); } } diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModel.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModel.java index 0271f6646..1b60ae5d8 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModel.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModel.java @@ -7,8 +7,8 @@ @Builder public record WahltagModel(@NotNull String wahltagID, @NotNull LocalDate wahltag, - @NotNull String beschreibung, - @NotNull String nummer + String beschreibung, + String nummer ) { } diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModelMapper.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModelMapper.java index 9dde6699a..c2764478e 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModelMapper.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModelMapper.java @@ -2,14 +2,11 @@ import de.muenchen.oss.wahllokalsystem.basisdatenservice.domain.Wahltag; import java.util.List; -import org.mapstruct.CollectionMappingStrategy; import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -@Mapper(collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED) +@Mapper public interface WahltagModelMapper { - @Mapping(target = "id", ignore = true) Wahltag toEntity(WahltagModel wahltagModel); WahltagModel toModel(Wahltag entity); diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImplTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImplTest.java index 9f3c21ae4..d4e853a50 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImplTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImplTest.java @@ -42,7 +42,7 @@ void clientResponseIsMapped() { val testDate = LocalDate.now().minusMonths(3); val mockedClientResponse = new WahltageDTO(); - val mockedMappedClientResponse = List.of(WahltagModel.builder().build()) ; + val mockedMappedClientResponse = List.of(WahltagModel.builder().build()); Mockito.when(wahldatenControllerApi.loadWahltageSinceIncluding(testDate)) .thenReturn(mockedClientResponse); diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapperTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapperTest.java index aed543379..95927232f 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapperTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapperTest.java @@ -43,8 +43,7 @@ void isMapped() { wahltag3.setTag(LocalDate.now().plusMonths(1)); dtoToMap.setWahltage(Set.of( - wahltag3, wahltag2, wahltag1 - )); + wahltag3, wahltag2, wahltag1)); Assertions.assertThat(dtoToMap).hasNoNullFieldsOrProperties(); Assertions.assertThat(dtoToMap.getWahltage()).size().isPositive(); @@ -52,22 +51,18 @@ void isMapped() { val result = unitUnderTest.toWahltageModel(dtoToMap); val expectedWahltage = List.of( - new WahltagModel("identifikatorWahltag1", - LocalDate.now().minusMonths(2), - "beschreibungWahltag1", - "nummerWahltag1" - ), - new WahltagModel("identifikatorWahltag2", - LocalDate.now().minusMonths(1), - "beschreibungWahltag2", - "nummerWahltag2" - ), - new WahltagModel("identifikatorWahltag3", - LocalDate.now().plusMonths(1), - "beschreibungWahltag3", - "nummerWahltag3" - ) - ); + new WahltagModel("identifikatorWahltag1", + LocalDate.now().minusMonths(2), + "beschreibungWahltag1", + "nummerWahltag1"), + new WahltagModel("identifikatorWahltag2", + LocalDate.now().minusMonths(1), + "beschreibungWahltag2", + "nummerWahltag2"), + new WahltagModel("identifikatorWahltag3", + LocalDate.now().plusMonths(1), + "beschreibungWahltag3", + "nummerWahltag3")); val expectedResult = new WahltageModel(expectedWahltage); @@ -93,10 +88,9 @@ void isMapped() { val expectedWahltag = new WahltagModel( "identifikatorWahltag1", - LocalDate.now().minusMonths(2), - "beschreibungWahltag1", - "nummerWahltag1" - ); + LocalDate.now().minusMonths(2), + "beschreibungWahltag1", + "nummerWahltag1"); Assertions.assertThat(result).usingRecursiveComparison().isEqualTo(expectedWahltag); } @@ -129,8 +123,7 @@ void isMapped() { wahltag3.setTag(LocalDate.now().plusMonths(1)); dtoToMap.setWahltage(Set.of( - wahltag1, wahltag2, wahltag3 - )); + wahltag1, wahltag2, wahltag3)); Assertions.assertThat(dtoToMap).hasNoNullFieldsOrProperties(); Assertions.assertThat(dtoToMap.getWahltage()).size().isPositive(); @@ -141,19 +134,15 @@ void isMapped() { new WahltagModel("identifikatorWahltag1", LocalDate.now().minusMonths(2), "beschreibungWahltag1", - "nummerWahltag1" - ), + "nummerWahltag1"), new WahltagModel("identifikatorWahltag2", LocalDate.now().minusMonths(1), "beschreibungWahltag2", - "nummerWahltag2" - ), + "nummerWahltag2"), new WahltagModel("identifikatorWahltag3", LocalDate.now().plusMonths(1), "beschreibungWahltag3", - "nummerWahltag3" - ) - ); + "nummerWahltag3")); Assertions.assertThat(result).containsExactlyInAnyOrderElementsOf(expectedWahltage); } 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 2159ce349..82449d37b 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 @@ -7,7 +7,6 @@ import com.github.tomakehurst.wiremock.client.WireMock; import de.muenchen.oss.wahllokalsystem.basisdatenservice.MicroServiceApplication; import de.muenchen.oss.wahllokalsystem.basisdatenservice.clients.WahltageClientMapper; -import de.muenchen.oss.wahllokalsystem.basisdatenservice.clients.WahltageClientMapper; import de.muenchen.oss.wahllokalsystem.basisdatenservice.domain.KandidatRepository; import de.muenchen.oss.wahllokalsystem.basisdatenservice.domain.Wahltag; import de.muenchen.oss.wahllokalsystem.basisdatenservice.domain.WahltagRepository; @@ -20,6 +19,8 @@ import de.muenchen.oss.wahllokalsystem.wls.common.exception.rest.model.WlsExceptionDTO; import de.muenchen.oss.wahllokalsystem.wls.common.testing.SecurityUtils; import java.time.LocalDate; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Set; import lombok.val; @@ -32,7 +33,6 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.SpyBean; import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; import org.springframework.http.HttpStatus; import org.springframework.test.context.ActiveProfiles; @@ -92,7 +92,7 @@ void loadedFromExternal() throws Exception { String requestDate = LocalDate.now().minusMonths(3).toString(); - val eaiWahltage = createClientWahltageDTO(LocalDate.now().minusMonths(3)); + val eaiWahltage = createClientWahltageDTO(LocalDate.now().minusMonths(3), false); WireMock.stubFor(WireMock.get("/wahldaten/wahltage?includingAfter=" + requestDate) .willReturn(WireMock.aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()) .withBody(objectMapper.writeValueAsBytes(eaiWahltage)))); @@ -100,9 +100,11 @@ void loadedFromExternal() throws Exception { val request = MockMvcRequestBuilders.get("/businessActions/wahltage"); val responseFromController = api.perform(request).andExpect(status().isOk()).andReturn(); - val responseBodyAsDTO = objectMapper.readValue(responseFromController.getResponse().getContentAsString(), de.muenchen.oss.wahllokalsystem.basisdatenservice.rest.wahltage.WahltagDTO[].class); + val responseBodyAsDTO = objectMapper.readValue(responseFromController.getResponse().getContentAsString(), + de.muenchen.oss.wahllokalsystem.basisdatenservice.rest.wahltage.WahltagDTO[].class); - val expectedResponseBody = dtoMapper.fromListOfWahltagModelToListOfWahltagDTO(wahltageClientMapper.fromRemoteClientWahltageDTOtoListOfWahltagModel(eaiWahltage)); + val expectedResponseBody = dtoMapper + .fromListOfWahltagModelToListOfWahltagDTO(wahltageClientMapper.fromRemoteClientWahltageDTOtoListOfWahltagModel(eaiWahltage)); Assertions.assertThat(responseBodyAsDTO).containsExactlyInAnyOrderElementsOf(expectedResponseBody); } @@ -113,7 +115,7 @@ void externalDataIsPersisted() throws Exception { String requestDate = LocalDate.now().minusMonths(3).toString(); - val eaiWahltage = createClientWahltageDTO(LocalDate.now().minusMonths(3)); + val eaiWahltage = createClientWahltageDTO(LocalDate.now().minusMonths(3), false); WireMock.stubFor(WireMock.get("/wahldaten/wahltage?includingAfter=" + requestDate) .willReturn(WireMock.aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()) .withBody(objectMapper.writeValueAsBytes(eaiWahltage)))); @@ -125,41 +127,44 @@ void externalDataIsPersisted() throws Exception { val dataFromRepo = wahltagRepository.findAllByOrderByWahltagAsc(); val expectedListOfData = modelMapper.fromWahltagModelToWahltagEntityList( - wahltageClientMapper.fromRemoteClientWahltageDTOtoListOfWahltagModel(eaiWahltage) - ); + wahltageClientMapper.fromRemoteClientWahltageDTOtoListOfWahltagModel(eaiWahltage)); Assertions.assertThat(dataFromRepo) .usingRecursiveComparison().ignoringCollectionOrder() - .ignoringFields("id") .isEqualTo(expectedListOfData); } @Test - void loadFromRepository() throws Exception { - - val entitiesToFind = modelMapper + void loadFromRemoteFirstAndThanUpdateRepository() throws Exception { + val entitiesToFindInRepository = modelMapper .fromWahltagModelToWahltagEntityList(wahltageClientMapper - .fromRemoteClientWahltageDTOtoListOfWahltagModel(createClientWahltageDTO(LocalDate.now().minusMonths(3)))); - //val savedEntities = wahltagRepository.saveAll(entitiesToFind); - + .fromRemoteClientWahltageDTOtoListOfWahltagModel(createClientWahltageDTO(LocalDate.now().minusMonths(3), true))); + val savedEntitiesInRepository_1 = wahltagRepository.saveAll(entitiesToFindInRepository); val request = MockMvcRequestBuilders.get("/businessActions/wahltage"); - //val responseFromController = api.perform(request).andExpect(status().isOk()).andReturn(); + val responseFromController = api.perform(request).andExpect(status().isOk()).andReturn(); + val responseBodyAsListOfDTOs = objectMapper.readValue(responseFromController.getResponse().getContentAsString(), + de.muenchen.oss.wahllokalsystem.basisdatenservice.rest.wahltage.WahltagDTO[].class); + WireMock.verify(1, WireMock.anyRequestedFor(WireMock.anyUrl())); + val expectedResponseBody_1 = dtoMapper.fromListOfWahltagModelToListOfWahltagDTO( + modelMapper.fromWahltagEntityToWahltagModelList((List) savedEntitiesInRepository_1)); - // beim lesen wird im service auch gespeichert und wegen uuid wird doppelt gespeichert. + Assertions.assertThat(new ArrayList(Arrays.asList(responseBodyAsListOfDTOs))) + .usingRecursiveComparison().ignoringCollectionOrder() + .ignoringFields("beschreibung") + .isEqualTo(expectedResponseBody_1); - val response = api.perform(request).andExpect(status().isOk()).andReturn(); - val responseBodyAsListOfDTOs = objectMapper.readValue(response.getResponse().getContentAsString(), de.muenchen.oss.wahllokalsystem.basisdatenservice.rest.wahltage.WahltagDTO[].class); + Assertions.assertThat(new ArrayList(Arrays.asList(responseBodyAsListOfDTOs))) + .usingRecursiveComparison().ignoringCollectionOrder() + .isNotEqualTo(expectedResponseBody_1); - val expectedResponseBody = dtoMapper.fromListOfWahltagModelToListOfWahltagDTO( - modelMapper.fromWahltagEntityToWahltagModelList(entitiesToFind) - ); + val expectedResponseBody_2 = dtoMapper.fromListOfWahltagModelToListOfWahltagDTO( + modelMapper.fromWahltagEntityToWahltagModelList(wahltagRepository.findAllByOrderByWahltagAsc())); - Assertions.assertThat(responseBodyAsListOfDTOs).containsExactlyInAnyOrderElementsOf(expectedResponseBody); - //WireMock.verify(0, WireMock.anyRequestedFor(WireMock.anyUrl())); + Assertions.assertThat(responseBodyAsListOfDTOs).containsExactlyInAnyOrderElementsOf(expectedResponseBody_2); } @Test @@ -182,30 +187,29 @@ void technischeWlsExceptionWhenNoExternalDataFound() throws Exception { } } - private de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO createClientWahltageDTO(LocalDate sinceTag) { + private de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO createClientWahltageDTO(LocalDate sinceTag, + boolean differentAsInDummyClient) { val clientWahltageDTO = new de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO(); val wahltag1 = new de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltagDTO(); wahltag1.setIdentifikator("identifikatorWahltag1"); - wahltag1.setBeschreibung("beschreibungWahltag1"); + wahltag1.setBeschreibung((differentAsInDummyClient) ? "diff_beschreibungWahltag1" : "beschreibungWahltag1"); wahltag1.setNummer("nummerWahltag1"); wahltag1.setTag(LocalDate.now().minusMonths(2)); val wahltag2 = new de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltagDTO(); wahltag2.setIdentifikator("identifikatorWahltag2"); - wahltag2.setBeschreibung("beschreibungWahltag2"); + wahltag2.setBeschreibung((differentAsInDummyClient) ? "diff_beschreibungWahltag2" : "beschreibungWahltag2"); wahltag2.setNummer("nummerWahltag2"); wahltag2.setTag(LocalDate.now().minusMonths(1)); val wahltag3 = new WahltagDTO(); wahltag3.setIdentifikator("identifikatorWahltag3"); - wahltag3.setBeschreibung("beschreibungWahltag3"); + wahltag3.setBeschreibung((differentAsInDummyClient) ? "diff_beschreibungWahltag3" : "beschreibungWahltag3"); wahltag3.setNummer("nummerWahltag3"); wahltag3.setTag(LocalDate.now().plusMonths(1)); - - val wahltage = Set.of(wahltag1, wahltag2, wahltag3); clientWahltageDTO.setWahltage(wahltage); diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageControllerTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageControllerTest.java new file mode 100644 index 000000000..ff29649b4 --- /dev/null +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageControllerTest.java @@ -0,0 +1,52 @@ +package de.muenchen.oss.wahllokalsystem.basisdatenservice.rest.wahltage; + +import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltagModel; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltageService; +import java.util.List; +import lombok.val; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class WahltageControllerTest { + + @Mock + WahltageService wahltageService; + + @Mock + WahltageDTOMapper wahltageDTOMapper; + + @InjectMocks + WahltageController wahltageController; + + @Nested + class GetWahltage { + + @Test + void serviceIsCalledAndObjectsAreMapped() { + + List wahltagModels = List.of( + WahltagModel.builder().build(), + WahltagModel.builder().build(), + WahltagModel.builder().build()); + + List wahltagDTOs = List.of( + WahltagDTO.builder().build(), + WahltagDTO.builder().build(), + WahltagDTO.builder().build()); + + Mockito.when(wahltageService.getWahltage()).thenReturn(wahltagModels); + Mockito.when(wahltageDTOMapper.fromListOfWahltagModelToListOfWahltagDTO(wahltagModels)).thenReturn(wahltagDTOs); + + val result = wahltageController.getWahltage(); + + Assertions.assertThat(result.getBody()).isEqualTo(wahltagDTOs); + } + } +} diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageDTOMapperTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageDTOMapperTest.java new file mode 100644 index 000000000..25b72ae4c --- /dev/null +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageDTOMapperTest.java @@ -0,0 +1,56 @@ +package de.muenchen.oss.wahllokalsystem.basisdatenservice.rest.wahltage; + +import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltagModel; +import java.time.LocalDate; +import java.util.List; +import lombok.val; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.mapstruct.factory.Mappers; + +class WahltageDTOMapperTest { + + private final WahltageDTOMapper unitUnderTest = Mappers.getMapper(WahltageDTOMapper.class); + + @Nested + class FromListOfWahltagModelToListOfWahltagDTO { + + @Test + void nullInNullOut() { + Assertions.assertThat(unitUnderTest.fromListOfWahltagModelToListOfWahltagDTO(null)).isNull(); + } + + @Test + void isMappedToDTO() { + + val modelsInput = createClientWahltagModels(); + val dtosExpected = createClientWahltagDTOs(); + + val result = unitUnderTest.fromListOfWahltagModelToListOfWahltagDTO(modelsInput); + Assertions.assertThat(result).isEqualTo(dtosExpected); + } + + private List createClientWahltagDTOs() { + + val wahltag1 = new WahltagDTO("identifikatorWahltag1", LocalDate.now().minusMonths(2), "beschreibungWahltag1", "nummerWahltag1"); + val wahltag2 = new WahltagDTO("identifikatorWahltag2", LocalDate.now().minusMonths(1), "beschreibungWahltag2", "nummerWahltag2"); + val wahltag3 = new WahltagDTO("identifikatorWahltag3", LocalDate.now().plusMonths(1), "beschreibungWahltag3", "nummerWahltag3"); + + val wahltageDTOs = List.of(wahltag1, wahltag2, wahltag3); + + return wahltageDTOs; + } + + private List createClientWahltagModels() { + + 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; + } + } +} From b076eea460d46204491743e24997d9b8ee054bd2 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Fri, 12 Jul 2024 17:45:06 +0200 Subject: [PATCH 05/51] =?UTF-8?q?Zugriffsrechte=20f=C3=BCr=20getWahltage?= =?UTF-8?q?=20erg=C3=A4nzt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../add-authorities-basisdaten-wahltage.yml | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 stack/keycloak/migration/add-authorities-basisdaten-wahltage.yml diff --git a/stack/keycloak/migration/add-authorities-basisdaten-wahltage.yml b/stack/keycloak/migration/add-authorities-basisdaten-wahltage.yml new file mode 100644 index 000000000..032595ad2 --- /dev/null +++ b/stack/keycloak/migration/add-authorities-basisdaten-wahltage.yml @@ -0,0 +1,37 @@ +id: add authorities basisdaten wahlvorschlaege +author: Nic12345678 +realm: ${SSO_REALM} +changes: + - addRole: + name: Basisdaten_BUSINESSACTION_GetWahltage + clientRole: true + clientId: ${SSO_CLIENT_ID} + - assignRoleToGroup: + group: allBasisdatenAuthorities + role: Basisdaten_BUSINESSACTION_GetWahltage + clientId: ${SSO_CLIENT_ID} + + - addRole: + name: Basisdaten_READ_Wahltag + clientRole: true + clientId: ${SSO_CLIENT_ID} + - assignRoleToGroup: + group: allBasisdatenAuthorities + role: Basisdaten_READ_Wahltag + clientId: ${SSO_CLIENT_ID} + - addRole: + name: Basisdaten_WRITE_Wahltag + clientRole: true + clientId: ${SSO_CLIENT_ID} + - assignRoleToGroup: + group: allBasisdatenAuthorities + role: Basisdaten_WRITE_Wahltag + clientId: ${SSO_CLIENT_ID} + - addRole: + name: Basisdaten_DELETE_Wahltag + clientRole: true + clientId: ${SSO_CLIENT_ID} + - assignRoleToGroup: + group: allBasisdatenAuthorities + role: Basisdaten_DELETE_Wahltag + clientId: ${SSO_CLIENT_ID} \ No newline at end of file From c22b6e49e158b42fb8673c1940226dd6663786c8 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Fri, 12 Jul 2024 17:45:59 +0200 Subject: [PATCH 06/51] =?UTF-8?q?Tests=20erg=C3=A4nzt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/WahltagRepositoryTest.java | 83 ++++++++++++ .../wahltag/WahltagModelMapperTest.java | 83 ++++++++++++ .../wahltag/WahltageServiceSecurityTest.java | 120 ++++++++++++++++++ .../services/wahltag/WahltageServiceTest.java | 71 +++++++++++ 4 files changed, 357 insertions(+) create mode 100644 wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/WahltagRepositoryTest.java create mode 100644 wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModelMapperTest.java create mode 100644 wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageServiceSecurityTest.java create mode 100644 wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageServiceTest.java 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 new file mode 100644 index 000000000..21afca9de --- /dev/null +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/WahltagRepositoryTest.java @@ -0,0 +1,83 @@ +package de.muenchen.oss.wahllokalsystem.basisdatenservice.domain; + +import static de.muenchen.oss.wahllokalsystem.basisdatenservice.TestConstants.SPRING_NO_SECURITY_PROFILE; +import static de.muenchen.oss.wahllokalsystem.basisdatenservice.TestConstants.SPRING_TEST_PROFILE; + +import java.time.LocalDate; +import java.util.Arrays; +import java.util.Optional; +import lombok.val; +import org.assertj.core.api.Assertions; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.MicroServiceApplication; +import java.util.Comparator; +import java.util.List; +import lombok.extern.slf4j.Slf4j; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +@SpringBootTest( + classes = { MicroServiceApplication.class }, + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT +) +@ActiveProfiles(profiles = { SPRING_TEST_PROFILE, SPRING_NO_SECURITY_PROFILE }) +@Slf4j +class WahltagRepositoryTest { + + @Autowired + private WahltagRepository repository; + + @Test + void findAll() { + List wahltageToSave1 = createWahltagList("1"); + List wahltageToSave2 = createWahltagList("2"); + List wahltageToSave3 = createWahltagList("3"); + repository.saveAll(wahltageToSave1); + repository.saveAll(wahltageToSave2); + repository.saveAll(wahltageToSave3); + List foundWahltage = repository.findAll(); + Assertions.assertThat(foundWahltage).containsAll(wahltageToSave1).containsAll(wahltageToSave2).containsAll(wahltageToSave3); + } + + @Test + void findById() { + List wahltageToSave1 = createWahltagList("X"); + repository.saveAll(wahltageToSave1); + Wahltag wahltag3 = wahltageToSave1.get(2); + Optional foundWahltagById = repository.findById("X_identifikatorWahltag3"); + + Assertions.assertThat(foundWahltagById).isPresent(); + Assertions.assertThat(foundWahltagById.get()).isEqualTo(wahltag3); + } + + /** + * Tests if searched returned Wahltags are right sorted + */ + @Test + @Transactional(propagation = Propagation.REQUIRED, noRollbackFor = Exception.class) + void findAllByOrderByWahltagAsc() { + List wahltageToSave = createWahltagList("1"); + repository.saveAll(wahltageToSave); + List foundWahltage = repository.findAllByOrderByWahltagAsc(); + + wahltageToSave.sort( + Comparator + .comparing((Wahltag w) -> w.getWahltag()) + .thenComparing((Wahltag w) -> w.getWahltag())); + + Assertions.assertThat(wahltageToSave).isEqualTo(foundWahltage); + } + + private List createWahltagList(String pIndex) { + val wahltag4 = new Wahltag(pIndex + "_identifikatorWahltag4", LocalDate.now().plusMonths(5), "beschreibungWahltag4", "nummerWahltag4"); + val wahltag1 = new Wahltag(pIndex + "_identifikatorWahltag1", LocalDate.now().minusMonths(2), "beschreibungWahltag1", "nummerWahltag1"); + 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; + } +} 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 new file mode 100644 index 000000000..cc6243ad0 --- /dev/null +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModelMapperTest.java @@ -0,0 +1,83 @@ +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; +import lombok.val; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.mapstruct.factory.Mappers; + +class WahltagModelMapperTest { + + private final WahltagModelMapper unitUnderTest = Mappers.getMapper(WahltagModelMapper.class); + + @Test + void toEntity() { + val modelToMap = createWahltagModel(); + + val result = unitUnderTest.toEntity(modelToMap); + + val expectedResult = createWahltagEntity(); + Assertions.assertThat(result).isEqualTo(expectedResult); + } + + @Test + void toModel() { + val entityToMap = createWahltagEntity(); + + val result = unitUnderTest.toModel(entityToMap); + + val expectedResult = createWahltagModel(); + Assertions.assertThat(result).isEqualTo(expectedResult); + } + + @Test + void fromWahltagModelToWahltagEntityList() { + val modelsToMap = createWahltagModelList(); + + val result = unitUnderTest.fromWahltagModelToWahltagEntityList(modelsToMap); + + val expectedResult = createWahltagList(); + Assertions.assertThat(result).isEqualTo(expectedResult); + } + + @Test + void fromWahltagEntityToWahltagModelList() { + val entitiesToMap = createWahltagList(); + + val result = unitUnderTest.fromWahltagEntityToWahltagModelList(entitiesToMap); + + val expectedResult = createWahltagModelList(); + Assertions.assertThat(result).isEqualTo(expectedResult); + } + + private Wahltag createWahltagEntity() { + return new Wahltag("identifikatorWahltag1", LocalDate.now().minusMonths(2), "beschreibungWahltag1", "nummerWahltag1"); + } + + private WahltagModel createWahltagModel() { + return new WahltagModel("identifikatorWahltag1", LocalDate.now().minusMonths(2), "beschreibungWahltag1", "nummerWahltag1"); + } + + private List createWahltagList() { + val wahltag1 = new Wahltag("identifikatorWahltag1", LocalDate.now().minusMonths(2), "beschreibungWahltag1", "nummerWahltag1"); + 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; + } + + private List 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; + } +} diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageServiceSecurityTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageServiceSecurityTest.java new file mode 100644 index 000000000..5a0842abc --- /dev/null +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageServiceSecurityTest.java @@ -0,0 +1,120 @@ +package de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.github.tomakehurst.wiremock.client.WireMock; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.MicroServiceApplication; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.TestConstants; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.domain.WahltagRepository; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.domain.WahlvorschlaegeRepository; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.KandidatDTO; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltagDTO; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahlvorschlaegeDTO; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahlvorschlagDTO; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahlvorschlag.WahlvorschlaegeService; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.utils.Authorities; +import de.muenchen.oss.wahllokalsystem.wls.common.security.domain.BezirkUndWahlID; +import de.muenchen.oss.wahllokalsystem.wls.common.testing.SecurityUtils; +import java.time.LocalDate; +import java.util.Set; +import java.util.stream.Stream; +import lombok.val; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.aggregator.ArgumentsAccessor; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; +import org.springframework.http.HttpStatus; +import org.springframework.security.access.AccessDeniedException; +import org.springframework.test.context.ActiveProfiles; + +@SpringBootTest(classes = MicroServiceApplication.class) +@ActiveProfiles(TestConstants.SPRING_TEST_PROFILE) +@AutoConfigureWireMock +public class WahltageServiceSecurityTest { + + @Autowired + WahltageService wahltageService; + + @Autowired + WahltagRepository wahltagRepository; + + @Autowired + ObjectMapper objectMapper; + + @Nested + class GetWahltage { + + @AfterEach + void tearDown() { + SecurityUtils.runWith(Authorities.ALL_AUTHORITIES_DELETE_WAHLTAGE); + wahltagRepository.deleteAll(); + } + + @Test + void accessGranted() throws Exception { + SecurityUtils.runWith(Authorities.ALL_AUTHORITIES_GET_WAHLTAGE); + + String requestDate = LocalDate.now().minusMonths(3).toString(); + val eaiWahltage = createClientWahltageDTO(); + + WireMock.stubFor(WireMock.get("/wahldaten/wahltage?includingAfter=" + requestDate) + .willReturn(WireMock.aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()) + .withBody(objectMapper.writeValueAsBytes(eaiWahltage)))); + + Assertions.assertThatNoException().isThrownBy(() -> wahltageService.getWahltage()); + } + + @ParameterizedTest(name = "{index} - {1} missing") + @MethodSource("getMissingAuthoritiesVariations") + void missingAuthorityCausesFailWithAccessDenied(final ArgumentsAccessor argumentsAccessor) throws Exception { + SecurityUtils.runWith(argumentsAccessor.get(0, String[].class)); + + String requestDate = LocalDate.now().minusMonths(3).toString(); + val eaiWahltage = createClientWahltageDTO(); + + WireMock.stubFor(WireMock.get("/wahldaten/wahltage?includingAfter=" + requestDate) + .willReturn(WireMock.aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()) + .withBody(objectMapper.writeValueAsBytes(eaiWahltage)))); + + Assertions.assertThatException().isThrownBy(() -> wahltageService.getWahltage()) + .isInstanceOf( + AccessDeniedException.class); + } + + private static Stream getMissingAuthoritiesVariations() { + return SecurityUtils.buildArgumentsForMissingAuthoritiesVariations(Authorities.ALL_AUTHORITIES_DELETE_WAHLTAGE); + } + + private WahltageDTO createClientWahltageDTO() { + val dto = new WahltageDTO(); + val wahltag1 = new WahltagDTO(); + wahltag1.setIdentifikator("identifikatorWahltag1"); + wahltag1.setBeschreibung("beschreibungWahltag1"); + wahltag1.setNummer("nummerWahltag1"); + wahltag1.setTag(LocalDate.now().minusMonths(2)); + + val wahltag2 = new WahltagDTO(); + wahltag2.setIdentifikator("identifikatorWahltag2"); + wahltag2.setBeschreibung("beschreibungWahltag2"); + wahltag2.setNummer("nummerWahltag2"); + wahltag2.setTag(LocalDate.now().minusMonths(1)); + + val wahltag3 = new WahltagDTO(); + wahltag3.setIdentifikator("identifikatorWahltag3"); + wahltag3.setBeschreibung("beschreibungWahltag3"); + wahltag3.setNummer("nummerWahltag3"); + wahltag3.setTag(LocalDate.now().plusMonths(1)); + + dto.setWahltage(Set.of(wahltag3, wahltag2, wahltag1)); + + return dto; + } + } +} 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 new file mode 100644 index 000000000..eb280b87d --- /dev/null +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageServiceTest.java @@ -0,0 +1,71 @@ +package de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag; + +import org.assertj.core.api.Assertions; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.domain.Wahltag; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.domain.WahltagRepository; +import java.time.LocalDate; +import java.util.List; +import lombok.val; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +class WahltageServiceTest { + + @Mock + WahltagRepository wahltagRepository; + @Mock + WahltagModelMapper wahltagModelMapper; + @Mock + WahltageClient wahltageClient; + + @InjectMocks + WahltageService unitUnderTest; + + @Nested + class GetWahltage { + + @Test + void dataIsLoadedFromRemoteEvenIfExistingInRepoAndRepoIsUpdated() { + List mockedListOfEntities = createWahltagList("2"); + List mockedClientResponse = createWahltagModelList("2"); + List mockedMappedSavedEntities = createWahltagModelList("2"); + + Mockito.when(wahltageClient.getWahltage(LocalDate.now().minusMonths(3))).thenReturn(mockedClientResponse); + Mockito.when(wahltagModelMapper.fromWahltagModelToWahltagEntityList(mockedClientResponse)).thenReturn(mockedListOfEntities); + Mockito.when(wahltagRepository.saveAll(mockedListOfEntities)).thenReturn(mockedListOfEntities); + Mockito.when(wahltagRepository.findAllByOrderByWahltagAsc()).thenReturn(mockedListOfEntities); + Mockito.when(wahltagModelMapper.fromWahltagEntityToWahltagModelList(mockedListOfEntities)).thenReturn(mockedMappedSavedEntities); + + val result = unitUnderTest.getWahltage(); + Assertions.assertThat(result).isSameAs(mockedMappedSavedEntities); + Mockito.verify(wahltagRepository).saveAll(mockedListOfEntities); + + } + + private List createWahltagList(String pIndex) { + val wahltag1 = new Wahltag(pIndex + "_identifikatorWahltag1", LocalDate.now().minusMonths(2), "beschreibungWahltag1", "nummerWahltag1"); + 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; + } + + private List 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; + } + } +} From 1fd6b124cdc5a87208741c96114dd5d298bb296a Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Fri, 12 Jul 2024 18:07:03 +0200 Subject: [PATCH 07/51] Tests an neue Api angepasst loadSince nicht loadFrom --- .../domain/WahltagRepositoryTest.java | 6 ++++++ .../wahltage/WahltageControllerIntegrationTest.java | 6 +++--- .../services/wahltag/WahltageServiceSecurityTest.java | 10 ++-------- 3 files changed, 11 insertions(+), 11 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 21afca9de..a6e19c9eb 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 @@ -12,6 +12,7 @@ import java.util.Comparator; import java.util.List; import lombok.extern.slf4j.Slf4j; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -30,6 +31,11 @@ class WahltagRepositoryTest { @Autowired private WahltagRepository repository; + @AfterEach + void tearDown() throws Exception { + repository.deleteAll(); + } + @Test void findAll() { List wahltageToSave1 = createWahltagList("1"); 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 82449d37b..9933490d3 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 @@ -93,7 +93,7 @@ void loadedFromExternal() throws Exception { String requestDate = LocalDate.now().minusMonths(3).toString(); val eaiWahltage = createClientWahltageDTO(LocalDate.now().minusMonths(3), false); - WireMock.stubFor(WireMock.get("/wahldaten/wahltage?includingAfter=" + requestDate) + WireMock.stubFor(WireMock.get("/wahldaten/wahltage?includingSince=" + requestDate) .willReturn(WireMock.aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()) .withBody(objectMapper.writeValueAsBytes(eaiWahltage)))); @@ -116,7 +116,7 @@ void externalDataIsPersisted() throws Exception { String requestDate = LocalDate.now().minusMonths(3).toString(); val eaiWahltage = createClientWahltageDTO(LocalDate.now().minusMonths(3), false); - WireMock.stubFor(WireMock.get("/wahldaten/wahltage?includingAfter=" + requestDate) + WireMock.stubFor(WireMock.get("/wahldaten/wahltage?includingSince=" + requestDate) .willReturn(WireMock.aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()) .withBody(objectMapper.writeValueAsBytes(eaiWahltage)))); @@ -172,7 +172,7 @@ void technischeWlsExceptionWhenNoExternalDataFound() throws Exception { String requestDate = LocalDate.now().minusMonths(3).toString(); - WireMock.stubFor(WireMock.get("/wahldaten/wahltage?includingAfter=" + requestDate) + WireMock.stubFor(WireMock.get("/wahldaten/wahltage?includingSince=" + requestDate) .willReturn(WireMock.aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.NOT_FOUND.value()))); val request = MockMvcRequestBuilders.get("/businessActions/wahltage"); diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageServiceSecurityTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageServiceSecurityTest.java index 5a0842abc..5be8576e2 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageServiceSecurityTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageServiceSecurityTest.java @@ -5,15 +5,9 @@ import de.muenchen.oss.wahllokalsystem.basisdatenservice.MicroServiceApplication; import de.muenchen.oss.wahllokalsystem.basisdatenservice.TestConstants; import de.muenchen.oss.wahllokalsystem.basisdatenservice.domain.WahltagRepository; -import de.muenchen.oss.wahllokalsystem.basisdatenservice.domain.WahlvorschlaegeRepository; -import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.KandidatDTO; import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltagDTO; import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO; -import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahlvorschlaegeDTO; -import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahlvorschlagDTO; -import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahlvorschlag.WahlvorschlaegeService; import de.muenchen.oss.wahllokalsystem.basisdatenservice.utils.Authorities; -import de.muenchen.oss.wahllokalsystem.wls.common.security.domain.BezirkUndWahlID; import de.muenchen.oss.wahllokalsystem.wls.common.testing.SecurityUtils; import java.time.LocalDate; import java.util.Set; @@ -64,7 +58,7 @@ void accessGranted() throws Exception { String requestDate = LocalDate.now().minusMonths(3).toString(); val eaiWahltage = createClientWahltageDTO(); - WireMock.stubFor(WireMock.get("/wahldaten/wahltage?includingAfter=" + requestDate) + WireMock.stubFor(WireMock.get("/wahldaten/wahltage?includingSince=" + requestDate) .willReturn(WireMock.aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()) .withBody(objectMapper.writeValueAsBytes(eaiWahltage)))); @@ -79,7 +73,7 @@ void missingAuthorityCausesFailWithAccessDenied(final ArgumentsAccessor argument String requestDate = LocalDate.now().minusMonths(3).toString(); val eaiWahltage = createClientWahltageDTO(); - WireMock.stubFor(WireMock.get("/wahldaten/wahltage?includingAfter=" + requestDate) + WireMock.stubFor(WireMock.get("/wahldaten/wahltage?includingSince=" + requestDate) .willReturn(WireMock.aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value()) .withBody(objectMapper.writeValueAsBytes(eaiWahltage)))); From 7f6ba66f7f687ff692a4139f71cd4eca76f380f1 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Fri, 12 Jul 2024 18:07:46 +0200 Subject: [PATCH 08/51] Umstieg auf neues openapi.json file --- wls-basisdaten-service/pom.xml | 33 ++++++++++++++++++- .../openapis/openapi.eai.0.0.1-RC1.json | 1 - .../src/main/resources/openapis/openapi.json | 1 + 3 files changed, 33 insertions(+), 2 deletions(-) delete mode 100644 wls-basisdaten-service/src/main/resources/openapis/openapi.eai.0.0.1-RC1.json create mode 100644 wls-basisdaten-service/src/main/resources/openapis/openapi.json diff --git a/wls-basisdaten-service/pom.xml b/wls-basisdaten-service/pom.xml index 52379108b..e3cc35ba0 100644 --- a/wls-basisdaten-service/pom.xml +++ b/wls-basisdaten-service/pom.xml @@ -333,6 +333,18 @@ repackage + + pre-integration-test + + start + + + + post-integration-test + + stop + + @@ -381,7 +393,7 @@ generate - ${project.basedir}/src/main/resources/openapis/openapi.eai.0.0.1-RC1.json + ${project.basedir}/src/main/resources/openapis/openapi.json java resttemplate @@ -516,6 +528,25 @@ + + + org.springdoc + springdoc-openapi-maven-plugin + 1.4 + + + integration-test + + generate + + + + + http://localhost:8080/v3/api-docs + openapi.json + ${project.build.directory} + + diff --git a/wls-basisdaten-service/src/main/resources/openapis/openapi.eai.0.0.1-RC1.json b/wls-basisdaten-service/src/main/resources/openapis/openapi.eai.0.0.1-RC1.json deleted file mode 100644 index e254cb9c9..000000000 --- a/wls-basisdaten-service/src/main/resources/openapis/openapi.eai.0.0.1-RC1.json +++ /dev/null @@ -1 +0,0 @@ -{"openapi":"3.0.1","info":{"title":"EAI Service","contact":{"name":"Your Name","email":"Your E-Mail-Address"},"version":"0.0.1-RC1"},"servers":[{"url":"http://localhost:8080","description":"Generated server url"}],"security":[{"bearerAuth":[]}],"paths":{"/wahlvorstaende":{"get":{"tags":["wahlvorstand-controller"],"operationId":"loadWahlvorstand","parameters":[{"name":"wahlbezirkID","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/WahlvorstandDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"no resource found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}},"post":{"tags":["wahlvorstand-controller"],"operationId":"saveAnwesenheit","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WahlvorstandsaktualisierungDTO"}}},"required":true},"responses":{"200":{"description":"OK"},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"no resource found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahllokalzustand":{"post":{"tags":["wahllokalzustand-controller"],"operationId":"saveWahllokalZustand","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WahllokalZustandDTO"}}},"required":true},"responses":{"200":{"description":"OK"},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"no resource found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahlergebnis":{"post":{"tags":["wahlergebnis-controller"],"operationId":"saveWahlergebnismeldung","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErgebnismeldungDTO"}}},"required":true},"responses":{"200":{"description":"OK"},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"no resource found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahlbeteiligung":{"post":{"tags":["wahlbeteiligung-controller"],"operationId":"saveWahlbeteiligung","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WahlbeteiligungsMeldungDTO"}}},"required":true},"responses":{"200":{"description":"OK"},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"no resource found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahldaten/wahltage":{"get":{"tags":["wahldaten-controller"],"operationId":"loadWahltageSinceIncluding","parameters":[{"name":"includingAfter","in":"query","required":true,"schema":{"type":"string","format":"date"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/WahltageDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"no resource found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahldaten/wahlen":{"get":{"tags":["wahldaten-controller"],"operationId":"loadWahlen","parameters":[{"name":"forDate","in":"query","required":true,"schema":{"type":"string","format":"date"}},{"name":"withNummer","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/WahlenDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"no resource found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahldaten/wahlbezirke/{wahlbezirkID}/wahlberechtigte":{"get":{"tags":["wahldaten-controller"],"operationId":"loadWahlberechtigte","parameters":[{"name":"wahlbezirkID","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/WahlberechtigteDTO"}}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"no resource found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahldaten/wahlbezirk":{"get":{"tags":["wahldaten-controller"],"operationId":"loadWahlbezirke","parameters":[{"name":"forDate","in":"query","required":true,"schema":{"type":"string","format":"date"}},{"name":"withNummer","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/WahlbezirkeDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"no resource found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahldaten/basisdaten":{"get":{"tags":["wahldaten-controller"],"operationId":"getBasisdaten","parameters":[{"name":"forDate","in":"query","required":true,"schema":{"type":"string","format":"date"}},{"name":"withNummer","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/BasisdatenDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"no resource found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/vorschlaege/wahl/{wahlID}/{wahlbezirkID}":{"get":{"tags":["wahlvorschlag-controller"],"operationId":"loadWahlvorschlaege","parameters":[{"name":"wahlID","in":"path","required":true,"schema":{"type":"string"}},{"name":"wahlbezirkID","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/WahlvorschlaegeDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"no resource found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/vorschlaege/wahl/{wahlID}/liste":{"get":{"tags":["wahlvorschlag-controller"],"operationId":"loadWahlvorschlaegeListe","parameters":[{"name":"forDate","in":"query","required":true,"schema":{"type":"string","format":"date"}},{"name":"wahlID","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/WahlvorschlaegeListeDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"no resource found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/vorschlaege/referendum/{wahlID}/{wahlbezirkID}":{"get":{"tags":["wahlvorschlag-controller"],"operationId":"loadReferendumvorlagen","parameters":[{"name":"wahlID","in":"path","required":true,"schema":{"type":"string"}},{"name":"wahlbezirkID","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ReferendumvorlagenDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"no resource found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}}},"components":{"schemas":{"WahlvorstandsaktualisierungDTO":{"required":["anwesenheitBeginn","mitglieder","wahlbezirkID"],"type":"object","properties":{"wahlbezirkID":{"type":"string"},"mitglieder":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlvorstandsmitgliedAktualisierungDTO"}},"anwesenheitBeginn":{"type":"string","format":"date-time"}}},"WahlvorstandsmitgliedAktualisierungDTO":{"required":["anwesend","identifikator"],"type":"object","properties":{"identifikator":{"type":"string"},"anwesend":{"type":"boolean"}}},"DruckzustandDTO":{"required":["niederschriftDruckUhrzeit","niederschriftSendenUhrzeit","schnellmeldungDruckUhrzeit","schnellmeldungSendenUhrzeit","wahlID"],"type":"object","properties":{"wahlID":{"type":"string"},"schnellmeldungSendenUhrzeit":{"type":"string","format":"date-time"},"niederschriftSendenUhrzeit":{"type":"string","format":"date-time"},"schnellmeldungDruckUhrzeit":{"type":"string","format":"date-time"},"niederschriftDruckUhrzeit":{"type":"string","format":"date-time"}}},"WahllokalZustandDTO":{"required":["druckzustaende","letzteAbmeldung","wahlbezirkID","zuletztGesehen"],"type":"object","properties":{"wahlbezirkID":{"type":"string"},"zuletztGesehen":{"type":"string","format":"date-time"},"letzteAbmeldung":{"type":"string","format":"date-time"},"druckzustaende":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/DruckzustandDTO"}}}},"AWerteDTO":{"type":"object","properties":{"a1":{"type":"integer","format":"int64"},"a2":{"type":"integer","format":"int64"}}},"BWerteDTO":{"type":"object","properties":{"b":{"type":"integer","format":"int64"},"b1":{"type":"integer","format":"int64"},"b2":{"type":"integer","format":"int64"}}},"ErgebnisDTO":{"required":["ergebnis","kandidatID","stimmenart","wahlvorschlagID","wahlvorschlagsordnungszahl"],"type":"object","properties":{"stimmenart":{"type":"string"},"wahlvorschlagsordnungszahl":{"type":"integer","format":"int64"},"ergebnis":{"type":"integer","format":"int64"},"wahlvorschlagID":{"type":"string"},"kandidatID":{"type":"string"}}},"ErgebnismeldungDTO":{"required":["wahlID","wahlbezirkID"],"type":"object","properties":{"wahlbezirkID":{"type":"string"},"wahlID":{"type":"string"},"meldungsart":{"type":"string","enum":["NIEDERSCHRIFT","SCHNELLMELDUNG"]},"aWerte":{"$ref":"#/components/schemas/AWerteDTO"},"bWerte":{"$ref":"#/components/schemas/BWerteDTO"},"wahlbriefeWerte":{"$ref":"#/components/schemas/WahlbriefeWerteDTO"},"ungueltigeStimmzettels":{"type":"array","items":{"$ref":"#/components/schemas/UngueltigeStimmzettelDTO"}},"ungueltigeStimmzettelAnzahl":{"type":"integer","format":"int64"},"ergebnisse":{"type":"array","items":{"$ref":"#/components/schemas/ErgebnisDTO"}},"wahlart":{"type":"string","enum":["BAW","BEB","BTW","BZW","EUW","LTW","MBW","OBW","SRW","SVW","VE"]}}},"UngueltigeStimmzettelDTO":{"type":"object","properties":{"stimmenart":{"type":"string"},"anzahl":{"type":"integer","format":"int64"},"wahlvorschlagID":{"type":"string"}}},"WahlbriefeWerteDTO":{"type":"object","properties":{"zurueckgewiesenGesamt":{"type":"integer","format":"int64"}}},"WahlbeteiligungsMeldungDTO":{"required":["anzahlWaehler","meldeZeitpunkt","wahlID","wahlbezirkID"],"type":"object","properties":{"wahlID":{"type":"string"},"wahlbezirkID":{"type":"string"},"anzahlWaehler":{"type":"integer","format":"int64"},"meldeZeitpunkt":{"type":"string","format":"date-time"}}},"WahlvorstandDTO":{"required":["anwesenheitBeginn","mitglieder","wahlbezirkID"],"type":"object","properties":{"anwesenheitBeginn":{"type":"string","format":"date-time"},"wahlbezirkID":{"type":"string"},"mitglieder":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlvorstandsmitgliedDTO"}}}},"WahlvorstandsmitgliedDTO":{"required":["anwesend","funktion","identifikator","nachname","vorname"],"type":"object","properties":{"identifikator":{"type":"string"},"vorname":{"type":"string"},"nachname":{"type":"string"},"funktion":{"type":"string"},"anwesend":{"type":"boolean"}}},"WahltagDTO":{"required":["beschreibung","identifikator","nummer","tag"],"type":"object","properties":{"identifikator":{"type":"string"},"tag":{"type":"string","format":"date"},"beschreibung":{"type":"string"},"nummer":{"type":"string"}}},"WahltageDTO":{"required":["wahltage"],"type":"object","properties":{"wahltage":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahltagDTO"}}}},"WahlDTO":{"required":["identifikator","name","nummer","wahlart","wahltag"],"type":"object","properties":{"identifikator":{"type":"string"},"name":{"type":"string"},"wahlart":{"type":"string","enum":["BAW","BEB","BTW","BZW","EUW","LTW","MBW","OBW","SRW","SVW","VE"]},"wahltag":{"type":"string","format":"date"},"nummer":{"type":"string"}}},"WahlenDTO":{"required":["wahlen"],"type":"object","properties":{"wahlen":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlDTO"}}}},"WahlberechtigteDTO":{"required":["a1","a2","a3","wahlID","wahlbezirkID"],"type":"object","properties":{"wahlID":{"type":"string"},"wahlbezirkID":{"type":"string"},"a1":{"type":"integer","format":"int64"},"a2":{"type":"integer","format":"int64"},"a3":{"type":"integer","format":"int64"}}},"WahlbezirkDTO":{"required":["identifikator","nummer","wahlID","wahlbezirkArt","wahlnummer","wahltag"],"type":"object","properties":{"identifikator":{"type":"string"},"wahlbezirkArt":{"type":"string","enum":["UWB","BWB"]},"nummer":{"type":"string"},"wahltag":{"type":"string","format":"date"},"wahlnummer":{"type":"string"},"wahlID":{"type":"string"}}},"WahlbezirkeDTO":{"required":["wahlbezirke"],"type":"object","properties":{"wahlbezirke":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlbezirkDTO"}}}},"BasisdatenDTO":{"required":["basisstrukturdaten","stimmzettelgebiete","wahlbezirke","wahlen"],"type":"object","properties":{"basisstrukturdaten":{"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/BasisstrukturdatenDTO"}},"wahlen":{"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlDTO"}},"wahlbezirke":{"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlbezirkDTO"}},"stimmzettelgebiete":{"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/StimmzettelgebietDTO"}}}},"BasisstrukturdatenDTO":{"required":["stimmzettelgebietID","wahlID","wahlbezirkID","wahltag"],"type":"object","properties":{"wahlID":{"type":"string"},"stimmzettelgebietID":{"type":"string"},"wahlbezirkID":{"type":"string"},"wahltag":{"type":"string","format":"date"}}},"StimmzettelgebietDTO":{"required":["stimmzettelgebietart"],"type":"object","properties":{"identifikator":{"type":"string"},"nummer":{"type":"string"},"name":{"type":"string"},"wahltag":{"type":"string","format":"date"},"stimmzettelgebietart":{"type":"string","enum":["SB","SG","SK","WK"]}}},"KandidatDTO":{"required":["identifikator","listenposition","name","tabellenSpalteInNiederschrift"],"type":"object","properties":{"identifikator":{"type":"string"},"name":{"type":"string"},"listenposition":{"type":"integer","format":"int64"},"direktkandidat":{"type":"boolean"},"tabellenSpalteInNiederschrift":{"type":"integer","format":"int64"},"einzelbewerber":{"type":"boolean"}}},"WahlvorschlaegeDTO":{"required":["stimmzettelgebietID","wahlID","wahlbezirkID","wahlvorschlaege"],"type":"object","properties":{"wahlbezirkID":{"type":"string"},"wahlID":{"type":"string"},"stimmzettelgebietID":{"type":"string"},"wahlvorschlaege":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlvorschlagDTO"}}}},"WahlvorschlagDTO":{"required":["erhaeltStimmen","identifikator","kurzname","ordnungszahl"],"type":"object","properties":{"identifikator":{"type":"string"},"ordnungszahl":{"type":"integer","format":"int64"},"kurzname":{"type":"string"},"erhaeltStimmen":{"type":"boolean"},"kandidaten":{"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/KandidatDTO"}}}},"WahlvorschlaegeListeDTO":{"required":["wahlvorschlaege"],"type":"object","properties":{"wahlvorschlaege":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlvorschlaegeDTO"}}}},"ReferendumoptionDTO":{"required":["id","name"],"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"position":{"type":"integer","format":"int64"}}},"ReferendumvorlageDTO":{"required":["frage","kurzname","ordnungszahl","referendumoption","wahlvorschlagID"],"type":"object","properties":{"wahlvorschlagID":{"type":"string"},"ordnungszahl":{"type":"integer","format":"int64"},"kurzname":{"type":"string"},"frage":{"type":"string"},"referendumoption":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/ReferendumoptionDTO"}}}},"ReferendumvorlagenDTO":{"required":["referendumvorlage","stimmzettelgebietID"],"type":"object","properties":{"stimmzettelgebietID":{"type":"string"},"referendumvorlage":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/ReferendumvorlageDTO"}}}},"WlsExceptionDTO":{"required":["category","code","message","service"],"type":"object","properties":{"category":{"type":"string","enum":["F","T","S","I"]},"code":{"type":"string"},"service":{"type":"string"},"message":{"type":"string"}}}},"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}}}} \ No newline at end of file diff --git a/wls-basisdaten-service/src/main/resources/openapis/openapi.json b/wls-basisdaten-service/src/main/resources/openapis/openapi.json new file mode 100644 index 000000000..bf93e7477 --- /dev/null +++ b/wls-basisdaten-service/src/main/resources/openapis/openapi.json @@ -0,0 +1 @@ +{"openapi":"3.0.1","info":{"title":"EAI Service","contact":{"name":"Your Name","email":"Your E-Mail-Address"},"version":"0.1.1-Beta1"},"servers":[{"url":"http://localhost:8080","description":"Generated server url"}],"security":[{"bearerAuth":[]}],"paths":{"/wahlvorstaende/anwesenheit":{"put":{"tags":["wahlvorstand-controller"],"description":"Aktualisieren der Anwesenheit der Wahlvorstandsmitglieder eines bestimmten Wahlbezirkes","operationId":"saveAnwesenheit","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WahlvorstandsaktualisierungDTO"}}},"required":true},"responses":{"200":{"description":"OK"},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahllokalzustand":{"post":{"tags":["wahllokalzustand-controller"],"operationId":"saveWahllokalZustand","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WahllokalZustandDTO"}}},"required":true},"responses":{"200":{"description":"OK"},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahlergebnis":{"post":{"tags":["wahlergebnis-controller"],"operationId":"saveWahlergebnismeldung","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErgebnismeldungDTO"}}},"required":true},"responses":{"200":{"description":"OK"},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahlbeteiligung":{"post":{"tags":["wahlbeteiligung-controller"],"operationId":"saveWahlbeteiligung","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WahlbeteiligungsMeldungDTO"}}},"required":true},"responses":{"200":{"description":"OK"},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahlvorstaende":{"get":{"tags":["wahlvorstand-controller"],"description":"Abrufen des Wahlvorstandes für einen bestimmten Wahlbezirk","operationId":"loadWahlvorstand","parameters":[{"name":"wahlbezirkID","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/WahlvorstandDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahldaten/wahltage":{"get":{"tags":["wahldaten-controller"],"operationId":"loadWahltageSinceIncluding","parameters":[{"name":"includingSince","in":"query","required":true,"schema":{"type":"string","format":"date"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/WahltageDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahldaten/wahlen":{"get":{"tags":["wahldaten-controller"],"operationId":"loadWahlen","parameters":[{"name":"forDate","in":"query","required":true,"schema":{"type":"string","format":"date"}},{"name":"withNummer","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/WahlenDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahldaten/wahlbezirke/{wahlbezirkID}/wahlberechtigte":{"get":{"tags":["wahldaten-controller"],"operationId":"loadWahlberechtigte","parameters":[{"name":"wahlbezirkID","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/WahlberechtigteDTO"}}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahldaten/wahlbezirk":{"get":{"tags":["wahldaten-controller"],"operationId":"loadWahlbezirke","parameters":[{"name":"forDate","in":"query","required":true,"schema":{"type":"string","format":"date"}},{"name":"withNummer","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/WahlbezirkeDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahldaten/basisdaten":{"get":{"tags":["wahldaten-controller"],"operationId":"loadBasisdaten","parameters":[{"name":"forDate","in":"query","required":true,"schema":{"type":"string","format":"date"}},{"name":"withNummer","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/BasisdatenDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/vorschlaege/wahl/{wahlID}/{wahlbezirkID}":{"get":{"tags":["wahlvorschlag-controller"],"operationId":"loadWahlvorschlaege","parameters":[{"name":"wahlID","in":"path","required":true,"schema":{"type":"string"}},{"name":"wahlbezirkID","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/WahlvorschlaegeDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/vorschlaege/wahl/{wahlID}/liste":{"get":{"tags":["wahlvorschlag-controller"],"operationId":"loadWahlvorschlaegeListe","parameters":[{"name":"forDate","in":"query","required":true,"schema":{"type":"string","format":"date"}},{"name":"wahlID","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/WahlvorschlaegeListeDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/vorschlaege/referendum/{wahlID}/{wahlbezirkID}":{"get":{"tags":["wahlvorschlag-controller"],"operationId":"loadReferendumvorlagen","parameters":[{"name":"wahlID","in":"path","required":true,"schema":{"type":"string"}},{"name":"wahlbezirkID","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ReferendumvorlagenDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}}},"components":{"schemas":{"WahlvorstandsaktualisierungDTO":{"required":["anwesenheitBeginn","mitglieder","wahlbezirkID"],"type":"object","properties":{"wahlbezirkID":{"type":"string"},"mitglieder":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlvorstandsmitgliedAktualisierungDTO"}},"anwesenheitBeginn":{"type":"string","format":"date-time"}}},"WahlvorstandsmitgliedAktualisierungDTO":{"required":["anwesend","identifikator"],"type":"object","properties":{"identifikator":{"type":"string"},"anwesend":{"type":"boolean"}}},"DruckzustandDTO":{"required":["niederschriftDruckUhrzeit","niederschriftSendenUhrzeit","schnellmeldungDruckUhrzeit","schnellmeldungSendenUhrzeit","wahlID"],"type":"object","properties":{"wahlID":{"type":"string"},"schnellmeldungSendenUhrzeit":{"type":"string","format":"date-time"},"niederschriftSendenUhrzeit":{"type":"string","format":"date-time"},"schnellmeldungDruckUhrzeit":{"type":"string","format":"date-time"},"niederschriftDruckUhrzeit":{"type":"string","format":"date-time"}}},"WahllokalZustandDTO":{"required":["druckzustaende","letzteAbmeldung","wahlbezirkID","zuletztGesehen"],"type":"object","properties":{"wahlbezirkID":{"type":"string"},"zuletztGesehen":{"type":"string","format":"date-time"},"letzteAbmeldung":{"type":"string","format":"date-time"},"druckzustaende":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/DruckzustandDTO"}}}},"AWerteDTO":{"type":"object","properties":{"a1":{"type":"integer","format":"int64"},"a2":{"type":"integer","format":"int64"}}},"BWerteDTO":{"type":"object","properties":{"b":{"type":"integer","format":"int64"},"b1":{"type":"integer","format":"int64"},"b2":{"type":"integer","format":"int64"}}},"ErgebnisDTO":{"required":["ergebnis","kandidatID","stimmenart","wahlvorschlagID","wahlvorschlagsordnungszahl"],"type":"object","properties":{"stimmenart":{"type":"string"},"wahlvorschlagsordnungszahl":{"type":"integer","format":"int64"},"ergebnis":{"type":"integer","format":"int64"},"wahlvorschlagID":{"type":"string"},"kandidatID":{"type":"string"}}},"ErgebnismeldungDTO":{"required":["wahlID","wahlbezirkID"],"type":"object","properties":{"wahlbezirkID":{"type":"string"},"wahlID":{"type":"string"},"meldungsart":{"type":"string","enum":["NIEDERSCHRIFT","SCHNELLMELDUNG"]},"aWerte":{"$ref":"#/components/schemas/AWerteDTO"},"bWerte":{"$ref":"#/components/schemas/BWerteDTO"},"wahlbriefeWerte":{"$ref":"#/components/schemas/WahlbriefeWerteDTO"},"ungueltigeStimmzettels":{"type":"array","items":{"$ref":"#/components/schemas/UngueltigeStimmzettelDTO"}},"ungueltigeStimmzettelAnzahl":{"type":"integer","format":"int64"},"ergebnisse":{"type":"array","items":{"$ref":"#/components/schemas/ErgebnisDTO"}},"wahlart":{"type":"string","enum":["BAW","BEB","BTW","BZW","EUW","LTW","MBW","OBW","SRW","SVW","VE"]}}},"UngueltigeStimmzettelDTO":{"type":"object","properties":{"stimmenart":{"type":"string"},"anzahl":{"type":"integer","format":"int64"},"wahlvorschlagID":{"type":"string"}}},"WahlbriefeWerteDTO":{"type":"object","properties":{"zurueckgewiesenGesamt":{"type":"integer","format":"int64"}}},"WahlbeteiligungsMeldungDTO":{"required":["anzahlWaehler","meldeZeitpunkt","wahlID","wahlbezirkID"],"type":"object","properties":{"wahlID":{"type":"string"},"wahlbezirkID":{"type":"string"},"anzahlWaehler":{"type":"integer","format":"int64"},"meldeZeitpunkt":{"type":"string","format":"date-time"}}},"WahlvorstandDTO":{"required":["mitglieder","wahlbezirkID"],"type":"object","properties":{"wahlbezirkID":{"type":"string"},"mitglieder":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlvorstandsmitgliedDTO"}}}},"WahlvorstandsmitgliedDTO":{"required":["anwesend","funktion","identifikator","nachname","vorname"],"type":"object","properties":{"identifikator":{"type":"string"},"vorname":{"type":"string"},"nachname":{"type":"string"},"funktion":{"type":"string","enum":["W","SB","SWB","SSB","B"]},"anwesend":{"type":"boolean"}}},"WahltagDTO":{"required":["beschreibung","identifikator","nummer","tag"],"type":"object","properties":{"identifikator":{"type":"string"},"tag":{"type":"string","format":"date"},"beschreibung":{"type":"string"},"nummer":{"type":"string"}}},"WahltageDTO":{"required":["wahltage"],"type":"object","properties":{"wahltage":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahltagDTO"}}}},"WahlDTO":{"required":["identifikator","name","nummer","wahlart","wahltag"],"type":"object","properties":{"identifikator":{"type":"string"},"name":{"type":"string"},"wahlart":{"type":"string","enum":["BAW","BEB","BTW","BZW","EUW","LTW","MBW","OBW","SRW","SVW","VE"]},"wahltag":{"type":"string","format":"date"},"nummer":{"type":"string"}}},"WahlenDTO":{"required":["wahlen"],"type":"object","properties":{"wahlen":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlDTO"}}}},"WahlberechtigteDTO":{"required":["a1","a2","a3","wahlID","wahlbezirkID"],"type":"object","properties":{"wahlID":{"type":"string"},"wahlbezirkID":{"type":"string"},"a1":{"type":"integer","format":"int64"},"a2":{"type":"integer","format":"int64"},"a3":{"type":"integer","format":"int64"}}},"WahlbezirkDTO":{"required":["identifikator","nummer","wahlID","wahlbezirkArt","wahlnummer","wahltag"],"type":"object","properties":{"identifikator":{"type":"string"},"wahlbezirkArt":{"type":"string","enum":["UWB","BWB"]},"nummer":{"type":"string"},"wahltag":{"type":"string","format":"date"},"wahlnummer":{"type":"string"},"wahlID":{"type":"string"}}},"WahlbezirkeDTO":{"required":["wahlbezirke"],"type":"object","properties":{"wahlbezirke":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlbezirkDTO"}}}},"BasisdatenDTO":{"required":["basisstrukturdaten","stimmzettelgebiete","wahlbezirke","wahlen"],"type":"object","properties":{"basisstrukturdaten":{"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/BasisstrukturdatenDTO"}},"wahlen":{"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlDTO"}},"wahlbezirke":{"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlbezirkDTO"}},"stimmzettelgebiete":{"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/StimmzettelgebietDTO"}}}},"BasisstrukturdatenDTO":{"required":["stimmzettelgebietID","wahlID","wahlbezirkID","wahltag"],"type":"object","properties":{"wahlID":{"type":"string"},"stimmzettelgebietID":{"type":"string"},"wahlbezirkID":{"type":"string"},"wahltag":{"type":"string","format":"date"}}},"StimmzettelgebietDTO":{"required":["stimmzettelgebietart"],"type":"object","properties":{"identifikator":{"type":"string"},"nummer":{"type":"string"},"name":{"type":"string"},"wahltag":{"type":"string","format":"date"},"stimmzettelgebietart":{"type":"string","enum":["SB","SG","SK","WK"]}}},"KandidatDTO":{"required":["direktkandidat","einzelbewerber","identifikator","listenposition","name","tabellenSpalteInNiederschrift"],"type":"object","properties":{"identifikator":{"type":"string"},"name":{"type":"string"},"listenposition":{"type":"integer","format":"int64"},"direktkandidat":{"type":"boolean"},"tabellenSpalteInNiederschrift":{"type":"integer","format":"int64"},"einzelbewerber":{"type":"boolean"}}},"WahlvorschlaegeDTO":{"required":["stimmzettelgebietID","wahlID","wahlbezirkID","wahlvorschlaege"],"type":"object","properties":{"wahlbezirkID":{"type":"string"},"wahlID":{"type":"string"},"stimmzettelgebietID":{"type":"string"},"wahlvorschlaege":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlvorschlagDTO"}}}},"WahlvorschlagDTO":{"required":["erhaeltStimmen","identifikator","kurzname","ordnungszahl"],"type":"object","properties":{"identifikator":{"type":"string"},"ordnungszahl":{"type":"integer","format":"int64"},"kurzname":{"type":"string"},"erhaeltStimmen":{"type":"boolean"},"kandidaten":{"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/KandidatDTO"}}}},"WahlvorschlaegeListeDTO":{"required":["wahlID","wahlvorschlaege"],"type":"object","properties":{"wahlID":{"type":"string"},"wahlvorschlaege":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlvorschlaegeDTO"}}}},"ReferendumoptionDTO":{"required":["id","name"],"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"position":{"type":"integer","format":"int64"}}},"ReferendumvorlageDTO":{"required":["frage","kurzname","ordnungszahl","referendumoption","wahlvorschlagID"],"type":"object","properties":{"wahlvorschlagID":{"type":"string"},"ordnungszahl":{"type":"integer","format":"int64"},"kurzname":{"type":"string"},"frage":{"type":"string"},"referendumoption":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/ReferendumoptionDTO"}}}},"ReferendumvorlagenDTO":{"required":["referendumvorlage","stimmzettelgebietID"],"type":"object","properties":{"stimmzettelgebietID":{"type":"string"},"referendumvorlage":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/ReferendumvorlageDTO"}}}},"WlsExceptionDTO":{"required":["category","code","message","service"],"type":"object","properties":{"category":{"type":"string","enum":["F","T","S","I"]},"code":{"type":"string"},"service":{"type":"string"},"message":{"type":"string"}}}},"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}}}} \ No newline at end of file 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 09/51] 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); } } } From f7bcac8ac5904d8fda0ec37c4815507163bf5f10 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Tue, 16 Jul 2024 10:04:14 +0200 Subject: [PATCH 10/51] Fix Fehler bei Conflict-Mergen --- .../configuration/SecurityConfigurationTest.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/configuration/SecurityConfigurationTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/configuration/SecurityConfigurationTest.java index 95e0547c6..13e283879 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/configuration/SecurityConfigurationTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/configuration/SecurityConfigurationTest.java @@ -106,12 +106,6 @@ class Wahltage { @WithAnonymousUser void accessGetWahltageUnauthorizedThenUnauthorized() throws Exception { api.perform(get("/businessActions/wahltage")).andExpect(status().isUnauthorized()); - class Handbuch { - - @Test - @WithAnonymousUser - void accessGetHandbuchUnauthorizedThenUnauthorized() throws Exception { - api.perform(get("/businessActions/handbuch/wahlID/UWB")).andExpect(status().isUnauthorized()); } @Test @@ -119,6 +113,16 @@ void accessGetHandbuchUnauthorizedThenUnauthorized() throws Exception { void accessGetWahltageUnauthorizedThenOk() throws Exception { api.perform(get("/businessActions/wahltage")).andExpect(status().isOk()); } + } + + @Nested + class Handbuch { + + @Test + @WithAnonymousUser + void accessGetHandbuchUnauthorizedThenUnauthorized() throws Exception { + api.perform(get("/businessActions/handbuch/wahlID/UWB")).andExpect(status().isUnauthorized()); + } @Test @WithMockUser From 1542bdac1ca663b7a7eeb85094c1a8436c95691c Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Tue, 16 Jul 2024 10:09:40 +0200 Subject: [PATCH 11/51] Fix Nummerierung --- ...{V2_0__createWahltagTable.sql => V3_0__createWahltagTable.sql} | 0 ...{V2_0__createWahltagTable.sql => V3_0__createWahltagTable.sql} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename wls-basisdaten-service/src/main/resources/db/migrations/h2/{V2_0__createWahltagTable.sql => V3_0__createWahltagTable.sql} (100%) rename wls-basisdaten-service/src/main/resources/db/migrations/oracle/{V2_0__createWahltagTable.sql => V3_0__createWahltagTable.sql} (100%) diff --git a/wls-basisdaten-service/src/main/resources/db/migrations/h2/V2_0__createWahltagTable.sql b/wls-basisdaten-service/src/main/resources/db/migrations/h2/V3_0__createWahltagTable.sql similarity index 100% rename from wls-basisdaten-service/src/main/resources/db/migrations/h2/V2_0__createWahltagTable.sql rename to wls-basisdaten-service/src/main/resources/db/migrations/h2/V3_0__createWahltagTable.sql diff --git a/wls-basisdaten-service/src/main/resources/db/migrations/oracle/V2_0__createWahltagTable.sql b/wls-basisdaten-service/src/main/resources/db/migrations/oracle/V3_0__createWahltagTable.sql similarity index 100% rename from wls-basisdaten-service/src/main/resources/db/migrations/oracle/V2_0__createWahltagTable.sql rename to wls-basisdaten-service/src/main/resources/db/migrations/oracle/V3_0__createWahltagTable.sql From 4cea86b990b928e94a318541785562f9c11e9017 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Tue, 16 Jul 2024 10:17:24 +0200 Subject: [PATCH 12/51] =?UTF-8?q?Erg=C3=A4nzen=20Authorities=20f=C3=BCr=20?= =?UTF-8?q?Wahltage=20in=20keycloak-changelog.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../keycloak/migration/add-authorities-basisdaten-wahltage.yml | 2 +- stack/keycloak/migration/keycloak-changelog.yml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/stack/keycloak/migration/add-authorities-basisdaten-wahltage.yml b/stack/keycloak/migration/add-authorities-basisdaten-wahltage.yml index 032595ad2..31c385c98 100644 --- a/stack/keycloak/migration/add-authorities-basisdaten-wahltage.yml +++ b/stack/keycloak/migration/add-authorities-basisdaten-wahltage.yml @@ -1,4 +1,4 @@ -id: add authorities basisdaten wahlvorschlaege +id: add authorities basisdaten wahltage author: Nic12345678 realm: ${SSO_REALM} changes: diff --git a/stack/keycloak/migration/keycloak-changelog.yml b/stack/keycloak/migration/keycloak-changelog.yml index 0ad30ab4f..1be1b5a89 100644 --- a/stack/keycloak/migration/keycloak-changelog.yml +++ b/stack/keycloak/migration/keycloak-changelog.yml @@ -33,4 +33,5 @@ includes: - path: add-authorities-basisdaten-wahlvorschlaege.yml - path: add-authorities-eai-wahlvorschlag.yml - path: add-authorities-eai-wahldaten.yml - - path: add-authorities-basisdaten-handbuch.yml \ No newline at end of file + - path: add-authorities-basisdaten-handbuch.yml + - path: add-authorities-basisdaten-wahltage.yml \ No newline at end of file From 5d9677ff439607fa2a41220edfdd9123ea1ac5f6 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Tue, 16 Jul 2024 10:25:15 +0200 Subject: [PATCH 13/51] =?UTF-8?q?Openapi.json=20Version=20auch=20in=20dem?= =?UTF-8?q?=20Dateinamen=20f=C3=BCr=20schnellere=20=C3=9Cbersicht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wls-basisdaten-service/pom.xml | 2 +- .../openapis/{openapi.json => openapi.eai.0.1.1-Beta1.json} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename wls-basisdaten-service/src/main/resources/openapis/{openapi.json => openapi.eai.0.1.1-Beta1.json} (100%) diff --git a/wls-basisdaten-service/pom.xml b/wls-basisdaten-service/pom.xml index e3cc35ba0..2346d00cd 100644 --- a/wls-basisdaten-service/pom.xml +++ b/wls-basisdaten-service/pom.xml @@ -393,7 +393,7 @@ generate - ${project.basedir}/src/main/resources/openapis/openapi.json + ${project.basedir}/src/main/resources/openapis/openapi.eai.0.1.1-Beta1.json java resttemplate diff --git a/wls-basisdaten-service/src/main/resources/openapis/openapi.json b/wls-basisdaten-service/src/main/resources/openapis/openapi.eai.0.1.1-Beta1.json similarity index 100% rename from wls-basisdaten-service/src/main/resources/openapis/openapi.json rename to wls-basisdaten-service/src/main/resources/openapis/openapi.eai.0.1.1-Beta1.json From be7c7c8113c045b6981455f0d6d0ef5d94b76c17 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Tue, 16 Jul 2024 10:28:09 +0200 Subject: [PATCH 14/51] Parameter final in WahltageClient --- .../basisdatenservice/services/wahltag/WahltageClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageClient.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageClient.java index 1ea8398ee..68bcf5445 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageClient.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageClient.java @@ -15,6 +15,6 @@ public interface WahltageClient { * {@link de.muenchen.oss.wahllokalsystem.wls.common.exception.TechnischeWlsException} * if there were trouble during communication */ - List getWahltage(LocalDate tag) throws WlsException; + List getWahltage(final LocalDate tag) throws WlsException; } From 814a802b650cd072dc1ad1242d1762e712f681fc Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Tue, 16 Jul 2024 10:31:27 +0200 Subject: [PATCH 15/51] Mapper Methode entfernt, da nur im Test verwendet, Test entfernt --- .../clients/WahltageClientMapper.java | 3 -- .../clients/WahltageClientMapperTest.java | 54 ------------------- 2 files changed, 57 deletions(-) diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapper.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapper.java index 633f0c3ff..52a55563a 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapper.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapper.java @@ -11,9 +11,6 @@ @Mapper public interface WahltageClientMapper { - @Mapping(target = "wahltagModels", source = "wahltage") - WahltageModel toWahltageModel(WahltageDTO wahltageDTO); - @Mapping(target = "wahltagID", source = "identifikator") @Mapping(target = "wahltag", source = "tag") WahltagModel toWahltagModel(WahltagDTO wahltagDTO); diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapperTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapperTest.java index 95927232f..5d4de90c1 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapperTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapperTest.java @@ -17,60 +17,6 @@ class WahltageClientMapperTest { private final WahltageClientMapper unitUnderTest = Mappers.getMapper(WahltageClientMapper.class); - @Nested - class ToWahltageModel { - - @Test - void isMapped() { - val dtoToMap = new WahltageDTO(); - - val wahltag1 = new WahltagDTO(); - wahltag1.setIdentifikator("identifikatorWahltag1"); - wahltag1.setBeschreibung("beschreibungWahltag1"); - wahltag1.setNummer("nummerWahltag1"); - wahltag1.setTag(LocalDate.now().minusMonths(2)); - - val wahltag2 = new WahltagDTO(); - wahltag2.setIdentifikator("identifikatorWahltag2"); - wahltag2.setBeschreibung("beschreibungWahltag2"); - wahltag2.setNummer("nummerWahltag2"); - wahltag2.setTag(LocalDate.now().minusMonths(1)); - - val wahltag3 = new WahltagDTO(); - wahltag3.setIdentifikator("identifikatorWahltag3"); - wahltag3.setBeschreibung("beschreibungWahltag3"); - wahltag3.setNummer("nummerWahltag3"); - wahltag3.setTag(LocalDate.now().plusMonths(1)); - - dtoToMap.setWahltage(Set.of( - wahltag3, wahltag2, wahltag1)); - - Assertions.assertThat(dtoToMap).hasNoNullFieldsOrProperties(); - Assertions.assertThat(dtoToMap.getWahltage()).size().isPositive(); - - val result = unitUnderTest.toWahltageModel(dtoToMap); - - val expectedWahltage = List.of( - new WahltagModel("identifikatorWahltag1", - LocalDate.now().minusMonths(2), - "beschreibungWahltag1", - "nummerWahltag1"), - new WahltagModel("identifikatorWahltag2", - LocalDate.now().minusMonths(1), - "beschreibungWahltag2", - "nummerWahltag2"), - new WahltagModel("identifikatorWahltag3", - LocalDate.now().plusMonths(1), - "beschreibungWahltag3", - "nummerWahltag3")); - - val expectedResult = new WahltageModel(expectedWahltage); - - Assertions.assertThat(result.wahltagModels()).containsExactlyInAnyOrderElementsOf(expectedResult.wahltagModels()); - } - - } - @Nested class ToWahltagModel { From ff4f81dcd23d94218692d312d123a502bbbc8653 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Tue, 16 Jul 2024 10:32:55 +0200 Subject: [PATCH 16/51] Methoden Parameter final --- .../basisdatenservice/clients/WahltageClientMapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapper.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapper.java index 52a55563a..bee54d8ac 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapper.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapper.java @@ -15,7 +15,7 @@ public interface WahltageClientMapper { @Mapping(target = "wahltag", source = "tag") WahltagModel toWahltagModel(WahltagDTO wahltagDTO); - default List fromRemoteClientWahltageDTOtoListOfWahltagModel(WahltageDTO wahltageDTO) { + default List fromRemoteClientWahltageDTOtoListOfWahltagModel(final WahltageDTO wahltageDTO) { return wahltageDTO.getWahltage().stream().map(this::toWahltagModel).toList(); } } From d1587268c647d9aefe57180581940888d7fb0efc Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Tue, 16 Jul 2024 10:36:04 +0200 Subject: [PATCH 17/51] Update wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageDTOMapperTest.java Co-authored-by: MrSebastian <13592751+MrSebastian@users.noreply.github.com> --- .../basisdatenservice/rest/wahltage/WahltageDTOMapperTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageDTOMapperTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageDTOMapperTest.java index 25b72ae4c..a716d0c47 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageDTOMapperTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageDTOMapperTest.java @@ -32,7 +32,6 @@ void isMappedToDTO() { } private List createClientWahltagDTOs() { - val wahltag1 = new WahltagDTO("identifikatorWahltag1", LocalDate.now().minusMonths(2), "beschreibungWahltag1", "nummerWahltag1"); val wahltag2 = new WahltagDTO("identifikatorWahltag2", LocalDate.now().minusMonths(1), "beschreibungWahltag2", "nummerWahltag2"); val wahltag3 = new WahltagDTO("identifikatorWahltag3", LocalDate.now().plusMonths(1), "beschreibungWahltag3", "nummerWahltag3"); From 9f1b8163aa9675371349c028be79657f6202fea3 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Tue, 16 Jul 2024 10:36:20 +0200 Subject: [PATCH 18/51] Update wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageDTOMapperTest.java Co-authored-by: MrSebastian <13592751+MrSebastian@users.noreply.github.com> --- .../basisdatenservice/rest/wahltage/WahltageDTOMapperTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageDTOMapperTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageDTOMapperTest.java index a716d0c47..d074af5ae 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageDTOMapperTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageDTOMapperTest.java @@ -42,7 +42,6 @@ private List createClientWahltagDTOs() { } private List createClientWahltagModels() { - 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"); From a952ae31d36ca7c77778e5837ec7b47cbd4d73ab Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Tue, 16 Jul 2024 10:42:32 +0200 Subject: [PATCH 19/51] Final Variablen lokal in der Methode --- .../services/wahltag/WahltageServiceTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 dec8f060b..0bf755f08 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 @@ -32,9 +32,9 @@ class GetWahltage { @Test void dataIsLoadedFromRemoteEvenIfExistingInRepoAndRepoIsUpdated() { - List mockedListOfEntities = createWahltagList("2"); - List mockedClientResponse = createWahltagModelList("2"); - List mockedMappedSavedEntities = createWahltagModelList("2"); + val mockedListOfEntities = createWahltagList("2"); + val mockedClientResponse = createWahltagModelList("2"); + val mockedMappedSavedEntities = createWahltagModelList("2"); Mockito.when(wahltageClient.getWahltage(LocalDate.now().minusMonths(3))).thenReturn(mockedClientResponse); Mockito.when(wahltagModelMapper.fromWahltagModelToWahltagEntityList(mockedClientResponse)).thenReturn(mockedListOfEntities); From 87465a701ea738474d080cd4f00a9f82dfe97200 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Tue, 16 Jul 2024 10:48:33 +0200 Subject: [PATCH 20/51] Update wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java Co-authored-by: MrSebastian <13592751+MrSebastian@users.noreply.github.com> --- .../oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java | 1 - 1 file changed, 1 deletion(-) diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java index 59ec94881..bf72e95d0 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java @@ -28,7 +28,6 @@ public class Wahltag { @Id - @Column(name = "wahltagID") @NotNull @Size(max = 1024) @ToString.Include From b927b36971978a1a78009fb79791885f9b718f08 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Tue, 16 Jul 2024 10:48:50 +0200 Subject: [PATCH 21/51] Update wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java Co-authored-by: MrSebastian <13592751+MrSebastian@users.noreply.github.com> --- .../oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java | 1 - 1 file changed, 1 deletion(-) diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java index bf72e95d0..02d83d412 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java @@ -40,7 +40,6 @@ public class Wahltag { @ToString.Include private LocalDate wahltag; - @Column(name = "beschreibung") @Size(max = 1024) @ToString.Include private String beschreibung; From c74f9a6ad9a637d3baefd525dfc0463e63bc0beb Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Tue, 16 Jul 2024 10:49:06 +0200 Subject: [PATCH 22/51] Update wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java Co-authored-by: MrSebastian <13592751+MrSebastian@users.noreply.github.com> --- .../oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java | 1 - 1 file changed, 1 deletion(-) diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java index 02d83d412..468a0b1a9 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java @@ -44,7 +44,6 @@ public class Wahltag { @ToString.Include private String beschreibung; - @Column(name = "nummer") @Size(max = 1024) @ToString.Include private String nummer; From c44d39615f36c29b8622c4625a7b9ac681797701 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Tue, 16 Jul 2024 11:16:05 +0200 Subject: [PATCH 23/51] Update wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java Co-authored-by: MrSebastian <13592751+MrSebastian@users.noreply.github.com> --- .../rest/wahltage/WahltageController.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java index 42af14315..06e51e838 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java @@ -26,14 +26,6 @@ public class WahltageController { private final WahltageDTOMapper wahltageDTOMapper; @Operation(description = "Laden der Liste der Wahltage, bei denen das Datum bis 3 Monate in die Vergangenheit reicht") - @ApiResponses( - value = { - @ApiResponse( - responseCode = "200", description = "OK", - content = { @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = WahltagDTO.class))) } - ) - } - ) @GetMapping public ResponseEntity> getWahltage() { return new ResponseEntity<>( From d0594301b2e08453dc4bc53d818f0e17362aabc7 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Tue, 16 Jul 2024 15:57:05 +0200 Subject: [PATCH 24/51] Update wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java Co-authored-by: MrSebastian <13592751+MrSebastian@users.noreply.github.com> --- .../oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java index 468a0b1a9..965874322 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/domain/Wahltag.java @@ -33,9 +33,6 @@ public class Wahltag { @ToString.Include private String wahltagID; - @Column(name = "wahltag") - @JsonDeserialize(using = LocalDateDeserializer.class) - @JsonSerialize(using = LocalDateSerializer.class) @NotNull @ToString.Include private LocalDate wahltag; From 9451f76d7aef5ef1b72aa612743f659ed8c0661a Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Tue, 16 Jul 2024 15:58:57 +0200 Subject: [PATCH 25/51] Update wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java Co-authored-by: MrSebastian <13592751+MrSebastian@users.noreply.github.com> --- .../basisdatenservice/rest/wahltage/WahltageController.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java index 06e51e838..fa75f66e6 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java @@ -27,9 +27,7 @@ public class WahltageController { @Operation(description = "Laden der Liste der Wahltage, bei denen das Datum bis 3 Monate in die Vergangenheit reicht") @GetMapping - public ResponseEntity> getWahltage() { - return new ResponseEntity<>( - wahltageDTOMapper.fromListOfWahltagModelToListOfWahltagDTO(wahltageService.getWahltage()), - HttpStatus.OK); + public List getWahltage() { + return wahltageDTOMapper.fromListOfWahltagModelToListOfWahltagDTO(wahltageService.getWahltage()); } } From ab0491bfc9bd41a34cc7ced2791b853a56b27a97 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Tue, 16 Jul 2024 16:05:49 +0200 Subject: [PATCH 26/51] Update wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModelMapper.java Co-authored-by: MrSebastian <13592751+MrSebastian@users.noreply.github.com> --- .../services/wahltag/WahltagModelMapper.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModelMapper.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModelMapper.java index c2764478e..c7d148efd 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModelMapper.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModelMapper.java @@ -7,10 +7,6 @@ @Mapper public interface WahltagModelMapper { - Wahltag toEntity(WahltagModel wahltagModel); - - WahltagModel toModel(Wahltag entity); - List fromWahltagEntityToWahltagModelList(List entities); List fromWahltagModelToWahltagEntityList(List entities); From 61da2df782b6ab476960e0ba6be77f48fb6b8451 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Tue, 16 Jul 2024 16:10:23 +0200 Subject: [PATCH 27/51] deleted not used model --- .../services/wahltag/WahltageModel.java | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageModel.java diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageModel.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageModel.java deleted file mode 100644 index 4b5b2c00b..000000000 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageModel.java +++ /dev/null @@ -1,13 +0,0 @@ -package de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag; - -import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahlvorschlag.WahlvorschlagModel; -import de.muenchen.oss.wahllokalsystem.wls.common.security.domain.BezirkUndWahlID; -import jakarta.validation.constraints.NotNull; -import java.util.List; -import java.util.Set; -import lombok.Builder; - -@Builder -public record WahltageModel(@NotNull List wahltagModels) { - -} From 3bbb4d31596c3d06d4bed2a03115c30607ef03e3 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Wed, 17 Jul 2024 11:06:04 +0200 Subject: [PATCH 28/51] deleted not used model --- .../clients/WahltageClientMapper.java | 1 - .../rest/wahltage/WahltageController.java | 8 -------- .../services/wahltag/WahltagModelMapper.java | 4 ---- .../clients/WahltageClientMapperTest.java | 1 - .../SecurityConfigurationTest.java | 2 +- .../wahltag/WahltagModelMapperTest.java | 20 ------------------- 6 files changed, 1 insertion(+), 35 deletions(-) diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapper.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapper.java index bee54d8ac..c00f63fb6 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapper.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapper.java @@ -3,7 +3,6 @@ import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltagDTO; import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO; import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltagModel; -import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltageModel; import java.util.List; import org.mapstruct.Mapper; import org.mapstruct.Mapping; diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java index 42af14315..06e51e838 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java @@ -26,14 +26,6 @@ public class WahltageController { private final WahltageDTOMapper wahltageDTOMapper; @Operation(description = "Laden der Liste der Wahltage, bei denen das Datum bis 3 Monate in die Vergangenheit reicht") - @ApiResponses( - value = { - @ApiResponse( - responseCode = "200", description = "OK", - content = { @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = WahltagDTO.class))) } - ) - } - ) @GetMapping public ResponseEntity> getWahltage() { return new ResponseEntity<>( diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModelMapper.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModelMapper.java index c2764478e..c7d148efd 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModelMapper.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltagModelMapper.java @@ -7,10 +7,6 @@ @Mapper public interface WahltagModelMapper { - Wahltag toEntity(WahltagModel wahltagModel); - - WahltagModel toModel(Wahltag entity); - List fromWahltagEntityToWahltagModelList(List entities); List fromWahltagModelToWahltagEntityList(List entities); diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapperTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapperTest.java index 5d4de90c1..189368303 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapperTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapperTest.java @@ -3,7 +3,6 @@ import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltagDTO; import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO; import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltagModel; -import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltageModel; import java.time.LocalDate; import java.util.List; import java.util.Set; diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/configuration/SecurityConfigurationTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/configuration/SecurityConfigurationTest.java index 13e283879..b8bbe3b34 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/configuration/SecurityConfigurationTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/configuration/SecurityConfigurationTest.java @@ -37,7 +37,7 @@ class SecurityConfigurationTest { @MockBean WahltageService wahltageService; - + @MockBean HandbuchService handbuchService; 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 9b76730f1..2b6fa5f36 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 @@ -12,26 +12,6 @@ class WahltagModelMapperTest { private final WahltagModelMapper unitUnderTest = Mappers.getMapper(WahltagModelMapper.class); - @Test - void toEntity() { - val modelToMap = createWahltagModel(); - - val result = unitUnderTest.toEntity(modelToMap); - - val expectedResult = createWahltagEntity(); - Assertions.assertThat(result).isEqualTo(expectedResult); - } - - @Test - void toModel() { - val entityToMap = createWahltagEntity(); - - val result = unitUnderTest.toModel(entityToMap); - - val expectedResult = createWahltagModel(); - Assertions.assertThat(result).isEqualTo(expectedResult); - } - @Test void fromWahltagModelToWahltagEntityList() { val modelsToMap = createWahltagModelList(); From 416af35d7cd5525a41851011b2e31720c15adbe4 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Wed, 17 Jul 2024 11:10:19 +0200 Subject: [PATCH 29/51] =?UTF-8?q?OpenApiu=20Beschreibung=20vervollst=C3=A4?= =?UTF-8?q?ndigt=20mit=20dem=20Detail,=20die=20Tage=20sind=20aufsteigend?= =?UTF-8?q?=20sortiert.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basisdatenservice/rest/wahltage/WahltageController.java | 2 +- .../basisdatenservice/services/wahltag/WahltageService.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java index 06e51e838..16e8432cf 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java @@ -25,7 +25,7 @@ public class WahltageController { private final WahltageService wahltageService; private final WahltageDTOMapper wahltageDTOMapper; - @Operation(description = "Laden der Liste der Wahltage, bei denen das Datum bis 3 Monate in die Vergangenheit reicht") + @Operation(description = "Laden der Liste der Wahltage, aufsteigend sortiert nach Wahltag-Datum und nicht länger als 3 Monate in der Vergangenheit.") @GetMapping public ResponseEntity> getWahltage() { return new ResponseEntity<>( diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageService.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageService.java index 6d2d1ca64..4d1b1cb0b 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageService.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageService.java @@ -5,7 +5,6 @@ import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; From d72ebb4565300573a408be6c22a3f8af320b44b9 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Wed, 17 Jul 2024 11:12:34 +0200 Subject: [PATCH 30/51] spotless hinweise bearbeitet --- .../rest/wahltage/WahltageController.java | 5 ----- .../services/wahltag/WahltagModelMapperTest.java | 8 -------- 2 files changed, 13 deletions(-) diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java index 16e8432cf..99299d069 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageController.java @@ -2,11 +2,6 @@ import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltageService; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; 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 2b6fa5f36..af8fbab2a 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 @@ -32,14 +32,6 @@ void fromWahltagEntityToWahltagModelList() { Assertions.assertThat(result).isEqualTo(expectedResult); } - private Wahltag createWahltagEntity() { - return new Wahltag("identifikatorWahltag1", LocalDate.now().minusMonths(2), "beschreibungWahltag1", "nummerWahltag1"); - } - - private WahltagModel createWahltagModel() { - return new WahltagModel("identifikatorWahltag1", LocalDate.now().minusMonths(2), "beschreibungWahltag1", "nummerWahltag1"); - } - private List createWahltagList() { val wahltag1 = new Wahltag("identifikatorWahltag1", LocalDate.now().minusMonths(2), "beschreibungWahltag1", "nummerWahltag1"); val wahltag2 = new Wahltag("identifikatorWahltag2", LocalDate.now().minusMonths(1), "beschreibungWahltag2", "nummerWahltag2"); From b7a8833026100242705e79a4cef0574bd3781321 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Wed, 17 Jul 2024 11:15:42 +0200 Subject: [PATCH 31/51] wahltage final var --- .../basisdatenservice/services/wahltag/WahltageService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageService.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageService.java index 4d1b1cb0b..a5ce66c99 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageService.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageService.java @@ -5,6 +5,7 @@ import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import lombok.val; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; @@ -24,7 +25,7 @@ public class WahltageService { ) public List getWahltage() { log.info("#getWahltage"); - List wahltage = wahltageClient.getWahltage(LocalDate.now().minusMonths(3)); + val wahltage = wahltageClient.getWahltage(LocalDate.now().minusMonths(3)); wahltagRepository.saveAll(wahltagModelMapper.fromWahltagModelToWahltagEntityList(wahltage)); return wahltagModelMapper.fromWahltagEntityToWahltagModelList(wahltagRepository.findAllByOrderByWahltagAsc()); } From 2ea2448cd36d3ecc9e3f79e7fd2e04843f4ce6b3 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Wed, 17 Jul 2024 12:37:31 +0200 Subject: [PATCH 32/51] =?UTF-8?q?Tests=20erg=C3=A4nzen=20der=20zeigt=20das?= =?UTF-8?q?s=20die=20Exception=20die=20von=20controllerAPI=20kommt=20gemap?= =?UTF-8?q?pt=20wird?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clients/WahltageClientImplTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImplTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImplTest.java index d4e853a50..cebba74e6 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImplTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImplTest.java @@ -6,6 +6,7 @@ import de.muenchen.oss.wahllokalsystem.basisdatenservice.exception.ExceptionConstants; import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltagModel; import de.muenchen.oss.wahllokalsystem.wls.common.exception.FachlicheWlsException; +import de.muenchen.oss.wahllokalsystem.wls.common.exception.TechnischeWlsException; import de.muenchen.oss.wahllokalsystem.wls.common.exception.util.ExceptionFactory; import java.time.LocalDate; import java.util.List; @@ -18,6 +19,7 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.web.client.RestClientException; @ExtendWith(MockitoExtension.class) class WahltageClientImplTest { @@ -63,5 +65,15 @@ void exceptionWhenClientResponseIsNull() { Assertions.assertThatException().isThrownBy(() -> unitUnderTest.getWahltage(LocalDate.now())).isSameAs(mockedWlsException); } + + @Test + void controllerApiExceptionIsMapped(){ + val testDate = LocalDate.now().minusMonths(3); + val mockedException = TechnischeWlsException.withCode("100").buildWithMessage("Bei der Kommunikation mit dem Aoueai-Service ist ein Fehler aufgetreten. Es konnten daher keine Daten geladen werden."); + + Mockito.when(wahldatenControllerApi.loadWahltageSinceIncluding(any())).thenThrow(new RestClientException("error occurs while attempting to invoke the API")); + Mockito.when(exceptionFactory.createTechnischeWlsException(ExceptionConstants.FAILED_COMMUNICATION_WITH_EAI)).thenThrow(mockedException); + Assertions.assertThatException().isThrownBy(() -> unitUnderTest.getWahltage(testDate)).isSameAs(mockedException); + } } } From 6616f2e58165fcd7d6ac98035b7ada485e24543d Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Wed, 17 Jul 2024 12:40:53 +0200 Subject: [PATCH 33/51] =?UTF-8?q?Nicht=20thematisch=20passende=20Korrektur?= =?UTF-8?q?=20r=C3=BCckg=C3=A4ngig=20gemacht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../configuration/SecurityConfigurationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/configuration/SecurityConfigurationTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/configuration/SecurityConfigurationTest.java index b8bbe3b34..47bd35573 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/configuration/SecurityConfigurationTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/configuration/SecurityConfigurationTest.java @@ -88,7 +88,7 @@ class Wahlvorschlaege { @Test @WithAnonymousUser - void accessGetWahlvorschlaegeUnauthorizedThenUnauthorized() throws Exception { + void accessGetWahlvorstaendeUnauthorizedThenUnauthorized() throws Exception { api.perform(get("/businessActions/wahlvorschlaege/wahlID/wahlbezirkID")).andExpect(status().isUnauthorized()); } From e447f18a53d39d6ed2df28c670238ba8c088f415 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Wed, 17 Jul 2024 12:42:40 +0200 Subject: [PATCH 34/51] not isPositive sondern isEqualTo 3, weil die Nummer schon bekannt und genauer --- .../basisdatenservice/clients/WahltageClientMapperTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapperTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapperTest.java index 189368303..755f2292b 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapperTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapperTest.java @@ -71,7 +71,7 @@ void isMapped() { wahltag1, wahltag2, wahltag3)); Assertions.assertThat(dtoToMap).hasNoNullFieldsOrProperties(); - Assertions.assertThat(dtoToMap.getWahltage()).size().isPositive(); + Assertions.assertThat(dtoToMap.getWahltage()).size().isEqualTo(3); val result = unitUnderTest.fromRemoteClientWahltageDTOtoListOfWahltagModel(dtoToMap); From ad08c9bc53929b1dcd530ac71d79b13726bc5223 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Wed, 17 Jul 2024 12:46:11 +0200 Subject: [PATCH 35/51] =?UTF-8?q?=C3=9Cberfl=C3=BCssige=20Tests=20der=20sp?= =?UTF-8?q?ring-data=20Methoden=20entfernt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/WahltagRepositoryTest.java | 23 ------------------- 1 file changed, 23 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 5fd114d4d..b657c304f 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 @@ -36,29 +36,6 @@ void tearDown() { repository.deleteAll(); } - @Test - void findAll() { - List wahltageToSave1 = createWahltagList("1"); - List wahltageToSave2 = createWahltagList("2"); - List wahltageToSave3 = createWahltagList("3"); - repository.saveAll(wahltageToSave1); - repository.saveAll(wahltageToSave2); - repository.saveAll(wahltageToSave3); - List foundWahltage = repository.findAll(); - Assertions.assertThat(foundWahltage).containsAll(wahltageToSave1).containsAll(wahltageToSave2).containsAll(wahltageToSave3); - } - - @Test - void findById() { - List wahltageToSave1 = createWahltagList("X"); - repository.saveAll(wahltageToSave1); - Wahltag wahltag3 = wahltageToSave1.get(2); - Optional foundWahltagById = repository.findById("X_identifikatorWahltag3"); - - Assertions.assertThat(foundWahltagById).isPresent(); - Assertions.assertThat(foundWahltagById.get()).isEqualTo(wahltag3); - } - /** * Tests if searched returned Wahltags are right sorted */ From c1e59f5936ad71788afc2daa780ea211b3def3a6 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Wed, 17 Jul 2024 12:49:27 +0200 Subject: [PATCH 36/51] =?UTF-8?q?Unn=C3=B6tige=20Annotationen=20entfernt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basisdatenservice/domain/WahltagRepositoryTest.java | 4 ---- 1 file changed, 4 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 b657c304f..e90484626 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 @@ -5,7 +5,6 @@ import java.time.LocalDate; import java.util.Arrays; -import java.util.Optional; import lombok.val; import org.assertj.core.api.Assertions; import de.muenchen.oss.wahllokalsystem.basisdatenservice.MicroServiceApplication; @@ -17,8 +16,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; @SpringBootTest( classes = { MicroServiceApplication.class }, @@ -40,7 +37,6 @@ void tearDown() { * Tests if searched returned Wahltags are right sorted */ @Test - @Transactional(propagation = Propagation.REQUIRED, noRollbackFor = Exception.class) void findAllByOrderByWahltagAsc() { List wahltageToSave = createWahltagList("1"); repository.saveAll(wahltageToSave); From 6385ce3f0f35cff9179b2315f5b8f6be4d73a968 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Wed, 17 Jul 2024 12:53:05 +0200 Subject: [PATCH 37/51] val statt String --- .../rest/wahltage/WahltageControllerIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 4f786d365..7c119b50e 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 @@ -90,7 +90,7 @@ class GetWahltage { @Test void loadedFromExternal() throws Exception { - String requestDate = LocalDate.now().minusMonths(3).toString(); + val requestDate = LocalDate.now().minusMonths(3).toString(); val eaiWahltage = createClientWahltageDTO(false); WireMock.stubFor(WireMock.get("/wahldaten/wahltage?includingSince=" + requestDate) From 40cb55f04e1d9c27ba3e766b60a8759b4483b366 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Wed, 17 Jul 2024 13:03:52 +0200 Subject: [PATCH 38/51] =?UTF-8?q?Aussagekr=C3=A4ftigeres=20Parameter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rest/wahltage/WahltageControllerIntegrationTest.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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 7c119b50e..7394df899 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 @@ -187,25 +187,25 @@ void technischeWlsExceptionWhenNoExternalDataFound() throws Exception { } } - private de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO createClientWahltageDTO(boolean differentAsInDummyClient) { + private de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO createClientWahltageDTO(boolean pDifferentValueBeschreibungAsInDummyClient) { val clientWahltageDTO = new de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO(); val wahltag1 = new de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltagDTO(); wahltag1.setIdentifikator("identifikatorWahltag1"); - wahltag1.setBeschreibung((differentAsInDummyClient) ? "diff_beschreibungWahltag1" : "beschreibungWahltag1"); + wahltag1.setBeschreibung((pDifferentValueBeschreibungAsInDummyClient) ? "diff_beschreibungWahltag1" : "beschreibungWahltag1"); wahltag1.setNummer("nummerWahltag1"); wahltag1.setTag(LocalDate.now().minusMonths(2)); val wahltag2 = new de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltagDTO(); wahltag2.setIdentifikator("identifikatorWahltag2"); - wahltag2.setBeschreibung((differentAsInDummyClient) ? "diff_beschreibungWahltag2" : "beschreibungWahltag2"); + wahltag2.setBeschreibung((pDifferentValueBeschreibungAsInDummyClient) ? "diff_beschreibungWahltag2" : "beschreibungWahltag2"); wahltag2.setNummer("nummerWahltag2"); wahltag2.setTag(LocalDate.now().minusMonths(1)); val wahltag3 = new WahltagDTO(); wahltag3.setIdentifikator("identifikatorWahltag3"); - wahltag3.setBeschreibung((differentAsInDummyClient) ? "diff_beschreibungWahltag3" : "beschreibungWahltag3"); + wahltag3.setBeschreibung((pDifferentValueBeschreibungAsInDummyClient) ? "diff_beschreibungWahltag3" : "beschreibungWahltag3"); wahltag3.setNummer("nummerWahltag3"); wahltag3.setTag(LocalDate.now().plusMonths(1)); @@ -214,5 +214,4 @@ private de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.Wahltage return clientWahltageDTO; } - } From 8bd25dd427e049419ca14cb566f7f130b8e9da8d Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Wed, 17 Jul 2024 13:06:17 +0200 Subject: [PATCH 39/51] val statt string --- .../rest/wahltage/WahltageControllerIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 7394df899..c6aa1ae67 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 @@ -170,7 +170,7 @@ void loadFromRemoteFirstAndThanUpdateRepository() throws Exception { @Test void technischeWlsExceptionWhenNoExternalDataFound() throws Exception { - String requestDate = LocalDate.now().minusMonths(3).toString(); + val requestDate = LocalDate.now().minusMonths(3).toString(); WireMock.stubFor(WireMock.get("/wahldaten/wahltage?includingSince=" + requestDate) .willReturn(WireMock.aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.NOT_FOUND.value()))); From aa0a4d60ddfb5d42bf342b504600e252d83626e8 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Wed, 17 Jul 2024 13:08:26 +0200 Subject: [PATCH 40/51] val statt List --- .../rest/wahltage/WahltageControllerTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageControllerTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageControllerTest.java index ff29649b4..84f56efb9 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageControllerTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageControllerTest.java @@ -31,12 +31,12 @@ class GetWahltage { @Test void serviceIsCalledAndObjectsAreMapped() { - List wahltagModels = List.of( + val wahltagModels = List.of( WahltagModel.builder().build(), WahltagModel.builder().build(), WahltagModel.builder().build()); - List wahltagDTOs = List.of( + val wahltagDTOs = List.of( WahltagDTO.builder().build(), WahltagDTO.builder().build(), WahltagDTO.builder().build()); From 07b613ff8dbdb4608e65cf098db67bdfeed8d458 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Wed, 17 Jul 2024 13:32:41 +0200 Subject: [PATCH 41/51] spotless korrkturen --- .../basisdatenservice/clients/WahltageClientImplTest.java | 8 +++++--- .../rest/wahltage/WahltageControllerIntegrationTest.java | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImplTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImplTest.java index cebba74e6..bc5ab0de1 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImplTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImplTest.java @@ -67,11 +67,13 @@ void exceptionWhenClientResponseIsNull() { } @Test - void controllerApiExceptionIsMapped(){ + void controllerApiExceptionIsMapped() { val testDate = LocalDate.now().minusMonths(3); - val mockedException = TechnischeWlsException.withCode("100").buildWithMessage("Bei der Kommunikation mit dem Aoueai-Service ist ein Fehler aufgetreten. Es konnten daher keine Daten geladen werden."); + val mockedException = TechnischeWlsException.withCode("100") + .buildWithMessage("Bei der Kommunikation mit dem Aoueai-Service ist ein Fehler aufgetreten. Es konnten daher keine Daten geladen werden."); - Mockito.when(wahldatenControllerApi.loadWahltageSinceIncluding(any())).thenThrow(new RestClientException("error occurs while attempting to invoke the API")); + Mockito.when(wahldatenControllerApi.loadWahltageSinceIncluding(any())) + .thenThrow(new RestClientException("error occurs while attempting to invoke the API")); Mockito.when(exceptionFactory.createTechnischeWlsException(ExceptionConstants.FAILED_COMMUNICATION_WITH_EAI)).thenThrow(mockedException); Assertions.assertThatException().isThrownBy(() -> unitUnderTest.getWahltage(testDate)).isSameAs(mockedException); } 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 c6aa1ae67..83ceb64df 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 @@ -187,7 +187,8 @@ void technischeWlsExceptionWhenNoExternalDataFound() throws Exception { } } - private de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO createClientWahltageDTO(boolean pDifferentValueBeschreibungAsInDummyClient) { + private de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO createClientWahltageDTO( + boolean pDifferentValueBeschreibungAsInDummyClient) { val clientWahltageDTO = new de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO(); From a87acc7631b55c73e98a6001d1a5c81fbaba834b Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Wed, 17 Jul 2024 13:42:14 +0200 Subject: [PATCH 42/51] Merge local with remote --- .../basisdatenservice/rest/wahltage/WahltageControllerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageControllerTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageControllerTest.java index 84f56efb9..f1fbe7aa8 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageControllerTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageControllerTest.java @@ -46,7 +46,7 @@ void serviceIsCalledAndObjectsAreMapped() { val result = wahltageController.getWahltage(); - Assertions.assertThat(result.getBody()).isEqualTo(wahltagDTOs); + Assertions.assertThat(result).isEqualTo(wahltagDTOs); } } } From 42209710dc768d8715816e674080af90d2d7f675 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Wed, 17 Jul 2024 13:46:23 +0200 Subject: [PATCH 43/51] val statt String --- .../rest/wahltage/WahltageControllerIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 83ceb64df..904fff10e 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 @@ -113,7 +113,7 @@ void loadedFromExternal() throws Exception { @Transactional void externalDataIsPersisted() throws Exception { - String requestDate = LocalDate.now().minusMonths(3).toString(); + val requestDate = LocalDate.now().minusMonths(3).toString(); val eaiWahltage = createClientWahltageDTO(false); WireMock.stubFor(WireMock.get("/wahldaten/wahltage?includingSince=" + requestDate) From 3d6b4734150e3fae3cc8d9d5ccce4a2e582218c0 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Wed, 17 Jul 2024 16:49:27 +0200 Subject: [PATCH 44/51] Leerzeile ist nicht mehr da --- .../rest/wahltage/WahltageControllerIntegrationTest.java | 4 ---- 1 file changed, 4 deletions(-) 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 904fff10e..d50e402f4 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 @@ -89,7 +89,6 @@ class GetWahltage { @Test void loadedFromExternal() throws Exception { - val requestDate = LocalDate.now().minusMonths(3).toString(); val eaiWahltage = createClientWahltageDTO(false); @@ -112,7 +111,6 @@ void loadedFromExternal() throws Exception { @Test @Transactional void externalDataIsPersisted() throws Exception { - val requestDate = LocalDate.now().minusMonths(3).toString(); val eaiWahltage = createClientWahltageDTO(false); @@ -169,7 +167,6 @@ void loadFromRemoteFirstAndThanUpdateRepository() throws Exception { @Test void technischeWlsExceptionWhenNoExternalDataFound() throws Exception { - val requestDate = LocalDate.now().minusMonths(3).toString(); WireMock.stubFor(WireMock.get("/wahldaten/wahltage?includingSince=" + requestDate) @@ -189,7 +186,6 @@ void technischeWlsExceptionWhenNoExternalDataFound() throws Exception { private de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO createClientWahltageDTO( boolean pDifferentValueBeschreibungAsInDummyClient) { - val clientWahltageDTO = new de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO(); val wahltag1 = new de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltagDTO(); From 10406a70ba2d17485875f5646c9cf18a78aa6377 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Wed, 17 Jul 2024 16:56:03 +0200 Subject: [PATCH 45/51] Leerzeile ist nicht mehr da --- .../basisdatenservice/rest/wahltage/WahltageControllerTest.java | 1 - .../basisdatenservice/rest/wahltage/WahltageDTOMapperTest.java | 1 - 2 files changed, 2 deletions(-) diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageControllerTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageControllerTest.java index f1fbe7aa8..86a5c70e8 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageControllerTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageControllerTest.java @@ -30,7 +30,6 @@ class GetWahltage { @Test void serviceIsCalledAndObjectsAreMapped() { - val wahltagModels = List.of( WahltagModel.builder().build(), WahltagModel.builder().build(), diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageDTOMapperTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageDTOMapperTest.java index d074af5ae..7cd11bc5e 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageDTOMapperTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageDTOMapperTest.java @@ -23,7 +23,6 @@ void nullInNullOut() { @Test void isMappedToDTO() { - val modelsInput = createClientWahltagModels(); val dtosExpected = createClientWahltagDTOs(); From 68df3e57f44b3180fe2fceda74cf516ba1271c22 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Wed, 17 Jul 2024 16:58:07 +0200 Subject: [PATCH 46/51] Redundante Variablen entfernt --- .../rest/wahltage/WahltageDTOMapperTest.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageDTOMapperTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageDTOMapperTest.java index 7cd11bc5e..0dbd33b6c 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageDTOMapperTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/rest/wahltage/WahltageDTOMapperTest.java @@ -35,9 +35,7 @@ private List createClientWahltagDTOs() { val wahltag2 = new WahltagDTO("identifikatorWahltag2", LocalDate.now().minusMonths(1), "beschreibungWahltag2", "nummerWahltag2"); val wahltag3 = new WahltagDTO("identifikatorWahltag3", LocalDate.now().plusMonths(1), "beschreibungWahltag3", "nummerWahltag3"); - val wahltageDTOs = List.of(wahltag1, wahltag2, wahltag3); - - return wahltageDTOs; + return List.of(wahltag1, wahltag2, wahltag3); } private List createClientWahltagModels() { @@ -45,9 +43,7 @@ private List createClientWahltagModels() { 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); } } } From d6b0ac229c1a7f8ea5bd3dd5d45ca6e4b339e998 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Wed, 17 Jul 2024 17:07:51 +0200 Subject: [PATCH 47/51] Stubing weggelassen --- .../basisdatenservice/services/wahltag/WahltageServiceTest.java | 1 - 1 file changed, 1 deletion(-) 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 0bf755f08..3474f566f 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 @@ -38,7 +38,6 @@ void dataIsLoadedFromRemoteEvenIfExistingInRepoAndRepoIsUpdated() { Mockito.when(wahltageClient.getWahltage(LocalDate.now().minusMonths(3))).thenReturn(mockedClientResponse); Mockito.when(wahltagModelMapper.fromWahltagModelToWahltagEntityList(mockedClientResponse)).thenReturn(mockedListOfEntities); - Mockito.when(wahltagRepository.saveAll(mockedListOfEntities)).thenReturn(mockedListOfEntities); Mockito.when(wahltagRepository.findAllByOrderByWahltagAsc()).thenReturn(mockedListOfEntities); Mockito.when(wahltagModelMapper.fromWahltagEntityToWahltagModelList(mockedListOfEntities)).thenReturn(mockedMappedSavedEntities); From 7e23a78442717279361428c32c6045ed75324abe Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Wed, 17 Jul 2024 17:17:23 +0200 Subject: [PATCH 48/51] pIndex in wahlbezirkIDPraefix umbenannt --- .../services/wahltag/WahltageServiceTest.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 3474f566f..7f51b2cfd 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 @@ -47,18 +47,18 @@ void dataIsLoadedFromRemoteEvenIfExistingInRepoAndRepoIsUpdated() { } - private List createWahltagList(String pIndex) { - val wahltag1 = new Wahltag(pIndex + "_identifikatorWahltag1", LocalDate.now().minusMonths(2), "beschreibungWahltag1", "nummerWahltag1"); - val wahltag2 = new Wahltag(pIndex + "_identifikatorWahltag2", LocalDate.now().minusMonths(1), "beschreibungWahltag2", "nummerWahltag2"); - val wahltag3 = new Wahltag(pIndex + "_identifikatorWahltag3", LocalDate.now().plusMonths(1), "beschreibungWahltag3", "nummerWahltag3"); + private List createWahltagList(String wahltagIDPrefix) { + val wahltag1 = new Wahltag(wahltagIDPrefix + "_identifikatorWahltag1", LocalDate.now().minusMonths(2), "beschreibungWahltag1", "nummerWahltag1"); + val wahltag2 = new Wahltag(wahltagIDPrefix + "_identifikatorWahltag2", LocalDate.now().minusMonths(1), "beschreibungWahltag2", "nummerWahltag2"); + val wahltag3 = new Wahltag(wahltagIDPrefix + "_identifikatorWahltag3", LocalDate.now().plusMonths(1), "beschreibungWahltag3", "nummerWahltag3"); return List.of(wahltag1, wahltag2, wahltag3); } - private List 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"); + private List createWahltagModelList(String wahltagIDPrefix) { + val wahltag1 = new WahltagModel(wahltagIDPrefix + "_identifikatorWahltag1", LocalDate.now().minusMonths(2), "beschreibungWahltag1", "nummerWahltag1"); + val wahltag2 = new WahltagModel(wahltagIDPrefix + "_identifikatorWahltag2", LocalDate.now().minusMonths(1), "beschreibungWahltag2", "nummerWahltag2"); + val wahltag3 = new WahltagModel(wahltagIDPrefix + "_identifikatorWahltag3", LocalDate.now().plusMonths(1), "beschreibungWahltag3", "nummerWahltag3"); return List.of(wahltag1, wahltag2, wahltag3); } From 976528d9445b079d62878368e54491ed976f2953 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Thu, 18 Jul 2024 15:08:57 +0200 Subject: [PATCH 49/51] fix spotless check forgotten --- .../services/wahltag/WahltageServiceTest.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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 7f51b2cfd..3cb0cd932 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 @@ -56,9 +56,12 @@ private List createWahltagList(String wahltagIDPrefix) { } private List createWahltagModelList(String wahltagIDPrefix) { - val wahltag1 = new WahltagModel(wahltagIDPrefix + "_identifikatorWahltag1", LocalDate.now().minusMonths(2), "beschreibungWahltag1", "nummerWahltag1"); - val wahltag2 = new WahltagModel(wahltagIDPrefix + "_identifikatorWahltag2", LocalDate.now().minusMonths(1), "beschreibungWahltag2", "nummerWahltag2"); - val wahltag3 = new WahltagModel(wahltagIDPrefix + "_identifikatorWahltag3", LocalDate.now().plusMonths(1), "beschreibungWahltag3", "nummerWahltag3"); + val wahltag1 = new WahltagModel(wahltagIDPrefix + "_identifikatorWahltag1", LocalDate.now().minusMonths(2), "beschreibungWahltag1", + "nummerWahltag1"); + val wahltag2 = new WahltagModel(wahltagIDPrefix + "_identifikatorWahltag2", LocalDate.now().minusMonths(1), "beschreibungWahltag2", + "nummerWahltag2"); + val wahltag3 = new WahltagModel(wahltagIDPrefix + "_identifikatorWahltag3", LocalDate.now().plusMonths(1), "beschreibungWahltag3", + "nummerWahltag3"); return List.of(wahltag1, wahltag2, wahltag3); } From 9dfc76381573e4447816073757d7226fbcc5a74d Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Fri, 19 Jul 2024 09:37:32 +0200 Subject: [PATCH 50/51] pParametrs umbenannt --- .../domain/WahltagRepositoryTest.java | 12 ++++++------ .../wahltage/WahltageControllerIntegrationTest.java | 8 ++++---- 2 files changed, 10 insertions(+), 10 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 e90484626..0b2479b1d 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 @@ -38,7 +38,7 @@ void tearDown() { */ @Test void findAllByOrderByWahltagAsc() { - List wahltageToSave = createWahltagList("1"); + List wahltageToSave = createWahltagList(); repository.saveAll(wahltageToSave); List foundWahltage = repository.findAllByOrderByWahltagAsc(); @@ -50,11 +50,11 @@ void findAllByOrderByWahltagAsc() { Assertions.assertThat(wahltageToSave).isEqualTo(foundWahltage); } - private List createWahltagList(String pIndex) { - val wahltag4 = new Wahltag(pIndex + "_identifikatorWahltag4", LocalDate.now().plusMonths(5), "beschreibungWahltag4", "nummerWahltag4"); - val wahltag1 = new Wahltag(pIndex + "_identifikatorWahltag1", LocalDate.now().minusMonths(2), "beschreibungWahltag1", "nummerWahltag1"); - val wahltag3 = new Wahltag(pIndex + "_identifikatorWahltag3", LocalDate.now().plusMonths(1), "beschreibungWahltag3", "nummerWahltag3"); - val wahltag2 = new Wahltag(pIndex + "_identifikatorWahltag2", LocalDate.now().minusMonths(1), "beschreibungWahltag2", "nummerWahltag2"); + private List createWahltagList() { + val wahltag4 = new Wahltag("_identifikatorWahltag4", LocalDate.now().plusMonths(5), "beschreibungWahltag4", "nummerWahltag4"); + val wahltag1 = new Wahltag("_identifikatorWahltag1", LocalDate.now().minusMonths(2), "beschreibungWahltag1", "nummerWahltag1"); + val wahltag3 = new Wahltag("_identifikatorWahltag3", LocalDate.now().plusMonths(1), "beschreibungWahltag3", "nummerWahltag3"); + val wahltag2 = new Wahltag("_identifikatorWahltag2", LocalDate.now().minusMonths(1), "beschreibungWahltag2", "nummerWahltag2"); 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 d50e402f4..dc95a3693 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 @@ -185,24 +185,24 @@ void technischeWlsExceptionWhenNoExternalDataFound() throws Exception { } private de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO createClientWahltageDTO( - boolean pDifferentValueBeschreibungAsInDummyClient) { + boolean beschreibungPartPreNumber) { val clientWahltageDTO = new de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO(); val wahltag1 = new de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltagDTO(); wahltag1.setIdentifikator("identifikatorWahltag1"); - wahltag1.setBeschreibung((pDifferentValueBeschreibungAsInDummyClient) ? "diff_beschreibungWahltag1" : "beschreibungWahltag1"); + wahltag1.setBeschreibung((beschreibungPartPreNumber) ? "diff_beschreibungWahltag1" : "beschreibungWahltag1"); wahltag1.setNummer("nummerWahltag1"); wahltag1.setTag(LocalDate.now().minusMonths(2)); val wahltag2 = new de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltagDTO(); wahltag2.setIdentifikator("identifikatorWahltag2"); - wahltag2.setBeschreibung((pDifferentValueBeschreibungAsInDummyClient) ? "diff_beschreibungWahltag2" : "beschreibungWahltag2"); + wahltag2.setBeschreibung((beschreibungPartPreNumber) ? "diff_beschreibungWahltag2" : "beschreibungWahltag2"); wahltag2.setNummer("nummerWahltag2"); wahltag2.setTag(LocalDate.now().minusMonths(1)); val wahltag3 = new WahltagDTO(); wahltag3.setIdentifikator("identifikatorWahltag3"); - wahltag3.setBeschreibung((pDifferentValueBeschreibungAsInDummyClient) ? "diff_beschreibungWahltag3" : "beschreibungWahltag3"); + wahltag3.setBeschreibung((beschreibungPartPreNumber) ? "diff_beschreibungWahltag3" : "beschreibungWahltag3"); wahltag3.setNummer("nummerWahltag3"); wahltag3.setTag(LocalDate.now().plusMonths(1)); From 7ed44f1b1c5673951ed958a336832546d705f737 Mon Sep 17 00:00:00 2001 From: Nic12345678 <162564162+Nic12345678@users.noreply.github.com> Date: Fri, 19 Jul 2024 11:07:31 +0200 Subject: [PATCH 51/51] =?UTF-8?q?Anpassung=20wegen=20=C3=84nderung=20opena?= =?UTF-8?q?pi-Beta=20zu=20openapi-0.1.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wls-basisdaten-service/pom.xml | 2 +- .../clients/WahltageClientImpl.java | 7 +++-- .../clients/WahltageClientMapper.java | 6 ++-- .../resources/openapis/openapi.eai.0.1.0.json | 1 + .../openapis/openapi.eai.0.1.1-Beta1.json | 1 - .../clients/WahltageClientImplTest.java | 30 +++++++++++++++++-- .../clients/WahltageClientMapperTest.java | 12 +++----- .../WahltageControllerIntegrationTest.java | 14 ++++----- .../wahltag/WahltageServiceSecurityTest.java | 8 ++--- 9 files changed, 46 insertions(+), 35 deletions(-) create mode 100644 wls-basisdaten-service/src/main/resources/openapis/openapi.eai.0.1.0.json delete mode 100644 wls-basisdaten-service/src/main/resources/openapis/openapi.eai.0.1.1-Beta1.json diff --git a/wls-basisdaten-service/pom.xml b/wls-basisdaten-service/pom.xml index 2346d00cd..09195ca67 100644 --- a/wls-basisdaten-service/pom.xml +++ b/wls-basisdaten-service/pom.xml @@ -393,7 +393,7 @@ generate - ${project.basedir}/src/main/resources/openapis/openapi.eai.0.1.1-Beta1.json + ${project.basedir}/src/main/resources/openapis/openapi.eai.0.1.0.json java resttemplate diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImpl.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImpl.java index ec299a424..d5e9f51e1 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImpl.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImpl.java @@ -2,7 +2,7 @@ import de.muenchen.oss.wahllokalsystem.basisdatenservice.configuration.Profiles; import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.client.WahldatenControllerApi; -import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltagDTO; import de.muenchen.oss.wahllokalsystem.basisdatenservice.exception.ExceptionConstants; import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltagModel; import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltageClient; @@ -10,6 +10,7 @@ import de.muenchen.oss.wahllokalsystem.wls.common.exception.util.ExceptionFactory; import java.time.LocalDate; import java.util.List; +import java.util.Set; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Profile; @@ -29,7 +30,7 @@ public class WahltageClientImpl implements WahltageClient { @Override public List getWahltage(LocalDate tag) throws WlsException { - final WahltageDTO wahltageDTO; + final Set wahltageDTO; try { wahltageDTO = wahldatenControllerApi.loadWahltageSinceIncluding(tag); } catch (final Exception exception) { @@ -39,6 +40,6 @@ public List getWahltage(LocalDate tag) throws WlsException { if (wahltageDTO == null) { throw exceptionFactory.createFachlicheWlsException(ExceptionConstants.NULL_FROM_CLIENT); } - return wahltageClientMapper.fromRemoteClientWahltageDTOtoListOfWahltagModel(wahltageDTO); + return wahltageClientMapper.fromRemoteClientSetOfWahltagDTOtoListOfWahltagModel(wahltageDTO); } } diff --git a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapper.java b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapper.java index c00f63fb6..7d56768bb 100644 --- a/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapper.java +++ b/wls-basisdaten-service/src/main/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapper.java @@ -1,9 +1,9 @@ package de.muenchen.oss.wahllokalsystem.basisdatenservice.clients; import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltagDTO; -import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO; import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltagModel; import java.util.List; +import java.util.Set; import org.mapstruct.Mapper; import org.mapstruct.Mapping; @@ -14,7 +14,5 @@ public interface WahltageClientMapper { @Mapping(target = "wahltag", source = "tag") WahltagModel toWahltagModel(WahltagDTO wahltagDTO); - default List fromRemoteClientWahltageDTOtoListOfWahltagModel(final WahltageDTO wahltageDTO) { - return wahltageDTO.getWahltage().stream().map(this::toWahltagModel).toList(); - } + List fromRemoteClientSetOfWahltagDTOtoListOfWahltagModel(Set wahltageDTO); } diff --git a/wls-basisdaten-service/src/main/resources/openapis/openapi.eai.0.1.0.json b/wls-basisdaten-service/src/main/resources/openapis/openapi.eai.0.1.0.json new file mode 100644 index 000000000..de8c135d1 --- /dev/null +++ b/wls-basisdaten-service/src/main/resources/openapis/openapi.eai.0.1.0.json @@ -0,0 +1 @@ +{"openapi":"3.0.1","info":{"title":"EAI Service","contact":{"name":"Your Name","email":"Your E-Mail-Address"},"version":"0.1.0"},"servers":[{"url":"http://localhost:8080","description":"Generated server url"}],"security":[{"bearerAuth":[]}],"paths":{"/wahlvorstaende/anwesenheit":{"put":{"tags":["wahlvorstand-controller"],"description":"Aktualisieren der Anwesenheit der Wahlvorstandsmitglieder eines bestimmten Wahlbezirkes","operationId":"saveAnwesenheit","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WahlvorstandsaktualisierungDTO"}}},"required":true},"responses":{"200":{"description":"OK"},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahllokalzustand":{"post":{"tags":["wahllokalzustand-controller"],"operationId":"saveWahllokalZustand","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WahllokalZustandDTO"}}},"required":true},"responses":{"200":{"description":"OK"},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahlergebnis":{"post":{"tags":["wahlergebnis-controller"],"operationId":"saveWahlergebnismeldung","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErgebnismeldungDTO"}}},"required":true},"responses":{"200":{"description":"OK"},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahlbeteiligung":{"post":{"tags":["wahlbeteiligung-controller"],"operationId":"saveWahlbeteiligung","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WahlbeteiligungsMeldungDTO"}}},"required":true},"responses":{"200":{"description":"OK"},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahlvorstaende":{"get":{"tags":["wahlvorstand-controller"],"description":"Abrufen des Wahlvorstandes für einen bestimmten Wahlbezirk","operationId":"loadWahlvorstand","parameters":[{"name":"wahlbezirkID","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/WahlvorstandDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahldaten/wahltage":{"get":{"tags":["wahldaten-controller"],"operationId":"loadWahltageSinceIncluding","parameters":[{"name":"includingSince","in":"query","required":true,"schema":{"type":"string","format":"date"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahltagDTO"}}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahldaten/wahlen":{"get":{"tags":["wahldaten-controller"],"operationId":"loadWahlen","parameters":[{"name":"forDate","in":"query","required":true,"schema":{"type":"string","format":"date"}},{"name":"withNummer","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlDTO"}}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahldaten/wahlbezirke/{wahlbezirkID}/wahlberechtigte":{"get":{"tags":["wahldaten-controller"],"operationId":"loadWahlberechtigte","parameters":[{"name":"wahlbezirkID","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/WahlberechtigteDTO"}}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahldaten/wahlbezirk":{"get":{"tags":["wahldaten-controller"],"operationId":"loadWahlbezirke","parameters":[{"name":"forDate","in":"query","required":true,"schema":{"type":"string","format":"date"}},{"name":"withNummer","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlbezirkDTO"}}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahldaten/basisdaten":{"get":{"tags":["wahldaten-controller"],"operationId":"loadBasisdaten","parameters":[{"name":"forDate","in":"query","required":true,"schema":{"type":"string","format":"date"}},{"name":"withNummer","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/BasisdatenDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/vorschlaege/wahl/{wahlID}/{wahlbezirkID}":{"get":{"tags":["wahlvorschlag-controller"],"operationId":"loadWahlvorschlaege","parameters":[{"name":"wahlID","in":"path","required":true,"schema":{"type":"string"}},{"name":"wahlbezirkID","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/WahlvorschlaegeDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/vorschlaege/wahl/{wahlID}/liste":{"get":{"tags":["wahlvorschlag-controller"],"operationId":"loadWahlvorschlaegeListe","parameters":[{"name":"forDate","in":"query","required":true,"schema":{"type":"string","format":"date"}},{"name":"wahlID","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/WahlvorschlaegeListeDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/vorschlaege/referendum/{wahlID}/{wahlbezirkID}":{"get":{"tags":["wahlvorschlag-controller"],"operationId":"loadReferendumvorlagen","parameters":[{"name":"wahlID","in":"path","required":true,"schema":{"type":"string"}},{"name":"wahlbezirkID","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ReferendumvorlagenDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}}},"components":{"schemas":{"WahlvorstandsaktualisierungDTO":{"required":["anwesenheitBeginn","mitglieder","wahlbezirkID"],"type":"object","properties":{"wahlbezirkID":{"type":"string"},"mitglieder":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlvorstandsmitgliedAktualisierungDTO"}},"anwesenheitBeginn":{"type":"string","format":"date-time"}}},"WahlvorstandsmitgliedAktualisierungDTO":{"required":["anwesend","identifikator"],"type":"object","properties":{"identifikator":{"type":"string"},"anwesend":{"type":"boolean"}}},"DruckzustandDTO":{"required":["niederschriftDruckUhrzeit","niederschriftSendenUhrzeit","schnellmeldungDruckUhrzeit","schnellmeldungSendenUhrzeit","wahlID"],"type":"object","properties":{"wahlID":{"type":"string"},"schnellmeldungSendenUhrzeit":{"type":"string","format":"date-time"},"niederschriftSendenUhrzeit":{"type":"string","format":"date-time"},"schnellmeldungDruckUhrzeit":{"type":"string","format":"date-time"},"niederschriftDruckUhrzeit":{"type":"string","format":"date-time"}}},"WahllokalZustandDTO":{"required":["druckzustaende","letzteAbmeldung","wahlbezirkID","zuletztGesehen"],"type":"object","properties":{"wahlbezirkID":{"type":"string"},"zuletztGesehen":{"type":"string","format":"date-time"},"letzteAbmeldung":{"type":"string","format":"date-time"},"druckzustaende":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/DruckzustandDTO"}}}},"AWerteDTO":{"type":"object","properties":{"a1":{"type":"integer","format":"int64"},"a2":{"type":"integer","format":"int64"}}},"BWerteDTO":{"type":"object","properties":{"b":{"type":"integer","format":"int64"},"b1":{"type":"integer","format":"int64"},"b2":{"type":"integer","format":"int64"}}},"ErgebnisDTO":{"required":["ergebnis","kandidatID","stimmenart","wahlvorschlagID","wahlvorschlagsordnungszahl"],"type":"object","properties":{"stimmenart":{"type":"string"},"wahlvorschlagsordnungszahl":{"type":"integer","format":"int64"},"ergebnis":{"type":"integer","format":"int64"},"wahlvorschlagID":{"type":"string"},"kandidatID":{"type":"string"}}},"ErgebnismeldungDTO":{"required":["wahlID","wahlbezirkID"],"type":"object","properties":{"wahlbezirkID":{"type":"string"},"wahlID":{"type":"string"},"meldungsart":{"type":"string","enum":["NIEDERSCHRIFT","SCHNELLMELDUNG"]},"aWerte":{"$ref":"#/components/schemas/AWerteDTO"},"bWerte":{"$ref":"#/components/schemas/BWerteDTO"},"wahlbriefeWerte":{"$ref":"#/components/schemas/WahlbriefeWerteDTO"},"ungueltigeStimmzettels":{"type":"array","items":{"$ref":"#/components/schemas/UngueltigeStimmzettelDTO"}},"ungueltigeStimmzettelAnzahl":{"type":"integer","format":"int64"},"ergebnisse":{"type":"array","items":{"$ref":"#/components/schemas/ErgebnisDTO"}},"wahlart":{"type":"string","enum":["BAW","BEB","BTW","BZW","EUW","LTW","MBW","OBW","SRW","SVW","VE"]}}},"UngueltigeStimmzettelDTO":{"type":"object","properties":{"stimmenart":{"type":"string"},"anzahl":{"type":"integer","format":"int64"},"wahlvorschlagID":{"type":"string"}}},"WahlbriefeWerteDTO":{"type":"object","properties":{"zurueckgewiesenGesamt":{"type":"integer","format":"int64"}}},"WahlbeteiligungsMeldungDTO":{"required":["anzahlWaehler","meldeZeitpunkt","wahlID","wahlbezirkID"],"type":"object","properties":{"wahlID":{"type":"string"},"wahlbezirkID":{"type":"string"},"anzahlWaehler":{"type":"integer","format":"int64"},"meldeZeitpunkt":{"type":"string","format":"date-time"}}},"WahlvorstandDTO":{"required":["mitglieder","wahlbezirkID"],"type":"object","properties":{"wahlbezirkID":{"type":"string"},"mitglieder":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlvorstandsmitgliedDTO"}}}},"WahlvorstandsmitgliedDTO":{"required":["anwesend","funktion","identifikator","nachname","vorname"],"type":"object","properties":{"identifikator":{"type":"string"},"vorname":{"type":"string"},"nachname":{"type":"string"},"funktion":{"type":"string","enum":["W","SB","SWB","SSB","B"]},"anwesend":{"type":"boolean"}}},"WahltagDTO":{"required":["beschreibung","identifikator","nummer","tag"],"type":"object","properties":{"identifikator":{"type":"string"},"tag":{"type":"string","format":"date"},"beschreibung":{"type":"string"},"nummer":{"type":"string"}}},"WahlDTO":{"required":["identifikator","name","nummer","wahlart","wahltag"],"type":"object","properties":{"identifikator":{"type":"string"},"name":{"type":"string"},"wahlart":{"type":"string","enum":["BAW","BEB","BTW","BZW","EUW","LTW","MBW","OBW","SRW","SVW","VE"]},"wahltag":{"type":"string","format":"date"},"nummer":{"type":"string"}}},"WahlberechtigteDTO":{"required":["a1","a2","a3","wahlID","wahlbezirkID"],"type":"object","properties":{"wahlID":{"type":"string"},"wahlbezirkID":{"type":"string"},"a1":{"type":"integer","format":"int64"},"a2":{"type":"integer","format":"int64"},"a3":{"type":"integer","format":"int64"}}},"WahlbezirkDTO":{"required":["identifikator","nummer","wahlID","wahlbezirkArt","wahlnummer","wahltag"],"type":"object","properties":{"identifikator":{"type":"string"},"wahlbezirkArt":{"type":"string","enum":["UWB","BWB"]},"nummer":{"type":"string"},"wahltag":{"type":"string","format":"date"},"wahlnummer":{"type":"string"},"wahlID":{"type":"string"}}},"BasisdatenDTO":{"required":["basisstrukturdaten","stimmzettelgebiete","wahlbezirke","wahlen"],"type":"object","properties":{"basisstrukturdaten":{"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/BasisstrukturdatenDTO"}},"wahlen":{"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlDTO"}},"wahlbezirke":{"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlbezirkDTO"}},"stimmzettelgebiete":{"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/StimmzettelgebietDTO"}}}},"BasisstrukturdatenDTO":{"required":["stimmzettelgebietID","wahlID","wahlbezirkID","wahltag"],"type":"object","properties":{"wahlID":{"type":"string"},"stimmzettelgebietID":{"type":"string"},"wahlbezirkID":{"type":"string"},"wahltag":{"type":"string","format":"date"}}},"StimmzettelgebietDTO":{"required":["stimmzettelgebietsart"],"type":"object","properties":{"identifikator":{"type":"string"},"nummer":{"type":"string"},"name":{"type":"string"},"wahltag":{"type":"string","format":"date"},"stimmzettelgebietsart":{"type":"string","enum":["SB","SG","SK","WK"]}}},"KandidatDTO":{"required":["direktkandidat","einzelbewerber","identifikator","listenposition","name","tabellenSpalteInNiederschrift"],"type":"object","properties":{"identifikator":{"type":"string"},"name":{"type":"string"},"listenposition":{"type":"integer","format":"int64"},"direktkandidat":{"type":"boolean"},"tabellenSpalteInNiederschrift":{"type":"integer","format":"int64"},"einzelbewerber":{"type":"boolean"}}},"WahlvorschlaegeDTO":{"required":["stimmzettelgebietID","wahlID","wahlbezirkID","wahlvorschlaege"],"type":"object","properties":{"wahlbezirkID":{"type":"string"},"wahlID":{"type":"string"},"stimmzettelgebietID":{"type":"string"},"wahlvorschlaege":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlvorschlagDTO"}}}},"WahlvorschlagDTO":{"required":["erhaeltStimmen","identifikator","kurzname","ordnungszahl"],"type":"object","properties":{"identifikator":{"type":"string"},"ordnungszahl":{"type":"integer","format":"int64"},"kurzname":{"type":"string"},"erhaeltStimmen":{"type":"boolean"},"kandidaten":{"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/KandidatDTO"}}}},"WahlvorschlaegeListeDTO":{"required":["wahlID","wahlvorschlaegeliste"],"type":"object","properties":{"wahlID":{"type":"string"},"wahlvorschlaegeliste":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlvorschlaegeDTO"}}}},"ReferendumoptionDTO":{"required":["id","name"],"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"position":{"type":"integer","format":"int64"}}},"ReferendumvorlageDTO":{"required":["frage","kurzname","ordnungszahl","referendumoptionen","wahlvorschlagID"],"type":"object","properties":{"wahlvorschlagID":{"type":"string"},"ordnungszahl":{"type":"integer","format":"int64"},"kurzname":{"type":"string"},"frage":{"type":"string"},"referendumoptionen":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/ReferendumoptionDTO"}}}},"ReferendumvorlagenDTO":{"required":["referendumvorlagen","stimmzettelgebietID"],"type":"object","properties":{"stimmzettelgebietID":{"type":"string"},"referendumvorlagen":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/ReferendumvorlageDTO"}}}},"WlsExceptionDTO":{"required":["category","code","message","service"],"type":"object","properties":{"category":{"type":"string","enum":["F","T","S","I"]},"code":{"type":"string"},"service":{"type":"string"},"message":{"type":"string"}}}},"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}}}} \ No newline at end of file diff --git a/wls-basisdaten-service/src/main/resources/openapis/openapi.eai.0.1.1-Beta1.json b/wls-basisdaten-service/src/main/resources/openapis/openapi.eai.0.1.1-Beta1.json deleted file mode 100644 index bf93e7477..000000000 --- a/wls-basisdaten-service/src/main/resources/openapis/openapi.eai.0.1.1-Beta1.json +++ /dev/null @@ -1 +0,0 @@ -{"openapi":"3.0.1","info":{"title":"EAI Service","contact":{"name":"Your Name","email":"Your E-Mail-Address"},"version":"0.1.1-Beta1"},"servers":[{"url":"http://localhost:8080","description":"Generated server url"}],"security":[{"bearerAuth":[]}],"paths":{"/wahlvorstaende/anwesenheit":{"put":{"tags":["wahlvorstand-controller"],"description":"Aktualisieren der Anwesenheit der Wahlvorstandsmitglieder eines bestimmten Wahlbezirkes","operationId":"saveAnwesenheit","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WahlvorstandsaktualisierungDTO"}}},"required":true},"responses":{"200":{"description":"OK"},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahllokalzustand":{"post":{"tags":["wahllokalzustand-controller"],"operationId":"saveWahllokalZustand","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WahllokalZustandDTO"}}},"required":true},"responses":{"200":{"description":"OK"},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahlergebnis":{"post":{"tags":["wahlergebnis-controller"],"operationId":"saveWahlergebnismeldung","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErgebnismeldungDTO"}}},"required":true},"responses":{"200":{"description":"OK"},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahlbeteiligung":{"post":{"tags":["wahlbeteiligung-controller"],"operationId":"saveWahlbeteiligung","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WahlbeteiligungsMeldungDTO"}}},"required":true},"responses":{"200":{"description":"OK"},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahlvorstaende":{"get":{"tags":["wahlvorstand-controller"],"description":"Abrufen des Wahlvorstandes für einen bestimmten Wahlbezirk","operationId":"loadWahlvorstand","parameters":[{"name":"wahlbezirkID","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/WahlvorstandDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahldaten/wahltage":{"get":{"tags":["wahldaten-controller"],"operationId":"loadWahltageSinceIncluding","parameters":[{"name":"includingSince","in":"query","required":true,"schema":{"type":"string","format":"date"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/WahltageDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahldaten/wahlen":{"get":{"tags":["wahldaten-controller"],"operationId":"loadWahlen","parameters":[{"name":"forDate","in":"query","required":true,"schema":{"type":"string","format":"date"}},{"name":"withNummer","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/WahlenDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahldaten/wahlbezirke/{wahlbezirkID}/wahlberechtigte":{"get":{"tags":["wahldaten-controller"],"operationId":"loadWahlberechtigte","parameters":[{"name":"wahlbezirkID","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/WahlberechtigteDTO"}}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahldaten/wahlbezirk":{"get":{"tags":["wahldaten-controller"],"operationId":"loadWahlbezirke","parameters":[{"name":"forDate","in":"query","required":true,"schema":{"type":"string","format":"date"}},{"name":"withNummer","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/WahlbezirkeDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/wahldaten/basisdaten":{"get":{"tags":["wahldaten-controller"],"operationId":"loadBasisdaten","parameters":[{"name":"forDate","in":"query","required":true,"schema":{"type":"string","format":"date"}},{"name":"withNummer","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/BasisdatenDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/vorschlaege/wahl/{wahlID}/{wahlbezirkID}":{"get":{"tags":["wahlvorschlag-controller"],"operationId":"loadWahlvorschlaege","parameters":[{"name":"wahlID","in":"path","required":true,"schema":{"type":"string"}},{"name":"wahlbezirkID","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/WahlvorschlaegeDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/vorschlaege/wahl/{wahlID}/liste":{"get":{"tags":["wahlvorschlag-controller"],"operationId":"loadWahlvorschlaegeListe","parameters":[{"name":"forDate","in":"query","required":true,"schema":{"type":"string","format":"date"}},{"name":"wahlID","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/WahlvorschlaegeListeDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}},"/vorschlaege/referendum/{wahlID}/{wahlbezirkID}":{"get":{"tags":["wahlvorschlag-controller"],"operationId":"loadReferendumvorlagen","parameters":[{"name":"wahlID","in":"path","required":true,"schema":{"type":"string"}},{"name":"wahlbezirkID","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ReferendumvorlagenDTO"}}}},"400":{"description":"request body validation failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}},"404":{"description":"resource not found"},"500":{"description":"unhandled error during communication with other system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WlsExceptionDTO"}}}}}}}},"components":{"schemas":{"WahlvorstandsaktualisierungDTO":{"required":["anwesenheitBeginn","mitglieder","wahlbezirkID"],"type":"object","properties":{"wahlbezirkID":{"type":"string"},"mitglieder":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlvorstandsmitgliedAktualisierungDTO"}},"anwesenheitBeginn":{"type":"string","format":"date-time"}}},"WahlvorstandsmitgliedAktualisierungDTO":{"required":["anwesend","identifikator"],"type":"object","properties":{"identifikator":{"type":"string"},"anwesend":{"type":"boolean"}}},"DruckzustandDTO":{"required":["niederschriftDruckUhrzeit","niederschriftSendenUhrzeit","schnellmeldungDruckUhrzeit","schnellmeldungSendenUhrzeit","wahlID"],"type":"object","properties":{"wahlID":{"type":"string"},"schnellmeldungSendenUhrzeit":{"type":"string","format":"date-time"},"niederschriftSendenUhrzeit":{"type":"string","format":"date-time"},"schnellmeldungDruckUhrzeit":{"type":"string","format":"date-time"},"niederschriftDruckUhrzeit":{"type":"string","format":"date-time"}}},"WahllokalZustandDTO":{"required":["druckzustaende","letzteAbmeldung","wahlbezirkID","zuletztGesehen"],"type":"object","properties":{"wahlbezirkID":{"type":"string"},"zuletztGesehen":{"type":"string","format":"date-time"},"letzteAbmeldung":{"type":"string","format":"date-time"},"druckzustaende":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/DruckzustandDTO"}}}},"AWerteDTO":{"type":"object","properties":{"a1":{"type":"integer","format":"int64"},"a2":{"type":"integer","format":"int64"}}},"BWerteDTO":{"type":"object","properties":{"b":{"type":"integer","format":"int64"},"b1":{"type":"integer","format":"int64"},"b2":{"type":"integer","format":"int64"}}},"ErgebnisDTO":{"required":["ergebnis","kandidatID","stimmenart","wahlvorschlagID","wahlvorschlagsordnungszahl"],"type":"object","properties":{"stimmenart":{"type":"string"},"wahlvorschlagsordnungszahl":{"type":"integer","format":"int64"},"ergebnis":{"type":"integer","format":"int64"},"wahlvorschlagID":{"type":"string"},"kandidatID":{"type":"string"}}},"ErgebnismeldungDTO":{"required":["wahlID","wahlbezirkID"],"type":"object","properties":{"wahlbezirkID":{"type":"string"},"wahlID":{"type":"string"},"meldungsart":{"type":"string","enum":["NIEDERSCHRIFT","SCHNELLMELDUNG"]},"aWerte":{"$ref":"#/components/schemas/AWerteDTO"},"bWerte":{"$ref":"#/components/schemas/BWerteDTO"},"wahlbriefeWerte":{"$ref":"#/components/schemas/WahlbriefeWerteDTO"},"ungueltigeStimmzettels":{"type":"array","items":{"$ref":"#/components/schemas/UngueltigeStimmzettelDTO"}},"ungueltigeStimmzettelAnzahl":{"type":"integer","format":"int64"},"ergebnisse":{"type":"array","items":{"$ref":"#/components/schemas/ErgebnisDTO"}},"wahlart":{"type":"string","enum":["BAW","BEB","BTW","BZW","EUW","LTW","MBW","OBW","SRW","SVW","VE"]}}},"UngueltigeStimmzettelDTO":{"type":"object","properties":{"stimmenart":{"type":"string"},"anzahl":{"type":"integer","format":"int64"},"wahlvorschlagID":{"type":"string"}}},"WahlbriefeWerteDTO":{"type":"object","properties":{"zurueckgewiesenGesamt":{"type":"integer","format":"int64"}}},"WahlbeteiligungsMeldungDTO":{"required":["anzahlWaehler","meldeZeitpunkt","wahlID","wahlbezirkID"],"type":"object","properties":{"wahlID":{"type":"string"},"wahlbezirkID":{"type":"string"},"anzahlWaehler":{"type":"integer","format":"int64"},"meldeZeitpunkt":{"type":"string","format":"date-time"}}},"WahlvorstandDTO":{"required":["mitglieder","wahlbezirkID"],"type":"object","properties":{"wahlbezirkID":{"type":"string"},"mitglieder":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlvorstandsmitgliedDTO"}}}},"WahlvorstandsmitgliedDTO":{"required":["anwesend","funktion","identifikator","nachname","vorname"],"type":"object","properties":{"identifikator":{"type":"string"},"vorname":{"type":"string"},"nachname":{"type":"string"},"funktion":{"type":"string","enum":["W","SB","SWB","SSB","B"]},"anwesend":{"type":"boolean"}}},"WahltagDTO":{"required":["beschreibung","identifikator","nummer","tag"],"type":"object","properties":{"identifikator":{"type":"string"},"tag":{"type":"string","format":"date"},"beschreibung":{"type":"string"},"nummer":{"type":"string"}}},"WahltageDTO":{"required":["wahltage"],"type":"object","properties":{"wahltage":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahltagDTO"}}}},"WahlDTO":{"required":["identifikator","name","nummer","wahlart","wahltag"],"type":"object","properties":{"identifikator":{"type":"string"},"name":{"type":"string"},"wahlart":{"type":"string","enum":["BAW","BEB","BTW","BZW","EUW","LTW","MBW","OBW","SRW","SVW","VE"]},"wahltag":{"type":"string","format":"date"},"nummer":{"type":"string"}}},"WahlenDTO":{"required":["wahlen"],"type":"object","properties":{"wahlen":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlDTO"}}}},"WahlberechtigteDTO":{"required":["a1","a2","a3","wahlID","wahlbezirkID"],"type":"object","properties":{"wahlID":{"type":"string"},"wahlbezirkID":{"type":"string"},"a1":{"type":"integer","format":"int64"},"a2":{"type":"integer","format":"int64"},"a3":{"type":"integer","format":"int64"}}},"WahlbezirkDTO":{"required":["identifikator","nummer","wahlID","wahlbezirkArt","wahlnummer","wahltag"],"type":"object","properties":{"identifikator":{"type":"string"},"wahlbezirkArt":{"type":"string","enum":["UWB","BWB"]},"nummer":{"type":"string"},"wahltag":{"type":"string","format":"date"},"wahlnummer":{"type":"string"},"wahlID":{"type":"string"}}},"WahlbezirkeDTO":{"required":["wahlbezirke"],"type":"object","properties":{"wahlbezirke":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlbezirkDTO"}}}},"BasisdatenDTO":{"required":["basisstrukturdaten","stimmzettelgebiete","wahlbezirke","wahlen"],"type":"object","properties":{"basisstrukturdaten":{"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/BasisstrukturdatenDTO"}},"wahlen":{"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlDTO"}},"wahlbezirke":{"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlbezirkDTO"}},"stimmzettelgebiete":{"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/StimmzettelgebietDTO"}}}},"BasisstrukturdatenDTO":{"required":["stimmzettelgebietID","wahlID","wahlbezirkID","wahltag"],"type":"object","properties":{"wahlID":{"type":"string"},"stimmzettelgebietID":{"type":"string"},"wahlbezirkID":{"type":"string"},"wahltag":{"type":"string","format":"date"}}},"StimmzettelgebietDTO":{"required":["stimmzettelgebietart"],"type":"object","properties":{"identifikator":{"type":"string"},"nummer":{"type":"string"},"name":{"type":"string"},"wahltag":{"type":"string","format":"date"},"stimmzettelgebietart":{"type":"string","enum":["SB","SG","SK","WK"]}}},"KandidatDTO":{"required":["direktkandidat","einzelbewerber","identifikator","listenposition","name","tabellenSpalteInNiederschrift"],"type":"object","properties":{"identifikator":{"type":"string"},"name":{"type":"string"},"listenposition":{"type":"integer","format":"int64"},"direktkandidat":{"type":"boolean"},"tabellenSpalteInNiederschrift":{"type":"integer","format":"int64"},"einzelbewerber":{"type":"boolean"}}},"WahlvorschlaegeDTO":{"required":["stimmzettelgebietID","wahlID","wahlbezirkID","wahlvorschlaege"],"type":"object","properties":{"wahlbezirkID":{"type":"string"},"wahlID":{"type":"string"},"stimmzettelgebietID":{"type":"string"},"wahlvorschlaege":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlvorschlagDTO"}}}},"WahlvorschlagDTO":{"required":["erhaeltStimmen","identifikator","kurzname","ordnungszahl"],"type":"object","properties":{"identifikator":{"type":"string"},"ordnungszahl":{"type":"integer","format":"int64"},"kurzname":{"type":"string"},"erhaeltStimmen":{"type":"boolean"},"kandidaten":{"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/KandidatDTO"}}}},"WahlvorschlaegeListeDTO":{"required":["wahlID","wahlvorschlaege"],"type":"object","properties":{"wahlID":{"type":"string"},"wahlvorschlaege":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/WahlvorschlaegeDTO"}}}},"ReferendumoptionDTO":{"required":["id","name"],"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"position":{"type":"integer","format":"int64"}}},"ReferendumvorlageDTO":{"required":["frage","kurzname","ordnungszahl","referendumoption","wahlvorschlagID"],"type":"object","properties":{"wahlvorschlagID":{"type":"string"},"ordnungszahl":{"type":"integer","format":"int64"},"kurzname":{"type":"string"},"frage":{"type":"string"},"referendumoption":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/ReferendumoptionDTO"}}}},"ReferendumvorlagenDTO":{"required":["referendumvorlage","stimmzettelgebietID"],"type":"object","properties":{"stimmzettelgebietID":{"type":"string"},"referendumvorlage":{"maxItems":2147483647,"minItems":1,"uniqueItems":true,"type":"array","items":{"$ref":"#/components/schemas/ReferendumvorlageDTO"}}}},"WlsExceptionDTO":{"required":["category","code","message","service"],"type":"object","properties":{"category":{"type":"string","enum":["F","T","S","I"]},"code":{"type":"string"},"service":{"type":"string"},"message":{"type":"string"}}}},"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}}}} \ No newline at end of file diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImplTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImplTest.java index bc5ab0de1..ad69c4d58 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImplTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientImplTest.java @@ -2,7 +2,7 @@ import static org.mockito.ArgumentMatchers.any; import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.client.WahldatenControllerApi; -import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO; +import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltagDTO; import de.muenchen.oss.wahllokalsystem.basisdatenservice.exception.ExceptionConstants; import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltagModel; import de.muenchen.oss.wahllokalsystem.wls.common.exception.FachlicheWlsException; @@ -10,6 +10,7 @@ import de.muenchen.oss.wahllokalsystem.wls.common.exception.util.ExceptionFactory; import java.time.LocalDate; import java.util.List; +import java.util.Set; import lombok.val; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Nested; @@ -43,12 +44,12 @@ class GetWahltage { void clientResponseIsMapped() { val testDate = LocalDate.now().minusMonths(3); - val mockedClientResponse = new WahltageDTO(); + val mockedClientResponse = createClientWahltageDTO(); val mockedMappedClientResponse = List.of(WahltagModel.builder().build()); Mockito.when(wahldatenControllerApi.loadWahltageSinceIncluding(testDate)) .thenReturn(mockedClientResponse); - Mockito.when(wahltageClientMapper.fromRemoteClientWahltageDTOtoListOfWahltagModel(mockedClientResponse)) + Mockito.when(wahltageClientMapper.fromRemoteClientSetOfWahltagDTOtoListOfWahltagModel(mockedClientResponse)) .thenReturn(mockedMappedClientResponse); val result = unitUnderTest.getWahltage(testDate); @@ -77,5 +78,28 @@ void controllerApiExceptionIsMapped() { Mockito.when(exceptionFactory.createTechnischeWlsException(ExceptionConstants.FAILED_COMMUNICATION_WITH_EAI)).thenThrow(mockedException); Assertions.assertThatException().isThrownBy(() -> unitUnderTest.getWahltage(testDate)).isSameAs(mockedException); } + + private Set createClientWahltageDTO() { + + val wahltag1 = new de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltagDTO(); + wahltag1.setIdentifikator("identifikatorWahltag1"); + wahltag1.setBeschreibung("beschreibungWahltag1"); + wahltag1.setNummer("nummerWahltag1"); + wahltag1.setTag(LocalDate.now().minusMonths(2)); + + val wahltag2 = new de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltagDTO(); + wahltag2.setIdentifikator("identifikatorWahltag2"); + wahltag2.setBeschreibung("beschreibungWahltag2"); + wahltag2.setNummer("nummerWahltag2"); + wahltag2.setTag(LocalDate.now().minusMonths(1)); + + val wahltag3 = new WahltagDTO(); + wahltag3.setIdentifikator("identifikatorWahltag3"); + wahltag3.setBeschreibung("beschreibungWahltag3"); + wahltag3.setNummer("nummerWahltag3"); + wahltag3.setTag(LocalDate.now().plusMonths(1)); + + return Set.of(wahltag1, wahltag2, wahltag3); + } } } diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapperTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapperTest.java index 755f2292b..cdccb46e4 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapperTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/clients/WahltageClientMapperTest.java @@ -1,7 +1,6 @@ package de.muenchen.oss.wahllokalsystem.basisdatenservice.clients; import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltagDTO; -import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO; import de.muenchen.oss.wahllokalsystem.basisdatenservice.services.wahltag.WahltagModel; import java.time.LocalDate; import java.util.List; @@ -47,8 +46,6 @@ class FromRemoteClientWahltageDTOtoListOfWahltagModel { @Test void isMapped() { - val dtoToMap = new WahltageDTO(); - val wahltag1 = new WahltagDTO(); wahltag1.setIdentifikator("identifikatorWahltag1"); wahltag1.setBeschreibung("beschreibungWahltag1"); @@ -67,13 +64,12 @@ void isMapped() { wahltag3.setNummer("nummerWahltag3"); wahltag3.setTag(LocalDate.now().plusMonths(1)); - dtoToMap.setWahltage(Set.of( - wahltag1, wahltag2, wahltag3)); + val dtoToMap = Set.of(wahltag1, wahltag2, wahltag3); - Assertions.assertThat(dtoToMap).hasNoNullFieldsOrProperties(); - Assertions.assertThat(dtoToMap.getWahltage()).size().isEqualTo(3); + Assertions.assertThat(dtoToMap).size().isEqualTo(3); + dtoToMap.forEach(wahltag -> Assertions.assertThat(wahltag).hasNoNullFieldsOrProperties()); - val result = unitUnderTest.fromRemoteClientWahltageDTOtoListOfWahltagModel(dtoToMap); + val result = unitUnderTest.fromRemoteClientSetOfWahltagDTOtoListOfWahltagModel(dtoToMap); val expectedWahltage = List.of( new WahltagModel("identifikatorWahltag1", 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 dc95a3693..be01e71f3 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 @@ -103,7 +103,7 @@ void loadedFromExternal() throws Exception { de.muenchen.oss.wahllokalsystem.basisdatenservice.rest.wahltage.WahltagDTO[].class); val expectedResponseBody = dtoMapper - .fromListOfWahltagModelToListOfWahltagDTO(wahltageClientMapper.fromRemoteClientWahltageDTOtoListOfWahltagModel(eaiWahltage)); + .fromListOfWahltagModelToListOfWahltagDTO(wahltageClientMapper.fromRemoteClientSetOfWahltagDTOtoListOfWahltagModel(eaiWahltage)); Assertions.assertThat(responseBodyAsDTO).containsExactlyInAnyOrderElementsOf(expectedResponseBody); } @@ -125,7 +125,7 @@ void externalDataIsPersisted() throws Exception { val dataFromRepo = wahltagRepository.findAllByOrderByWahltagAsc(); val expectedListOfData = modelMapper.fromWahltagModelToWahltagEntityList( - wahltageClientMapper.fromRemoteClientWahltageDTOtoListOfWahltagModel(eaiWahltage)); + wahltageClientMapper.fromRemoteClientSetOfWahltagDTOtoListOfWahltagModel(eaiWahltage)); Assertions.assertThat(dataFromRepo) .usingRecursiveComparison().ignoringCollectionOrder() @@ -136,7 +136,7 @@ void externalDataIsPersisted() throws Exception { void loadFromRemoteFirstAndThanUpdateRepository() throws Exception { val entitiesToFindInRepository = modelMapper .fromWahltagModelToWahltagEntityList(wahltageClientMapper - .fromRemoteClientWahltageDTOtoListOfWahltagModel(createClientWahltageDTO(true))); + .fromRemoteClientSetOfWahltagDTOtoListOfWahltagModel(createClientWahltageDTO(true))); val savedEntitiesInRepository_1 = wahltagRepository.saveAll(entitiesToFindInRepository); val request = MockMvcRequestBuilders.get("/businessActions/wahltage"); @@ -184,9 +184,8 @@ void technischeWlsExceptionWhenNoExternalDataFound() throws Exception { } } - private de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO createClientWahltageDTO( + private Set createClientWahltageDTO( boolean beschreibungPartPreNumber) { - val clientWahltageDTO = new de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO(); val wahltag1 = new de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltagDTO(); wahltag1.setIdentifikator("identifikatorWahltag1"); @@ -206,9 +205,6 @@ private de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.Wahltage wahltag3.setNummer("nummerWahltag3"); wahltag3.setTag(LocalDate.now().plusMonths(1)); - val wahltage = Set.of(wahltag1, wahltag2, wahltag3); - clientWahltageDTO.setWahltage(wahltage); - - return clientWahltageDTO; + return Set.of(wahltag1, wahltag2, wahltag3); } } diff --git a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageServiceSecurityTest.java b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageServiceSecurityTest.java index 5be8576e2..e7b79c031 100644 --- a/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageServiceSecurityTest.java +++ b/wls-basisdaten-service/src/test/java/de/muenchen/oss/wahllokalsystem/basisdatenservice/services/wahltag/WahltageServiceSecurityTest.java @@ -6,7 +6,6 @@ import de.muenchen.oss.wahllokalsystem.basisdatenservice.TestConstants; import de.muenchen.oss.wahllokalsystem.basisdatenservice.domain.WahltagRepository; import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltagDTO; -import de.muenchen.oss.wahllokalsystem.basisdatenservice.eai.aou.model.WahltageDTO; import de.muenchen.oss.wahllokalsystem.basisdatenservice.utils.Authorities; import de.muenchen.oss.wahllokalsystem.wls.common.testing.SecurityUtils; import java.time.LocalDate; @@ -86,8 +85,7 @@ private static Stream getMissingAuthoritiesVariations() { return SecurityUtils.buildArgumentsForMissingAuthoritiesVariations(Authorities.ALL_AUTHORITIES_DELETE_WAHLTAGE); } - private WahltageDTO createClientWahltageDTO() { - val dto = new WahltageDTO(); + private Set createClientWahltageDTO() { val wahltag1 = new WahltagDTO(); wahltag1.setIdentifikator("identifikatorWahltag1"); wahltag1.setBeschreibung("beschreibungWahltag1"); @@ -106,9 +104,7 @@ private WahltageDTO createClientWahltageDTO() { wahltag3.setNummer("nummerWahltag3"); wahltag3.setTag(LocalDate.now().plusMonths(1)); - dto.setWahltage(Set.of(wahltag3, wahltag2, wahltag1)); - - return dto; + return Set.of(wahltag3, wahltag2, wahltag1); } } }