Skip to content

Commit

Permalink
wahlID und wahlbezirkID aus DTO entfernt weil im Controller über Pfad…
Browse files Browse the repository at this point in the history
…variablen gesetzt
  • Loading branch information
dragonfly28 committed Oct 25, 2024
1 parent 0864c42 commit edc7596
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

@Builder
public record WaehleranzahlDTO(
@NotNull String wahlID,
@NotNull String wahlbezirkID,
@NotNull Long anzahlWaehler,
@NotNull LocalDateTime uhrzeit) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
import de.muenchen.oss.wahllokalsystem.monitoringservice.service.waehleranzahl.WaehleranzahlModel;
import de.muenchen.oss.wahllokalsystem.wls.common.security.domain.BezirkUndWahlID;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

@Mapper
public interface WaehleranzahlDTOMapper {

@Mapping(source = "bezirkUndWahlID.wahlID", target = "wahlID")
@Mapping(source = "bezirkUndWahlID.wahlbezirkID", target = "wahlbezirkID")
WaehleranzahlDTO toDTO(WaehleranzahlModel waehleranzahlModel);

WaehleranzahlModel toSetModel(BezirkUndWahlID bezirkUndWahlID, WaehleranzahlDTO waehleranzahlDTO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void should_return401Unauthorized_when_postWithUnauthorizedAnonymousUser() throw
@Test
@WithMockUser
void should_return200OK_when_postWithAuthorizedMockUser() throws Exception {
val requestBody = new WaehleranzahlDTO(null, null, null, null);
val requestBody = new WaehleranzahlDTO(null, null);
val request = post("/businessActions/wahlbeteiligung/wahlID/wahlbezirkID").with(csrf()).contentType(MediaType.APPLICATION_JSON).content(
objectMapper.writeValueAsString(requestBody));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void should_overwriteExistingData_when_newDataIsStoredWithSameID() throws Except
val anzahlWaehler_1 = 99L;
val uhrzeit_1 = LocalDateTime.parse("2024-09-13T12:11:21.343");

val waehleranzahlDTO_1 = new WaehleranzahlDTO(wahlID, wahlbezirkID, anzahlWaehler_1, uhrzeit_1);
val waehleranzahlDTO_1 = new WaehleranzahlDTO(anzahlWaehler_1, uhrzeit_1);

WireMock.stubFor(WireMock.post("/wahlbeteiligung")
.willReturn(WireMock.aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.OK.value())
Expand All @@ -139,7 +139,7 @@ void should_overwriteExistingData_when_newDataIsStoredWithSameID() throws Except
// Overwrite existing data
val anzahlWaehler_2 = 55L;
val uhrzeit_2 = LocalDateTime.parse("2024-09-13T12:11:21.666");
val waehleranzahlDTO_2 = new WaehleranzahlDTO(wahlID, wahlbezirkID, anzahlWaehler_2, uhrzeit_2);
val waehleranzahlDTO_2 = new WaehleranzahlDTO(anzahlWaehler_2, uhrzeit_2);

val request_2 = buildPostRequest(wahlID, wahlbezirkID, waehleranzahlDTO_2);
api.perform(request_2).andExpect(status().isOk()).andReturn();
Expand All @@ -159,7 +159,7 @@ void should_throwTechnischeWlsException_when_requestIsInvalid() throws Exception
val wahlbezirkID = "wahlbezirkID01";
val anzahlWaehler = 99L;
val uhrzeit = LocalDateTime.parse("2024-09-13T12:11:21.343");
val waehleranzahlDTO = new WaehleranzahlDTO(wahlID, wahlbezirkID, anzahlWaehler, uhrzeit);
val waehleranzahlDTO = new WaehleranzahlDTO(anzahlWaehler, uhrzeit);

val request = MockMvcRequestBuilders.post("/businessActions/wahlbeteiligung/" + wahlID + "/" + wahlbezirkID).with(csrf())
.contentType(MediaType.APPLICATION_JSON)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void should_mapModelToDto_when_ModelIsNotNull() {
BezirkUndWahlID bezirkUndWahlID = new BezirkUndWahlID(wahlID, wahlbezirkID);

val modelInput = new WaehleranzahlModel(bezirkUndWahlID, anzahlWaehler, uhrzeit);
val dtoExpected = new WaehleranzahlDTO(wahlID, wahlbezirkID, anzahlWaehler, uhrzeit);
val dtoExpected = new WaehleranzahlDTO(anzahlWaehler, uhrzeit);

val result = unitUnderTest.toDTO(modelInput);
Assertions.assertThat(result).isEqualTo(dtoExpected);
Expand All @@ -49,7 +49,7 @@ void should_mapDtoToModel_when_DtoIsNotNull() {
LocalDateTime uhrzeit = LocalDateTime.now();
BezirkUndWahlID bezirkUndWahlID = new BezirkUndWahlID(wahlID, wahlbezirkID);

val dtoInput = new WaehleranzahlDTO(wahlID, wahlbezirkID, anzahlWaehler, uhrzeit);
val dtoInput = new WaehleranzahlDTO(anzahlWaehler, uhrzeit);
val modelExpected = new WaehleranzahlModel(bezirkUndWahlID, anzahlWaehler, uhrzeit);

val result = unitUnderTest.toSetModel(bezirkUndWahlID, dtoInput);
Expand Down

0 comments on commit edc7596

Please sign in to comment.