Skip to content

Commit

Permalink
Superior Courts dont get location transformed
Browse files Browse the repository at this point in the history
RISDEV-2846
  • Loading branch information
HPrinz committed Dec 4, 2023
1 parent a93811f commit 36c5510
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ public static Court transformToDomain(CourtDTO courtDTO) {

String revoked = extractRevoked(courtDTO.getAdditionalInformation());

if (Boolean.TRUE.equals(courtDTO.isSuperiorCourt())
&& Boolean.TRUE.equals(!courtDTO.isForeignCourt())) {

if (Boolean.TRUE.equals(courtDTO.isSuperiorCourt())) {
return Court.builder()
.id(courtDTO.getId())
.type(courtDTO.getType())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package de.bund.digitalservice.ris.caselaw.adapter;

import static org.assertj.core.api.Assertions.assertThat;

import de.bund.digitalservice.ris.caselaw.adapter.database.jpa.CourtDTO;
import de.bund.digitalservice.ris.caselaw.adapter.transformer.CourtTransformer;
import de.bund.digitalservice.ris.caselaw.domain.court.Court;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

class CourtTransformerTest {

@ParameterizedTest
@CsvSource({
"Bonn, NonSuperiorNonForeignCourt, false, false",
"London, NonSuperiorForeignCourt, false, true"
})
void shouldTransformLocation(
String location, String type, boolean isSuperiorCourt, boolean isForeignCourt) {
CourtDTO courtDTO =
CourtDTO.builder()
.jurisId(1)
.type(type)
.location(location)
.isSuperiorCourt(isSuperiorCourt)
.isForeignCourt(isForeignCourt)
.build();

Court court = CourtTransformer.transformToDomain(courtDTO);

// Assertion
assertThat(court)
.extracting("type", "location", "label")
.containsExactly(type, location, type + " " + location);
}

@ParameterizedTest
@CsvSource({
"BGH, SuperiorNonForeignCourt, true, false",
"DenHaag, SuperiorForeignCourt, true, true"
})
void shouldNotTransformLocation(
String location, String type, boolean isSuperiorCourt, boolean isForeignCourt) {
CourtDTO courtDTO =
CourtDTO.builder()
.jurisId(1)
.type(type)
.location(location)
.isSuperiorCourt(isSuperiorCourt)
.isForeignCourt(isForeignCourt)
.build();

Court court = CourtTransformer.transformToDomain(courtDTO);
assertThat(court).extracting("type", "location", "label").containsExactly(type, null, type);
}
}

0 comments on commit 36c5510

Please sign in to comment.