diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/AnnouncementControllerTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/AnnouncementControllerTest.java index 66ec558c6..402ed71fa 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/AnnouncementControllerTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/AnnouncementControllerTest.java @@ -200,8 +200,8 @@ class getRelease { @Test void itReturnsRelease() throws Exception { // Given - var amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); - var affectedNormZf0 = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + var amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); + var affectedNormZf0 = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); var announcement = Announcement .builder() .eli(amendingNorm.getExpressionEli()) @@ -252,8 +252,8 @@ class putRelease { @Test void itReleaseAnAnnouncement() throws Exception { // Given - var amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); - var affectedNormZf0 = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + var amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); + var affectedNormZf0 = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); var announcement = Announcement .builder() .eli(amendingNorm.getExpressionEli()) @@ -303,7 +303,7 @@ class postAnnouncement { @Test void itCreatesAnAnnouncement() throws Exception { // Given - var norm = NormFixtures.loadFromDisk("NormWithMods.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithMods.xml"); var xmlContent = XmlMapper.toString(norm.getDocument()); final MockMultipartFile file = new MockMultipartFile( "file", @@ -333,7 +333,7 @@ void itCreatesAnAnnouncement() throws Exception { @Test void itCreatesAnAnnouncementWithForce() throws Exception { // Given - var norm = NormFixtures.loadFromDisk("NormWithMods.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithMods.xml"); var xmlContent = XmlMapper.toString(norm.getDocument()); final MockMultipartFile file = new MockMultipartFile( "file", @@ -363,7 +363,7 @@ void itCreatesAnAnnouncementWithForce() throws Exception { @Test void itShouldNotExposeInternalInformationOnUnexpectedErrors() throws Exception { // Given - var norm = NormFixtures.loadFromDisk("NormWithMods.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithMods.xml"); var xmlContent = XmlMapper.toString(norm.getDocument()); final MockMultipartFile file = new MockMultipartFile( "file", diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/ArticleControllerTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/ArticleControllerTest.java index c8c61beae..0a0f085ee 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/ArticleControllerTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/ArticleControllerTest.java @@ -7,8 +7,8 @@ import de.bund.digitalservice.ris.norms.application.port.input.*; import de.bund.digitalservice.ris.norms.config.SecurityConfig; +import de.bund.digitalservice.ris.norms.domain.entity.Fixtures; import de.bund.digitalservice.ris.norms.domain.entity.Norm; -import de.bund.digitalservice.ris.norms.domain.entity.NormFixtures; import de.bund.digitalservice.ris.norms.domain.entity.Regelungstext; import de.bund.digitalservice.ris.norms.domain.entity.eli.DokumentExpressionEli; import de.bund.digitalservice.ris.norms.utils.XmlMapper; @@ -61,8 +61,8 @@ class getArticles { @Test void itReturnsArticles() throws Exception { // Given - var norm = NormFixtures.loadFromDisk("NormWithMods.xml"); - var zf0Norm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithMods.xml"); + var zf0Norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); when(loadNormUseCase.loadNorm(any())).thenReturn(zf0Norm); when(loadArticlesFromNormUseCase.loadArticlesFromNorm(any())).thenReturn(norm.getArticles()); @@ -103,7 +103,7 @@ void itReturnsArticles() throws Exception { @Test void itReturnsArticlesFilteredByAmendedAt() throws Exception { // Given - var norm = NormFixtures.loadFromDisk("NormWithMultiplePassiveModifications.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithMultiplePassiveModifications.xml"); when(loadNormUseCase.loadNorm(any())).thenReturn(norm); @@ -145,7 +145,7 @@ void itReturnsArticlesFilteredByAmendedAt() throws Exception { @Test void itReturnsArticlesFilteredByAmendedBy() throws Exception { // Given - var norm = NormFixtures.loadFromDisk("NormWithPassiveModificationsInDifferentArticles.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithPassiveModificationsInDifferentArticles.xml"); when(loadNormUseCase.loadNorm(any())).thenReturn(norm); @@ -189,7 +189,7 @@ void itReturnsArticlesFilteredByAmendedBy() throws Exception { @Test void itReturnsUnprocessableEntityWhenMandatoryNodeIsMissing() throws Exception { // Given - var norm = NormFixtures.loadFromDisk("NormWithPassiveModificationsInDifferentArticles.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithPassiveModificationsInDifferentArticles.xml"); when(loadNormUseCase.loadNorm(any())).thenReturn(norm); @@ -244,8 +244,8 @@ class getArticle { @Test void itReturnsArticle() throws Exception { // Given - var norm = NormFixtures.loadFromDisk("NormWithMods.xml"); - var normZf0 = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithMods.xml"); + var normZf0 = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); when(loadNormUseCase.loadNorm(any())).thenReturn(norm).thenReturn(normZf0); diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/NormExpressionControllerTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/NormExpressionControllerTest.java index 7039fa764..e16f240ce 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/NormExpressionControllerTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/NormExpressionControllerTest.java @@ -12,8 +12,8 @@ import de.bund.digitalservice.ris.norms.application.exception.NormNotFoundException; import de.bund.digitalservice.ris.norms.application.port.input.*; import de.bund.digitalservice.ris.norms.config.SecurityConfig; +import de.bund.digitalservice.ris.norms.domain.entity.Fixtures; import de.bund.digitalservice.ris.norms.domain.entity.Norm; -import de.bund.digitalservice.ris.norms.domain.entity.NormFixtures; import de.bund.digitalservice.ris.norms.domain.entity.Regelungstext; import de.bund.digitalservice.ris.norms.domain.entity.eli.DokumentExpressionEli; import de.bund.digitalservice.ris.norms.utils.XmlMapper; @@ -255,10 +255,10 @@ void itCallsNormServiceAndReturnsNormRenderWithAtIsoDate() throws Exception { final String eli = "eli/bund/bgbl-1/1990/s2954/2022-12-19/1/deu/regelungstext-1"; final String html = "
"; - when(loadNormUseCase.loadNorm(any())).thenReturn(NormFixtures.loadFromDisk("SimpleNorm.xml")); + when(loadNormUseCase.loadNorm(any())).thenReturn(Fixtures.loadNormFromDisk("SimpleNorm.xml")); when(transformLegalDocMlToHtmlUseCase.transformLegalDocMlToHtml(any())).thenReturn(html); when(applyPassiveModificationsUseCase.applyPassiveModifications(any())) - .thenReturn(NormFixtures.loadFromDisk("SimpleNorm.xml")); + .thenReturn(Fixtures.loadNormFromDisk("SimpleNorm.xml")); // When // Then mockMvc diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/ProprietaryControllerTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/ProprietaryControllerTest.java index 0fda080af..3a786f37f 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/ProprietaryControllerTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/ProprietaryControllerTest.java @@ -15,7 +15,7 @@ import de.bund.digitalservice.ris.norms.application.port.input.UpdateProprietaryFrameFromNormUseCase; import de.bund.digitalservice.ris.norms.application.port.input.UpdateProprietarySingleElementFromNormUseCase; import de.bund.digitalservice.ris.norms.config.SecurityConfig; -import de.bund.digitalservice.ris.norms.domain.entity.NormFixtures; +import de.bund.digitalservice.ris.norms.domain.entity.Fixtures; import de.bund.digitalservice.ris.norms.domain.entity.Proprietary; import de.bund.digitalservice.ris.norms.domain.entity.eli.DokumentExpressionEli; import de.bund.digitalservice.ris.norms.utils.XmlMapper; @@ -86,7 +86,7 @@ void returnsProprietaryResponseSchema() throws Exception { "eli/bund/bgbl-1/2002/s1181/2019-11-22/1/deu/rechtsetzungsdokument-1" ); var atDateString = "2024-06-03"; - var normWithProprietary = NormFixtures.loadFromDisk("NormWithProprietary.xml"); + var normWithProprietary = Fixtures.loadNormFromDisk("NormWithProprietary.xml"); var proprietary = normWithProprietary.getMeta().getOrCreateProprietary(); when( loadProprietaryFromNormUseCase.loadProprietaryFromNorm( @@ -122,7 +122,7 @@ void returnsEmptyValuesIfSpecificProprietaryDataIsNotFound() throws Exception { "eli/bund/bgbl-1/2002/s1181/2019-11-22/1/deu/rechtsetzungsdokument-1" ); var atDateString = "2024-06-03"; - var normWithInvalidProprietary = NormFixtures.loadFromDisk("NormWithInvalidProprietary.xml"); + var normWithInvalidProprietary = Fixtures.loadNormFromDisk("NormWithInvalidProprietary.xml"); var proprietary = normWithInvalidProprietary.getMeta().getOrCreateProprietary(); when( loadProprietaryFromNormUseCase.loadProprietaryFromNorm( @@ -158,7 +158,7 @@ void returnsEmptyValuesIfProprietaryDoesNotExist() throws Exception { "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1" ); var atDateString = "2024-06-03"; - var normWithInvalidProprietary = NormFixtures.loadFromDisk("SimpleNorm.xml"); + var normWithInvalidProprietary = Fixtures.loadNormFromDisk("SimpleNorm.xml"); var proprietary = normWithInvalidProprietary.getMeta().getOrCreateProprietary(); when( loadProprietaryFromNormUseCase.loadProprietaryFromNorm( @@ -342,7 +342,7 @@ void returnsProprietaryResponseSchema() throws Exception { ); var eid = "hauptteil-1_abschnitt-0_art-1"; var atDateString = "2024-06-03"; - var normWithProprietary = NormFixtures.loadFromDisk("NormWithProprietary.xml"); + var normWithProprietary = Fixtures.loadNormFromDisk("NormWithProprietary.xml"); var proprietary = normWithProprietary.getMeta().getOrCreateProprietary(); when( loadProprietaryFromNormUseCase.loadProprietaryFromNorm( @@ -370,7 +370,7 @@ void returnsEmptyValuesIfSpecificProprietaryDataIsNotFound() throws Exception { ); var eid = "hauptteil-1_abschnitt-0_art-1"; var atDateString = "2024-06-03"; - var normWithInvalidProprietary = NormFixtures.loadFromDisk("NormWithInvalidProprietary.xml"); + var normWithInvalidProprietary = Fixtures.loadNormFromDisk("NormWithInvalidProprietary.xml"); var proprietary = normWithInvalidProprietary.getMeta().getOrCreateProprietary(); when( loadProprietaryFromNormUseCase.loadProprietaryFromNorm( @@ -398,7 +398,7 @@ void returnsEmptyValuesIfProprietaryDoesNotExist() throws Exception { ); var eid = "hauptteil-1_abschnitt-0_art-1"; var atDateString = "2024-06-03"; - var normWithInvalidProprietary = NormFixtures.loadFromDisk("SimpleNorm.xml"); + var normWithInvalidProprietary = Fixtures.loadNormFromDisk("SimpleNorm.xml"); var proprietary = normWithInvalidProprietary.getMeta().getOrCreateProprietary(); when( loadProprietaryFromNormUseCase.loadProprietaryFromNorm( diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/mapper/ReleaseResponseMapperTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/mapper/ReleaseResponseMapperTest.java index 302420b16..cd3f52ba6 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/mapper/ReleaseResponseMapperTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/mapper/ReleaseResponseMapperTest.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import de.bund.digitalservice.ris.norms.adapter.input.restapi.schema.ReleaseResponseSchema; -import de.bund.digitalservice.ris.norms.domain.entity.NormFixtures; +import de.bund.digitalservice.ris.norms.domain.entity.Fixtures; import de.bund.digitalservice.ris.norms.domain.entity.Release; import java.time.Instant; import java.util.List; @@ -18,8 +18,8 @@ void canMapAnnouncementAndEffectedNorms() { .releasedAt(Instant.parse("2024-01-02T10:20:30.0Z")) .publishedNorms( List.of( - NormFixtures.loadFromDisk("SimpleNorm.xml"), - NormFixtures.loadFromDisk("NormWithMods.xml") + Fixtures.loadNormFromDisk("SimpleNorm.xml"), + Fixtures.loadNormFromDisk("NormWithMods.xml") ) ) .build(); diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/output/database/dto/NormDtoTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/output/database/dto/NormDtoTest.java index 1a9e43ab2..09b6f3e2a 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/output/database/dto/NormDtoTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/output/database/dto/NormDtoTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import de.bund.digitalservice.ris.norms.domain.entity.NormFixtures; +import de.bund.digitalservice.ris.norms.domain.entity.Fixtures; import de.bund.digitalservice.ris.norms.domain.entity.NormPublishState; import jakarta.validation.ConstraintViolation; import jakarta.validation.Validation; @@ -28,7 +28,7 @@ public static void setUp() { @Test void testAllConstraintsAreMet() { // Given - var xml = NormFixtures.loadTextFromDisk("SimpleNorm.xml"); + var xml = Fixtures.loadTextFromDisk("SimpleNorm.xml"); var guid = UUID.fromString("c01334e2-f12b-4055-ac82-15ac03c74c78"); // When @@ -60,7 +60,7 @@ void shouldBeUnpublishedByDefaultWhenCreatedUsingBuilder() { // Given final NormDto normDto = NormDto .builder() - .xml(NormFixtures.loadTextFromDisk("SimpleNorm.xml")) + .xml(Fixtures.loadTextFromDisk("SimpleNorm.xml")) .build(); // Then diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/AnnouncementServiceTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/AnnouncementServiceTest.java index 7e0a04082..82c04e443 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/AnnouncementServiceTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/AnnouncementServiceTest.java @@ -11,8 +11,8 @@ import de.bund.digitalservice.ris.norms.application.port.input.LoadTargetNormsAffectedByAnnouncementUseCase; import de.bund.digitalservice.ris.norms.application.port.output.*; import de.bund.digitalservice.ris.norms.domain.entity.Announcement; -import de.bund.digitalservice.ris.norms.domain.entity.NormFixtures; import de.bund.digitalservice.ris.norms.domain.entity.eli.DokumentExpressionEli; +import de.bund.digitalservice.ris.norms.domain.entity.Fixtures; import de.bund.digitalservice.ris.norms.utils.XmlMapper; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -66,7 +66,7 @@ class loadAllAnnouncements { @Test void itReturnsAnnouncements() { // Given - var norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + var norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); var announcement = Announcement.builder().eli(norm.getExpressionEli()).build(); when(loadAllAnnouncementsPort.loadAllAnnouncements()).thenReturn(List.of(announcement)); @@ -85,7 +85,7 @@ class loadAnnouncement { @Test void itThrowsAnnouncementNotFoundException() { // given - var norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + var norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); final var query = new LoadAnnouncementByNormEliUseCase.Query( DokumentExpressionEli.fromString( "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1" @@ -122,7 +122,7 @@ void itThrowsAnnouncementNotFoundExceptionIfNormDoesNotExist() { @Test void itReturnsAnnouncement() { // Given - var norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + var norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); var announcement = Announcement.builder().eli(norm.getExpressionEli()).build(); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(norm)); @@ -150,8 +150,8 @@ class loadTargetNormsAffectedByAnnouncement { @Test void itReturnsNorms() { // Given - var amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); - var affectedNormZf0 = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + var amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); + var affectedNormZf0 = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); when(loadNormPort.loadNorm(any())) .thenReturn(Optional.of(amendingNorm)) @@ -185,7 +185,7 @@ class createAnnouncement { void itCreatesANewAnnouncement() throws IOException { // Given var xmlContent = XmlMapper.toString( - NormFixtures.loadFromDisk("NormWithMods.xml").getDocument() + Fixtures.loadNormFromDisk("NormWithMods.xml").getDocument() ); final MultipartFile file = new MockMultipartFile( "file", @@ -203,7 +203,7 @@ void itCreatesANewAnnouncement() throws IOException { ) ) ) - .thenReturn(Optional.of(NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"))); + .thenReturn(Optional.of(Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"))); when( loadNormPort.loadNorm( new LoadNormPort.Command( @@ -230,7 +230,7 @@ void itCreatesANewAnnouncement() throws IOException { void itThrowsWhenTheFileIsNotXML() throws IOException { // Given var xmlContent = XmlMapper.toString( - NormFixtures.loadFromDisk("NormWithMods.xml").getDocument() + Fixtures.loadNormFromDisk("NormWithMods.xml").getDocument() ); final MultipartFile file = new MockMultipartFile( "file", @@ -271,7 +271,7 @@ void itThrowsWhenXmlNotLdmlDe() throws IOException { void itThrowsWhenADestinationEliDoesNotExist() throws IOException { // Given var xmlContent = XmlMapper.toString( - NormFixtures.loadFromDisk("NormWithMods.xml").getDocument() + Fixtures.loadNormFromDisk("NormWithMods.xml").getDocument() ); final MultipartFile file = new MockMultipartFile( "file", @@ -301,7 +301,7 @@ void itThrowsWhenADestinationEliDoesNotExist() throws IOException { void itThrowsWhenAnEliOfTheSameEliExists() throws IOException { // Given var xmlContent = XmlMapper.toString( - NormFixtures.loadFromDisk("NormWithMods.xml").getDocument() + Fixtures.loadNormFromDisk("NormWithMods.xml").getDocument() ); final MultipartFile file = new MockMultipartFile( "file", @@ -319,7 +319,7 @@ void itThrowsWhenAnEliOfTheSameEliExists() throws IOException { ) ) ) - .thenReturn(Optional.of(NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"))); + .thenReturn(Optional.of(Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"))); when( loadNormPort.loadNorm( new LoadNormPort.Command( @@ -329,7 +329,7 @@ void itThrowsWhenAnEliOfTheSameEliExists() throws IOException { ) ) ) - .thenReturn(Optional.of(NormFixtures.loadFromDisk("NormWithMods.xml"))); + .thenReturn(Optional.of(Fixtures.loadNormFromDisk("NormWithMods.xml"))); // When // Then var query = new CreateAnnouncementUseCase.Query(file, false); @@ -340,7 +340,7 @@ void itThrowsWhenAnEliOfTheSameEliExists() throws IOException { @Test void itThrowsWhenANormWithSameGuidExists() throws IOException { // Given - var norm = NormFixtures.loadFromDisk("NormWithMods.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithMods.xml"); var xmlContent = XmlMapper.toString(norm.getDocument()); final MultipartFile file = new MockMultipartFile( "file", @@ -358,7 +358,7 @@ void itThrowsWhenANormWithSameGuidExists() throws IOException { ) ) ) - .thenReturn(Optional.of(NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"))); + .thenReturn(Optional.of(Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"))); when( loadNormPort.loadNorm( new LoadNormPort.Command( @@ -386,7 +386,7 @@ void itThrowsWhenANormWithSameGuidExists() throws IOException { void itThrowsWhenTheNormIsNotXsdValid() throws IOException { // Given var xmlContent = XmlMapper.toString( - NormFixtures.loadFromDisk("NormWithModsXsdInvalid.xml").getDocument() + Fixtures.loadNormFromDisk("NormWithModsXsdInvalid.xml").getDocument() ); final MultipartFile file = new MockMultipartFile( "file", @@ -404,7 +404,7 @@ void itThrowsWhenTheNormIsNotXsdValid() throws IOException { ) ) ) - .thenReturn(Optional.of(NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"))); + .thenReturn(Optional.of(Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"))); when( loadNormPort.loadNorm( new LoadNormPort.Command( @@ -427,7 +427,7 @@ void itThrowsWhenTheNormIsNotXsdValid() throws IOException { @Test void itThrowsWhenTheNormIsNotSchematronValid() throws IOException { // Given - var norm = NormFixtures.loadFromDisk("NormWithModsSchematronInvalid.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithModsSchematronInvalid.xml"); var xmlContent = XmlMapper.toString(norm.getDocument()); final MultipartFile file = new MockMultipartFile( "file", @@ -445,7 +445,7 @@ void itThrowsWhenTheNormIsNotSchematronValid() throws IOException { ) ) ) - .thenReturn(Optional.of(NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"))); + .thenReturn(Optional.of(Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"))); when( loadNormPort.loadNorm( new LoadNormPort.Command( @@ -471,7 +471,7 @@ void itThrowsWhenTheNormIsNotSchematronValid() throws IOException { void itCreatesANewAnnouncementWithForce() throws IOException { // Given var xmlContent = XmlMapper.toString( - NormFixtures.loadFromDisk("NormWithMods.xml").getDocument() + Fixtures.loadNormFromDisk("NormWithMods.xml").getDocument() ); final MultipartFile file = new MockMultipartFile( "file", @@ -490,7 +490,7 @@ void itCreatesANewAnnouncementWithForce() throws IOException { ) ) ) - .thenReturn(Optional.of(NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml"))); + .thenReturn(Optional.of(Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml"))); when( loadNormPort.loadNorm( new LoadNormPort.Command( @@ -500,7 +500,7 @@ void itCreatesANewAnnouncementWithForce() throws IOException { ) ) ) - .thenReturn(Optional.of(NormFixtures.loadFromDisk("NormWithMods.xml"))); + .thenReturn(Optional.of(Fixtures.loadNormFromDisk("NormWithMods.xml"))); var announcement = announcementService.createAnnouncement( new CreateAnnouncementUseCase.Query(file, true) diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/ArticleServiceTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/ArticleServiceTest.java index 8f9ea3019..780d90e11 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/ArticleServiceTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/ArticleServiceTest.java @@ -13,8 +13,8 @@ import de.bund.digitalservice.ris.norms.application.port.input.LoadArticlesFromNormUseCase; import de.bund.digitalservice.ris.norms.application.port.input.LoadSpecificArticlesXmlFromNormUseCase; import de.bund.digitalservice.ris.norms.application.port.output.LoadNormPort; +import de.bund.digitalservice.ris.norms.domain.entity.Fixtures; import de.bund.digitalservice.ris.norms.domain.entity.Norm; -import de.bund.digitalservice.ris.norms.domain.entity.NormFixtures; import de.bund.digitalservice.ris.norms.domain.entity.Regelungstext; import de.bund.digitalservice.ris.norms.domain.entity.eli.DokumentExpressionEli; import de.bund.digitalservice.ris.norms.utils.XmlMapper; @@ -44,7 +44,7 @@ void returnResult() { var eli = DokumentExpressionEli.fromString( "eli/bund/bgbl-1/2000/s1/1970-01-01/1/deu/regelungstext-1" ); - var norm = NormFixtures.loadFromDisk("NormWithMods.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithMods.xml"); var eid = "hauptteil-1_art-1"; when(loadNormPort.loadNorm(new LoadNormPort.Command(eli))).thenReturn(Optional.of(norm)); when(timeMachineService.applyPassiveModifications(any())).thenReturn(norm); @@ -76,7 +76,7 @@ void throwsIfNormNotFound() { @Test void throwsIfArticleNotFound() { // given - var norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + var norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); var eli = DokumentExpressionEli.fromString( "eli/bund/DOES_NOT_EXIST/2000/s1/1970-01-01/1/deu/regelungstext-1" ); @@ -101,7 +101,7 @@ void itReturnsArticlesFromNorm() { final var eli = DokumentExpressionEli.fromString( "eli/bund/bgbl-1/1990/s2954/2022-12-19/1/deu/regelungstext-1" ); - final var norm = NormFixtures.loadFromDisk("NormWithMultiplePassiveModifications.xml"); + final var norm = Fixtures.loadNormFromDisk("NormWithMultiplePassiveModifications.xml"); final var query = new LoadArticlesFromNormUseCase.Query(eli); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(norm)); @@ -125,7 +125,7 @@ void itFiltersArticlesByAmendedBy() { "eli/bund/bgbl-1/2017/s815/1995-03-15/1/deu/regelungstext-1" ); final String amendedAt = null; - final var norm = NormFixtures.loadFromDisk( + final var norm = Fixtures.loadNormFromDisk( "NormWithPassiveModificationsInDifferentArticles.xml" ); final var query = new LoadArticlesFromNormUseCase.Query(eli, amendedBy, amendedAt); @@ -148,7 +148,7 @@ void itFiltersArticlesByAmendedAt() { ); final DokumentExpressionEli amendedBy = null; final var amendedAt = "meta-1_lebzykl-1_ereignis-4"; - final var norm = NormFixtures.loadFromDisk("NormWithMultiplePassiveModifications.xml"); + final var norm = Fixtures.loadNormFromDisk("NormWithMultiplePassiveModifications.xml"); final var query = new LoadArticlesFromNormUseCase.Query(eli, amendedBy, amendedAt); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(norm)); @@ -171,7 +171,7 @@ void itFiltersArticlesByAmendedByAndAmendedAt() { "eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/regelungstext-1" ); final var amendedAt = "meta-1_lebzykl-1_ereignis-4"; - final var norm = NormFixtures.loadFromDisk("NormWithMultiplePassiveModifications.xml"); + final var norm = Fixtures.loadNormFromDisk("NormWithMultiplePassiveModifications.xml"); final var query = new LoadArticlesFromNormUseCase.Query(eli, amendedBy, amendedAt); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(norm)); @@ -205,7 +205,7 @@ void itReturnsEmptyListWhenTheNormHasNoArticles() { final var eli = DokumentExpressionEli.fromString( "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1" ); - final var norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + final var norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); final var query = new LoadArticlesFromNormUseCase.Query(eli); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(norm)); @@ -227,7 +227,7 @@ void itReturnsEmptyListWhenAmendedByIsNotFound() { "eli/bund/DOES-NOT-EXIST/2017/s419/2017-03-15/1/deu/regelungstext-1" ); final var amendedAt = "meta-1_lebzykl-1_ereignis-4"; - final var norm = NormFixtures.loadFromDisk("NormWithMultiplePassiveModifications.xml"); + final var norm = Fixtures.loadNormFromDisk("NormWithMultiplePassiveModifications.xml"); final var query = new LoadArticlesFromNormUseCase.Query(eli, amendedBy, amendedAt); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(norm)); @@ -249,7 +249,7 @@ void itReturnsEmptyListWhenAmendedAtIsNotFound() { "eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/regelungstext-1" ); final var amendedAt = "DOES-NOT-EXIST"; - final var norm = NormFixtures.loadFromDisk("NormWithMultiplePassiveModifications.xml"); + final var norm = Fixtures.loadNormFromDisk("NormWithMultiplePassiveModifications.xml"); final var query = new LoadArticlesFromNormUseCase.Query(eli, amendedBy, amendedAt); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(norm)); @@ -271,7 +271,7 @@ void itReturnsEmptyListWhenNormHasNoPassiveMods() { "eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/regelungstext-1" ); final var amendedAt = "meta-1_lebzykl-1_ereignis-4"; - final var norm = NormFixtures.loadFromDisk("NormWithMods.xml"); + final var norm = Fixtures.loadNormFromDisk("NormWithMods.xml"); final var query = new LoadArticlesFromNormUseCase.Query(eli, amendedBy, amendedAt); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(norm)); diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/BillToActServiceTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/BillToActServiceTest.java index 692fdd062..0b74adc88 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/BillToActServiceTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/BillToActServiceTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; -import de.bund.digitalservice.ris.norms.domain.entity.NormFixtures; +import de.bund.digitalservice.ris.norms.domain.entity.Fixtures; import de.bund.digitalservice.ris.norms.utils.XmlMapper; import org.junit.jupiter.api.Test; import org.xmlunit.builder.DiffBuilder; @@ -16,7 +16,7 @@ class BillToActServiceTest { @Test void itChangesNothing() { // given - final String xmlString = NormFixtures.loadTextFromDisk("NormWithMods.xml"); + final String xmlString = Fixtures.loadTextFromDisk("NormWithMods.xml"); // when String result = underTest.convert(XmlMapper.toDocument(xmlString)); @@ -32,10 +32,8 @@ void itChangesNothing() { @Test void convert() { // given - final String xmlString = NormFixtures.loadTextFromDisk("ReglungstextEntwurfsfassung.xml"); - final String expectedResult = NormFixtures.loadTextFromDisk( - "ReglungstextVerkuendungsfassung.xml" - ); + final String xmlString = Fixtures.loadTextFromDisk("ReglungstextEntwurfsfassung.xml"); + final String expectedResult = Fixtures.loadTextFromDisk("ReglungstextVerkuendungsfassung.xml"); // when String result = underTest.convert(XmlMapper.toDocument(xmlString)); diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/CreateNewVersionOfNormServiceTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/CreateNewVersionOfNormServiceTest.java index fa00861df..14e2ae2a8 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/CreateNewVersionOfNormServiceTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/CreateNewVersionOfNormServiceTest.java @@ -8,9 +8,9 @@ import de.bund.digitalservice.ris.norms.application.port.output.LoadNormByGuidPort; import de.bund.digitalservice.ris.norms.domain.entity.FRBRExpression; import de.bund.digitalservice.ris.norms.domain.entity.FRBRManifestation; -import de.bund.digitalservice.ris.norms.domain.entity.NormFixtures; import de.bund.digitalservice.ris.norms.domain.entity.eli.DokumentExpressionEli; import de.bund.digitalservice.ris.norms.domain.entity.eli.DokumentManifestationEli; +import de.bund.digitalservice.ris.norms.domain.entity.Fixtures; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.Optional; @@ -27,7 +27,7 @@ class CreateNewVersionOfNormServiceTest { @Test void createNewExpressionWithSameDate() { // Given - var norm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); var currentDate = LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE); when(eliService.findNextExpressionEli(any(), any(), any())) @@ -37,7 +37,7 @@ void createNewExpressionWithSameDate() { ) ); when(loadNormByGuidPort.loadNormByGuid(any())) - .thenReturn(Optional.of(NormFixtures.loadFromDisk("Vereinsgesetz_2017_s419_2017-03-15.xml"))); + .thenReturn(Optional.of(Fixtures.loadNormFromDisk("Vereinsgesetz_2017_s419_2017-03-15.xml"))); // When var result = createNewVersionOfNormService.createNewExpression( @@ -99,7 +99,7 @@ void createNewExpressionWithDifferentDate() { "eli/bund/bgbl-1/1964/s593/2024-01-01/1/deu/regelungstext-1" ) ); - var norm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); var currentDate = LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE); // When @@ -156,7 +156,7 @@ void createNewExpressionWithDifferentDate() { @Test void createNewManifestation() { // Given - var norm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); // When var result = createNewVersionOfNormService.createNewManifestation( diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/CreateZf0ServiceTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/CreateZf0ServiceTest.java index 25e463ebe..3d0c54546 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/CreateZf0ServiceTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/CreateZf0ServiceTest.java @@ -25,9 +25,9 @@ class CreateZf0ServiceTest { @Test void itSuccessfullyCreatesZf0OutOfTargetLaw() { // Given - final Norm amendingLaw = NormFixtures.loadFromDisk("NormWithMods.xml"); - final Norm targetLaw = NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml"); - final Norm targetLawNewManifestation = NormFixtures.loadFromDisk( + final Norm amendingLaw = Fixtures.loadNormFromDisk("NormWithMods.xml"); + final Norm targetLaw = Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml"); + final Norm targetLawNewManifestation = Fixtures.loadNormFromDisk( "NormWithoutPassiveModificationsNoNextVersion.xml" ); @@ -82,11 +82,11 @@ void itSuccessfullyCreatesZf0OutOfTargetLaw() { @Test void itSuccessfullyCreatesZf0OutOfQuotedStructureWithUpToMods() { // Given - final Norm amendingLaw = NormFixtures.loadFromDisk("NormWithQuotedStructureModsAndUpTo.xml"); - final Norm targetLaw = NormFixtures.loadFromDisk( + final Norm amendingLaw = Fixtures.loadNormFromDisk("NormWithQuotedStructureModsAndUpTo.xml"); + final Norm targetLaw = Fixtures.loadNormFromDisk( "NormWithoutPassiveModsQuotedStructureAndUpTo.xml" ); - final Norm targetLawNewManifestation = NormFixtures.loadFromDisk( + final Norm targetLawNewManifestation = Fixtures.loadNormFromDisk( "NormWithoutPassiveModsQuotedStructureAndUpTo.xml" ); diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/ElementServiceTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/ElementServiceTest.java index c940c8aaa..18dea95fb 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/ElementServiceTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/ElementServiceTest.java @@ -9,8 +9,8 @@ import de.bund.digitalservice.ris.norms.application.exception.NormNotFoundException; import de.bund.digitalservice.ris.norms.application.port.input.*; import de.bund.digitalservice.ris.norms.application.port.output.LoadNormPort; +import de.bund.digitalservice.ris.norms.domain.entity.Fixtures; import de.bund.digitalservice.ris.norms.domain.entity.Norm; -import de.bund.digitalservice.ris.norms.domain.entity.NormFixtures; import de.bund.digitalservice.ris.norms.domain.entity.Regelungstext; import de.bund.digitalservice.ris.norms.domain.entity.eli.DokumentExpressionEli; import de.bund.digitalservice.ris.norms.utils.NodeParser; @@ -413,7 +413,7 @@ class loadElementsByTypeFromNorm { @Test void returnsAllSupportedTypesFromANorm() { // Given - var norm = NormFixtures.loadFromDisk("NormWithPrefacePreambleAndConclusions.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithPrefacePreambleAndConclusions.xml"); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(norm)); // When @@ -438,7 +438,7 @@ void returnsAllSupportedTypesFromANorm() { @Test void returnsASubsetOfTypesFromANorm() { // Given - var norm = NormFixtures.loadFromDisk("NormWithPrefacePreambleAndConclusions.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithPrefacePreambleAndConclusions.xml"); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(norm)); // When @@ -455,7 +455,7 @@ void returnsASubsetOfTypesFromANorm() { @Test void returnsEmptyListIfTypeIsNotInNorm() { // Given - var norm = NormFixtures.loadFromDisk("NormWithMultipleMods.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithMultipleMods.xml"); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(norm)); // When @@ -470,7 +470,7 @@ void returnsEmptyListIfTypeIsNotInNorm() { @Test void returnsEmptyListIfTypesAreEmpty() { // Given - var norm = NormFixtures.loadFromDisk("NormWithMultipleMods.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithMultipleMods.xml"); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(norm)); // When @@ -485,7 +485,7 @@ void returnsEmptyListIfTypesAreEmpty() { @Test void throwsWhenAttemptingToLoadUnsupportedType() { // Given - var norm = NormFixtures.loadFromDisk("NormWithMultipleMods.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithMultipleMods.xml"); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(norm)); // When / Then @@ -522,7 +522,7 @@ void throwsWhenNormDoesNotExist() { @Test void filtersReturnedElementsByAmendingNorm() { // Given - var targetNorm = NormFixtures.loadFromDisk( + var targetNorm = Fixtures.loadNormFromDisk( "NormWithPassiveModificationsInDifferentArticles.xml" ); var targetNormEli = targetNorm.getExpressionEli(); @@ -548,7 +548,7 @@ void filtersReturnedElementsByAmendingNorm() { @Test void returnsEmptyListIfNoElementIsAffectedByTheAmendingNorm() { // Given - var targetNorm = NormFixtures.loadFromDisk("NormWithMultiplePassiveModifications.xml"); + var targetNorm = Fixtures.loadNormFromDisk("NormWithMultiplePassiveModifications.xml"); var targetNormEli = targetNorm.getExpressionEli(); when( loadNormPort.loadNorm( diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/EliServiceTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/EliServiceTest.java index 66b66a33c..50509e2ee 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/EliServiceTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/EliServiceTest.java @@ -7,8 +7,8 @@ import de.bund.digitalservice.ris.norms.application.exception.NormNotFoundException; import de.bund.digitalservice.ris.norms.application.port.input.LoadNormUseCase; -import de.bund.digitalservice.ris.norms.domain.entity.NormFixtures; import de.bund.digitalservice.ris.norms.domain.entity.eli.DokumentWorkEli; +import de.bund.digitalservice.ris.norms.domain.entity.Fixtures; import java.time.LocalDate; import org.junit.jupiter.api.Test; @@ -33,7 +33,7 @@ void findNextExpressionEli() { @Test void findNextExpressionEliVersion1AlreadyInUse() { when(loadNormUseCase.loadNorm(any())) - .thenReturn(NormFixtures.loadFromDisk("SimpleNorm.xml")) + .thenReturn(Fixtures.loadNormFromDisk("SimpleNorm.xml")) .thenThrow(new NormNotFoundException("")); var eli = eliService.findNextExpressionEli( diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/LdmlDeValidatorTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/LdmlDeValidatorTest.java index 19404eeb2..97d17f9cd 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/LdmlDeValidatorTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/LdmlDeValidatorTest.java @@ -4,8 +4,8 @@ import de.bund.digitalservice.ris.norms.application.exception.LdmlDeNotValidException; import de.bund.digitalservice.ris.norms.application.exception.LdmlDeSchematronException; +import de.bund.digitalservice.ris.norms.domain.entity.Fixtures; import de.bund.digitalservice.ris.norms.domain.entity.Norm; -import de.bund.digitalservice.ris.norms.domain.entity.NormFixtures; import de.bund.digitalservice.ris.norms.utils.NodeParser; import java.net.URI; import java.util.Objects; @@ -36,7 +36,7 @@ class parseAndValidate { @Test void itShouldParseAValidNorm() { // Given - String xml = NormFixtures.loadTextFromDisk("NormWithMods.xml"); + String xml = Fixtures.loadTextFromDisk("NormWithMods.xml"); // When Norm norm = ldmlDeValidator.parseAndValidate(xml); @@ -55,7 +55,7 @@ void itShouldParseAValidNorm() { @Test void itShouldThrowForInvalidNorms() { // Given - String xml = NormFixtures.loadTextFromDisk("NormWithModsXsdInvalid.xml"); + String xml = Fixtures.loadTextFromDisk("NormWithModsXsdInvalid.xml"); // When // Then assertThatThrownBy(() -> ldmlDeValidator.parseAndValidate(xml)) @@ -91,7 +91,7 @@ class validateSchematron { @Test void itShouldSuccessfullyValidateNorm() { // Given - Norm norm = NormFixtures.loadFromDisk("NormWithMods.xml", true); + Norm norm = Fixtures.loadNormFromDisk("NormWithMods.xml", true); // When // Then assertThatCode(() -> ldmlDeValidator.validateSchematron(norm)).doesNotThrowAnyException(); @@ -100,7 +100,7 @@ void itShouldSuccessfullyValidateNorm() { @Test void itShouldValidateAInvalidNormWithError() { // Given - Norm norm = NormFixtures.loadFromDisk("NormWithModsSchematronInvalid.xml", true); + Norm norm = Fixtures.loadNormFromDisk("NormWithModsSchematronInvalid.xml", true); // When // Then assertThatThrownBy(() -> ldmlDeValidator.validateSchematron(norm)) @@ -149,7 +149,7 @@ void itShouldValidateAInvalidNormWithError() { @Test void itShouldSuccessfullyValidateANormWithWarnings() { // Given - Norm norm = NormFixtures.loadFromDisk("NormWithModsSchematronWarning.xml", true); + Norm norm = Fixtures.loadNormFromDisk("NormWithModsSchematronWarning.xml", true); // When // Then assertThatCode(() -> ldmlDeValidator.validateSchematron(norm)).doesNotThrowAnyException(); diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/NormServiceTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/NormServiceTest.java index 04d817146..f384d0d7b 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/NormServiceTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/NormServiceTest.java @@ -33,12 +33,11 @@ class NormServiceTest { final TimeMachineService timeMachineService = mock(TimeMachineService.class); final NormService service = new NormService( - loadNormPort, - updateNormPort, - singleModValidator, - updateNormService, - timeMachineService - ); + loadNormPort, + updateNormPort, + singleModValidator, + updateNormService, + timeMachineService); @Nested class loadNorm { @@ -47,37 +46,32 @@ class loadNorm { void itCallsLoadNormAndReturnsNorm() { // Given var eli = DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1" - ); + "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1"); var norm = Norm - .builder() - .regelungstexte( - Set.of( - new Regelungstext( - XmlMapper.toDocument( - """ - - - - - - - - - - - - - - """ - ) - ) - ) - ) - .build(); + .builder() + .regelungstexte( + Set.of( + new Regelungstext( + XmlMapper.toDocument( + """ + + + + + + + + + + + + + + """)))) + .build(); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(norm)); // When @@ -85,7 +79,7 @@ void itCallsLoadNormAndReturnsNorm() { // Then verify(loadNormPort, times(1)) - .loadNorm(argThat(argument -> Objects.equals(argument.eli(), eli))); + .loadNorm(argThat(argument -> Objects.equals(argument.eli(), eli))); assertThat(returnedNorm).isEqualTo(norm); } @@ -93,18 +87,17 @@ void itCallsLoadNormAndReturnsNorm() { void itThrowsWhenNormIsNotFound() { // Given var eli = DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1" - ); + "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1"); var query = new LoadNormUseCase.Query(eli); when(loadNormPort.loadNorm(any())).thenReturn(Optional.empty()); // When assertThatThrownBy(() -> service.loadNorm(query)) - // Then - .isInstanceOf(NormNotFoundException.class); + // Then + .isInstanceOf(NormNotFoundException.class); verify(loadNormPort, times(1)) - .loadNorm(argThat(argument -> Objects.equals(argument.eli(), eli))); + .loadNorm(argThat(argument -> Objects.equals(argument.eli(), eli))); } } @@ -115,37 +108,32 @@ class loadNormXml { void itCallsLoadNormAndReturnsXml() { // Given var eli = DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1" - ); + "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1"); var norm = Norm - .builder() - .regelungstexte( - Set.of( - new Regelungstext( - XmlMapper.toDocument( - """ - - - - - - - - - - - - - - """ - ) - ) - ) - ) - .build(); + .builder() + .regelungstexte( + Set.of( + new Regelungstext( + XmlMapper.toDocument( + """ + + + + + + + + + + + + + + """)))) + .build(); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(norm)); // When @@ -153,7 +141,7 @@ void itCallsLoadNormAndReturnsXml() { // Then verify(loadNormPort, times(1)) - .loadNorm(argThat(argument -> Objects.equals(argument.eli(), eli))); + .loadNorm(argThat(argument -> Objects.equals(argument.eli(), eli))); assertThat(xml).contains("eId=\"meta-1_ident-1_frbrexpression-1_frbrthis-1\""); } @@ -161,15 +149,14 @@ void itCallsLoadNormAndReturnsXml() { void itCallsLoadNormAndThrowsNotFound() { // Given var eli = DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1" - ); + "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1"); when(loadNormPort.loadNorm(any())).thenReturn(Optional.empty()); var query = new LoadNormXmlUseCase.Query(eli); // When assertThatThrownBy(() -> service.loadNormXml(query)) - // then - .isInstanceOf(NormNotFoundException.class); + // then + .isInstanceOf(NormNotFoundException.class); } } @@ -180,85 +167,82 @@ class updateNormXml { void itUpdatesXml() throws InvalidUpdateException { // Given var eli = DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1" - ); - - var oldXml = - """ - - - - - - - - - - - - - - - - - - Referentenentwurf - des Bundesministeriums des - Innern - Entwurf eines Zweiten Gesetzes zur Änderung des Vereinsgesetzes - - - - Vom 01.01.1900 - - - - - """; - var newXml = - """ - - - - - - - - - - - - - - - - - - Referentenentwurf - des Bundesministeriums des - Innern - Entwurf eines Dritten Gesetzes zur Änderung des Vereinsgesetzes - - - - Vom 01.01.1900 - - - - - """; + "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1"); + + var oldXml = """ + + + + + + + + + + + + + + + + + + Referentenentwurf + des Bundesministeriums des + Innern + Entwurf eines Zweiten Gesetzes zur Änderung des Vereinsgesetzes + + + + Vom 01.01.1900 + + + + + """; + var newXml = """ + + + + + + + + + + + + + + + + + + Referentenentwurf + des Bundesministeriums des + Innern + Entwurf eines Dritten Gesetzes zur Änderung des Vereinsgesetzes + + + + Vom 01.01.1900 + + + + + """; var oldNorm = Norm - .builder() - .regelungstexte(Set.of(new Regelungstext(XmlMapper.toDocument(oldXml)))) - .build(); + .builder() + .regelungstexte(Set.of(new Regelungstext(XmlMapper.toDocument(oldXml)))) + .build(); var newNorm = Norm - .builder() - .regelungstexte(Set.of(new Regelungstext(XmlMapper.toDocument(newXml)))) - .build(); + .builder() + .regelungstexte(Set.of(new Regelungstext(XmlMapper.toDocument(newXml)))) + .build(); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(oldNorm)); when(updateNormPort.updateNorm(any())).thenReturn(Optional.of(newNorm)); @@ -268,65 +252,63 @@ void itUpdatesXml() throws InvalidUpdateException { // Then verify(loadNormPort, times(1)) - .loadNorm(argThat(argument -> Objects.equals(argument.eli(), eli))); + .loadNorm(argThat(argument -> Objects.equals(argument.eli(), eli))); verify(updateNormPort, times(1)) - .updateNorm(argThat(argument -> argument.norm().equals(newNorm))); + .updateNorm(argThat(argument -> argument.norm().equals(newNorm))); assertThat(result) - .contains("Entwurf eines Dritten Gesetzes zur Änderung des Vereinsgesetzes"); + .contains("Entwurf eines Dritten Gesetzes zur Änderung des Vereinsgesetzes"); } @Test void itThrowsNormNotFoundIfNormDoesNotExist() throws InvalidUpdateException { // Given var eli = DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1" - ); - - var newXml = - """ - - - - - - - - - - - - - - - - - - Referentenentwurf - des Bundesministeriums des - Innern - Entwurf eines Dritten Gesetzes zur Änderung des Vereinsgesetzes - - - - Vom 01.01.1900 - - - - - """; + "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1"); + + var newXml = """ + + + + + + + + + + + + + + + + + + Referentenentwurf + des Bundesministeriums des + Innern + Entwurf eines Dritten Gesetzes zur Änderung des Vereinsgesetzes + + + + Vom 01.01.1900 + + + + + """; when(loadNormPort.loadNorm(any())).thenReturn(Optional.empty()); var query = new UpdateNormXmlUseCase.Query(eli, newXml); // When assertThatThrownBy(() -> service.updateNormXml(query)) - // then - .isInstanceOf(NormNotFoundException.class); + // then + .isInstanceOf(NormNotFoundException.class); verify(loadNormPort, times(1)) - .loadNorm(argThat(argument -> Objects.equals(argument.eli(), eli))); + .loadNorm(argThat(argument -> Objects.equals(argument.eli(), eli))); verify(updateNormPort, times(0)).updateNorm(any()); } @@ -334,92 +316,87 @@ void itThrowsNormNotFoundIfNormDoesNotExist() throws InvalidUpdateException { void itThrowsIfEliChanges() { // Given var eli = DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1" - ); - - var oldXml = - """ - - - - - - - - - - - - - - - - - - Referentenentwurf - des Bundesministeriums des - Innern - Entwurf eines Zweiten Gesetzes zur Änderung des Vereinsgesetzes - - - - Vom 01.01.1900 - - - - - """; - var newXml = - """ - - - - - - - - - - - - - - - - - - Referentenentwurf - des Bundesministeriums des - Innern - Entwurf eines Dritten Gesetzes zur Änderung des Vereinsgesetzes - - - - Vom 01.01.1900 - - - - - """; + "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1"); + + var oldXml = """ + + + + + + + + + + + + + + + + + + Referentenentwurf + des Bundesministeriums des + Innern + Entwurf eines Zweiten Gesetzes zur Änderung des Vereinsgesetzes + + + + Vom 01.01.1900 + + + + + """; + var newXml = """ + + + + + + + + + + + + + + + + + + Referentenentwurf + des Bundesministeriums des + Innern + Entwurf eines Dritten Gesetzes zur Änderung des Vereinsgesetzes + + + + Vom 01.01.1900 + + + + + """; var oldNorm = Norm - .builder() - .regelungstexte(Set.of(new Regelungstext(XmlMapper.toDocument(oldXml)))) - .build(); + .builder() + .regelungstexte(Set.of(new Regelungstext(XmlMapper.toDocument(oldXml)))) + .build(); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(oldNorm)); // When - var thrown = catchThrowable(() -> - service.updateNormXml(new UpdateNormXmlUseCase.Query(eli, newXml)) - ); + var thrown = catchThrowable(() -> service.updateNormXml(new UpdateNormXmlUseCase.Query(eli, newXml))); // Then verify(loadNormPort, times(1)) - .loadNorm(argThat(argument -> Objects.equals(argument.eli(), eli))); + .loadNorm(argThat(argument -> Objects.equals(argument.eli(), eli))); verify(updateNormPort, times(0)).updateNorm(any()); assertThat(thrown).isInstanceOf(InvalidUpdateException.class); } @@ -428,92 +405,87 @@ void itThrowsIfEliChanges() { void itThrowsIfGuidChanges() { // Given var eli = DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1" - ); - - var oldXml = - """ - - - - - - - - - - - - - - - - - - Referentenentwurf - des Bundesministeriums des - Innern - Entwurf eines Zweiten Gesetzes zur Änderung des Vereinsgesetzes - - - - Vom 01.01.1900 - - - - - """; - var newXml = - """ - - - - - - - - - - - - - - - - - - Referentenentwurf - des Bundesministeriums des - Innern - Entwurf eines Dritten Gesetzes zur Änderung des Vereinsgesetzes - - - - Vom 01.01.1900 - - - - - """; + "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1"); + + var oldXml = """ + + + + + + + + + + + + + + + + + + Referentenentwurf + des Bundesministeriums des + Innern + Entwurf eines Zweiten Gesetzes zur Änderung des Vereinsgesetzes + + + + Vom 01.01.1900 + + + + + """; + var newXml = """ + + + + + + + + + + + + + + + + + + Referentenentwurf + des Bundesministeriums des + Innern + Entwurf eines Dritten Gesetzes zur Änderung des Vereinsgesetzes + + + + Vom 01.01.1900 + + + + + """; var oldNorm = Norm - .builder() - .regelungstexte(Set.of(new Regelungstext(XmlMapper.toDocument(oldXml)))) - .build(); + .builder() + .regelungstexte(Set.of(new Regelungstext(XmlMapper.toDocument(oldXml)))) + .build(); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(oldNorm)); // When - var thrown = catchThrowable(() -> - service.updateNormXml(new UpdateNormXmlUseCase.Query(eli, newXml)) - ); + var thrown = catchThrowable(() -> service.updateNormXml(new UpdateNormXmlUseCase.Query(eli, newXml))); // Then verify(loadNormPort, times(1)) - .loadNorm(argThat(argument -> Objects.equals(argument.eli(), eli))); + .loadNorm(argThat(argument -> Objects.equals(argument.eli(), eli))); verify(updateNormPort, times(0)).updateNorm(any()); assertThat(thrown).isInstanceOf(InvalidUpdateException.class); } @@ -525,124 +497,111 @@ class updateNorm { @Test void itSavesANorm() { // given - Norm amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); - Norm targetNorm = NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml"); + Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); + Norm targetNorm = Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml"); DokumentExpressionEli zf0EliTargetNorm = DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1" - ); + "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1"); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(targetNorm)); when(updateNormPort.updateNorm(new UpdateNormPort.Command(amendingNorm))) - .thenReturn(Optional.of(amendingNorm)); + .thenReturn(Optional.of(amendingNorm)); when(updateNormPort.updateNorm(new UpdateNormPort.Command(targetNorm))) - .thenReturn(Optional.of(targetNorm)); + .thenReturn(Optional.of(targetNorm)); when( - updateNormService.updateOnePassiveModification( - new UpdatePassiveModificationsUseCase.Query(targetNorm, amendingNorm, zf0EliTargetNorm) - ) - ) - .thenReturn(targetNorm); + updateNormService.updateOnePassiveModification( + new UpdatePassiveModificationsUseCase.Query(targetNorm, amendingNorm, zf0EliTargetNorm))) + .thenReturn(targetNorm); // when service.updateNorm(amendingNorm); // then verify(loadNormPort, times(1)) - .loadNorm(argThat(argument -> Objects.equals(argument.eli(), zf0EliTargetNorm))); + .loadNorm(argThat(argument -> Objects.equals(argument.eli(), zf0EliTargetNorm))); verify(updateNormPort, times(1)) - .updateNorm( - argThat(argument -> Objects.equals(argument, new UpdateNormPort.Command(amendingNorm))) - ); + .updateNorm( + argThat(argument -> Objects.equals(argument, new UpdateNormPort.Command(amendingNorm)))); verify(updateNormPort, times(1)) - .updateNorm( - argThat(argument -> Objects.equals(argument, new UpdateNormPort.Command(targetNorm))) - ); + .updateNorm( + argThat(argument -> Objects.equals(argument, new UpdateNormPort.Command(targetNorm)))); verify(updateNormService, times(1)) - .updateOnePassiveModification( - argThat(argument -> - Objects.equals(argument.zf0Norm(), targetNorm) && - Objects.equals(argument.amendingNorm(), amendingNorm) && - Objects.equals(argument.targetNormEli(), zf0EliTargetNorm) - ) - ); + .updateOnePassiveModification( + argThat(argument -> Objects.equals(argument.zf0Norm(), targetNorm) && + Objects.equals(argument.amendingNorm(), amendingNorm) && + Objects.equals(argument.targetNormEli(), zf0EliTargetNorm))); } @Test void itThrowsAnExceptionIfNormIsNotFound() { // given - String text = - """ - - - - - - - - - - - - - - - - - - - - - - - """; + String text = """ + + + + + + + + + + + + + + + + + + + + + + + """; Norm amendingNorm = Norm - .builder() - .regelungstexte(Set.of(new Regelungstext(XmlMapper.toDocument(text)))) - .build(); + .builder() + .regelungstexte(Set.of(new Regelungstext(XmlMapper.toDocument(text)))) + .build(); amendingNorm.getMeta().getAnalysis().get().getActiveModifications(); - Norm targetNorm = NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml"); + Norm targetNorm = Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml"); DokumentExpressionEli zf0EliTargetNorm = DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1" - ); + "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1"); DokumentExpressionEli zf0EliNonExistent = DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/2000/s111/2000-08-05/1/deu/regelungstext-1" - ); + "eli/bund/bgbl-1/2000/s111/2000-08-05/1/deu/regelungstext-1"); when(loadNormPort.loadNorm(new LoadNormPort.Command(zf0EliTargetNorm))) - .thenReturn(Optional.of(targetNorm)); + .thenReturn(Optional.of(targetNorm)); when(loadNormPort.loadNorm(new LoadNormPort.Command(zf0EliNonExistent))) - .thenReturn(Optional.empty()); + .thenReturn(Optional.empty()); when(updateNormPort.updateNorm(new UpdateNormPort.Command(amendingNorm))) - .thenReturn(Optional.of(amendingNorm)); + .thenReturn(Optional.of(amendingNorm)); when(updateNormPort.updateNorm(new UpdateNormPort.Command(targetNorm))) - .thenReturn(Optional.of(targetNorm)); + .thenReturn(Optional.of(targetNorm)); when( - updateNormService.updateOnePassiveModification( - new UpdatePassiveModificationsUseCase.Query(targetNorm, amendingNorm, zf0EliTargetNorm) - ) - ) - .thenReturn(targetNorm); + updateNormService.updateOnePassiveModification( + new UpdatePassiveModificationsUseCase.Query(targetNorm, amendingNorm, zf0EliTargetNorm))) + .thenReturn(targetNorm); // when Throwable thrown = catchThrowable(() -> { @@ -651,23 +610,18 @@ void itThrowsAnExceptionIfNormIsNotFound() { // then verify(loadNormPort, times(1)) - .loadNorm(argThat(argument -> Objects.equals(argument.eli(), zf0EliNonExistent))); + .loadNorm(argThat(argument -> Objects.equals(argument.eli(), zf0EliNonExistent))); verify(updateNormPort, never()) - .updateNorm( - argThat(argument -> Objects.equals(argument, new UpdateNormPort.Command(amendingNorm))) - ); + .updateNorm( + argThat(argument -> Objects.equals(argument, new UpdateNormPort.Command(amendingNorm)))); verify(updateNormPort, never()) - .updateNorm( - argThat(argument -> Objects.equals(argument, new UpdateNormPort.Command(targetNorm))) - ); + .updateNorm( + argThat(argument -> Objects.equals(argument, new UpdateNormPort.Command(targetNorm)))); verify(updateNormService, never()) - .updateOnePassiveModification( - argThat(argument -> - Objects.equals(argument.zf0Norm(), targetNorm) && - Objects.equals(argument.amendingNorm(), amendingNorm) && - Objects.equals(argument.targetNormEli(), zf0EliTargetNorm) - ) - ); + .updateOnePassiveModification( + argThat(argument -> Objects.equals(argument.zf0Norm(), targetNorm) && + Objects.equals(argument.amendingNorm(), amendingNorm) && + Objects.equals(argument.targetNormEli(), zf0EliTargetNorm))); assertThat(thrown).isInstanceOf(NormNotFoundException.class); } } @@ -679,29 +633,24 @@ class UpdateMod { void itCallsLoadNormAndThrowsNormNotFoundBecauseEliNotFound() { // Given var eli = DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1" - ); + "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1"); when(loadNormPort.loadNorm(any())).thenReturn(Optional.empty()); // when/than - var throwable = AssertionsForClassTypes.catchThrowable(() -> - service.updateMod( + var throwable = AssertionsForClassTypes.catchThrowable(() -> service.updateMod( new UpdateModUseCase.Query( - eli, - "eid", - "refersTo", - "time-boundary-eid", - new Href("destinanation-href"), - null, - "new text" - ) - ) - ); + eli, + "eid", + "refersTo", + "time-boundary-eid", + new Href("destinanation-href"), + null, + "new text"))); assertThat(throwable).isInstanceOf(NormNotFoundException.class); verify(loadNormPort, times(1)) - .loadNorm(argThat(argument -> Objects.equals(argument.eli(), eli))); + .loadNorm(argThat(argument -> Objects.equals(argument.eli(), eli))); verify(updateNormPort, times(0)).updateNorm(any()); } @@ -709,137 +658,125 @@ void itCallsLoadNormAndThrowsNormNotFoundBecauseEliNotFound() { void itThrowsValidationExceptionBecauseInputDestinationHrefWithoutEli() { // Given var eli = DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1" - ); - final Norm amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); + "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1"); + final Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(amendingNorm)); // when/than final UpdateModUseCase.Query query = new UpdateModUseCase.Query( - eli, - "eid", - "refersTo", - "time-boundary-eid", - new Href("#destinanation-href"), - null, - "new text" - ); + eli, + "eid", + "refersTo", + "time-boundary-eid", + new Href("#destinanation-href"), + null, + "new text"); assertThatThrownBy(() -> service.updateMod(query)) - .isInstanceOf(ValidationException.class) - .hasMessageContaining( - "The destinationHref with value #destinanation-href does not contain a eli" - ); + .isInstanceOf(ValidationException.class) + .hasMessageContaining( + "The destinationHref with value #destinanation-href does not contain a eli"); } @Test void itThrowsValidationExceptionBecauseMetaModNotFound() { // Given var eli = DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1" - ); - final Norm amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); - final Norm targetNorm = NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml"); - final Norm zf0Norm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1"); + final Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); + final Norm targetNorm = Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml"); + final Norm zf0Norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); when(loadNormPort.loadNorm(any())) - .thenReturn(Optional.of(amendingNorm)) - .thenReturn(Optional.of(targetNorm)); + .thenReturn(Optional.of(amendingNorm)) + .thenReturn(Optional.of(targetNorm)); when(updateNormService.updateOneActiveModification(any())).thenReturn(amendingNorm); when(updateNormService.updateOnePassiveModification(any())).thenReturn(zf0Norm); // when/than final UpdateModUseCase.Query query = new UpdateModUseCase.Query( - eli, - "eid", - "refersTo", - "time-boundary-eid", - new Href("eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1"), - null, - "new text" - ); + eli, + "eid", + "refersTo", + "time-boundary-eid", + new Href("eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1"), + null, + "new text"); assertThatThrownBy(() -> service.updateMod(query)) - .isInstanceOf(ValidationException.class) - .hasMessageContaining( - "Did not find a textual mod with eId eid in the norm eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/regelungstext-1" - ); + .isInstanceOf(ValidationException.class) + .hasMessageContaining( + "Did not find a textual mod with eId eid in the norm eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/regelungstext-1"); } @Test void itCallsTimeMachineBeforeValidator() { // Given - Norm amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); + Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); DokumentExpressionEli amendingNormEli = amendingNorm.getExpressionEli(); - Norm zf0Norm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + Norm zf0Norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); String newCharacterRange = "20-25"; String newTimeBoundaryEid = "#time-boundary-eid"; Href newDestinationHref = new Href.Builder() - .setEli(zf0Norm.getExpressionEli()) - .setEId("hauptteil-1_art-20_abs-1_untergl-1_listenelem-2_inhalt-1_text-1") - .setCharacterRange(new CharacterRange(newCharacterRange)) - .setFileExtension("xml") - .buildAbsolute(); + .setEli(zf0Norm.getExpressionEli()) + .setEId("hauptteil-1_art-20_abs-1_untergl-1_listenelem-2_inhalt-1_text-1") + .setCharacterRange(new CharacterRange(newCharacterRange)) + .setFileExtension("xml") + .buildAbsolute(); String newContent = "new text"; when(loadNormPort.loadNorm(any())) - .thenReturn(Optional.of(amendingNorm)) - .thenReturn(Optional.of(zf0Norm)); + .thenReturn(Optional.of(amendingNorm)) + .thenReturn(Optional.of(zf0Norm)); when(updateNormService.updateOneActiveModification(any())).thenReturn(amendingNorm); when(updateNormService.updateOnePassiveModification(any())).thenReturn(zf0Norm); when(updateNormPort.updateNorm(any())).thenReturn(Optional.of(amendingNorm)); // When service.updateMod( - new UpdateModUseCase.Query( - amendingNormEli, - "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1", // <- - // this - // matters now - "refersTo", - newTimeBoundaryEid, // <- this will be set - newDestinationHref, // <- this will be set in ActivMods AND mod - null, - newContent, - false - ) - ); + new UpdateModUseCase.Query( + amendingNormEli, + "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1", // <- + // this + // matters now + "refersTo", + newTimeBoundaryEid, // <- this will be set + newDestinationHref, // <- this will be set in ActivMods AND mod + null, + newContent, + false)); // Then verify(timeMachineService, times(1)) - .applyPassiveModifications( - argThat(argument -> - Objects.equals(argument.norm(), zf0Norm) && Objects.equals(argument.date(), Instant.MIN) - ) - ); + .applyPassiveModifications( + argThat(argument -> Objects.equals(argument.norm(), zf0Norm) + && Objects.equals(argument.date(), Instant.MIN))); } @Test void itCallsTheValidator() { // Given - Norm amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); + Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); DokumentExpressionEli amendingNormEli = amendingNorm.getExpressionEli(); Mod mod = amendingNorm - .getMods() - .stream() - .filter(m -> - m - .getEid() - .equals("hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1") - ) - .findFirst() - .orElseThrow(); - Norm targetNorm = NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml"); + .getMods() + .stream() + .filter(m -> m + .getEid() + .equals("hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1")) + .findFirst() + .orElseThrow(); + Norm targetNorm = Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml"); DokumentExpressionEli targetNormEli = targetNorm.getExpressionEli(); - Norm zf0Norm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + Norm zf0Norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); String newCharacterRange = "20-25"; String newTimeBoundaryEid = "#time-boundary-eid"; Href newDestinationHref = new Href.Builder() - .setEli(targetNormEli) - .setEId("hauptteil-1_art-20_abs-1_untergl-1_listenelem-2_inhalt-1_text-1") - .setCharacterRange(new CharacterRange(newCharacterRange)) - .setFileExtension("xml") - .buildAbsolute(); + .setEli(targetNormEli) + .setEId("hauptteil-1_art-20_abs-1_untergl-1_listenelem-2_inhalt-1_text-1") + .setCharacterRange(new CharacterRange(newCharacterRange)) + .setFileExtension("xml") + .buildAbsolute(); String newContent = "new text"; when(loadNormPort.loadNorm(any())) - .thenReturn(Optional.of(amendingNorm)) - .thenReturn(Optional.of(targetNorm)); + .thenReturn(Optional.of(amendingNorm)) + .thenReturn(Optional.of(targetNorm)); when(updateNormService.updateOneActiveModification(any())).thenReturn(amendingNorm); when(updateNormService.updateOnePassiveModification(any())).thenReturn(zf0Norm); when(updateNormPort.updateNorm(any())).thenReturn(Optional.of(amendingNorm)); @@ -847,100 +784,90 @@ void itCallsTheValidator() { // When service.updateMod( - new UpdateModUseCase.Query( - amendingNormEli, - "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1", // <- - // this - // matters now - "refersTo", - newTimeBoundaryEid, // <- this will be set - newDestinationHref, // <- this will be set in ActivMods AND mod - null, - newContent, - false - ) - ); + new UpdateModUseCase.Query( + amendingNormEli, + "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1", // <- + // this + // matters now + "refersTo", + newTimeBoundaryEid, // <- this will be set + newDestinationHref, // <- this will be set in ActivMods AND mod + null, + newContent, + false)); // Then verify(singleModValidator, times(1)) - .validate(argThat(zf0NormArg -> zf0NormArg.equals(zf0Norm)), argThat(m -> m.equals(mod))); + .validate(argThat(zf0NormArg -> zf0NormArg.equals(zf0Norm)), argThat(m -> m.equals(mod))); } @Test void itCallsAllUpdateServices() { // Given - Norm amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); + Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); DokumentExpressionEli amendingNormEli = amendingNorm.getExpressionEli(); - Norm zf0Norm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + Norm zf0Norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); String eId = "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1"; String newCharacterRange = "9-34"; String newTimeBoundaryEid = "#time-boundary-eid"; Href newDestinationHref = new Href.Builder() - .setEli(zf0Norm.getExpressionEli()) - .setEId("hauptteil-1_art-1_abs-1_untergl-1_listenelem-2_inhalt-1_text-1") - .setCharacterRange(new CharacterRange(newCharacterRange)) - .setFileExtension("xml") - .buildAbsolute(); + .setEli(zf0Norm.getExpressionEli()) + .setEId("hauptteil-1_art-1_abs-1_untergl-1_listenelem-2_inhalt-1_text-1") + .setCharacterRange(new CharacterRange(newCharacterRange)) + .setFileExtension("xml") + .buildAbsolute(); String newContent = "§ 9 Absatz 1 Satz 2, Absatz 2 oder 3"; when(loadNormPort.loadNorm(any())) - .thenReturn(Optional.of(amendingNorm)) - .thenReturn(Optional.of(zf0Norm)); + .thenReturn(Optional.of(amendingNorm)) + .thenReturn(Optional.of(zf0Norm)); when(updateNormService.updateOneActiveModification(any())).thenReturn(amendingNorm); when(updateNormService.updateOnePassiveModification(any())).thenReturn(zf0Norm); when(updateNormPort.updateNorm(any())).thenReturn(Optional.of(amendingNorm)); // When var returnedXml = service.updateMod( - new UpdateModUseCase.Query( - amendingNormEli, - eId, - "refersTo", - newTimeBoundaryEid, // <- this will be set - newDestinationHref, // <- this will be set in ActivMods AND mod - null, - newContent, - false - ) - ); + new UpdateModUseCase.Query( + amendingNormEli, + eId, + "refersTo", + newTimeBoundaryEid, // <- this will be set + newDestinationHref, // <- this will be set in ActivMods AND mod + null, + newContent, + false)); // Then verify(loadNormPort, times(1)) - .loadNorm(argThat(argument -> Objects.equals(argument.eli(), amendingNormEli))); + .loadNorm(argThat(argument -> Objects.equals(argument.eli(), amendingNormEli))); verify(loadNormPort, times(2)) - .loadNorm(argThat(argument -> Objects.equals(argument.eli(), zf0Norm.getExpressionEli()))); + .loadNorm(argThat(argument -> Objects.equals(argument.eli(), zf0Norm.getExpressionEli()))); verify(updateNormService, times(1)) - .updateOneActiveModification( - argThat(argument -> - Objects.equals(argument.amendingNorm(), amendingNorm) && - Objects.equals(argument.eId(), eId) && - Objects.equals(argument.timeBoundaryEid(), newTimeBoundaryEid) && - Objects.equals(argument.destinationHref(), newDestinationHref) - ) - ); + .updateOneActiveModification( + argThat(argument -> Objects.equals(argument.amendingNorm(), amendingNorm) && + Objects.equals(argument.eId(), eId) && + Objects.equals(argument.timeBoundaryEid(), newTimeBoundaryEid) && + Objects.equals(argument.destinationHref(), newDestinationHref))); verify(updateNormService, times(2)) - .updateOnePassiveModification( - argThat(argument -> - Objects.equals(argument.zf0Norm(), zf0Norm) && - Objects.equals(argument.amendingNorm(), amendingNorm) - ) - ); + .updateOnePassiveModification( + argThat(argument -> Objects.equals(argument.zf0Norm(), zf0Norm) && + Objects.equals(argument.amendingNorm(), amendingNorm))); verify(updateNormPort, times(1)) - .updateNorm(argThat(argument -> Objects.equals(argument.norm(), amendingNorm))); + .updateNorm(argThat(argument -> Objects.equals(argument.norm(), amendingNorm))); verify(updateNormPort, times(1)) - .updateNorm(argThat(argument -> Objects.equals(argument.norm(), zf0Norm))); + .updateNorm(argThat(argument -> Objects.equals(argument.norm(), zf0Norm))); final Document amendingXmlDocument = XmlMapper.toDocument(returnedXml.amendingNormXml()); final Norm resultAmendingNorm = Norm - .builder() - .regelungstexte(Set.of(new Regelungstext(amendingXmlDocument))) - .build(); + .builder() + .regelungstexte(Set.of(new Regelungstext(amendingXmlDocument))) + .build(); final Mod mod = resultAmendingNorm.getMods().getFirst(); assertThat(mod.getTargetRefHref()).isPresent(); assertThat(mod.getTargetRefHref()).contains(newDestinationHref); assertThat(mod.getNewText()).contains(newContent); assertThat(returnedXml.targetNormZf0Xml()) - .isEqualTo(XmlMapper.toString(zf0Norm.getDocument())); + .isEqualTo(XmlMapper.toString(zf0Norm.getDocument())); } } @@ -950,61 +877,53 @@ class updateMods { @Test void itCallsTheTimeMachineBeforeValidator() { // Given - Norm amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); + Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); DokumentExpressionEli amendingNormEli = amendingNorm.getExpressionEli(); - Norm zf0Norm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + Norm zf0Norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); String newTimeBoundaryEid = "#time-boundary-eid"; when(loadNormPort.loadNorm(any())) - .thenReturn(Optional.of(amendingNorm)) - .thenReturn(Optional.of(zf0Norm)); + .thenReturn(Optional.of(amendingNorm)) + .thenReturn(Optional.of(zf0Norm)); when(updateNormService.updateOneActiveModification(any())).thenReturn(amendingNorm); when(updateNormService.updateOnePassiveModification(any())).thenReturn(zf0Norm); when(updateNormPort.updateNorm(any())).thenReturn(Optional.of(amendingNorm)); // When service.updateMods( - new UpdateModsUseCase.Query( - amendingNormEli, - List.of( - new UpdateModsUseCase.NewModData( - "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1", - newTimeBoundaryEid - ) - ), - false - ) - ); + new UpdateModsUseCase.Query( + amendingNormEli, + List.of( + new UpdateModsUseCase.NewModData( + "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1", + newTimeBoundaryEid)), + false)); // Then verify(timeMachineService, times(1)) - .applyPassiveModifications( - argThat(argument -> - Objects.equals(argument.norm(), zf0Norm) && Objects.equals(argument.date(), Instant.MIN) - ) - ); + .applyPassiveModifications( + argThat(argument -> Objects.equals(argument.norm(), zf0Norm) + && Objects.equals(argument.date(), Instant.MIN))); } @Test void itCallsTheValidator() { // Given - Norm amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); + Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); DokumentExpressionEli amendingNormEli = amendingNorm.getExpressionEli(); Mod mod = amendingNorm - .getMods() - .stream() - .filter(m -> - m - .getEid() - .equals("hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1") - ) - .findFirst() - .orElseThrow(); - Norm targetNorm = NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml"); - Norm zf0Norm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + .getMods() + .stream() + .filter(m -> m + .getEid() + .equals("hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1")) + .findFirst() + .orElseThrow(); + Norm targetNorm = Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml"); + Norm zf0Norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); String newTimeBoundaryEid = "#time-boundary-eid"; when(loadNormPort.loadNorm(any())) - .thenReturn(Optional.of(amendingNorm)) - .thenReturn(Optional.of(targetNorm)); + .thenReturn(Optional.of(amendingNorm)) + .thenReturn(Optional.of(targetNorm)); when(updateNormService.updateOneActiveModification(any())).thenReturn(amendingNorm); when(updateNormService.updateOnePassiveModification(any())).thenReturn(zf0Norm); when(updateNormPort.updateNorm(any())).thenReturn(Optional.of(amendingNorm)); @@ -1012,82 +931,69 @@ void itCallsTheValidator() { // When service.updateMods( - new UpdateModsUseCase.Query( - amendingNormEli, - List.of( - new UpdateModsUseCase.NewModData( - "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1", - newTimeBoundaryEid - ) - ), - false - ) - ); + new UpdateModsUseCase.Query( + amendingNormEli, + List.of( + new UpdateModsUseCase.NewModData( + "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1", + newTimeBoundaryEid)), + false)); // Then verify(singleModValidator, times(1)) - .validate(argThat(zf0NormArg -> zf0NormArg.equals(zf0Norm)), argThat(m -> m.equals(mod))); + .validate(argThat(zf0NormArg -> zf0NormArg.equals(zf0Norm)), argThat(m -> m.equals(mod))); } @Test void itCallsAllUpdateServices() { // Given - Norm amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); + Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); DokumentExpressionEli amendingNormEli = amendingNorm.getExpressionEli(); - Norm zf0Norm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + Norm zf0Norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); String eId = "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1"; String newTimeBoundaryEid = "#time-boundary-eid"; when(loadNormPort.loadNorm(any())) - .thenReturn(Optional.of(amendingNorm)) - .thenReturn(Optional.of(zf0Norm)); + .thenReturn(Optional.of(amendingNorm)) + .thenReturn(Optional.of(zf0Norm)); when(updateNormService.updateOneActiveModification(any())).thenReturn(amendingNorm); when(updateNormService.updateOnePassiveModification(any())).thenReturn(zf0Norm); when(updateNormPort.updateNorm(any())).thenReturn(Optional.of(amendingNorm)); // When var result = service.updateMods( - new UpdateModsUseCase.Query( - amendingNormEli, - List.of(new UpdateModsUseCase.NewModData(eId, newTimeBoundaryEid)), - false - ) - ); + new UpdateModsUseCase.Query( + amendingNormEli, + List.of(new UpdateModsUseCase.NewModData(eId, newTimeBoundaryEid)), + false)); // Then verify(loadNormPort, times(1)) - .loadNorm(argThat(argument -> Objects.equals(argument.eli(), amendingNormEli))); + .loadNorm(argThat(argument -> Objects.equals(argument.eli(), amendingNormEli))); verify(loadNormPort, times(2)) - .loadNorm(argThat(argument -> Objects.equals(argument.eli(), zf0Norm.getExpressionEli()))); + .loadNorm(argThat(argument -> Objects.equals(argument.eli(), zf0Norm.getExpressionEli()))); verify(updateNormService, times(1)) - .updateOneActiveModification( - argThat(argument -> - Objects.equals(argument.amendingNorm(), amendingNorm) && - Objects.equals(argument.eId(), eId) && - Objects.equals(argument.timeBoundaryEid(), newTimeBoundaryEid) - ) - ); + .updateOneActiveModification( + argThat(argument -> Objects.equals(argument.amendingNorm(), amendingNorm) && + Objects.equals(argument.eId(), eId) && + Objects.equals(argument.timeBoundaryEid(), newTimeBoundaryEid))); verify(updateNormService, times(2)) - .updateOnePassiveModification( - argThat(argument -> - Objects.equals(argument.zf0Norm(), zf0Norm) && - Objects.equals(argument.amendingNorm(), amendingNorm) - ) - ); + .updateOnePassiveModification( + argThat(argument -> Objects.equals(argument.zf0Norm(), zf0Norm) && + Objects.equals(argument.amendingNorm(), amendingNorm))); verify(updateNormPort, times(1)) - .updateNorm(argThat(argument -> Objects.equals(argument.norm(), amendingNorm))); + .updateNorm(argThat(argument -> Objects.equals(argument.norm(), amendingNorm))); final Document amendingXmlDocument = XmlMapper.toDocument(result.amendingNormXml()); final Norm resultAmendingNorm = Norm - .builder() - .regelungstexte(Set.of(new Regelungstext(amendingXmlDocument))) - .build(); + .builder() + .regelungstexte(Set.of(new Regelungstext(amendingXmlDocument))) + .build(); final Mod mod = resultAmendingNorm.getMods().getFirst(); assertThat(mod.getTargetRefHref()).isPresent(); assertThat(mod.getTargetRefHref().get().value()) - .contains( - "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1/hauptteil-1_art-1_abs-1_untergl-1_listenelem-2_inhalt-1_text-1/9-34.xml" - ); + .contains( + "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1/hauptteil-1_art-1_abs-1_untergl-1_listenelem-2_inhalt-1_text-1/9-34.xml"); assertThat(mod.getNewText()).contains("§ 9 Absatz 1 Satz 2, Absatz 2 oder 3"); assertThat(result.targetNormZf0Xml()).isEqualTo(XmlMapper.toString(zf0Norm.getDocument())); } @@ -1095,42 +1001,37 @@ void itCallsAllUpdateServices() { @Test void itUpdatesTheSameZf0IfMultipleModsModifyIt() { // Given - Norm amendingNorm = NormFixtures.loadFromDisk("NormWithMultipleSimpleMods.xml"); + Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithMultipleSimpleMods.xml"); DokumentExpressionEli amendingNormEli = amendingNorm.getExpressionEli(); - Norm targetNorm = NormFixtures.loadFromDisk("NormWithMultipleSimpleModsTargetNorm.xml"); + Norm targetNorm = Fixtures.loadNormFromDisk("NormWithMultipleSimpleModsTargetNorm.xml"); DokumentExpressionEli targetNormEli = targetNorm.getExpressionEli(); - Norm zf0Norm = NormFixtures.loadFromDisk("NormWithMultipleSimpleModsTargetNorm.xml"); + Norm zf0Norm = Fixtures.loadNormFromDisk("NormWithMultipleSimpleModsTargetNorm.xml"); when(loadNormPort.loadNorm(any())) - .thenReturn(Optional.of(amendingNorm)) - .thenReturn(Optional.of(targetNorm)); + .thenReturn(Optional.of(amendingNorm)) + .thenReturn(Optional.of(targetNorm)); when(updateNormService.updateOneActiveModification(any())).thenReturn(amendingNorm); when(updateNormService.updateOnePassiveModification(any())).thenReturn(zf0Norm); when(updateNormPort.updateNorm(any())).thenReturn(Optional.of(amendingNorm)); // When service.updateMods( - new UpdateModsUseCase.Query( - amendingNormEli, - List.of( - new UpdateModsUseCase.NewModData( - "hauptteil-1_art-1_abs-1_untergl-1_listenelem-2_inhalt-1_text-1_ändbefehl-1", - "#meta-1_geltzeiten-1_geltungszeitgr-1" - ), - new UpdateModsUseCase.NewModData( - "hauptteil-1_art-1_abs-1_untergl-1_listenelem-2_inhalt-1_text-1_ändbefehl-1", - "#meta-1_geltzeiten-1_geltungszeitgr-1" - ) - ), - false - ) - ); + new UpdateModsUseCase.Query( + amendingNormEli, + List.of( + new UpdateModsUseCase.NewModData( + "hauptteil-1_art-1_abs-1_untergl-1_listenelem-2_inhalt-1_text-1_ändbefehl-1", + "#meta-1_geltzeiten-1_geltungszeitgr-1"), + new UpdateModsUseCase.NewModData( + "hauptteil-1_art-1_abs-1_untergl-1_listenelem-2_inhalt-1_text-1_ändbefehl-1", + "#meta-1_geltzeiten-1_geltungszeitgr-1")), + false)); // Then verify(loadNormPort, times(1)) - .loadNorm(argThat(argument -> Objects.equals(argument.eli(), amendingNormEli))); + .loadNorm(argThat(argument -> Objects.equals(argument.eli(), amendingNormEli))); verify(loadNormPort, times(2)) - .loadNorm(argThat(argument -> Objects.equals(argument.eli(), targetNormEli))); + .loadNorm(argThat(argument -> Objects.equals(argument.eli(), targetNormEli))); verify(updateNormService, times(2)).updateOneActiveModification(any()); verify(updateNormService, times(3)).updateOnePassiveModification(any()); verify(updateNormPort, times(2)).updateNorm(any()); @@ -1139,44 +1040,38 @@ void itUpdatesTheSameZf0IfMultipleModsModifyIt() { @Test void itUpdatesUsingRref() { // Given - Norm amendingNorm = NormFixtures.loadFromDisk("NormWithQuotedStructureModsAndUpTo.xml"); + Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithQuotedStructureModsAndUpTo.xml"); DokumentExpressionEli amendingNormEli = amendingNorm.getExpressionEli(); - Norm targetNorm = NormFixtures.loadFromDisk( - "NormWithoutPassiveModsQuotedStructureAndUpTo.xml" - ); + Norm targetNorm = Fixtures.loadNormFromDisk( + "NormWithoutPassiveModsQuotedStructureAndUpTo.xml"); DokumentExpressionEli targetNormEli = targetNorm.getExpressionEli(); - Norm zf0Norm = NormFixtures.loadFromDisk("NormWithPassiveModsQuotedStructureAndUpTo.xml"); + Norm zf0Norm = Fixtures.loadNormFromDisk("NormWithPassiveModsQuotedStructureAndUpTo.xml"); when(loadNormPort.loadNorm(any())) - .thenReturn(Optional.of(amendingNorm)) - .thenReturn(Optional.of(targetNorm)); + .thenReturn(Optional.of(amendingNorm)) + .thenReturn(Optional.of(targetNorm)); when(updateNormService.updateOneActiveModification(any())).thenReturn(amendingNorm); when(updateNormService.updateOnePassiveModification(any())).thenReturn(zf0Norm); when(updateNormPort.updateNorm(any())).thenReturn(Optional.of(amendingNorm)); // When service.updateMods( - new UpdateModsUseCase.Query( - amendingNormEli, - List.of( - new UpdateModsUseCase.NewModData( - "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1", - "#meta-1_geltzeiten-1_geltungszeitgr-2" - ), - new UpdateModsUseCase.NewModData( - "hauptteil-1_art-1_abs-1_untergl-1_listenelem-2_inhalt-1_text-1_ändbefehl-1", - "#meta-1_geltzeiten-1_geltungszeitgr-2" - ) - ), - false - ) - ); + new UpdateModsUseCase.Query( + amendingNormEli, + List.of( + new UpdateModsUseCase.NewModData( + "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1", + "#meta-1_geltzeiten-1_geltungszeitgr-2"), + new UpdateModsUseCase.NewModData( + "hauptteil-1_art-1_abs-1_untergl-1_listenelem-2_inhalt-1_text-1_ändbefehl-1", + "#meta-1_geltzeiten-1_geltungszeitgr-2")), + false)); // Then verify(loadNormPort, times(1)) - .loadNorm(argThat(argument -> Objects.equals(argument.eli(), amendingNormEli))); + .loadNorm(argThat(argument -> Objects.equals(argument.eli(), amendingNormEli))); verify(loadNormPort, times(2)) - .loadNorm(argThat(argument -> Objects.equals(argument.eli(), targetNormEli))); + .loadNorm(argThat(argument -> Objects.equals(argument.eli(), targetNormEli))); verify(updateNormService, times(2)).updateOneActiveModification(any()); verify(updateNormService, times(3)).updateOnePassiveModification(any()); verify(updateNormPort, times(2)).updateNorm(any()); @@ -1189,55 +1084,50 @@ void itThrowsNormNotFoundExceptionWhenAmendingLawCanNotBeLoaded() { // when UpdateModsUseCase.Query query = new UpdateModsUseCase.Query( - DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/3000/s1/3000-01-01/1/deu/regelungstext-1" - ), - List.of(new UpdateModsUseCase.NewModData("not-relevant", "not-relevant")), - false - ); + DokumentExpressionEli.fromString( + "eli/bund/bgbl-1/3000/s1/3000-01-01/1/deu/regelungstext-1"), + List.of(new UpdateModsUseCase.NewModData("not-relevant", "not-relevant")), + false); assertThatThrownBy(() -> service.updateMods(query)) - // Then - .isInstanceOf(NormNotFoundException.class) - .hasMessageContaining( - "Norm with eli eli/bund/bgbl-1/3000/s1/3000-01-01/1/deu/regelungstext-1 does not exist" - ); + // Then + .isInstanceOf(NormNotFoundException.class) + .hasMessageContaining( + "Norm with eli eli/bund/bgbl-1/3000/s1/3000-01-01/1/deu/regelungstext-1 does not exist"); } @Test void itThrowsInvalidUpdateExceptionWhenModWithGivenEidNotFound() { // Given - Norm amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); + Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); DokumentExpressionEli amendingNormEli = amendingNorm.getExpressionEli(); String newTimeBoundaryEid = "#time-boundary-eid"; when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(amendingNorm)); // when UpdateModsUseCase.Query query = new UpdateModsUseCase.Query( - amendingNormEli, - List.of(new UpdateModsUseCase.NewModData("eid-that-does-not-exist", newTimeBoundaryEid)), - false - ); + amendingNormEli, + List.of(new UpdateModsUseCase.NewModData("eid-that-does-not-exist", newTimeBoundaryEid)), + false); assertThatThrownBy(() -> service.updateMods(query)) - // Then - .isInstanceOf(InvalidUpdateException.class) - .hasMessageContaining( - "Mod with eId eid-that-does-not-exist not found in amending law eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/regelungstext-1" - ); + // Then + .isInstanceOf(InvalidUpdateException.class) + .hasMessageContaining( + "Mod with eId eid-that-does-not-exist not found in amending law eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/regelungstext-1"); } @Test void itThrowsInvalidUpdateExceptionWhenModHrefDoesNotContainEli() { // Given - Norm amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); + Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); String eid = "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1"; amendingNorm - .getMods() - .stream() - .filter(mod -> mod.getEid().equals(eid)) - .findFirst() - .ifPresent(m -> m.setTargetRefHref(new Href("#fake-href"))); + .getMods() + .stream() + .filter(mod -> mod.getEid().equals(eid)) + .findFirst() + .ifPresent(m -> m.setTargetRefHref(new Href("#fake-href"))); DokumentExpressionEli amendingNormEli = amendingNorm.getExpressionEli(); String newTimeBoundaryEid = "#time-boundary-eid"; @@ -1245,17 +1135,15 @@ void itThrowsInvalidUpdateExceptionWhenModHrefDoesNotContainEli() { // when UpdateModsUseCase.Query query = new UpdateModsUseCase.Query( - amendingNormEli, - List.of(new UpdateModsUseCase.NewModData(eid, newTimeBoundaryEid)), - false - ); + amendingNormEli, + List.of(new UpdateModsUseCase.NewModData(eid, newTimeBoundaryEid)), + false); assertThatThrownBy(() -> service.updateMods(query)) - // Then - .isInstanceOf(InvalidUpdateException.class) - .hasMessageContaining( - "No eli found in href of mod hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1" - ); + // Then + .isInstanceOf(InvalidUpdateException.class) + .hasMessageContaining( + "No eli found in href of mod hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1"); } } } diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/ProprietaryServiceTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/ProprietaryServiceTest.java index 0f1d4aac9..3d42c140a 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/ProprietaryServiceTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/ProprietaryServiceTest.java @@ -12,7 +12,7 @@ import de.bund.digitalservice.ris.norms.application.port.input.UpdateProprietarySingleElementFromNormUseCase; import de.bund.digitalservice.ris.norms.application.port.output.LoadNormPort; import de.bund.digitalservice.ris.norms.application.port.output.UpdateNormPort; -import de.bund.digitalservice.ris.norms.domain.entity.NormFixtures; +import de.bund.digitalservice.ris.norms.domain.entity.Fixtures; import de.bund.digitalservice.ris.norms.domain.entity.Proprietary; import de.bund.digitalservice.ris.norms.domain.entity.eli.DokumentExpressionEli; import java.time.LocalDate; @@ -55,7 +55,7 @@ void returnNewProprietaryNodeIfProprietaryNotFound() { var eli = DokumentExpressionEli.fromString( "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1" ); - var normWithoutProprietary = NormFixtures.loadFromDisk("NormWithoutProprietary.xml"); + var normWithoutProprietary = Fixtures.loadNormFromDisk("NormWithoutProprietary.xml"); when(loadNormPort.loadNorm(new LoadNormPort.Command(eli))) .thenReturn(Optional.of(normWithoutProprietary)); @@ -74,7 +74,7 @@ void returnsProprietary() { var eli = DokumentExpressionEli.fromString( "eli/bund/bgbl-1/2002/s1181/2019-11-22/1/deu/rechtsetzungsdokument-1" ); - var normWithProprietary = NormFixtures.loadFromDisk("NormWithProprietary.xml"); + var normWithProprietary = Fixtures.loadNormFromDisk("NormWithProprietary.xml"); when(loadNormPort.loadNorm(new LoadNormPort.Command(eli))) .thenReturn(Optional.of(normWithProprietary)); // when @@ -153,7 +153,7 @@ void updatesProprietaryByCreatingNewProprietaryAndMetadatenDsAndEinzelelementNod "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1" ); var date = LocalDate.parse("2003-01-01"); - var normWithoutProprietary = NormFixtures.loadFromDisk("NormWithoutProprietary.xml"); + var normWithoutProprietary = Fixtures.loadNormFromDisk("NormWithoutProprietary.xml"); when(loadNormPort.loadNorm(new LoadNormPort.Command(eli))) .thenReturn(Optional.of(normWithoutProprietary)); @@ -180,7 +180,7 @@ void updatesProprietaryByCreatingNewMetadatenDsNodes() { "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1" ); var date = LocalDate.parse("2003-01-01"); - var normWithProprietary = NormFixtures.loadFromDisk("NormWithProprietary.xml"); + var normWithProprietary = Fixtures.loadNormFromDisk("NormWithProprietary.xml"); when(loadNormPort.loadNorm(new LoadNormPort.Command(eli))) .thenReturn(Optional.of(normWithProprietary)); @@ -207,7 +207,7 @@ void resetsAllFields() { "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1" ); var date = LocalDate.parse("1980-01-01"); - var normWithProprietary = NormFixtures.loadFromDisk("NormWithProprietary.xml"); + var normWithProprietary = Fixtures.loadNormFromDisk("NormWithProprietary.xml"); when(loadNormPort.loadNorm(new LoadNormPort.Command(eli))) .thenReturn(Optional.of(normWithProprietary)); diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/PublishServiceTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/PublishServiceTest.java index e7688990a..0aad3a870 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/PublishServiceTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/PublishServiceTest.java @@ -7,9 +7,9 @@ import de.bund.digitalservice.ris.norms.adapter.output.exception.BucketException; import de.bund.digitalservice.ris.norms.application.exception.MigrationJobException; import de.bund.digitalservice.ris.norms.application.port.output.*; +import de.bund.digitalservice.ris.norms.domain.entity.Fixtures; import de.bund.digitalservice.ris.norms.domain.entity.MigrationLog; import de.bund.digitalservice.ris.norms.domain.entity.Norm; -import de.bund.digitalservice.ris.norms.domain.entity.NormFixtures; import de.bund.digitalservice.ris.norms.domain.entity.NormPublishState; import java.time.Instant; import java.time.LocalDate; @@ -66,7 +66,7 @@ class processQueuedFilesForPublish { @Test void publishNormToPublicAndPrivateStorage() { // Given - final Norm norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + final Norm norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); final UUID uuid = UUID.randomUUID(); when(loadNormIdsByPublishStatePort.loadNormIdsByPublishState(any())) .thenReturn(List.of(uuid)); @@ -92,7 +92,7 @@ void publishNormToPublicAndPrivateStorage() { @Test void publishNormToPublicButPrivateFails() { // Given - final Norm norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + final Norm norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); final UUID uuid = UUID.randomUUID(); when(loadNormIdsByPublishStatePort.loadNormIdsByPublishState(any())) .thenReturn(List.of(uuid)); @@ -123,7 +123,7 @@ void publishNormToPublicButPrivateFails() { @Test void publishNormToPublicFails() { // Given - final Norm norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + final Norm norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); final UUID uuid = UUID.randomUUID(); when(loadNormIdsByPublishStatePort.loadNormIdsByPublishState(any())) .thenReturn(List.of(uuid)); @@ -154,7 +154,7 @@ void publishNormToPublicFails() { @Test void deleteAllNormsIfMigrationLogExists() { // Given - final Norm norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + final Norm norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); final MigrationLog migrationLog = MigrationLog .builder() .size(5) @@ -194,7 +194,7 @@ void deleteAllNormsIfMigrationLogExists() { @Test void doNotdeleteAllNormsIfMigrationLogExistsButSizeIsZero() { // Given - final Norm norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + final Norm norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); final MigrationLog migrationLog = MigrationLog .builder() .size(0) @@ -236,7 +236,7 @@ void doNotdeleteAllNormsIfMigrationLogExistsButSizeIsZero() { @Test void doNotDeleteNormsIfNoMigrationLogExists() { // Given - final Norm norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + final Norm norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); final UUID uuid = UUID.randomUUID(); when(loadNormIdsByPublishStatePort.loadNormIdsByPublishState(any())) @@ -274,7 +274,7 @@ class prepareForPublish { @Test void removesOrganisationsEinheitFromMetadata() { // Given - var norm = NormFixtures.loadFromDisk("NormToBeReleased.xml"); + var norm = Fixtures.loadNormFromDisk("NormToBeReleased.xml"); var proprietary = norm.getMeta().getProprietary().get(); assertThat(proprietary.getOrganisationsEinheit(LocalDate.of(2005, 1, 1))) diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/ReferenceServiceTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/ReferenceServiceTest.java index d0230a236..8fb29eae9 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/ReferenceServiceTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/ReferenceServiceTest.java @@ -2,8 +2,8 @@ import static org.assertj.core.api.Assertions.assertThat; +import de.bund.digitalservice.ris.norms.domain.entity.Fixtures; import de.bund.digitalservice.ris.norms.domain.entity.Norm; -import de.bund.digitalservice.ris.norms.domain.entity.NormFixtures; import de.bund.digitalservice.ris.norms.domain.entity.Regelungstext; import de.bund.digitalservice.ris.norms.utils.XmlMapper; import java.util.Set; @@ -84,7 +84,7 @@ void itDoesNotLookForReferencesBecauseQuotedTextContainReferencesAlready() { @Test void itDoesNotLookForReferencesBecauseQuotedStructureContainReferencesAlready() { // Given - final Norm norm = NormFixtures.loadFromDisk("NormWithReferencesFound.xml"); + final Norm norm = Fixtures.loadNormFromDisk("NormWithReferencesFound.xml"); // When final String result = service.findAndCreateReferences(norm); @@ -100,13 +100,13 @@ void itDoesNotLookForReferencesBecauseQuotedStructureContainReferencesAlready() @Test void ifFindsAndCreatesReferences() { // Given - final Norm norm = NormFixtures.loadFromDisk("NormWithReferencesToFind.xml"); + final Norm norm = Fixtures.loadNormFromDisk("NormWithReferencesToFind.xml"); // When final String result = service.findAndCreateReferences(norm); // Then - final Norm expectedUpdatedNorm = NormFixtures.loadFromDisk("NormWithReferencesFound.xml"); + final Norm expectedUpdatedNorm = Fixtures.loadNormFromDisk("NormWithReferencesFound.xml"); final Diff diff = DiffBuilder .compare(Input.from(XmlMapper.toDocument(result))) .ignoreElementContentWhitespace() @@ -119,12 +119,12 @@ void ifFindsAndCreatesReferences() { @Test void itDoesNotFindReferencesInNum() { // Given - final Norm norm = NormFixtures.loadFromDisk("NormWithReferencesInNumToSkip.xml"); + final Norm norm = Fixtures.loadNormFromDisk("NormWithReferencesInNumToSkip.xml"); // When final String result = service.findAndCreateReferences(norm); // Then - final Norm sameNormReload = NormFixtures.loadFromDisk("NormWithReferencesInNumToSkip.xml"); + final Norm sameNormReload = Fixtures.loadNormFromDisk("NormWithReferencesInNumToSkip.xml"); final Diff diff = DiffBuilder .compare(Input.from(XmlMapper.toDocument(result))) .withTest(Input.from(sameNormReload.getDocument())) diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/ReleaseServiceTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/ReleaseServiceTest.java index 82a6d11cc..44c6ea246 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/ReleaseServiceTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/ReleaseServiceTest.java @@ -15,7 +15,7 @@ import de.bund.digitalservice.ris.norms.application.port.output.SaveReleaseToAnnouncementPort; import de.bund.digitalservice.ris.norms.application.port.output.UpdateOrSaveNormPort; import de.bund.digitalservice.ris.norms.domain.entity.Announcement; -import de.bund.digitalservice.ris.norms.domain.entity.NormFixtures; +import de.bund.digitalservice.ris.norms.domain.entity.Fixtures; import de.bund.digitalservice.ris.norms.domain.entity.NormPublishState; import de.bund.digitalservice.ris.norms.domain.entity.eli.DokumentExpressionEli; import de.bund.digitalservice.ris.norms.utils.XmlMapper; @@ -58,12 +58,12 @@ class ReleaseServiceTest { @Test void itShouldReleaseAnAnnouncementWithoutTargetNorms() { // Given - var norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + var norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); // these are just arbitrary norm files, it's not important what is in them just that they are all different. - var manifestationOfNormToQueue = NormFixtures.loadFromDisk( + var manifestationOfNormToQueue = Fixtures.loadNormFromDisk( "NormWithoutPassiveModifications.xml" ); - var newNewestUnpublishedManifestationOfNorm = NormFixtures.loadFromDisk( + var newNewestUnpublishedManifestationOfNorm = Fixtures.loadNormFromDisk( "NormWithoutPassiveModificationsNoNextVersion.xml" ); @@ -119,28 +119,28 @@ void itShouldReleaseAnAnnouncementWithoutTargetNorms() { @Test void itShouldReleaseAnAnnouncementWithTargetNorm() { // Given - var amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); - var targetNorm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + var amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); + var targetNorm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); // these are just arbitrary norm files, it's not important what is in them just that they are all different. - var targetNormExpressionAtDateOne = NormFixtures.loadFromDisk( + var targetNormExpressionAtDateOne = Fixtures.loadNormFromDisk( "NormWithAppliedQuotedStructure.xml" ); - var manifestationOfAmendingNormToQueue = NormFixtures.loadFromDisk( + var manifestationOfAmendingNormToQueue = Fixtures.loadNormFromDisk( "NormWithModsSameTarget.xml" ); - var manifestationOfTargetNormToUseForCreatingExpressions = NormFixtures.loadFromDisk( + var manifestationOfTargetNormToUseForCreatingExpressions = Fixtures.loadNormFromDisk( "NormWithoutPassiveModificationsNoNextVersion.xml" ); - var manifestationOfTargetNormToUseInTimeMachine = NormFixtures.loadFromDisk( + var manifestationOfTargetNormToUseInTimeMachine = Fixtures.loadNormFromDisk( "NormWithoutPassiveModificationsSameTarget.xml" ); - var manifestationOfTargetNormToQueue = NormFixtures.loadFromDisk( + var manifestationOfTargetNormToQueue = Fixtures.loadNormFromDisk( "NormWithoutPassiveModsQuotedStructure.xml" ); - var newNewestUnpublishedManifestationOfAmendingNorm = NormFixtures.loadFromDisk( + var newNewestUnpublishedManifestationOfAmendingNorm = Fixtures.loadNormFromDisk( "NormWithMultipleMods.xml" ); - var newNewestUnpublishedManifestationOfTargetNorm = NormFixtures.loadFromDisk( + var newNewestUnpublishedManifestationOfTargetNorm = Fixtures.loadNormFromDisk( "NormWithoutPassiveModsQuotedStructureAndUpTo.xml" ); @@ -240,7 +240,7 @@ void itShouldReleaseAnAnnouncementWithTargetNorm() { @Test void itShouldUpdateTheReleasedByDocumentalistAtDate() { // Given - var norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + var norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); var announcement = Announcement.builder().eli(norm.getExpressionEli()).build(); when(loadAnnouncementByNormEliUseCase.loadAnnouncementByNormEli(any())) @@ -272,13 +272,13 @@ void itShouldUpdateTheReleasedByDocumentalistAtDate() { @Test void itShouldThrowWhenTryingToReleaseXsdInvalidNorm() { // Given - var norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + var norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); // these are just arbitrary norm files, it's not important what is in them just that they are all different. - var manifestationOfNormToQueue = NormFixtures.loadFromDisk( + var manifestationOfNormToQueue = Fixtures.loadNormFromDisk( "NormWithoutPassiveModifications.xml" ); - var newNewestUnpublishedManifestationOfNorm = NormFixtures.loadFromDisk( + var newNewestUnpublishedManifestationOfNorm = Fixtures.loadNormFromDisk( "NormWithoutPassiveModificationsNoNextVersion.xml" ); @@ -320,13 +320,13 @@ void itShouldThrowWhenTryingToReleaseXsdInvalidNorm() { @Test void itShouldThrowWhenTryingToReleaseSchematronInvalidNorm() { // Given - var norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + var norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); // these are just arbitrary norm files, it's not important what is in them just that they are all different. - var manifestationOfNormToQueue = NormFixtures.loadFromDisk( + var manifestationOfNormToQueue = Fixtures.loadNormFromDisk( "NormWithoutPassiveModifications.xml" ); - var newNewestUnpublishedManifestationOfNorm = NormFixtures.loadFromDisk( + var newNewestUnpublishedManifestationOfNorm = Fixtures.loadNormFromDisk( "NormWithoutPassiveModificationsNoNextVersion.xml" ); diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/SingleModValidatorTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/SingleModValidatorTest.java index 8e52a2811..af0b0f087 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/SingleModValidatorTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/SingleModValidatorTest.java @@ -6,10 +6,10 @@ import de.bund.digitalservice.ris.norms.application.exception.ValidationException; import de.bund.digitalservice.ris.norms.domain.entity.Analysis; import de.bund.digitalservice.ris.norms.domain.entity.CharacterRange; +import de.bund.digitalservice.ris.norms.domain.entity.Fixtures; import de.bund.digitalservice.ris.norms.domain.entity.Href; import de.bund.digitalservice.ris.norms.domain.entity.Mod; import de.bund.digitalservice.ris.norms.domain.entity.Norm; -import de.bund.digitalservice.ris.norms.domain.entity.NormFixtures; import de.bund.digitalservice.ris.norms.domain.entity.TextualMod; import de.bund.digitalservice.ris.norms.domain.entity.eli.DokumentExpressionEli; import de.bund.digitalservice.ris.norms.utils.exceptions.MandatoryNodeNotFoundException; @@ -32,7 +32,7 @@ class quotedText { @Test void oldTextIsEmpty() { // given - final Norm amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); + final Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); final Element modNode = amendingNorm .getElementByEId( "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1" @@ -41,7 +41,7 @@ void oldTextIsEmpty() { final Mod mod = new Mod(modNode); mod.setOldText(""); - final Norm zf0Norm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + final Norm zf0Norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); // when Throwable thrown = catchThrowable(() -> underTest.validate(zf0Norm, mod)); @@ -57,7 +57,7 @@ void oldTextIsEmpty() { @Test void oldTextNotTheSameInZf0Norm() { // given - final Norm amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); + final Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); final Element modNode = amendingNorm .getElementByEId( "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1" @@ -66,7 +66,7 @@ void oldTextNotTheSameInZf0Norm() { final Mod mod = new Mod(modNode); mod.setOldText("not the same text as in target law"); - final Norm zf0Norm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + final Norm zf0Norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); // when Throwable thrown = catchThrowable(() -> underTest.validate(zf0Norm, mod)); @@ -82,14 +82,14 @@ void oldTextNotTheSameInZf0Norm() { @Test void nodeWithGivenDestEidDoesNotExists() { // given - final Norm amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); + final Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); final Element modNode = amendingNorm .getElementByEId( "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1" ) .orElseThrow(); final Mod mod = new Mod(modNode); - final Norm zf0Norm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + final Norm zf0Norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); final TextualMod passiveMod = zf0Norm .getMeta() .getAnalysis() @@ -114,14 +114,14 @@ void nodeWithGivenDestEidDoesNotExists() { @Test void validationSuccessful() { // given - final Norm amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); + final Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); final Element modNode = amendingNorm .getElementByEId( "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1" ) .orElseThrow(); final Mod mod = new Mod(modNode); - final Norm zf0Norm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + final Norm zf0Norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); // when/then assertThatCode(() -> underTest.validate(zf0Norm, mod)).doesNotThrowAnyException(); @@ -130,7 +130,7 @@ void validationSuccessful() { @Test void validationSuccessfulUntilEndOfParagraph() { // given - final Norm amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); + final Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); final Element modNode = amendingNorm .getElementByEId( "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1" @@ -156,7 +156,7 @@ void validationSuccessfulUntilEndOfParagraph() { mod.setTargetRefHref(href); mod.setOldText("§ 9 Abs. 1 Satz 2, Abs. 2"); - final Norm zf0Norm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + final Norm zf0Norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); // when/then assertThatCode(() -> underTest.validate(zf0Norm, mod)).doesNotThrowAnyException(); @@ -165,7 +165,7 @@ void validationSuccessfulUntilEndOfParagraph() { @Test void validationSuccessfulStartingAt0() { // given - final Norm amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); + final Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); final Element modNode = amendingNorm .getElementByEId( "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1" @@ -191,7 +191,7 @@ void validationSuccessfulStartingAt0() { mod.setTargetRefHref(href); mod.setOldText("§ 9 Abs. 1 Satz 2, Abs. 2"); - final Norm zf0Norm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + final Norm zf0Norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); // when/then assertThatCode(() -> underTest.validate(zf0Norm, mod)).doesNotThrowAnyException(); @@ -200,7 +200,7 @@ void validationSuccessfulStartingAt0() { @Test void throwsExceptionWhenCharacterRangeIsNotSet() { // given - final Norm amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); + final Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); final DokumentExpressionEli amendingNormEli = amendingNorm.getExpressionEli(); final Element modNode = amendingNorm .getElementByEId( @@ -216,7 +216,7 @@ void throwsExceptionWhenCharacterRangeIsNotSet() { .buildInternalReference() ); - final Norm zf0Norm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + final Norm zf0Norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); final TextualMod passiveMod = zf0Norm .getMeta() .getAnalysis() @@ -266,7 +266,7 @@ private static Stream provideParametersForThrowsExceptionWhenCharacte @MethodSource("provideParametersForThrowsExceptionWhenCharacterRange") void throwsExceptionWhenCharacterRangeIsMalformed(String cr, String message) { // given - final Norm amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); + final Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); final Element modNode = amendingNorm .getElementByEId( "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1" @@ -274,7 +274,7 @@ void throwsExceptionWhenCharacterRangeIsMalformed(String cr, String message) { .orElseThrow(); final Mod mod = new Mod(modNode); - final Norm zf0Norm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + final Norm zf0Norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); final TextualMod passiveMod = zf0Norm .getMeta() .getAnalysis() @@ -298,7 +298,7 @@ void throwsExceptionWhenCharacterRangeIsMalformed(String cr, String message) { @Test void ThrowsExceptionWhenCharacterRangeEndIsTooHigh() { // given - final Norm amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); + final Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); final Element modNode = amendingNorm .getElementByEId( "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1" @@ -306,7 +306,7 @@ void ThrowsExceptionWhenCharacterRangeEndIsTooHigh() { .orElseThrow(); final Mod mod = new Mod(modNode); - final Norm zf0Norm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + final Norm zf0Norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); final TextualMod passiveMod = zf0Norm .getMeta() .getAnalysis() @@ -338,14 +338,14 @@ class quotedStructure { @Test void validationSuccessNoUpTo() { // given - final Norm amendingNorm = NormFixtures.loadFromDisk("NormWithQuotedStructureMods.xml"); + final Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithQuotedStructureMods.xml"); final Element modNode = amendingNorm .getElementByEId( "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1" ) .orElseThrow(); final Mod mod = new Mod(modNode); - final Norm zf0Norm = NormFixtures.loadFromDisk("NormWithPassiveModsQuotedStructure.xml"); + final Norm zf0Norm = Fixtures.loadNormFromDisk("NormWithPassiveModsQuotedStructure.xml"); // when then assertThatCode(() -> underTest.validate(zf0Norm, mod)).doesNotThrowAnyException(); @@ -354,14 +354,14 @@ void validationSuccessNoUpTo() { @Test void validationSuccessWithUpTo() { // given - final Norm amendingNorm = NormFixtures.loadFromDisk("NormWithQuotedStructureModsAndUpTo.xml"); + final Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithQuotedStructureModsAndUpTo.xml"); final Element modNode = amendingNorm .getElementByEId( "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1" ) .orElseThrow(); final Mod mod = new Mod(modNode); - final Norm zf0Norm = NormFixtures.loadFromDisk( + final Norm zf0Norm = Fixtures.loadNormFromDisk( "NormWithPassiveModsQuotedStructureAndUpTo.xml" ); @@ -372,14 +372,14 @@ void validationSuccessWithUpTo() { @Test void upToNodeNotPresent() { // given - final Norm amendingNorm = NormFixtures.loadFromDisk("NormWithQuotedStructureModsAndUpTo.xml"); + final Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithQuotedStructureModsAndUpTo.xml"); final Element modNode = amendingNorm .getElementByEId( "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1" ) .orElseThrow(); final Mod mod = new Mod(modNode); - final Norm zf0Norm = NormFixtures.loadFromDisk( + final Norm zf0Norm = Fixtures.loadNormFromDisk( "NormWithPassiveModsQuotedStructureAndUpTo.xml" ); @@ -405,14 +405,14 @@ void upToNodeNotPresent() { @Test void upToNodeAndTargetNodeNotSiblings() { // given - final Norm amendingNorm = NormFixtures.loadFromDisk("NormWithQuotedStructureModsAndUpTo.xml"); + final Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithQuotedStructureModsAndUpTo.xml"); final Element modNode = amendingNorm .getElementByEId( "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1" ) .orElseThrow(); final Mod mod = new Mod(modNode); - final Norm zf0Norm = NormFixtures.loadFromDisk( + final Norm zf0Norm = Fixtures.loadNormFromDisk( "NormWithPassiveModsQuotedStructureAndUpTo.xml" ); @@ -440,14 +440,14 @@ void upToNodeAndTargetNodeNotSiblings() { @Test void upToNodeBeforeTargetNode() { // given - final Norm amendingNorm = NormFixtures.loadFromDisk("NormWithQuotedStructureModsAndUpTo.xml"); + final Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithQuotedStructureModsAndUpTo.xml"); final Element modNode = amendingNorm .getElementByEId( "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1" ) .orElseThrow(); final Mod mod = new Mod(modNode); - final Norm zf0Norm = NormFixtures.loadFromDisk( + final Norm zf0Norm = Fixtures.loadNormFromDisk( "NormWithPassiveModsQuotedStructureAndUpTo.xml" ); diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/TimeMachineServiceTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/TimeMachineServiceTest.java index a10e13624..e6d0f86a9 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/TimeMachineServiceTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/TimeMachineServiceTest.java @@ -6,8 +6,8 @@ import de.bund.digitalservice.ris.norms.application.port.input.ApplyPassiveModificationsUseCase; import de.bund.digitalservice.ris.norms.application.port.output.LoadNormPort; +import de.bund.digitalservice.ris.norms.domain.entity.Fixtures; import de.bund.digitalservice.ris.norms.domain.entity.Norm; -import de.bund.digitalservice.ris.norms.domain.entity.NormFixtures; import de.bund.digitalservice.ris.norms.domain.entity.Regelungstext; import de.bund.digitalservice.ris.norms.utils.NodeParser; import de.bund.digitalservice.ris.norms.utils.XmlMapper; @@ -76,9 +76,9 @@ void returnUnchangedIfNoPassiveModifications() { @Test void applyOnePassiveModification() { // given - final var norm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + final var norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); - final var amendingLaw = NormFixtures.loadFromDisk("NormWithMods.xml"); + final var amendingLaw = Fixtures.loadNormFromDisk("NormWithMods.xml"); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(amendingLaw)); @@ -104,9 +104,9 @@ void applyOnePassiveModification() { @Test void applyPassiveModificationsInCorrectOrder() { // given - final var norm = NormFixtures.loadFromDisk("NormWithMultiplePassiveModifications.xml"); + final var norm = Fixtures.loadNormFromDisk("NormWithMultiplePassiveModifications.xml"); - final var amendingLaw = NormFixtures.loadFromDisk("NormWithMultipleMods.xml"); + final var amendingLaw = Fixtures.loadNormFromDisk("NormWithMultipleMods.xml"); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(amendingLaw)); @@ -133,9 +133,9 @@ void applyPassiveModificationsInCorrectOrder() { @Test void applyPassiveModificationsDoesNotModifyTheParameter() { // given - final var norm = NormFixtures.loadFromDisk("NormWithMultiplePassiveModifications.xml"); + final var norm = Fixtures.loadNormFromDisk("NormWithMultiplePassiveModifications.xml"); - final var amendingLaw = NormFixtures.loadFromDisk("NormWithMultipleMods.xml"); + final var amendingLaw = Fixtures.loadNormFromDisk("NormWithMultipleMods.xml"); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(amendingLaw)); @@ -153,11 +153,11 @@ void applyPassiveModificationsDoesNotModifyTheParameter() { @Test void applyPassiveModificationsWhereTargetNodeEqualsNodeToChange() { // given - final var norm = NormFixtures.loadFromDisk( + final var norm = Fixtures.loadNormFromDisk( "NormWithPassiveModsWhereTargetNodeEqualsNodeToChange.xml" ); - final var amendingLaw = NormFixtures.loadFromDisk( + final var amendingLaw = Fixtures.loadNormFromDisk( "NormWithModsWhereTargetNodeEqualsNodeToChange.xml" ); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(amendingLaw)); @@ -194,8 +194,8 @@ void applyPassiveModificationsWhereTargetNodeEqualsNodeToChange() { @Test void applyPassiveModificationsBeforeDate() { // given - final var norm = NormFixtures.loadFromDisk("NormWithMultiplePassiveModifications.xml"); - final var amendingLaw = NormFixtures.loadFromDisk("NormWithMultipleMods.xml"); + final var norm = Fixtures.loadNormFromDisk("NormWithMultiplePassiveModifications.xml"); + final var amendingLaw = Fixtures.loadNormFromDisk("NormWithMultipleMods.xml"); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(amendingLaw)); @@ -219,9 +219,9 @@ void applyPassiveModificationsBeforeDate() { @Test void applyOnePassiveModificationWithCustomNorm() { // given - final var norm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + final var norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); - final var amendingLaw = NormFixtures.loadFromDisk("NormWithMods.xml"); + final var amendingLaw = Fixtures.loadNormFromDisk("NormWithMods.xml"); // when Norm result = timeMachineService.applyPassiveModifications( @@ -243,10 +243,10 @@ void applyOnePassiveModificationWithCustomNorm() { @Test void doNotApplyPassiveModificationWithoutForcePeriod() { // given - final var norm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + final var norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); norm.deleteByEId("meta-1_analysis-1_pasmod-1_textualmod-1_gelzeitnachw-1"); - final var amendingLaw = NormFixtures.loadFromDisk("NormWithMods.xml"); + final var amendingLaw = Fixtures.loadNormFromDisk("NormWithMods.xml"); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(amendingLaw)); @@ -270,9 +270,9 @@ void doNotApplyPassiveModificationWithoutForcePeriod() { @Test void applyOnePassiveModificationQuotedStructure() { // given - final var targetLawNorm = NormFixtures.loadFromDisk("NormWithPassiveModsQuotedStructure.xml"); - final var amendingLawNorm = NormFixtures.loadFromDisk("NormWithQuotedStructureMods.xml"); - final var expectedResult = NormFixtures.loadFromDisk("NormWithAppliedQuotedStructure.xml"); + final var targetLawNorm = Fixtures.loadNormFromDisk("NormWithPassiveModsQuotedStructure.xml"); + final var amendingLawNorm = Fixtures.loadNormFromDisk("NormWithQuotedStructureMods.xml"); + final var expectedResult = Fixtures.loadNormFromDisk("NormWithAppliedQuotedStructure.xml"); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(amendingLawNorm)); @@ -295,13 +295,13 @@ void applyOnePassiveModificationQuotedStructure() { @Test void applyOnePassiveModificationQuotedStructureWithUpTo() { // given - final var targetLawNorm = NormFixtures.loadFromDisk( + final var targetLawNorm = Fixtures.loadNormFromDisk( "NormWithPassiveModsQuotedStructureAndUpTo.xml" ); - final var amendingLawNorm = NormFixtures.loadFromDisk( + final var amendingLawNorm = Fixtures.loadNormFromDisk( "NormWithQuotedStructureModsAndUpTo.xml" ); - final var expectedResult = NormFixtures.loadFromDisk( + final var expectedResult = Fixtures.loadNormFromDisk( "NormWithAppliedQuotedStructureAndUpTo.xml" ); @@ -325,9 +325,9 @@ void applyOnePassiveModificationQuotedStructureWithUpTo() { @Test void applyQuotedTextWithRefs() { // given - final var norm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + final var norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); - final var amendingLaw = NormFixtures.loadFromDisk("NormWithQuotedTextModAndRefs.xml"); + final var amendingLaw = Fixtures.loadNormFromDisk("NormWithQuotedTextModAndRefs.xml"); final Node expectedNode = XmlMapper.toElement( """ @@ -360,9 +360,9 @@ void applyQuotedTextWithRefs() { @Test void applyQuotedTextWithRefsToNodeWithExistingRefs() { // given - final var norm = NormFixtures.loadFromDisk("NormWithPassiveModificationsAndExistingRef.xml"); + final var norm = Fixtures.loadNormFromDisk("NormWithPassiveModificationsAndExistingRef.xml"); - final var amendingLaw = NormFixtures.loadFromDisk("NormWithQuotedTextModAndRefs.xml"); + final var amendingLaw = Fixtures.loadNormFromDisk("NormWithQuotedTextModAndRefs.xml"); when(loadNormPort.loadNorm(any())).thenReturn(Optional.of(amendingLaw)); diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/UpdateNormServiceTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/UpdateNormServiceTest.java index 994bcb4b5..3d996d656 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/UpdateNormServiceTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/application/service/UpdateNormServiceTest.java @@ -23,9 +23,9 @@ class updatePassiveModifications { @Test void itChangesNothingImportantIfPassiveModificationsAlreadyExist() { // Given - Norm amendingLaw = NormFixtures.loadFromDisk("NormWithMods.xml"); - Norm targetLaw = NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml"); - Norm zf0Law = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + Norm amendingLaw = Fixtures.loadNormFromDisk("NormWithMods.xml"); + Norm targetLaw = Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml"); + Norm zf0Law = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); // When var updatedZfoLaw = updateNormService.updateOnePassiveModification( @@ -62,8 +62,8 @@ void itChangesNothingImportantIfPassiveModificationsAlreadyExist() { @Test void itAddsPassiveModificationsIfNoneExist() { // Given - Norm amendingLaw = NormFixtures.loadFromDisk("NormWithMods.xml"); - Norm zf0Law = NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml"); + Norm amendingLaw = Fixtures.loadNormFromDisk("NormWithMods.xml"); + Norm zf0Law = Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml"); // When var updatedZf0Law = updateNormService.updateOnePassiveModification( @@ -109,9 +109,9 @@ void itAddsPassiveModificationsIfNoneExist() { @Test void itAddsMultiplePassiveModificationsIfNoneExist() { // Given - Norm amendingLaw = NormFixtures.loadFromDisk("NormWithMultipleMods.xml"); - Norm targetLaw = NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml"); - Norm zf0Law = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + Norm amendingLaw = Fixtures.loadNormFromDisk("NormWithMultipleMods.xml"); + Norm targetLaw = Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml"); + Norm zf0Law = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); // When var updatedZfoLaw = updateNormService.updateOnePassiveModification( @@ -178,9 +178,9 @@ void itAddsMultiplePassiveModificationsIfNoneExist() { @Test void itAddsPassiveModificationWithoutForcePeriodIfNoneExist() { // Given - Norm amendingLaw = NormFixtures.loadFromDisk("NormWithMods.xml"); + Norm amendingLaw = Fixtures.loadNormFromDisk("NormWithMods.xml"); amendingLaw.deleteByEId("meta-1_analysis-1_activemod-1_textualmod-1_gelzeitnachw-1"); - Norm zf0Law = NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml"); + Norm zf0Law = Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml"); // When var updatedZf0Law = updateNormService.updateOnePassiveModification( @@ -225,7 +225,7 @@ void itAddsPassiveModificationWithoutForcePeriodIfNoneExist() { @Test void itAddsOnePassiveModificationWithUpTo() { // Given - final Norm amendingLaw = NormFixtures.loadFromDisk("NormWithQuotedStructureModsAndUpTo.xml"); + final Norm amendingLaw = Fixtures.loadNormFromDisk("NormWithQuotedStructureModsAndUpTo.xml"); final TextualMod activeMod = amendingLaw .getMeta() .getOrCreateAnalysis() @@ -237,7 +237,7 @@ void itAddsOnePassiveModificationWithUpTo() { ) ); - final Norm zf0Law = NormFixtures.loadFromDisk( + final Norm zf0Law = Fixtures.loadNormFromDisk( "NormWithPassiveModsQuotedStructureAndUpTo.xml" ); final DokumentExpressionEli targetLawELi = DokumentExpressionEli.fromString( @@ -301,8 +301,8 @@ class updateActiveModifications { @Test void itChangesActiveModForQuotedText() { // Given - Norm amendingLaw = NormFixtures.loadFromDisk("NormWithMods.xml"); - Norm targetNorm = NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml"); + Norm amendingLaw = Fixtures.loadNormFromDisk("NormWithMods.xml"); + Norm targetNorm = Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml"); DokumentExpressionEli targetNormEli = targetNorm.getExpressionEli(); String eId = "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1"; String newCharacterRange = "20-25"; @@ -348,8 +348,8 @@ void itChangesActiveModForQuotedText() { @Test void itChangesActiveModForQuotedStructureRangeMod() { // Given - Norm amendingLaw = NormFixtures.loadFromDisk("NormWithQuotedStructureMods.xml"); - Norm targetNorm = NormFixtures.loadFromDisk("NormWithoutPassiveModsQuotedStructure.xml"); + Norm amendingLaw = Fixtures.loadNormFromDisk("NormWithQuotedStructureMods.xml"); + Norm targetNorm = Fixtures.loadNormFromDisk("NormWithoutPassiveModsQuotedStructure.xml"); DokumentExpressionEli targetNormEli = targetNorm.getExpressionEli(); String eId = "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1"; Href newDestinationHref = new Href( @@ -392,8 +392,8 @@ void itChangesActiveModForQuotedStructureRangeMod() { @Test void itChangesActiveModForQuotedStructureSingleTargetMod() { // Given - Norm amendingLaw = NormFixtures.loadFromDisk("NormWithQuotedStructureMods.xml"); - Norm targetNorm = NormFixtures.loadFromDisk("NormWithoutPassiveModsQuotedStructure.xml"); + Norm amendingLaw = Fixtures.loadNormFromDisk("NormWithQuotedStructureMods.xml"); + Norm targetNorm = Fixtures.loadNormFromDisk("NormWithoutPassiveModsQuotedStructure.xml"); DokumentExpressionEli targetNormEli = targetNorm.getExpressionEli(); String eId = "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1"; Href newDestinationHref = new Href( @@ -434,8 +434,8 @@ void itChangesActiveModForQuotedStructureSingleTargetMod() { @Test void itDeletesUpToInActiveModForQuotedStructureSingleTargetMod() { // Given - Norm amendingLawSetup = NormFixtures.loadFromDisk("NormWithQuotedStructureMods.xml"); - Norm targetNormSetup = NormFixtures.loadFromDisk("NormWithoutPassiveModsQuotedStructure.xml"); + Norm amendingLawSetup = Fixtures.loadNormFromDisk("NormWithQuotedStructureMods.xml"); + Norm targetNormSetup = Fixtures.loadNormFromDisk("NormWithoutPassiveModsQuotedStructure.xml"); DokumentExpressionEli targetNormEliSetup = targetNormSetup.getExpressionEli(); String eIdSetup = "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1"; @@ -459,8 +459,8 @@ void itDeletesUpToInActiveModForQuotedStructureSingleTargetMod() { ) ); - Norm amendingLaw = NormFixtures.loadFromDisk("NormWithQuotedStructureMods.xml"); - Norm targetNorm = NormFixtures.loadFromDisk("NormWithoutPassiveModsQuotedStructure.xml"); + Norm amendingLaw = Fixtures.loadNormFromDisk("NormWithQuotedStructureMods.xml"); + Norm targetNorm = Fixtures.loadNormFromDisk("NormWithoutPassiveModsQuotedStructure.xml"); DokumentExpressionEli targetNormEli = targetNorm.getExpressionEli(); String eId = "hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1_text-1_ändbefehl-1"; Href newDestinationHref = new Href( @@ -501,8 +501,8 @@ void itDeletesUpToInActiveModForQuotedStructureSingleTargetMod() { @Test void itReplacesRefWithRrefAfterPassingUpTo() { // Given - final Norm amendingLaw = NormFixtures.loadFromDisk("NormWithQuotedStructureMods.xml"); - final Norm targetNorm = NormFixtures.loadFromDisk( + final Norm amendingLaw = Fixtures.loadNormFromDisk("NormWithQuotedStructureMods.xml"); + final Norm targetNorm = Fixtures.loadNormFromDisk( "NormWithoutPassiveModsQuotedStructure.xml" ); final String modEid = @@ -561,8 +561,8 @@ void itReplacesRefWithRrefAfterPassingUpTo() { @Test void itReplacesRrefWithRefAfterNotPassingUpTo() { // Given - final Norm amendingLaw = NormFixtures.loadFromDisk("NormWithQuotedStructureModsAndUpTo.xml"); - final Norm targetNorm = NormFixtures.loadFromDisk( + final Norm amendingLaw = Fixtures.loadNormFromDisk("NormWithQuotedStructureModsAndUpTo.xml"); + final Norm targetNorm = Fixtures.loadNormFromDisk( "NormWithoutPassiveModsQuotedStructure.xml" ); final String modEid = diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/domain/entity/CharacterRangeTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/domain/entity/CharacterRangeTest.java index d6b2c29d2..7b82869a5 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/domain/entity/CharacterRangeTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/domain/entity/CharacterRangeTest.java @@ -175,7 +175,7 @@ void itShouldFindRangeInAText() { @Test void itShouldFindRangeInAValidatedNormIgnoringIndentation() { // given //when - var norm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml", true); + var norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml", true); var n2 = NodeParser.getNodeFromExpression( "//*[@eId='hauptteil-1_art-1_abs-1_untergl-1_listenelem-1_inhalt-1']", diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/domain/entity/NormFixtures.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/domain/entity/Fixtures.java similarity index 71% rename from backend/src/test/java/de/bund/digitalservice/ris/norms/domain/entity/NormFixtures.java rename to backend/src/test/java/de/bund/digitalservice/ris/norms/domain/entity/Fixtures.java index 56e6063b9..ba80d808c 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/domain/entity/NormFixtures.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/domain/entity/Fixtures.java @@ -9,7 +9,7 @@ import org.apache.commons.io.IOUtils; import org.springframework.core.io.UrlResource; -public class NormFixtures { +public class Fixtures { private static final LdmlDeValidator ldmlDeValidator = new LdmlDeValidator( new UrlResource( @@ -26,29 +26,29 @@ public class NormFixtures { ) ); - public static Norm loadFromDisk(final String fileName) { - return loadFromDisk(fileName, false); + public static Norm loadNormFromDisk(final String fileName) { + return loadNormFromDisk(fileName, false); } - public static String loadTextFromDisk(final String fileName) { - return loadNormFile(fileName); - } - - public static Norm loadFromDisk(final String fileName, boolean validated) { + public static Norm loadNormFromDisk(final String fileName, boolean validated) { if (validated) { - return ldmlDeValidator.parseAndValidate(loadNormFile(fileName)); + return ldmlDeValidator.parseAndValidate(loadFile(fileName)); } return Norm .builder() - .regelungstexte(Set.of(new Regelungstext(XmlMapper.toDocument(loadNormFile(fileName))))) + .regelungstexte(Set.of(new Regelungstext(XmlMapper.toDocument(loadFile(fileName))))) .build(); } - private static String loadNormFile(final String fileName) { + public static String loadTextFromDisk(final String fileName) { + return loadFile(fileName); + } + + private static String loadFile(final String fileName) { try { return IOUtils.toString( - Objects.requireNonNull(NormFixtures.class.getResourceAsStream(fileName)), + Objects.requireNonNull(Fixtures.class.getResourceAsStream(fileName)), StandardCharsets.UTF_8 ); } catch (IOException e) { diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/domain/entity/NormTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/domain/entity/NormTest.java index 8e907b2f2..5d23ae49f 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/domain/entity/NormTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/domain/entity/NormTest.java @@ -26,7 +26,7 @@ class NormTest { @Test void getExpressionEli() { // given - Norm norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + Norm norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); DokumentExpressionEli expectedEli = DokumentExpressionEli.fromString( "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1" ); @@ -41,7 +41,7 @@ void getExpressionEli() { @Test void getWorkEli() { // given - Norm norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + Norm norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); // when var actualEli = norm.getWorkEli(); @@ -784,9 +784,7 @@ void shouldBeUnpublishedByDefaultWhenCreatedUsingBuild() { final Norm norm = Norm .builder() .regelungstexte( - Set.of( - new Regelungstext(XmlMapper.toDocument(NormFixtures.loadTextFromDisk("SimpleNorm.xml"))) - ) + Set.of(new Regelungstext(XmlMapper.toDocument(Fixtures.loadTextFromDisk("SimpleNorm.xml")))) ) .build(); @@ -1133,7 +1131,7 @@ void deleteTimeBoundary() { @Test void getMods() { // given - Norm norm = NormFixtures.loadFromDisk("NormWithMods.xml"); + Norm norm = Fixtures.loadNormFromDisk("NormWithMods.xml"); // when var mods = norm.getMods(); @@ -1147,7 +1145,7 @@ void getMods() { @Test void getStartDateForTemporalGroup() { // given - Norm norm = NormFixtures.loadFromDisk("NormWithMultiplePassiveModifications.xml"); + Norm norm = Fixtures.loadNormFromDisk("NormWithMultiplePassiveModifications.xml"); // when var date = norm.getStartDateForTemporalGroup("meta-1_geltzeiten-1_geltungszeitgr-2"); @@ -1159,7 +1157,7 @@ void getStartDateForTemporalGroup() { @Test void getStartEventRefForTemporalGroup() { // given - Norm norm = NormFixtures.loadFromDisk("NormWithMultiplePassiveModifications.xml"); + Norm norm = Fixtures.loadNormFromDisk("NormWithMultiplePassiveModifications.xml"); // when var eId = norm.getStartEventRefForTemporalGroup("meta-1_geltzeiten-1_geltungszeitgr-2"); @@ -1171,7 +1169,7 @@ void getStartEventRefForTemporalGroup() { @Test void getStartDateForEventRef() { // given - Norm norm = NormFixtures.loadFromDisk("NormWithMultiplePassiveModifications.xml"); + Norm norm = Fixtures.loadNormFromDisk("NormWithMultiplePassiveModifications.xml"); // when var date = norm.getStartDateForEventRef("meta-1_lebzykl-1_ereignis-3"); @@ -1186,7 +1184,7 @@ class createElementWithEidAndGuid { @Test void itShouldCreatesANewElement() { // given - Norm norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + Norm norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); Node parentNode = NodeParser .getNodeFromExpression("//act/meta", norm.getDocument()) .orElseThrow(); @@ -1208,7 +1206,7 @@ class getOrCreateAnalysisNode { @Test void itShouldCreatesTheAnalysisNodeIfItDoesNotExist() { // given - final Norm norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + final Norm norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); // when final var analysis = norm.getMeta().getOrCreateAnalysis(); @@ -1226,7 +1224,7 @@ class getOrCreateTemporalDataNode { @Test void itShouldCreatesTheTemporalDataNodeIfItDoesNotExist() { // given - final Norm norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + final Norm norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); // when final var temporalData = norm.getMeta().getOrCreateTemporalData(); @@ -1240,7 +1238,7 @@ void itShouldCreatesTheTemporalDataNodeIfItDoesNotExist() { @Test void itShouldFindTheTemporalDataNodeIfItExist() { // given - final Norm norm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + final Norm norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); // when final var temporalData = norm.getMeta().getTemporalData(); @@ -1258,7 +1256,7 @@ class deleteByEId { @Test void itShouldDeleteTheNodeOfTheEId() { // given - Norm norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + Norm norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); // when norm.deleteByEId("meta-1_ident-1_frbrexpression-1_frbrthis-1"); @@ -1275,7 +1273,7 @@ class deleteTemporalGroupIfUnused { @Test void itShouldDeleteTemporalGroupIfUnused() { // given - Norm norm = NormFixtures.loadFromDisk("NormWithMods.xml"); + Norm norm = Fixtures.loadNormFromDisk("NormWithMods.xml"); // delete the mod so the temporal group is unused norm.deleteByEId("meta-1_analysis-1_activemod-1"); @@ -1289,7 +1287,7 @@ void itShouldDeleteTemporalGroupIfUnused() { @Test void itShouldNotDeleteTemporalGroupIfUsed() { // given - Norm norm = NormFixtures.loadFromDisk("NormWithMods.xml"); + Norm norm = Fixtures.loadNormFromDisk("NormWithMods.xml"); // when norm.deleteTemporalGroupIfUnused("meta-1_geltzeiten-1_geltungszeitgr-1"); @@ -1305,7 +1303,7 @@ class deleteEventRefIfUnused { @Test void itShouldDeleteEventRefIfUnused() { // given - Norm norm = NormFixtures.loadFromDisk("NormWithMods.xml"); + Norm norm = Fixtures.loadNormFromDisk("NormWithMods.xml"); // delete the mod so the temporal group is unused norm.deleteByEId("meta-1_analysis-1_activemod-1"); @@ -1325,7 +1323,7 @@ void itShouldDeleteEventRefIfUnused() { @Test void itShouldNotDeleteEventRefIfUsed() { // given - Norm norm = NormFixtures.loadFromDisk("NormWithMods.xml"); + Norm norm = Fixtures.loadNormFromDisk("NormWithMods.xml"); assertThat( NodeParser.getNodeFromExpression( diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/AnnouncementControllerIntegrationTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/AnnouncementControllerIntegrationTest.java index f59731d86..4667b87c4 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/AnnouncementControllerIntegrationTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/AnnouncementControllerIntegrationTest.java @@ -593,7 +593,7 @@ void itDoesNotReleaseBecauseAmendingLawNotFound() throws Exception { @Test void itDoesNotReleaseButReturnsNotFoundIfTargetLawNotFound() throws Exception { // Given - var amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); + var amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); var announcement = Announcement.builder().eli(amendingNorm.getExpressionEli()).build(); normRepository.save(NormMapper.mapToDto(amendingNorm)); announcementRepository.save(AnnouncementMapper.mapToDto(announcement)); @@ -630,9 +630,9 @@ void itDoesNotReleaseButReturnsNotFoundIfTargetLawNotFound() throws Exception { @Test void itReleaseAnnouncement() throws Exception { // Given - var amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); - var affectedNorm = NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml"); - var affectedNormZf0 = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + var amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); + var affectedNorm = Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml"); + var affectedNormZf0 = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); var announcement = Announcement.builder().eli(amendingNorm.getExpressionEli()).build(); normRepository.save(NormMapper.mapToDto(amendingNorm)); @@ -722,10 +722,10 @@ void itReleaseAnnouncement() throws Exception { void releasingAnAnnouncementASecondTimeCreatesTheSameFilesAndCleansUpOldRelease() throws Exception { // Given - var amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); - var affectedNorm = NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml"); + var amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); + var affectedNorm = Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml"); affectedNorm.setPublishState(NormPublishState.PUBLISHED); - var affectedNormZf0 = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + var affectedNormZf0 = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); var announcement = Announcement.builder().eli(amendingNorm.getExpressionEli()).build(); normRepository.save(NormMapper.mapToDto(amendingNorm)); @@ -806,9 +806,9 @@ void releasingAnAnnouncementASecondTimeCreatesTheSameFilesAndCleansUpOldRelease( @Test void failsWhenTryingToReleaseAnXsdInvalidNorm() throws Exception { // Given - var amendingNorm = NormFixtures.loadFromDisk("NormWithModsXsdInvalid.xml"); - var affectedNorm = NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml"); - var affectedNormZf0 = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + var amendingNorm = Fixtures.loadNormFromDisk("NormWithModsXsdInvalid.xml"); + var affectedNorm = Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml"); + var affectedNormZf0 = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); affectedNormZf0.setPublishState(NormPublishState.QUEUED_FOR_PUBLISH); var announcement = Announcement.builder().eli(amendingNorm.getExpressionEli()).build(); @@ -857,9 +857,9 @@ void failsWhenTryingToReleaseAnXsdInvalidNorm() throws Exception { @Test void failsWhenTryingToReleaseASchematronInvalidNorm() throws Exception { // Given - var amendingNorm = NormFixtures.loadFromDisk("NormWithModsSchematronInvalid.xml"); - var affectedNorm = NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml"); - var affectedNormZf0 = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + var amendingNorm = Fixtures.loadNormFromDisk("NormWithModsSchematronInvalid.xml"); + var affectedNorm = Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml"); + var affectedNormZf0 = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); var announcement = Announcement.builder().eli(amendingNorm.getExpressionEli()).build(); normRepository.save(NormMapper.mapToDto(amendingNorm)); @@ -908,8 +908,8 @@ class postAnnouncement { @Test void itCreatesANewAnnouncement() throws Exception { // Given - var norm = NormFixtures.loadFromDisk("NormWithMods.xml"); - var affectedNorm = NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithMods.xml"); + var affectedNorm = Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml"); normRepository.save(NormMapper.mapToDto(affectedNorm)); @@ -986,7 +986,7 @@ void itFailsIfTheXmlIsNotLdmlDe() throws Exception { @Test void itFailsIfTheAffectedNormDoesNotExist() throws Exception { // Given - var norm = NormFixtures.loadFromDisk("NormWithMods.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithMods.xml"); var xmlContent = XmlMapper.toString(norm.getDocument()); var file = new MockMultipartFile( @@ -1015,8 +1015,8 @@ void itFailsIfTheAffectedNormDoesNotExist() throws Exception { @Test void itFailsIfTheNormAlreadyExist() throws Exception { // Given - var norm = NormFixtures.loadFromDisk("NormWithMods.xml"); - var affectedNorm = NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithMods.xml"); + var affectedNorm = Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml"); normRepository.save(NormMapper.mapToDto(affectedNorm)); normRepository.save(NormMapper.mapToDto(norm)); @@ -1039,12 +1039,12 @@ void itFailsIfTheNormAlreadyExist() throws Exception { @Test void itFailsIfANormWithSameGuidAlreadyExist() throws Exception { // Given - var normWithSameGuid = NormFixtures.loadFromDisk("NormWithMods.xml"); - var affectedNormForNormWithSameGuid = NormFixtures.loadFromDisk( + var normWithSameGuid = Fixtures.loadNormFromDisk("NormWithMods.xml"); + var affectedNormForNormWithSameGuid = Fixtures.loadNormFromDisk( "NormWithoutPassiveModifications.xml" ); - var norm = NormFixtures.loadFromDisk("NormWithQuotedStructureMods.xml"); - var affectedNorm = NormFixtures.loadFromDisk("NormWithPassiveModsQuotedStructure.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithQuotedStructureMods.xml"); + var affectedNorm = Fixtures.loadNormFromDisk("NormWithPassiveModsQuotedStructure.xml"); normRepository.save(NormMapper.mapToDto(affectedNormForNormWithSameGuid)); normRepository.save(NormMapper.mapToDto(affectedNorm)); @@ -1069,8 +1069,8 @@ void itFailsIfANormWithSameGuidAlreadyExist() throws Exception { @Test void itFailsIfTheNormIsInvalid() throws Exception { // Given - var norm = NormFixtures.loadFromDisk("NormWithModsXsdInvalid.xml"); - var affectedNorm = NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithModsXsdInvalid.xml"); + var affectedNorm = Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml"); normRepository.save(NormMapper.mapToDto(affectedNorm)); @@ -1095,8 +1095,8 @@ void itFailsIfTheNormIsInvalid() throws Exception { @Test void itFailsIfTheNormIsSchematronInvalid() throws Exception { // Given - var norm = NormFixtures.loadFromDisk("NormWithModsSchematronInvalid.xml"); - var affectedNorm = NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithModsSchematronInvalid.xml"); + var affectedNorm = Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml"); normRepository.save(NormMapper.mapToDto(affectedNorm)); @@ -1164,10 +1164,10 @@ void itFailsIfTheNormIsSchematronInvalid() throws Exception { @Test void ifCreatesAnnouncementWithForce() throws Exception { // Given - var norm = NormFixtures.loadFromDisk("NormWithMods.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithMods.xml"); var announcement = Announcement.builder().eli(norm.getExpressionEli()).build(); - var affectedNorm = NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml"); // eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1" - var affectedNormZf0 = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); // the one for the existing amending norm; eli/bund/bgbl-1/1964/s593/2022-08-23/1/deu/regelungstext-1" + var affectedNorm = Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml"); // eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1" + var affectedNormZf0 = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); // the one for the existing amending norm; eli/bund/bgbl-1/1964/s593/2022-08-23/1/deu/regelungstext-1" normRepository.save(NormMapper.mapToDto(norm)); normRepository.save(NormMapper.mapToDto(affectedNorm)); diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/ArticleControllerIntegrationTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/ArticleControllerIntegrationTest.java index a8c4aa7fb..45778dcf7 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/ArticleControllerIntegrationTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/ArticleControllerIntegrationTest.java @@ -7,8 +7,8 @@ import de.bund.digitalservice.ris.norms.adapter.output.database.mapper.NormMapper; import de.bund.digitalservice.ris.norms.adapter.output.database.repository.NormRepository; +import de.bund.digitalservice.ris.norms.domain.entity.Fixtures; import de.bund.digitalservice.ris.norms.domain.entity.Norm; -import de.bund.digitalservice.ris.norms.domain.entity.NormFixtures; import de.bund.digitalservice.ris.norms.domain.entity.Regelungstext; import de.bund.digitalservice.ris.norms.integration.BaseIntegrationTest; import de.bund.digitalservice.ris.norms.utils.XmlMapper; @@ -42,12 +42,12 @@ class getArticles { @Test void itReturnsArticles() throws Exception { // Given - normRepository.save(NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithMods.xml"))); + normRepository.save(NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithMods.xml"))); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml")) ); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithPassiveModifications.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml")) ); // When // Then @@ -73,7 +73,7 @@ void itReturnsArticles() throws Exception { @Test void itReturnsArticlesFilteredByAmendedAt() throws Exception { // Given - var affectedNorm = NormFixtures.loadFromDisk("NormWithMultiplePassiveModifications.xml"); + var affectedNorm = Fixtures.loadNormFromDisk("NormWithMultiplePassiveModifications.xml"); normRepository.save(NormMapper.mapToDto(affectedNorm)); // When // Then @@ -93,7 +93,7 @@ void itReturnsArticlesFilteredByAmendedAt() throws Exception { @Test void itReturnsArticlesFilteredByAmendedBy() throws Exception { // Given - var affectedNorm = NormFixtures.loadFromDisk( + var affectedNorm = Fixtures.loadNormFromDisk( "NormWithPassiveModificationsInDifferentArticles.xml" ); normRepository.save(NormMapper.mapToDto(affectedNorm)); @@ -115,7 +115,7 @@ void itReturnsArticlesFilteredByAmendedBy() throws Exception { @Test void itReturnsEmptyListWhenTheNormHasNoArticles() throws Exception { // Given - var affectedNorm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + var affectedNorm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); normRepository.save(NormMapper.mapToDto(affectedNorm)); // When // Then @@ -131,7 +131,7 @@ void itReturnsEmptyListWhenTheNormHasNoArticles() throws Exception { @Test void itReturnsEmptyListIfAmendedByIsNotFound() throws Exception { // Given - var norm = NormFixtures.loadFromDisk("NormWithMultiplePassiveModifications.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithMultiplePassiveModifications.xml"); normRepository.save(NormMapper.mapToDto(norm)); // When / Then @@ -149,7 +149,7 @@ void itReturnsEmptyListIfAmendedByIsNotFound() throws Exception { @Test void itReturnsEmptyListIfAmendedAtIsNotFound() throws Exception { // Given - var norm = NormFixtures.loadFromDisk("NormWithMultiplePassiveModifications.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithMultiplePassiveModifications.xml"); normRepository.save(NormMapper.mapToDto(norm)); // When / Then @@ -204,7 +204,7 @@ class getArticlesRender { @Test void itReturnsTheXmlOfArticles() throws Exception { // Given - var amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); + var amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); normRepository.save(NormMapper.mapToDto(amendingNorm)); // When // Then @@ -242,7 +242,7 @@ void itReturnsTheXmlOfArticles() throws Exception { @Test void itReturnsTheXmlOfTheArticleInkrafttreten() throws Exception { // Given - var amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); + var amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); normRepository.save(NormMapper.mapToDto(amendingNorm)); @@ -319,7 +319,7 @@ void itReturnsNotFoundIfTheNormDoesntExist() throws Exception { @Test void itReturnsNotFoundIfNoArticleOfTypeExist() throws Exception { // Given - var norm = NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml"); normRepository.save(NormMapper.mapToDto(norm)); @@ -356,7 +356,7 @@ void itReturnsNotFoundIfNoArticleOfTypeExist() throws Exception { @Test void itReturnsNotFoundIfTheNormHasNoArticles() throws Exception { // Given - var amendingNorm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + var amendingNorm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); normRepository.save(NormMapper.mapToDto(amendingNorm)); @@ -398,12 +398,12 @@ class getArticle { void itReturnsArticle() throws Exception { // Given - normRepository.save(NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithMods.xml"))); + normRepository.save(NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithMods.xml"))); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml")) ); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithPassiveModifications.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml")) ); // When // Then @@ -459,7 +459,7 @@ void itReturnsNothingIfNormDoesNotExist() throws Exception { @Test void itReturnsNothingIfArticleDoesNotExist() throws Exception { // Given - normRepository.save(NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithMods.xml"))); + normRepository.save(NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithMods.xml"))); // When // Then mockMvc @@ -498,7 +498,7 @@ class getArticleRender { @Test void itReturnsArticleRender() throws Exception { // Given - var amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); + var amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); normRepository.save(NormMapper.mapToDto(amendingNorm)); @@ -521,8 +521,8 @@ void itReturnsArticleRender() throws Exception { @Test void itReturnsArticleRenderAtIsoDate() throws Exception { // Given - var amendingNorm = NormFixtures.loadFromDisk("NormWithMultipleMods.xml"); - var targetNorm = NormFixtures.loadFromDisk("NormWithMultiplePassiveModifications.xml"); + var amendingNorm = Fixtures.loadNormFromDisk("NormWithMultipleMods.xml"); + var targetNorm = Fixtures.loadNormFromDisk("NormWithMultiplePassiveModifications.xml"); normRepository.save(NormMapper.mapToDto(amendingNorm)); normRepository.save(NormMapper.mapToDto(targetNorm)); @@ -602,8 +602,8 @@ void itReturnsNotFoundIfNormDoesntExist() throws Exception { @Test void itReturnsNotFoundIfArticleDoesntExist() throws Exception { // Given - var amendingNorm = NormFixtures.loadFromDisk("NormWithMultipleMods.xml"); - var targetNorm = NormFixtures.loadFromDisk("NormWithMultiplePassiveModifications.xml"); + var amendingNorm = Fixtures.loadNormFromDisk("NormWithMultipleMods.xml"); + var targetNorm = Fixtures.loadNormFromDisk("NormWithMultiplePassiveModifications.xml"); normRepository.save(NormMapper.mapToDto(amendingNorm)); normRepository.save(NormMapper.mapToDto(targetNorm)); @@ -711,7 +711,7 @@ void itThrowsValidationExceptionBecauseWithinTimeMachineMetaModDoesNotHaveSource ) ) .build(); - final Norm amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); + final Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); normRepository.save(NormMapper.mapToDto(amendingNorm)); normRepository.save(NormMapper.mapToDto(targetNorm)); @@ -813,7 +813,7 @@ void itThrowsMandatoryNodeNotFoundBecauseTemporalDataMissing() throws Exception ) ) .build(); - final Norm amendingNorm = NormFixtures.loadFromDisk("NormWithMods.xml"); + final Norm amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); normRepository.save(NormMapper.mapToDto(amendingNorm)); normRepository.save(NormMapper.mapToDto(targetNorm)); diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/ElementControllerIntegrationTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/ElementControllerIntegrationTest.java index c8cd54b3e..b7ef877b8 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/ElementControllerIntegrationTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/ElementControllerIntegrationTest.java @@ -7,7 +7,7 @@ import de.bund.digitalservice.ris.norms.adapter.output.database.mapper.NormMapper; import de.bund.digitalservice.ris.norms.adapter.output.database.repository.NormRepository; -import de.bund.digitalservice.ris.norms.domain.entity.NormFixtures; +import de.bund.digitalservice.ris.norms.domain.entity.Fixtures; import de.bund.digitalservice.ris.norms.integration.BaseIntegrationTest; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Nested; @@ -73,7 +73,7 @@ void returnsNotFoundIfNormNotFoundByEli() throws Exception { @Test void returnsNotFoundIfElementNotFoundByEid() throws Exception { // Given - var norm = NormFixtures.loadFromDisk("NormWithMultipleMods.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithMultipleMods.xml"); normRepository.save(NormMapper.mapToDto(norm)); // When @@ -110,7 +110,7 @@ void returnsNotFoundIfElementNotFoundByEid() throws Exception { @Test void returnsElementRenderedAsHtml() throws Exception { // Given - var norm = NormFixtures.loadFromDisk("NormWithMultipleMods.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithMultipleMods.xml"); normRepository.save(NormMapper.mapToDto(norm)); // When @@ -129,8 +129,8 @@ void returnsElementRenderedAsHtml() throws Exception { @Test void returnsElementAtGivenIsoDateRenderedAsHtml() throws Exception { // Given - var amendingNorm = NormFixtures.loadFromDisk("NormWithMultipleMods.xml"); - var targetNorm = NormFixtures.loadFromDisk("NormWithMultiplePassiveModifications.xml"); + var amendingNorm = Fixtures.loadNormFromDisk("NormWithMultipleMods.xml"); + var targetNorm = Fixtures.loadNormFromDisk("NormWithMultiplePassiveModifications.xml"); normRepository.save(NormMapper.mapToDto(amendingNorm)); normRepository.save(NormMapper.mapToDto(targetNorm)); @@ -217,7 +217,7 @@ void returnsNotFoundIfNormNotFoundByEli() throws Exception { @Test void returnsNotFoundIfElementNotFoundByEid() throws Exception { // Given - var norm = NormFixtures.loadFromDisk("NormWithMultipleMods.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithMultipleMods.xml"); normRepository.save(NormMapper.mapToDto(norm)); // When @@ -254,7 +254,7 @@ void returnsNotFoundIfElementNotFoundByEid() throws Exception { @Test void returnElementEidTitleAndType() throws Exception { // Given - var norm = NormFixtures.loadFromDisk("NormWithMultipleMods.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithMultipleMods.xml"); normRepository.save(NormMapper.mapToDto(norm)); // When @@ -367,7 +367,7 @@ void itReturnsNotFoundIfNormIsNotFound() throws Exception { @Test void itReturnsEmptyListIfNoMatchingElementsAreFound() throws Exception { // Given - var norm = NormFixtures.loadFromDisk("NormWithMultipleMods.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithMultipleMods.xml"); normRepository.save(NormMapper.mapToDto(norm)); // When @@ -385,7 +385,7 @@ void itReturnsEmptyListIfNoMatchingElementsAreFound() throws Exception { @Test void itReturnsEntriesWithPrefacePreambleArticleAndConclusionInformation() throws Exception { // Given - var norm = NormFixtures.loadFromDisk("NormWithPrefacePreambleAndConclusions.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithPrefacePreambleAndConclusions.xml"); normRepository.save(NormMapper.mapToDto(norm)); var url = "/api/v1/norms/eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/regelungstext-1/elements" + @@ -425,7 +425,7 @@ void itReturnsEntriesWithPrefacePreambleArticleAndConclusionInformation() throws void itReturnsEntriesWithBookPartChapterTitleSubtitleSectionAndSubsectionInformation() throws Exception { // Given - var norm = NormFixtures.loadFromDisk("NormWithGliederung.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithGliederung.xml"); normRepository.save(NormMapper.mapToDto(norm)); var url = "/api/v1/norms/eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/regelungstext-1/elements" + @@ -490,9 +490,9 @@ void itReturnsEntriesWithBookPartChapterTitleSubtitleSectionAndSubsectionInforma @Test void itReturnsAnEmptyListIfNoElementIsAffectedByTheGivenAmendingLaw() throws Exception { // Given - var targetNorm = NormFixtures.loadFromDisk("NormWithMultiplePassiveModifications.xml"); + var targetNorm = Fixtures.loadNormFromDisk("NormWithMultiplePassiveModifications.xml"); normRepository.save(NormMapper.mapToDto(targetNorm)); - var amendingNorm = NormFixtures.loadFromDisk("NormWithPrefacePreambleAndConclusions.xml"); + var amendingNorm = Fixtures.loadNormFromDisk("NormWithPrefacePreambleAndConclusions.xml"); normRepository.save(NormMapper.mapToDto(amendingNorm)); var url = @@ -514,7 +514,7 @@ void itReturnsAnEmptyListIfNoElementIsAffectedByTheGivenAmendingLaw() throws Exc @Test void itReturnsOnlyTheElementsMatchingTheGivenAmendingLaw() throws Exception { - var targetNorm = NormFixtures.loadFromDisk( + var targetNorm = Fixtures.loadNormFromDisk( "NormWithPassiveModificationsInDifferentArticles.xml" ); normRepository.save(NormMapper.mapToDto(targetNorm)); diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/NormExpressionControllerIntegrationTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/NormExpressionControllerIntegrationTest.java index f3ccbac23..0aebe1b8c 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/NormExpressionControllerIntegrationTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/NormExpressionControllerIntegrationTest.java @@ -8,9 +8,9 @@ import de.bund.digitalservice.ris.norms.XmlMatcher; import de.bund.digitalservice.ris.norms.adapter.output.database.mapper.NormMapper; import de.bund.digitalservice.ris.norms.adapter.output.database.repository.NormRepository; +import de.bund.digitalservice.ris.norms.domain.entity.Fixtures; import de.bund.digitalservice.ris.norms.domain.entity.Href; import de.bund.digitalservice.ris.norms.domain.entity.Norm; -import de.bund.digitalservice.ris.norms.domain.entity.NormFixtures; import de.bund.digitalservice.ris.norms.domain.entity.Regelungstext; import de.bund.digitalservice.ris.norms.domain.entity.eli.DokumentExpressionEli; import de.bund.digitalservice.ris.norms.integration.BaseIntegrationTest; @@ -48,7 +48,7 @@ class GetNormByEli { @Test void itCallsNormsServiceAndReturnsNorm() throws Exception { // Given - normRepository.save(NormMapper.mapToDto(NormFixtures.loadFromDisk("Vereinsgesetz.xml"))); + normRepository.save(NormMapper.mapToDto(Fixtures.loadNormFromDisk("Vereinsgesetz.xml"))); // When // Then mockMvc @@ -69,7 +69,7 @@ void itCallsNormsServiceAndReturnsNorm() throws Exception { @Test void itCallsNormsServiceAndReturnsNormXml() throws Exception { // Given - normRepository.save(NormMapper.mapToDto(NormFixtures.loadFromDisk("Vereinsgesetz.xml"))); + normRepository.save(NormMapper.mapToDto(Fixtures.loadNormFromDisk("Vereinsgesetz.xml"))); // When // Then mockMvc @@ -88,7 +88,7 @@ void itCallsNormsServiceAndReturnsNormXml() throws Exception { void itCallsNormServiceAndReturnsNormRender() throws Exception { // Given normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("Vereinsgesetz_2017_s419_2017-03-15.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("Vereinsgesetz_2017_s419_2017-03-15.xml")) ); // When // Then @@ -118,7 +118,7 @@ class GetNormRenderWithQueryParameters { @Test void itCallsNormServiceAndReturnsNormRenderWithMetadata() throws Exception { // Given - normRepository.save(NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithMods.xml"))); + normRepository.save(NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithMods.xml"))); // When // Then mockMvc @@ -152,7 +152,7 @@ void itCallsNormServiceAndReturnsNormRenderWithMetadata() throws Exception { @Test void itReturnsBadRequestWhenRenderingAtInvalidIsoDate() throws Exception { // Given - normRepository.save(NormMapper.mapToDto(NormFixtures.loadFromDisk("SimpleNorm.xml"))); + normRepository.save(NormMapper.mapToDto(Fixtures.loadNormFromDisk("SimpleNorm.xml"))); // When // Then mockMvc @@ -176,7 +176,7 @@ void itReturnsBadRequestWhenRenderingAtInvalidIsoDate() throws Exception { @Test void itReturnsHtmlWhenRenderingAtValidTimeBoundary() throws Exception { // Given - normRepository.save(NormMapper.mapToDto(NormFixtures.loadFromDisk("SimpleNorm.xml"))); + normRepository.save(NormMapper.mapToDto(Fixtures.loadNormFromDisk("SimpleNorm.xml"))); // When // Then mockMvc @@ -231,7 +231,7 @@ void itReturnsNormNotFound() throws Exception { @Test void itThrowsInvalidUpdateExceptionBecauseEliChanged() throws Exception { // Given - normRepository.save(NormMapper.mapToDto(NormFixtures.loadFromDisk("SimpleNorm.xml"))); + normRepository.save(NormMapper.mapToDto(Fixtures.loadNormFromDisk("SimpleNorm.xml"))); var newXml = """ @@ -289,7 +289,7 @@ void itThrowsInvalidUpdateExceptionBecauseEliChanged() throws Exception { @Test void itThrowsInvalidUpdateExceptionBecauseGuidChanged() throws Exception { // Given - normRepository.save(NormMapper.mapToDto(NormFixtures.loadFromDisk("SimpleNorm.xml"))); + normRepository.save(NormMapper.mapToDto(Fixtures.loadNormFromDisk("SimpleNorm.xml"))); var newXml = """ @@ -347,7 +347,7 @@ void itThrowsInvalidUpdateExceptionBecauseGuidChanged() throws Exception { @Test void itCallsNormServiceAndUpdatesNorm() throws Exception { // Given - normRepository.save(NormMapper.mapToDto(NormFixtures.loadFromDisk("SimpleNorm.xml"))); + normRepository.save(NormMapper.mapToDto(Fixtures.loadNormFromDisk("SimpleNorm.xml"))); var newXml = """ @@ -428,7 +428,7 @@ class GetNormTimeBoundaries { @Test void itExtractsAndReturnsTimeBoundariesFromNorm() throws Exception { // Given - var norm = NormFixtures.loadFromDisk("NormWithMods.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithMods.xml"); normRepository.save(NormMapper.mapToDto(norm)); // When // Then @@ -573,7 +573,7 @@ void itReturns404NotFound() throws Exception { @Test void itThrowsValidationExceptionBecauseDestinationHrefHasNoEli() throws Exception { // Given - normRepository.save(NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithMods.xml"))); + normRepository.save(NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithMods.xml"))); final String eli = "eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/regelungstext-1"; final String destinationHref = "#destination-href-without-eli"; @@ -618,12 +618,12 @@ void itThrowsValidationExceptionBecauseDestinationHrefHasNoEli() throws Exceptio @Test void itThrowsValidationExceptionBecauseModWithGivenEidNotFound() throws Exception { - normRepository.save(NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithMods.xml"))); + normRepository.save(NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithMods.xml"))); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml")) ); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithPassiveModifications.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml")) ); final String eli = "eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/regelungstext-1"; @@ -669,12 +669,12 @@ void itThrowsValidationExceptionBecauseModWithGivenEidNotFound() throws Exceptio @ValueSource(strings = { "", "?dryRun=true" }) void itUpdatesAQuotedTextMod(String queryParameters) throws Exception { // When - normRepository.save(NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithMods.xml"))); + normRepository.save(NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithMods.xml"))); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml")) ); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithPassiveModifications.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml")) ); String path = @@ -779,11 +779,11 @@ void itUpdatesAQuotedTextMod(String queryParameters) throws Exception { void itUpdatesAQuotedTextModBasedOnPreviousChange() throws Exception { // When normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithModsSameTarget.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithModsSameTarget.xml")) ); normRepository.save( NormMapper.mapToDto( - NormFixtures.loadFromDisk("NormWithoutPassiveModificationsSameTarget.xml") + Fixtures.loadNormFromDisk("NormWithoutPassiveModificationsSameTarget.xml") ) ); @@ -889,13 +889,13 @@ void itUpdatesAQuotedTextModBasedOnPreviousChange() throws Exception { void itUpdatesAQuotedStructureMod() throws Exception { // When normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithQuotedStructureMods.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithQuotedStructureMods.xml")) ); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithoutPassiveModsQuotedStructure.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithoutPassiveModsQuotedStructure.xml")) ); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithPassiveModsQuotedStructure.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithPassiveModsQuotedStructure.xml")) ); String refersTo = "THIS_IS_NOT_BEING_HANDLED"; @@ -989,13 +989,13 @@ void itUpdatesAQuotedStructureMod() throws Exception { void itUpdatesAQuotedStructureModFromRefToRref() throws Exception { // When normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithQuotedStructureMods.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithQuotedStructureMods.xml")) ); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithoutPassiveModsQuotedStructure.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithoutPassiveModsQuotedStructure.xml")) ); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithPassiveModsQuotedStructure.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithPassiveModsQuotedStructure.xml")) ); String refersTo = "THIS_IS_NOT_BEING_HANDLED"; @@ -1101,19 +1101,19 @@ void itUpdatesAQuotedStructureModFromRefToRref() throws Exception { void itUpdatesAQuotedStructureModFromRrefToRef() throws Exception { // When normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithQuotedStructureModsAndUpTo.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithQuotedStructureModsAndUpTo.xml")) ); normRepository.save( NormMapper.mapToDto( - NormFixtures.loadFromDisk("NormWithoutPassiveModsQuotedStructureAndUpTo.xml") + Fixtures.loadNormFromDisk("NormWithoutPassiveModsQuotedStructureAndUpTo.xml") ) ); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithoutPassiveModsQuotedStructure.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithoutPassiveModsQuotedStructure.xml")) ); normRepository.save( NormMapper.mapToDto( - NormFixtures.loadFromDisk("NormWithPassiveModsQuotedStructureAndUpTo.xml") + Fixtures.loadNormFromDisk("NormWithPassiveModsQuotedStructureAndUpTo.xml") ) ); @@ -1185,12 +1185,12 @@ void itUpdatesAQuotedStructureModFromRrefToRef() throws Exception { @Test void itThrowsValidationExceptionBecauseCharacterRangeNotPresent() throws Exception { // When - normRepository.save(NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithMods.xml"))); + normRepository.save(NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithMods.xml"))); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml")) ); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithPassiveModifications.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml")) ); String path = @@ -1255,12 +1255,12 @@ void itThrowsValidationExceptionBecauseCharacterRangeNotPresent() throws Excepti @Test void itThrowsValidationExceptionBecauseCharacterRangeHasInvalidFormat() throws Exception { // When - normRepository.save(NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithMods.xml"))); + normRepository.save(NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithMods.xml"))); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml")) ); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithPassiveModifications.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml")) ); String path = @@ -1323,12 +1323,12 @@ void itThrowsValidationExceptionBecauseCharacterRangeHasInvalidFormat() throws E void itThrowsValidationExceptionBecauseCharacterRangeDoesNotResolveToTargetText() throws Exception { // When - normRepository.save(NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithMods.xml"))); + normRepository.save(NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithMods.xml"))); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml")) ); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithPassiveModifications.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml")) ); String path = @@ -1390,12 +1390,12 @@ void itThrowsValidationExceptionBecauseCharacterRangeDoesNotResolveToTargetText( @Test void itThrowsValidationExceptionBecauseCharacterRangeNotWithinNodeRange() throws Exception { // When - normRepository.save(NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithMods.xml"))); + normRepository.save(NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithMods.xml"))); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml")) ); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithPassiveModifications.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml")) ); String path = @@ -1458,12 +1458,12 @@ void itThrowsValidationExceptionBecauseCharacterRangeNotWithinNodeRange() throws @Test void itThrowsValidationExceptionBecauseTargetNodeNotPresent() throws Exception { // When - normRepository.save(NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithMods.xml"))); + normRepository.save(NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithMods.xml"))); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml")) ); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithPassiveModifications.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml")) ); String path = @@ -1529,13 +1529,13 @@ void itThrowsValidationExceptionBecauseTargetNodeNotPresent() throws Exception { void itThrowsValidationExceptionBecauseTargetUptoNodeNotPresent() throws Exception { // When normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithQuotedStructureMods.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithQuotedStructureMods.xml")) ); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithoutPassiveModsQuotedStructure.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithoutPassiveModsQuotedStructure.xml")) ); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithPassiveModsQuotedStructure.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithPassiveModsQuotedStructure.xml")) ); String refersTo = "THIS_IS_NOT_BEING_HANDLED"; @@ -1603,13 +1603,13 @@ void itThrowsValidationExceptionBecauseTargetUptoNodeNotPresent() throws Excepti void itThrowsValidationExceptionBecauseTargetNodeAndUptoNodeNotSiblings() throws Exception { // When normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithQuotedStructureMods.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithQuotedStructureMods.xml")) ); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithoutPassiveModsQuotedStructure.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithoutPassiveModsQuotedStructure.xml")) ); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithPassiveModsQuotedStructure.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithPassiveModsQuotedStructure.xml")) ); String refersTo = "THIS_IS_NOT_BEING_HANDLED"; @@ -1678,13 +1678,13 @@ void itThrowsValidationExceptionBecauseTargetNodeAndUptoNodeNotSiblings() throws void itThrowsValidationExceptionBecauseTargetNodeAfterUptoNode() throws Exception { // When normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithQuotedStructureMods.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithQuotedStructureMods.xml")) ); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithoutPassiveModsQuotedStructure.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithoutPassiveModsQuotedStructure.xml")) ); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithPassiveModsQuotedStructure.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithPassiveModsQuotedStructure.xml")) ); String refersTo = "THIS_IS_NOT_BEING_HANDLED"; @@ -1798,7 +1798,7 @@ void itReturnsNormNotFoundAsEliNotFound() throws Exception { @Test void itThrowsInvalidUpdateExceptionBecauseModEidNotInAmendingLaw() throws Exception { // Given - normRepository.save(NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithMods.xml"))); + normRepository.save(NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithMods.xml"))); final String eli = "eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/regelungstext-1"; // When @@ -1829,7 +1829,7 @@ void itThrowsInvalidUpdateExceptionBecauseModEidNotInAmendingLaw() throws Except @Test void itThrowsInvalidateUpdateExceptionBecauseTargetHrefWithoutEli() throws Exception { // Given - final Norm norm = NormFixtures.loadFromDisk("NormWithMods.xml"); + final Norm norm = Fixtures.loadNormFromDisk("NormWithMods.xml"); norm .getMods() .stream() @@ -1874,7 +1874,7 @@ void itThrowsInvalidateUpdateExceptionBecauseTargetHrefWithoutEli() throws Excep @Test void itThrowsInvalidateUpdateExceptionBecauseModsWithoutSameTarget() throws Exception { // Given - final Norm norm = NormFixtures.loadFromDisk("NormWithMultipleMods.xml"); + final Norm norm = Fixtures.loadNormFromDisk("NormWithMultipleMods.xml"); norm .getMods() .stream() @@ -1924,12 +1924,12 @@ void itThrowsInvalidateUpdateExceptionBecauseModsWithoutSameTarget() throws Exce @Test void itUpdatesASingleMod() throws Exception { // When - normRepository.save(NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithMods.xml"))); + normRepository.save(NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithMods.xml"))); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml")) ); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithPassiveModifications.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml")) ); // When @@ -2051,10 +2051,10 @@ void itUpdatesASingleMod() throws Exception { void itUpdatesMultipleMods() throws Exception { // When normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithMultipleSimpleMods.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithMultipleSimpleMods.xml")) ); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithMultipleSimpleModsTargetNorm.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithMultipleSimpleModsTargetNorm.xml")) ); // When @@ -2146,12 +2146,12 @@ void itUpdatesMultipleMods() throws Exception { @Test void itDryRunsTheUpdate() throws Exception { // When - normRepository.save(NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithMods.xml"))); + normRepository.save(NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithMods.xml"))); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml")) ); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithPassiveModifications.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml")) ); // When @@ -2214,12 +2214,12 @@ void itDryRunsTheUpdate() throws Exception { @Test void itReturnsBadRequestAndDoesNotSaveIt() throws Exception { // When - normRepository.save(NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithMods.xml"))); + normRepository.save(NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithMods.xml"))); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml")) ); normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithPassiveModifications.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml")) ); // When (the eid does not exist) diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/NormManifestationControllerIntegrationTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/NormManifestationControllerIntegrationTest.java index eeef752f0..9e1260136 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/NormManifestationControllerIntegrationTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/NormManifestationControllerIntegrationTest.java @@ -5,7 +5,7 @@ import de.bund.digitalservice.ris.norms.adapter.output.database.mapper.NormMapper; import de.bund.digitalservice.ris.norms.adapter.output.database.repository.NormRepository; -import de.bund.digitalservice.ris.norms.domain.entity.NormFixtures; +import de.bund.digitalservice.ris.norms.domain.entity.Fixtures; import de.bund.digitalservice.ris.norms.integration.BaseIntegrationTest; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Nested; @@ -35,7 +35,7 @@ class getNormManifestationXml { @Test void itCallsNormServiceAndReturnsNormXml() throws Exception { // Given - normRepository.save(NormMapper.mapToDto(NormFixtures.loadFromDisk("SimpleNorm.xml"))); + normRepository.save(NormMapper.mapToDto(Fixtures.loadNormFromDisk("SimpleNorm.xml"))); var eli = "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/1964-08-05/regelungstext-1.xml"; // When // Then @@ -78,7 +78,7 @@ void itReturnsNotFoundIfManifestationDoesntExist() throws Exception { @Test void itReturnsNotFoundIfTypeIsNotXml() throws Exception { // Given - normRepository.save(NormMapper.mapToDto(NormFixtures.loadFromDisk("SimpleNorm.xml"))); + normRepository.save(NormMapper.mapToDto(Fixtures.loadNormFromDisk("SimpleNorm.xml"))); var eli = "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/1964-08-05/regelungstext-1.pdf"; // When // Then diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/ProprietaryControllerIntegrationTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/ProprietaryControllerIntegrationTest.java index c0cc77e3d..73e7b8a1b 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/ProprietaryControllerIntegrationTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/ProprietaryControllerIntegrationTest.java @@ -7,8 +7,8 @@ import de.bund.digitalservice.ris.norms.adapter.output.database.mapper.NormMapper; import de.bund.digitalservice.ris.norms.adapter.output.database.repository.NormRepository; +import de.bund.digitalservice.ris.norms.domain.entity.Fixtures; import de.bund.digitalservice.ris.norms.domain.entity.Norm; -import de.bund.digitalservice.ris.norms.domain.entity.NormFixtures; import de.bund.digitalservice.ris.norms.domain.entity.eli.DokumentExpressionEli; import de.bund.digitalservice.ris.norms.integration.BaseIntegrationTest; import java.time.LocalDate; @@ -80,7 +80,7 @@ void returnEmptyValuesIfNormHasNoProprietaryAtAll() throws Exception { "eli/bund/bgbl-1/2002/s1181/2019-11-22/1/deu/rechtsetzungsdokument-1" ); var atDateString = "2024-06-03"; - var norm = NormFixtures.loadFromDisk("NormWithoutProprietary.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithoutProprietary.xml"); normRepository.save(NormMapper.mapToDto(norm)); // when @@ -110,7 +110,7 @@ void returnEmptyValuesIfInvalidProprietaryDoesNotContainThem() throws Exception "eli/bund/bgbl-1/2002/s1181/2019-11-22/1/deu/rechtsetzungsdokument-1" ); var atDateString = "2024-06-03"; - var norm = NormFixtures.loadFromDisk("NormWithInvalidProprietary.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithInvalidProprietary.xml"); normRepository.save(NormMapper.mapToDto(norm)); // when @@ -140,7 +140,7 @@ void returnProprietary() throws Exception { "eli/bund/bgbl-1/2002/s1181/2019-11-22/1/deu/rechtsetzungsdokument-1" ); var atDateString = "2024-06-03"; - var norm = NormFixtures.loadFromDisk("NormWithProprietary.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithProprietary.xml"); normRepository.save(NormMapper.mapToDto(norm)); // when @@ -219,7 +219,7 @@ void updatesAll() throws Exception { // given final String eli = "eli/bund/bgbl-1/2002/s1181/2019-11-22/1/deu/rechtsetzungsdokument-1"; final LocalDate date = LocalDate.parse("1990-01-01"); - final Norm norm = NormFixtures.loadFromDisk("NormWithProprietary.xml"); + final Norm norm = Fixtures.loadNormFromDisk("NormWithProprietary.xml"); normRepository.save(NormMapper.mapToDto(norm)); // when @@ -284,7 +284,7 @@ void doesResetAllFieldsBySendingNullAndGetSomeDefaults() throws Exception { // given final String eli = "eli/bund/bgbl-1/2002/s1181/2019-11-22/1/deu/rechtsetzungsdokument-1"; final LocalDate date = LocalDate.parse("1990-01-01"); - final Norm norm = NormFixtures.loadFromDisk("NormWithProprietary.xml"); + final Norm norm = Fixtures.loadNormFromDisk("NormWithProprietary.xml"); normRepository.save(NormMapper.mapToDto(norm)); // when @@ -348,7 +348,7 @@ void doesResetAllFieldsBySendingEmptyStringAndGetSomeDefaults() throws Exception // given final String eli = "eli/bund/bgbl-1/2002/s1181/2019-11-22/1/deu/rechtsetzungsdokument-1"; final LocalDate date = LocalDate.parse("1990-01-01"); - final Norm norm = NormFixtures.loadFromDisk("NormWithProprietary.xml"); + final Norm norm = Fixtures.loadNormFromDisk("NormWithProprietary.xml"); normRepository.save(NormMapper.mapToDto(norm)); // when @@ -412,7 +412,7 @@ void updatesProprietaryByCreatingNewMetadatenDsNodes() throws Exception { // given final String eli = "eli/bund/bgbl-1/2002/s1181/2019-11-22/1/deu/rechtsetzungsdokument-1"; final LocalDate date = LocalDate.parse("2003-01-01"); - final Norm norm = NormFixtures.loadFromDisk("NormWithProprietary.xml"); + final Norm norm = Fixtures.loadNormFromDisk("NormWithProprietary.xml"); normRepository.save(NormMapper.mapToDto(norm)); // when @@ -477,7 +477,7 @@ void updatesProprietaryByCreatingNewProprietaryAndMetadatenDsNodes() throws Exce // given final String eli = "eli/bund/bgbl-1/2002/s1181/2019-11-22/1/deu/rechtsetzungsdokument-1"; final LocalDate date = LocalDate.parse("2003-01-01"); - final Norm norm = NormFixtures.loadFromDisk("NormWithProprietary.xml"); + final Norm norm = Fixtures.loadNormFromDisk("NormWithProprietary.xml"); normRepository.save(NormMapper.mapToDto(norm)); // when @@ -541,7 +541,7 @@ void doesRemoveQualifizierteMehrheitFromBeschliessendesOrganWhenNull() throws Ex // given final String eli = "eli/bund/bgbl-1/2002/s1181/2019-11-22/1/deu/rechtsetzungsdokument-1"; final LocalDate date = LocalDate.parse("2003-01-01"); - final Norm norm = NormFixtures.loadFromDisk( + final Norm norm = Fixtures.loadNormFromDisk( "NormWithProprietaryAndMultipleTimeBoundaries.xml" ); normRepository.save(NormMapper.mapToDto(norm)); @@ -607,7 +607,7 @@ void createsProprietaryAndMetadatenDsAndUpdatesFna() throws Exception { // given final String eli = "eli/bund/bgbl-1/2002/s1181/2019-11-22/1/deu/rechtsetzungsdokument-1"; final LocalDate date = LocalDate.parse("1990-01-01"); - final Norm norm = NormFixtures.loadFromDisk("NormWithoutProprietary.xml"); + final Norm norm = Fixtures.loadNormFromDisk("NormWithoutProprietary.xml"); normRepository.save(NormMapper.mapToDto(norm)); // when @@ -712,7 +712,7 @@ void returnEmptyValuesIfNormHasNoProprietaryAtAll() throws Exception { ); var eid = "hauptteil-1_abschnitt-0_art-1"; var atDateString = "2024-06-03"; - var norm = NormFixtures.loadFromDisk("NormWithoutProprietary.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithoutProprietary.xml"); normRepository.save(NormMapper.mapToDto(norm)); // when @@ -734,7 +734,7 @@ void returnEmptyValuesIfInvalidProprietaryDoesNotContainThem() throws Exception ); var eid = "hauptteil-1_abschnitt-0_art-1"; var atDateString = "2024-06-03"; - var norm = NormFixtures.loadFromDisk("NormWithInvalidProprietary.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithInvalidProprietary.xml"); normRepository.save(NormMapper.mapToDto(norm)); // when @@ -756,7 +756,7 @@ void returnProprietaryEinzelelement() throws Exception { ); var eid = "hauptteil-1_abschnitt-0_art-1"; var atDateString = "2024-06-03"; - var norm = NormFixtures.loadFromDisk("NormWithProprietary.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithProprietary.xml"); normRepository.save(NormMapper.mapToDto(norm)); // when @@ -821,7 +821,7 @@ void createsProprietaryAndMetadatenDsAndEinzelelementAndSetsValue() throws Excep ); var eid = "hauptteil-1_abschnitt-0_art-1"; var atDateString = "2024-06-03"; - var norm = NormFixtures.loadFromDisk("NormWithoutProprietary.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithoutProprietary.xml"); normRepository.save(NormMapper.mapToDto(norm)); // when diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/RenderingControllerIntegrationTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/RenderingControllerIntegrationTest.java index 62c6c3a10..fb38c7673 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/RenderingControllerIntegrationTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/RenderingControllerIntegrationTest.java @@ -7,7 +7,7 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; import de.bund.digitalservice.ris.norms.adapter.output.database.repository.NormRepository; -import de.bund.digitalservice.ris.norms.domain.entity.NormFixtures; +import de.bund.digitalservice.ris.norms.domain.entity.Fixtures; import de.bund.digitalservice.ris.norms.integration.BaseIntegrationTest; import de.bund.digitalservice.ris.norms.utils.XmlMapper; import org.junit.jupiter.api.AfterEach; @@ -42,12 +42,12 @@ void itReturnsRender() throws Exception { jsonPayload.addProperty( "norm", XmlMapper.toString( - NormFixtures.loadFromDisk("NormWithPassiveModifications.xml").getDocument() + Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml").getDocument() ) ); var customNormsJson = new JsonArray(); customNormsJson.add( - XmlMapper.toString(NormFixtures.loadFromDisk("NormWithMods.xml").getDocument()) + XmlMapper.toString(Fixtures.loadNormFromDisk("NormWithMods.xml").getDocument()) ); jsonPayload.add("customNorms", customNormsJson); @@ -73,13 +73,13 @@ void itReturnsRenderOfQuotedStructure() throws Exception { jsonPayload.addProperty( "norm", XmlMapper.toString( - NormFixtures.loadFromDisk("NormWithPassiveModsQuotedStructure.xml").getDocument() + Fixtures.loadNormFromDisk("NormWithPassiveModsQuotedStructure.xml").getDocument() ) ); var customNormsJson = new JsonArray(); customNormsJson.add( XmlMapper.toString( - NormFixtures.loadFromDisk("NormWithQuotedStructureMods.xml").getDocument() + Fixtures.loadNormFromDisk("NormWithQuotedStructureMods.xml").getDocument() ) ); jsonPayload.add("customNorms", customNormsJson); diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/output/database/DBServiceIntegrationTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/output/database/DBServiceIntegrationTest.java index 853175ae1..f9511657a 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/output/database/DBServiceIntegrationTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/output/database/DBServiceIntegrationTest.java @@ -60,7 +60,7 @@ void cleanUp() { @Test void itFindsNormOnDB() { // Given - var norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + var norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); normRepository.save(NormMapper.mapToDto(norm)); // When @@ -79,7 +79,7 @@ void itFindsNormOnDB() { @Test void itFindsNormByManifestationEliWithoutPointInTimeManifestationOnDB() { // Given - var norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + var norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); normRepository.save(NormMapper.mapToDto(norm)); // When @@ -98,7 +98,7 @@ void itFindsNormByManifestationEliWithoutPointInTimeManifestationOnDB() { @Test void itFindsNormByManifestationEli() { // Given - var norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + var norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); normRepository.save(NormMapper.mapToDto(norm)); // When @@ -118,9 +118,9 @@ void itFindsNormByManifestationEli() { void itFindsNewestManifestationOfNorm() { // Given normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithoutPassiveModifications.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml")) ); - var norm = NormFixtures.loadFromDisk("NormWithPassiveModifications.xml"); + var norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); normRepository.save(NormMapper.mapToDto(norm)); // When @@ -139,7 +139,7 @@ void itFindsNewestManifestationOfNorm() { @Test void itFindsNormByGuidOnDB() { // When - var norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + var norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); normRepository.save(NormMapper.mapToDto(norm)); // When @@ -154,7 +154,7 @@ void itFindsNormByGuidOnDB() { @Test void itFindsAnnouncementOnDB() { // Given - var norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + var norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); var announcement = Announcement.builder().eli(norm.getExpressionEli()).build(); announcementRepository.save(AnnouncementMapper.mapToDto(announcement)); @@ -260,7 +260,7 @@ void itLoadsAllAnnouncementsFromDB() { @Test void itUpdatesNorm() { // Given - var oldNorm = NormFixtures.loadFromDisk("NormWithAppliedQuotedStructure.xml"); + var oldNorm = Fixtures.loadNormFromDisk("NormWithAppliedQuotedStructure.xml"); oldNorm.setPublishState(NormPublishState.UNPUBLISHED); normRepository.save(NormMapper.mapToDto(oldNorm)); @@ -336,10 +336,10 @@ void itCreatesNewAnnouncement() { void itFindsReleaseOnDB() { // Given var norm = normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("SimpleNorm.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("SimpleNorm.xml")) ); var norm2 = normRepository.save( - NormMapper.mapToDto(NormFixtures.loadFromDisk("NormWithMods.xml")) + NormMapper.mapToDto(Fixtures.loadNormFromDisk("NormWithMods.xml")) ); var release1 = releaseRepository.save( ReleaseDto @@ -392,7 +392,7 @@ class saveReleaseToAnnouncement { @Test void itUpdatesAnnouncementAndSavesRelease() { // Given - var norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + var norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); var announcement = Announcement.builder().eli(norm.getExpressionEli()).build(); var release = Release.builder().publishedNorms(List.of(norm)).build(); @@ -422,7 +422,7 @@ class deleteQueuedReleases { @Test void itDeletesQueuedReleases() { // Given - var norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + var norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); norm.setPublishState(NormPublishState.QUEUED_FOR_PUBLISH); var announcement = Announcement.builder().eli(norm.getExpressionEli()).build(); var release = Release.builder().publishedNorms(List.of(norm)).build(); @@ -456,10 +456,10 @@ class loadNormsByPublishState { @Test void itLoadsNormIdByPublishState() { // Given - var normQueued = NormFixtures.loadFromDisk("SimpleNorm.xml"); + var normQueued = Fixtures.loadNormFromDisk("SimpleNorm.xml"); normQueued.setPublishState(NormPublishState.QUEUED_FOR_PUBLISH); - var normPublished = NormFixtures.loadFromDisk("NormToBeReleased.xml"); + var normPublished = Fixtures.loadNormFromDisk("NormToBeReleased.xml"); normPublished.setPublishState(NormPublishState.PUBLISHED); normRepository.save(NormMapper.mapToDto(normQueued)); @@ -477,7 +477,7 @@ void itLoadsNormIdByPublishState() { @Test void itLoadsNormById() { // Given - var normQueued = NormFixtures.loadFromDisk("SimpleNorm.xml"); + var normQueued = Fixtures.loadNormFromDisk("SimpleNorm.xml"); normQueued.setPublishState(NormPublishState.QUEUED_FOR_PUBLISH); NormDto norm = normRepository.save(NormMapper.mapToDto(normQueued)); diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/output/s3/BucketServiceIntegrationTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/output/s3/BucketServiceIntegrationTest.java index 8ea575465..c1d19f99b 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/output/s3/BucketServiceIntegrationTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/output/s3/BucketServiceIntegrationTest.java @@ -10,8 +10,8 @@ import de.bund.digitalservice.ris.norms.application.port.output.DeletePublicNormPort; import de.bund.digitalservice.ris.norms.application.port.output.PublishPrivateNormPort; import de.bund.digitalservice.ris.norms.application.port.output.PublishPublicNormPort; +import de.bund.digitalservice.ris.norms.domain.entity.Fixtures; import de.bund.digitalservice.ris.norms.domain.entity.Norm; -import de.bund.digitalservice.ris.norms.domain.entity.NormFixtures; import de.bund.digitalservice.ris.norms.integration.BaseS3MockIntegrationTest; import java.nio.file.Files; import java.nio.file.Path; @@ -35,7 +35,7 @@ class BucketServiceIntegrationTest extends BaseS3MockIntegrationTest { @Test void itPublishesNormToPublicBucket() { // Given - final Norm norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + final Norm norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); // When final PublishPublicNormPort.Command command = new PublishPublicNormPort.Command(norm); @@ -51,7 +51,7 @@ void itPublishesNormToPublicBucket() { @Test void itPublishesNormToPrivateBucket() { // Given - final Norm norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + final Norm norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); // When final PublishPrivateNormPort.Command command = new PublishPrivateNormPort.Command(norm); @@ -67,7 +67,7 @@ void itPublishesNormToPrivateBucket() { @Test void itPublishesNormToPublicAndPrivateBucket() { // Given - final Norm norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + final Norm norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); // When final PublishPublicNormPort.Command commandPublic = new PublishPublicNormPort.Command(norm); @@ -88,7 +88,7 @@ void itPublishesNormToPublicAndPrivateBucket() { @Test void itDeletesNormFromPublicBucket() { // Given - final Norm norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + final Norm norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); final PublishPublicNormPort.Command commandPublish = new PublishPublicNormPort.Command(norm); bucketService.publishPublicNorm(commandPublish); @@ -107,7 +107,7 @@ void itDeletesNormFromPublicBucket() { @Test void itDeletesNormFromPrivateBucket() { // Given - final Norm norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + final Norm norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); final PublishPrivateNormPort.Command commandPublish = new PublishPrivateNormPort.Command(norm); bucketService.publishPrivateNorm(commandPublish); @@ -126,8 +126,8 @@ void itDeletesNormFromPrivateBucket() { @Test void itDeletesAllNormsFromPublicBucket() { // Given - final Norm norm1 = NormFixtures.loadFromDisk("SimpleNorm.xml"); - final Norm norm2 = NormFixtures.loadFromDisk("NormToBeReleased.xml"); + final Norm norm1 = Fixtures.loadNormFromDisk("SimpleNorm.xml"); + final Norm norm2 = Fixtures.loadNormFromDisk("NormToBeReleased.xml"); final PublishPublicNormPort.Command commandPublish1 = new PublishPublicNormPort.Command(norm1); final PublishPublicNormPort.Command commandPublish2 = new PublishPublicNormPort.Command(norm2); bucketService.publishPublicNorm(commandPublish1); @@ -149,8 +149,8 @@ void itDeletesAllNormsFromPublicBucket() { @Test void itDeletesAllNormsFromPrivateBucket() { // Given - final Norm norm1 = NormFixtures.loadFromDisk("SimpleNorm.xml"); - final Norm norm2 = NormFixtures.loadFromDisk("NormToBeReleased.xml"); + final Norm norm1 = Fixtures.loadNormFromDisk("SimpleNorm.xml"); + final Norm norm2 = Fixtures.loadNormFromDisk("NormToBeReleased.xml"); final PublishPrivateNormPort.Command commandPublish1 = new PublishPrivateNormPort.Command( norm1 ); @@ -176,9 +176,9 @@ void itDeletesAllNormsFromPrivateBucket() { @Test void itAddsToExistingChangelog() { // Given - final Norm norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + final Norm norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); final PublishPublicNormPort.Command command = new PublishPublicNormPort.Command(norm); - final Norm anotherNorm = NormFixtures.loadFromDisk("NormToBeReleased.xml"); + final Norm anotherNorm = Fixtures.loadNormFromDisk("NormToBeReleased.xml"); final PublishPublicNormPort.Command commandAnotherNorm = new PublishPublicNormPort.Command( anotherNorm ); diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/application/PublishServiceIntegrationTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/application/PublishServiceIntegrationTest.java index bb60a49e4..b7a95b46c 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/application/PublishServiceIntegrationTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/application/PublishServiceIntegrationTest.java @@ -6,8 +6,8 @@ import de.bund.digitalservice.ris.norms.adapter.output.database.mapper.NormMapper; import de.bund.digitalservice.ris.norms.adapter.output.database.repository.NormRepository; import de.bund.digitalservice.ris.norms.application.service.PublishService; +import de.bund.digitalservice.ris.norms.domain.entity.Fixtures; import de.bund.digitalservice.ris.norms.domain.entity.Norm; -import de.bund.digitalservice.ris.norms.domain.entity.NormFixtures; import de.bund.digitalservice.ris.norms.domain.entity.NormPublishState; import de.bund.digitalservice.ris.norms.integration.BaseS3MockIntegrationTest; import java.nio.file.Files; @@ -27,7 +27,7 @@ class PublishServiceIntegrationTest extends BaseS3MockIntegrationTest { @Test void processQueuedFilesForPublish() { // Given - final Norm norm = NormFixtures.loadFromDisk("SimpleNorm.xml"); + final Norm norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); final NormDto normDto = NormMapper.mapToDto(norm); normDto.setPublishState(NormPublishState.QUEUED_FOR_PUBLISH); normRepository.save(normDto); diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/utils/NodeParserTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/utils/NodeParserTest.java index f4b92a438..9ea9d80cf 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/utils/NodeParserTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/utils/NodeParserTest.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import de.bund.digitalservice.ris.norms.domain.entity.NormFixtures; +import de.bund.digitalservice.ris.norms.domain.entity.Fixtures; import de.bund.digitalservice.ris.norms.utils.exceptions.MandatoryNodeNotFoundException; import java.util.Optional; import org.junit.jupiter.api.Nested; @@ -253,7 +253,7 @@ void returnFalseIfNodeHasChildNode() { { "//act/@name", "//*:act/@name", "//Q{http://Inhaltsdaten.LegalDocML.de/1.7.1/}act/@name" } ) void xPathsWorkWithoutNamespaceAwareness(String xPath) { - var norm = NormFixtures.loadFromDisk("NormWithMods.xml", false); + var norm = Fixtures.loadNormFromDisk("NormWithMods.xml", false); Node node = norm.getDocument(); Optional result = NodeParser.getValueFromExpression(xPath, node); assertThat(result).contains("regelungstext"); @@ -264,7 +264,7 @@ void xPathsWorkWithoutNamespaceAwareness(String xPath) { { "//act/@name", "//*:act/@name", "//Q{http://Inhaltsdaten.LegalDocML.de/1.7.1/}act/@name" } ) void xPathsWorkWithNamespaceAwareness(String xPath) { - var norm = NormFixtures.loadFromDisk("NormWithMods.xml", true); + var norm = Fixtures.loadNormFromDisk("NormWithMods.xml", true); Node node = norm.getDocument(); Optional result = NodeParser.getValueFromExpression(xPath, node); assertThat(result).contains("regelungstext"); @@ -272,7 +272,7 @@ void xPathsWorkWithNamespaceAwareness(String xPath) { @Test void xPathsWorkWithNamespaceDoesNotMatchInDocumentWithDifferentNamespace() { - var norm = NormFixtures.loadFromDisk("NormWithMods.xml", true); + var norm = Fixtures.loadNormFromDisk("NormWithMods.xml", true); Node node = norm.getDocument(); Optional result = NodeParser.getValueFromExpression( "//Q{http://Inhaltsdaten.LegalDocML.de/1.5/}act/@name",