diff --git a/backend/src/main/java/de/bund/digitalservice/ris/norms/adapter/output/database/dto/NormDto.java b/backend/src/main/java/de/bund/digitalservice/ris/norms/adapter/output/database/dto/NormDto.java index d375e701b..c37bd3065 100644 --- a/backend/src/main/java/de/bund/digitalservice/ris/norms/adapter/output/database/dto/NormDto.java +++ b/backend/src/main/java/de/bund/digitalservice/ris/norms/adapter/output/database/dto/NormDto.java @@ -46,16 +46,28 @@ public class NormDto { private UUID guid; @Generated(event = { INSERT, UPDATE }) - @Column(name = "eli_work", updatable = false, insertable = false) - private String eliWork; + @Column(name = "eli_dokument_work", updatable = false, insertable = false) + private String eliDokumentWork; @Generated(event = { INSERT, UPDATE }) - @Column(name = "eli_expression", updatable = false, insertable = false) - private String eliExpression; + @Column(name = "eli_dokument_expression", updatable = false, insertable = false) + private String eliDokumentExpression; @Generated(event = { INSERT, UPDATE }) - @Column(name = "eli_manifestation", updatable = false, insertable = false) - private String eliManifestation; + @Column(name = "eli_dokument_manifestation", updatable = false, insertable = false) + private String eliDokumentManifestation; + + @Generated(event = { INSERT, UPDATE }) + @Column(name = "eli_norm_work", updatable = false, insertable = false) + private String eliNormWork; + + @Generated(event = { INSERT, UPDATE }) + @Column(name = "eli_norm_expression", updatable = false, insertable = false) + private String eliNormExpression; + + @Generated(event = { INSERT, UPDATE }) + @Column(name = "eli_norm_manifestation", updatable = false, insertable = false) + private String eliNormManifestation; @NotNull @Column diff --git a/backend/src/main/java/de/bund/digitalservice/ris/norms/adapter/output/database/dto/ReleaseDto.java b/backend/src/main/java/de/bund/digitalservice/ris/norms/adapter/output/database/dto/ReleaseDto.java index 8f5eac0fe..6375dfd42 100644 --- a/backend/src/main/java/de/bund/digitalservice/ris/norms/adapter/output/database/dto/ReleaseDto.java +++ b/backend/src/main/java/de/bund/digitalservice/ris/norms/adapter/output/database/dto/ReleaseDto.java @@ -44,7 +44,7 @@ public class ReleaseDto { joinColumns = @JoinColumn(name = "release_id"), inverseJoinColumns = @JoinColumn( name = "norm_eli_manifestation", - referencedColumnName = "eli_manifestation" + referencedColumnName = "eli_dokument_manifestation" ) ) @Builder.Default diff --git a/backend/src/main/java/de/bund/digitalservice/ris/norms/adapter/output/database/repository/NormRepository.java b/backend/src/main/java/de/bund/digitalservice/ris/norms/adapter/output/database/repository/NormRepository.java index 32900b4c1..2a254c02e 100644 --- a/backend/src/main/java/de/bund/digitalservice/ris/norms/adapter/output/database/repository/NormRepository.java +++ b/backend/src/main/java/de/bund/digitalservice/ris/norms/adapter/output/database/repository/NormRepository.java @@ -25,7 +25,9 @@ public interface NormRepository extends JpaRepository { * @param expressionEli The ELI to search for. * @return An {@link Optional} containing the found {@link NormDto} if exists, or empty if not found. */ - Optional findFirstByEliExpressionOrderByEliManifestationDesc(final String expressionEli); + Optional findFirstByEliDokumentExpressionOrderByEliDokumentManifestationDesc( + final String expressionEli + ); /** * Finds a {@link NormDto} by its manifestation ELI (European Legislation Identifier). @@ -33,7 +35,7 @@ public interface NormRepository extends JpaRepository { * @param manifestationEli The ELI to search for. * @return An {@link Optional} containing the found {@link NormDto} if exists, or empty if not found. */ - Optional findByEliManifestation(final String manifestationEli); + Optional findByEliDokumentManifestation(final String manifestationEli); /** * Finds a {@link NormDto} by its GUID. @@ -42,7 +44,7 @@ public interface NormRepository extends JpaRepository { * @param guid The GUID to search for. * @return An {@link Optional} containing the found {@link NormDto} if exists, or empty if not found. */ - Optional findFirstByGuidOrderByEliManifestation(final UUID guid); + Optional findFirstByGuidOrderByEliDokumentManifestation(final UUID guid); /** * Deletes all {@link NormDto} with the given GUID @@ -58,7 +60,7 @@ public interface NormRepository extends JpaRepository { * @param manifestationEli The ELI to search for. * @param publishState The publishState to search for. */ - void deleteByEliManifestationAndPublishState( + void deleteByEliDokumentManifestationAndPublishState( final String manifestationEli, final NormPublishState publishState ); @@ -68,7 +70,10 @@ void deleteByEliManifestationAndPublishState( * @param workEli The ELI to search for. * @param publishState The publishState to search for. */ - void deleteAllByEliWorkAndPublishState(final String workEli, final NormPublishState publishState); + void deleteAllByEliDokumentWorkAndPublishState( + final String workEli, + final NormPublishState publishState + ); /** * Retrieves the ids of all {@link NormDto} with a specific {@link NormPublishState}. @@ -76,7 +81,6 @@ void deleteByEliManifestationAndPublishState( * @param normPublishState the publish state to filter the norms by (e.g., {@link NormPublishState#QUEUED_FOR_PUBLISH}) * @return a {@link List} of {@link UUID}s of the {@link NormDto}s matching the specified publish state */ - @Query("SELECT n.id FROM NormDto n WHERE n.publishState = :publishState") List findNormIdsByPublishState( @Param("publishState") final NormPublishState normPublishState diff --git a/backend/src/main/java/de/bund/digitalservice/ris/norms/adapter/output/database/service/DBService.java b/backend/src/main/java/de/bund/digitalservice/ris/norms/adapter/output/database/service/DBService.java index 7c2b0c329..7b742a240 100644 --- a/backend/src/main/java/de/bund/digitalservice/ris/norms/adapter/output/database/service/DBService.java +++ b/backend/src/main/java/de/bund/digitalservice/ris/norms/adapter/output/database/service/DBService.java @@ -70,7 +70,9 @@ public DBService( public Optional loadNorm(LoadNormPort.Command command) { return switch (command.eli()) { case DokumentExpressionEli expressionEli -> normRepository - .findFirstByEliExpressionOrderByEliManifestationDesc(expressionEli.toString()) + .findFirstByEliDokumentExpressionOrderByEliDokumentManifestationDesc( + expressionEli.toString() + ) .map(NormMapper::mapToDomain); case DokumentManifestationEli manifestationEli -> { if (!manifestationEli.hasPointInTimeManifestation()) { @@ -79,7 +81,7 @@ public Optional loadNorm(LoadNormPort.Command command) { } yield normRepository - .findByEliManifestation(manifestationEli.toString()) + .findByEliDokumentManifestation(manifestationEli.toString()) .map(NormMapper::mapToDomain); } case DokumentWorkEli workEli -> throw new IllegalArgumentException( @@ -91,7 +93,7 @@ public Optional loadNorm(LoadNormPort.Command command) { @Override public Optional loadNormByGuid(LoadNormByGuidPort.Command command) { return normRepository - .findFirstByGuidOrderByEliManifestation(command.guid()) + .findFirstByGuidOrderByEliDokumentManifestation(command.guid()) .map(NormMapper::mapToDomain); } @@ -122,7 +124,7 @@ public List loadAllAnnouncements() { public Optional updateNorm(UpdateNormPort.Command command) { var normXml = XmlMapper.toString(command.norm().getDocument()); return normRepository - .findByEliManifestation(command.norm().getManifestationEli().toString()) + .findByEliDokumentManifestation(command.norm().getManifestationEli().toString()) .map(normDto -> { normDto.setXml(normXml); normDto.setPublishState(command.norm().getPublishState()); @@ -173,7 +175,7 @@ public void deleteAnnouncementByNormEli(DeleteAnnouncementByNormEliPort.Command @Override @Transactional public void deleteNorm(DeleteNormPort.Command command) { - normRepository.deleteByEliManifestationAndPublishState( + normRepository.deleteByEliDokumentManifestationAndPublishState( command.eli().toString(), command.publishState() ); @@ -182,7 +184,7 @@ public void deleteNorm(DeleteNormPort.Command command) { @Override @Transactional public void deleteQueuedForPublishNorms(DeleteQueuedNormsPort.Command command) { - normRepository.deleteAllByEliWorkAndPublishState( + normRepository.deleteAllByEliDokumentWorkAndPublishState( command.eli().toString(), NormPublishState.QUEUED_FOR_PUBLISH ); @@ -208,7 +210,7 @@ public Release saveReleaseToAnnouncement(SaveReleaseToAnnouncementPort.Command c .getPublishedNorms() .forEach(norm -> normRepository - .findByEliManifestation(norm.getManifestationEli().toString()) + .findByEliDokumentManifestation(norm.getManifestationEli().toString()) .ifPresent(normDto -> releaseDto.getNorms().add(normDto)) ); diff --git a/backend/src/main/resources/db/data/R__001_2017_s419_2017-03-15_Vereinsgesetzes.sql b/backend/src/main/resources/db/data/R__001_2017_s419_2017-03-15_Vereinsgesetzes.sql index 1b49a7cdc..bfb925f3d 100644 --- a/backend/src/main/resources/db/data/R__001_2017_s419_2017-03-15_Vereinsgesetzes.sql +++ b/backend/src/main/resources/db/data/R__001_2017_s419_2017-03-15_Vereinsgesetzes.sql @@ -2,7 +2,7 @@ -- TARGET LAW DELETE FROM norms -WHERE eli_expression = 'eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1'; +WHERE eli_dokument_expression = 'eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1'; INSERT INTO norms (publish_state, xml) VALUES ('PUBLISHED', ' @@ -177,4 +177,4 @@ VALUES ('PUBLISHED', ' -'); \ No newline at end of file +'); diff --git a/backend/src/main/resources/db/data/R__002_2023_413_2023-12-29_Nachrichtendienstrechts.sql b/backend/src/main/resources/db/data/R__002_2023_413_2023-12-29_Nachrichtendienstrechts.sql index b0327ea17..ddef0e4c2 100644 --- a/backend/src/main/resources/db/data/R__002_2023_413_2023-12-29_Nachrichtendienstrechts.sql +++ b/backend/src/main/resources/db/data/R__002_2023_413_2023-12-29_Nachrichtendienstrechts.sql @@ -2,7 +2,7 @@ -- TARGET LAW DELETE FROM norms -WHERE eli_expression = 'eli/bund/bgbl-1/1990/s2954/2022-12-19/1/deu/regelungstext-1'; +WHERE eli_dokument_expression = 'eli/bund/bgbl-1/1990/s2954/2022-12-19/1/deu/regelungstext-1'; INSERT INTO norms (publish_state, xml) VALUES ('PUBLISHED', ' @@ -1763,4 +1763,4 @@ VALUES ('PUBLISHED', ' -'); \ No newline at end of file +'); diff --git a/backend/src/main/resources/db/data/R__003_1000_1_1000-01-01_Formatting.sql b/backend/src/main/resources/db/data/R__003_1000_1_1000-01-01_Formatting.sql index 4cc1641d0..634540731 100644 --- a/backend/src/main/resources/db/data/R__003_1000_1_1000-01-01_Formatting.sql +++ b/backend/src/main/resources/db/data/R__003_1000_1_1000-01-01_Formatting.sql @@ -2,7 +2,7 @@ -- TARGET LAW DELETE FROM norms -WHERE eli_expression = 'eli/bund/bgbl-1/1000/s1/1000-01-01/1/deu/regelungstext-1'; +WHERE eli_dokument_expression = 'eli/bund/bgbl-1/1000/s1/1000-01-01/1/deu/regelungstext-1'; INSERT INTO norms (publish_state, xml) VALUES ('PUBLISHED', ' diff --git a/backend/src/main/resources/db/data/R__004_2024_108_2024-03-27_Wachstumschancengesetz.sql b/backend/src/main/resources/db/data/R__004_2024_108_2024-03-27_Wachstumschancengesetz.sql index 5d6efc431..bdf95d941 100644 --- a/backend/src/main/resources/db/data/R__004_2024_108_2024-03-27_Wachstumschancengesetz.sql +++ b/backend/src/main/resources/db/data/R__004_2024_108_2024-03-27_Wachstumschancengesetz.sql @@ -2,7 +2,7 @@ -- TARGET LAW DELETE FROM norms -where eli_expression = 'eli/bund/bgbl-1/2024/108/2024-03-27/1/deu/regelungstext-1'; +where eli_dokument_expression = 'eli/bund/bgbl-1/2024/108/2024-03-27/1/deu/regelungstext-1'; INSERT INTO norms (publish_state, xml) VALUES ('PUBLISHED', ' diff --git a/backend/src/main/resources/db/data/R__007_1001_11_1001-01-01_Mods.sql b/backend/src/main/resources/db/data/R__007_1001_11_1001-01-01_Mods.sql index c73eb9cbd..44830fea8 100644 --- a/backend/src/main/resources/db/data/R__007_1001_11_1001-01-01_Mods.sql +++ b/backend/src/main/resources/db/data/R__007_1001_11_1001-01-01_Mods.sql @@ -2,7 +2,7 @@ -- TARGET LAW DELETE FROM norms -WHERE eli_expression = 'eli/bund/bgbl-1/1001/1/1001-01-01/1/deu/regelungstext-1'; +WHERE eli_dokument_expression = 'eli/bund/bgbl-1/1001/1/1001-01-01/1/deu/regelungstext-1'; INSERT INTO norms (publish_state, xml) VALUES ('PUBLISHED', ' @@ -133,4 +133,4 @@ VALUES ('PUBLISHED', ' -'); \ No newline at end of file +'); diff --git a/backend/src/main/resources/db/data/R__008_1002_10_1002-01-10_Mods_Substitution_01.sql b/backend/src/main/resources/db/data/R__008_1002_10_1002-01-10_Mods_Substitution_01.sql index 9285eabc8..f7770417e 100644 --- a/backend/src/main/resources/db/data/R__008_1002_10_1002-01-10_Mods_Substitution_01.sql +++ b/backend/src/main/resources/db/data/R__008_1002_10_1002-01-10_Mods_Substitution_01.sql @@ -2,7 +2,7 @@ -- TARGET LAW DELETE FROM norms -WHERE eli_expression = 'eli/bund/bgbl-1/1002/1/1002-01-01/1/deu/regelungstext-1'; +WHERE eli_dokument_expression = 'eli/bund/bgbl-1/1002/1/1002-01-01/1/deu/regelungstext-1'; INSERT INTO norms (publish_state, xml) VALUES ('PUBLISHED', ' @@ -681,4 +681,4 @@ VALUES ('PUBLISHED', ' -'); \ No newline at end of file +'); diff --git a/backend/src/main/resources/db/data/R__009_bgbl-1_2024_10.sql b/backend/src/main/resources/db/data/R__009_bgbl-1_2024_10.sql index 209430ba2..a80c18834 100644 --- a/backend/src/main/resources/db/data/R__009_bgbl-1_2024_10.sql +++ b/backend/src/main/resources/db/data/R__009_bgbl-1_2024_10.sql @@ -2,7 +2,7 @@ -- TARGET LAW DELETE FROM norms -WHERE eli_expression = 'eli/bund/bgbl-1/2021/s818/2021-04-16/1/deu/regelungstext-1'; +WHERE eli_dokument_expression = 'eli/bund/bgbl-1/2021/s818/2021-04-16/1/deu/regelungstext-1'; INSERT INTO norms (publish_state, xml) VALUES ('PUBLISHED', ' diff --git a/backend/src/main/resources/db/migration/V0.21__normeli_and_documenteli.sql b/backend/src/main/resources/db/migration/V0.21__normeli_and_documenteli.sql new file mode 100644 index 000000000..e1f6c13da --- /dev/null +++ b/backend/src/main/resources/db/migration/V0.21__normeli_and_documenteli.sql @@ -0,0 +1,18 @@ +ALTER TABLE norms RENAME COLUMN eli_manifestation TO eli_dokument_manifestation; +-- For the FRBRManifestation the FRBRuri contains the subtype and format, this is different, than for FRBRExpression or FRBRWork. Therefore, we need to additionally remove those part from it. +ALTER TABLE norms + ADD COLUMN eli_norm_manifestation text GENERATED ALWAYS AS (regexp_replace((xpath( + '(//*[local-name()="act"]/*[local-name()="meta"]/*[local-name()="identification"]/*[local-name()="FRBRManifestation"]/*[local-name()="FRBRuri"]/@value)', + xml))[1]::text, '/[^/]*$', '')) STORED NOT NULL; + +ALTER TABLE norms RENAME COLUMN eli_expression TO eli_dokument_expression; +ALTER TABLE norms + ADD COLUMN eli_norm_expression text GENERATED ALWAYS AS ((xpath( + '//*[local-name()="act"]/*[local-name()="meta"]/*[local-name()="identification"]/*[local-name()="FRBRExpression"]/*[local-name()="FRBRuri"]/@value', + xml))[1]::text) STORED NOT NULL; + +ALTER TABLE norms RENAME COLUMN eli_work TO eli_dokument_work; +ALTER TABLE norms + ADD COLUMN eli_norm_work text GENERATED ALWAYS AS ((xpath( + '//*[local-name()="act"]/*[local-name()="meta"]/*[local-name()="identification"]/*[local-name()="FRBRWork"]/*[local-name()="FRBRuri"]/@value', + xml))[1]::text) STORED NOT NULL; 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 4667b87c4..ccc268c70 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 @@ -19,7 +19,6 @@ import java.time.Instant; import java.time.LocalDate; import java.util.List; -import java.util.Set; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -69,70 +68,7 @@ void itReturnsEmptyListOfAnnouncements() throws Exception { @Test void itReturnsAllAnnouncementsNorm() throws Exception { // Given - var norm = Norm - .builder() - .regelungstexte( - Set.of( - new Regelungstext( - XmlMapper.toDocument( - """ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Gesetz zum ersten Teil der Reform des Nachrichtendienstrechts - - - - - - """ - ) - ) - ) - ) - .build(); + var norm = Fixtures.loadNormFromDisk("Vereinsgesetz.xml"); var announcement = Announcement.builder().eli(norm.getExpressionEli()).build(); normRepository.save(NormMapper.mapToDto(norm)); announcementRepository.save(AnnouncementMapper.mapToDto(announcement)); @@ -145,13 +81,13 @@ void itReturnsAllAnnouncementsNorm() throws Exception { .andExpect(jsonPath("$[0]").exists()) .andExpect(jsonPath("$[1]").doesNotExist()) .andExpect( - jsonPath( - "$[0].title", - equalTo("Gesetz zum ersten Teil der Reform des Nachrichtendienstrechts") - ) + jsonPath("$[0].title", equalTo("Gesetz zur Regelung des öffentlichen Vereinsrechts")) ) .andExpect( - jsonPath("$[0].eli", equalTo("eli/bund/bgbl-1/2023/413/2023-12-29/1/deu/regelungstext-1")) + jsonPath( + "$[0].eli", + equalTo("eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1") + ) ); } } @@ -196,94 +132,7 @@ void itDoesNotReturnReleaseBecauseAmendingLawNotFound() throws Exception { @Test void itDoesReturnNoReleasesIfNoneFound() throws Exception { // Given - var amendingNorm = Norm - .builder() - .regelungstexte( - Set.of( - new Regelungstext( - XmlMapper.toDocument( - """ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Artikel 1 - Änderung des Vereinsgesetzes - - - - - - - - Das Vereinsgesetz vom 5. August 1964 (BGBl. I S. 593), das zuletzt durch … geändert worden ist, wird wie folgt geändert: - - - - - - - - Artikel 3 - Inkrafttreten - - - - - - - Dieses Gesetz tritt am Tag - nach der Verkündung in Kraft. - - - - - - - """ - ) - ) - ) - ) - .build(); + var amendingNorm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); normRepository.save(NormMapper.mapToDto(amendingNorm)); var announcement = Announcement.builder().eli(amendingNorm.getExpressionEli()).build(); @@ -293,7 +142,7 @@ void itDoesReturnNoReleasesIfNoneFound() throws Exception { mockMvc .perform( get( - "/api/v1/announcements/eli/bund/bgbl-1/2023/413/2023-12-29/1/deu/regelungstext-1/releases" + "/api/v1/announcements/eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1/releases" ) .accept(MediaType.APPLICATION_JSON) ) @@ -304,200 +153,9 @@ void itDoesReturnNoReleasesIfNoneFound() throws Exception { @Test void itReturnsRelease() throws Exception { // Given - var amendingNorm = Norm - .builder() - .regelungstexte( - Set.of( - new Regelungstext( - XmlMapper.toDocument( - """ - - - - - - - - - - - - - - - - - - - - - - - - - - - - Artikel 1 - Änderung des Vereinsgesetzes - - - - - - - - Das Vereinsgesetz vom 5. August 1964 (BGBl. I S. 593), das zuletzt durch … geändert worden ist, wird wie folgt geändert: - - - - - - - - Artikel 3 - Inkrafttreten - - - - - - - Dieses Gesetz tritt am Tag - nach der Verkündung in Kraft. - - - - - - - """ - ) - ) - ) - ) - .build(); - var affectedNorm = Norm - .builder() - .regelungstexte( - Set.of( - new Regelungstext( - XmlMapper.toDocument( - """ - - - - - - - - - - - - - - - - - - - - - - - - - - - """ - ) - ) - ) - ) - .build(); - var affectedNormZf0 = Norm - .builder() - .regelungstexte( - Set.of( - new Regelungstext( - XmlMapper.toDocument( - """ - - - - - - - - - - - - - - - - - - - - - - - - - - - """ - ) - ) - ) - ) - .build(); + var amendingNorm = Fixtures.loadNormFromDisk("NormWithMods.xml"); + var affectedNorm = Fixtures.loadNormFromDisk("NormWithoutPassiveModifications.xml"); + var affectedNormZf0 = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); var normDto1 = normRepository.save(NormMapper.mapToDto(amendingNorm)); var normDto2 = normRepository.save(NormMapper.mapToDto(affectedNorm)); @@ -522,7 +180,7 @@ void itReturnsRelease() throws Exception { mockMvc .perform( get( - "/api/v1/announcements/eli/bund/bgbl-1/2023/413/2023-12-29/1/deu/regelungstext-1/releases" + "/api/v1/announcements/eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/regelungstext-1/releases" ) .accept(MediaType.APPLICATION_JSON) ) @@ -535,19 +193,19 @@ void itReturnsRelease() throws Exception { .andExpect( jsonPath( "[0].norms[0]", - equalTo("eli/bund/bgbl-1/2023/413/2023-12-29/1/deu/2022-08-23/regelungstext-1.xml") + equalTo("eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/2022-08-23/regelungstext-1.xml") ) ) .andExpect( jsonPath( "[0].norms[1]", - equalTo("eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/2022-08-23/regelungstext-1.xml") + equalTo("eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/1964-08-05/regelungstext-1.xml") ) ) .andExpect( jsonPath( "[0].norms[2]", - equalTo("eli/bund/bgbl-1/1964/s593/2023-12-29/1/deu/2022-08-23/regelungstext-1.xml") + equalTo("eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/2022-08-23/regelungstext-1.xml") ) ); } @@ -668,7 +326,7 @@ void itReleaseAnnouncement() throws Exception { ) ); - var publishedManifestationOfAmendingNorm = normRepository.findByEliManifestation( + var publishedManifestationOfAmendingNorm = normRepository.findByEliDokumentManifestation( "eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/%s/regelungstext-1.xml".formatted( LocalDate.now().toString() ) @@ -677,7 +335,7 @@ void itReleaseAnnouncement() throws Exception { assertThat(publishedManifestationOfAmendingNorm.get().getPublishState()) .isEqualTo(NormPublishState.QUEUED_FOR_PUBLISH); - var publishedZf0ManifestationOfTargetNorm = normRepository.findByEliManifestation( + var publishedZf0ManifestationOfTargetNorm = normRepository.findByEliDokumentManifestation( "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/%s/regelungstext-1.xml".formatted( LocalDate.now().toString() ) @@ -687,7 +345,7 @@ void itReleaseAnnouncement() throws Exception { .isEqualTo(NormPublishState.QUEUED_FOR_PUBLISH); var publishedManifestationOfTargetNormAtFirstTimeBoundary = - normRepository.findByEliManifestation( + normRepository.findByEliDokumentManifestation( "eli/bund/bgbl-1/1964/s593/2017-03-23/1/deu/%s/regelungstext-1.xml".formatted( LocalDate.now().toString() ) @@ -696,7 +354,7 @@ void itReleaseAnnouncement() throws Exception { assertThat(publishedManifestationOfTargetNormAtFirstTimeBoundary.get().getPublishState()) .isEqualTo(NormPublishState.QUEUED_FOR_PUBLISH); - var newUnpublishedManifestationOfAmendingNorm = normRepository.findByEliManifestation( + var newUnpublishedManifestationOfAmendingNorm = normRepository.findByEliDokumentManifestation( "eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/%s/regelungstext-1.xml".formatted( LocalDate.now().plusDays(1).toString() ) @@ -705,7 +363,7 @@ void itReleaseAnnouncement() throws Exception { assertThat(newUnpublishedManifestationOfAmendingNorm.get().getPublishState()) .isEqualTo(NormPublishState.UNPUBLISHED); - var newUnpublishedManifestationOfTargetNorm = normRepository.findByEliManifestation( + var newUnpublishedManifestationOfTargetNorm = normRepository.findByEliDokumentManifestation( "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/%s/regelungstext-1.xml".formatted( LocalDate.now().plusDays(1).toString() ) @@ -753,7 +411,7 @@ void releasingAnAnnouncementASecondTimeCreatesTheSameFilesAndCleansUpOldRelease( ) .andExpect(status().isOk()); - var publishedManifestationOfAmendingNorm = normRepository.findByEliManifestation( + var publishedManifestationOfAmendingNorm = normRepository.findByEliDokumentManifestation( "eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/%s/regelungstext-1.xml".formatted( LocalDate.now().toString() ) @@ -762,7 +420,7 @@ void releasingAnAnnouncementASecondTimeCreatesTheSameFilesAndCleansUpOldRelease( assertThat(publishedManifestationOfAmendingNorm.get().getPublishState()) .isEqualTo(NormPublishState.QUEUED_FOR_PUBLISH); - var publishedZf0ManifestationOfTargetNorm = normRepository.findByEliManifestation( + var publishedZf0ManifestationOfTargetNorm = normRepository.findByEliDokumentManifestation( "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/%s/regelungstext-1.xml".formatted( LocalDate.now().toString() ) @@ -772,7 +430,7 @@ void releasingAnAnnouncementASecondTimeCreatesTheSameFilesAndCleansUpOldRelease( .isEqualTo(NormPublishState.QUEUED_FOR_PUBLISH); var publishedManifestationOfTargetNormAtFirstTimeBoundary = - normRepository.findByEliManifestation( + normRepository.findByEliDokumentManifestation( "eli/bund/bgbl-1/1964/s593/2017-03-23/1/deu/%s/regelungstext-1.xml".formatted( LocalDate.now().toString() ) @@ -781,7 +439,7 @@ void releasingAnAnnouncementASecondTimeCreatesTheSameFilesAndCleansUpOldRelease( assertThat(publishedManifestationOfTargetNormAtFirstTimeBoundary.get().getPublishState()) .isEqualTo(NormPublishState.QUEUED_FOR_PUBLISH); - var newUnpublishedManifestationOfAmendingNorm = normRepository.findByEliManifestation( + var newUnpublishedManifestationOfAmendingNorm = normRepository.findByEliDokumentManifestation( "eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/%s/regelungstext-1.xml".formatted( LocalDate.now().plusDays(1).toString() ) @@ -790,7 +448,7 @@ void releasingAnAnnouncementASecondTimeCreatesTheSameFilesAndCleansUpOldRelease( assertThat(newUnpublishedManifestationOfAmendingNorm.get().getPublishState()) .isEqualTo(NormPublishState.UNPUBLISHED); - var newUnpublishedManifestationOfTargetNorm = normRepository.findByEliManifestation( + var newUnpublishedManifestationOfTargetNorm = normRepository.findByEliDokumentManifestation( "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/%s/regelungstext-1.xml".formatted( LocalDate.now().plusDays(1).toString() ) @@ -833,19 +491,19 @@ void failsWhenTryingToReleaseAnXsdInvalidNorm() throws Exception { // Content of the DB should be unchanged = 3 sample norms, all unpublished assertThat(normRepository.findAll()).hasSize(3); assertThat( - normRepository.findByEliManifestation( + normRepository.findByEliDokumentManifestation( "eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/2022-08-23/regelungstext-1.xml" ) ) .isNotEmpty(); assertThat( - normRepository.findByEliManifestation( + normRepository.findByEliDokumentManifestation( "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/1964-08-05/regelungstext-1.xml" ) ) .isNotEmpty(); - var originalNormWithPassiveMods = normRepository.findByEliManifestation( + var originalNormWithPassiveMods = normRepository.findByEliDokumentManifestation( "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/2022-08-23/regelungstext-1.xml" ); @@ -882,19 +540,19 @@ void failsWhenTryingToReleaseASchematronInvalidNorm() throws Exception { // Content of the DB should be unchanged = 3 sample norms, all unpublished assertThat(normRepository.findAll()).hasSize(3); assertThat( - normRepository.findByEliManifestation( + normRepository.findByEliDokumentManifestation( "eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/2022-08-23/regelungstext-1.xml" ) ) .isNotEmpty(); assertThat( - normRepository.findByEliManifestation( + normRepository.findByEliDokumentManifestation( "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/1964-08-05/regelungstext-1.xml" ) ) .isNotEmpty(); assertThat( - normRepository.findByEliManifestation( + normRepository.findByEliDokumentManifestation( "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/2022-08-23/regelungstext-1.xml" ) ) @@ -931,7 +589,7 @@ void itCreatesANewAnnouncement() throws Exception { // Assert ZF0 was created assertThat( - normRepository.findByEliManifestation( + normRepository.findByEliDokumentManifestation( "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/%s/regelungstext-1.xml".formatted( LocalDate.now().toString() ) @@ -1196,7 +854,7 @@ void ifCreatesAnnouncementWithForce() throws Exception { // Assert ZF0 was created assertThat( - normRepository.findByEliManifestation( + normRepository.findByEliDokumentManifestation( "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/%s/regelungstext-1.xml".formatted( LocalDate.now().toString() ) @@ -1206,7 +864,7 @@ void ifCreatesAnnouncementWithForce() throws Exception { // Assert old ZF0 was deleted assertThat( - normRepository.findByEliManifestation( + normRepository.findByEliDokumentManifestation( "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/2022-08-23/regelungstext-1.xml" ) ) 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 45778dcf7..85451c354 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 @@ -659,9 +659,11 @@ void itThrowsValidationExceptionBecauseWithinTimeMachineMetaModDoesNotHaveSource + + @@ -766,9 +768,11 @@ void itThrowsMandatoryNodeNotFoundBecauseTemporalDataMissing() throws Exception + + 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 0aebe1b8c..153147c36 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 @@ -360,9 +360,11 @@ void itCallsNormServiceAndUpdatesNorm() throws Exception { + + @@ -372,6 +374,9 @@ void itCallsNormServiceAndUpdatesNorm() throws Exception { + + + 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 73e7b8a1b..f7c56d7a4 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 @@ -256,7 +256,9 @@ void updatesAll() throws Exception { .andExpect(jsonPath("organisationsEinheit").value("Andere Organisationseinheit")); final Norm normLoaded = NormMapper.mapToDomain( - normRepository.findFirstByEliExpressionOrderByEliManifestationDesc(eli).get() + normRepository + .findFirstByEliDokumentExpressionOrderByEliDokumentManifestationDesc(eli) + .get() ); assertThat(normLoaded.getMeta().getOrCreateProprietary().getFna(date)).contains("new-fna"); @@ -322,7 +324,9 @@ void doesResetAllFieldsBySendingNullAndGetSomeDefaults() throws Exception { .andExpect(jsonPath("organisationsEinheit").isEmpty()); final Norm normLoaded = NormMapper.mapToDomain( - normRepository.findFirstByEliExpressionOrderByEliManifestationDesc(eli).get() + normRepository + .findFirstByEliDokumentExpressionOrderByEliDokumentManifestationDesc(eli) + .get() ); assertThat(normLoaded.getMeta().getOrCreateProprietary().getFna(date)).contains("754-28-1"); @@ -386,7 +390,9 @@ void doesResetAllFieldsBySendingEmptyStringAndGetSomeDefaults() throws Exception .andExpect(jsonPath("organisationsEinheit").isEmpty()); final Norm normLoaded = NormMapper.mapToDomain( - normRepository.findFirstByEliExpressionOrderByEliManifestationDesc(eli).get() + normRepository + .findFirstByEliDokumentExpressionOrderByEliDokumentManifestationDesc(eli) + .get() ); assertThat(normLoaded.getMeta().getOrCreateProprietary().getFna(date)).contains("754-28-1"); @@ -450,7 +456,9 @@ void updatesProprietaryByCreatingNewMetadatenDsNodes() throws Exception { // then final Norm normLoaded = NormMapper.mapToDomain( - normRepository.findFirstByEliExpressionOrderByEliManifestationDesc(eli).get() + normRepository + .findFirstByEliDokumentExpressionOrderByEliDokumentManifestationDesc(eli) + .get() ); assertThat(normLoaded.getMeta().getOrCreateProprietary().getFna(date)).contains("fna"); @@ -515,7 +523,9 @@ void updatesProprietaryByCreatingNewProprietaryAndMetadatenDsNodes() throws Exce // then final Norm normLoaded = NormMapper.mapToDomain( - normRepository.findFirstByEliExpressionOrderByEliManifestationDesc(eli).get() + normRepository + .findFirstByEliDokumentExpressionOrderByEliDokumentManifestationDesc(eli) + .get() ); assertThat(normLoaded.getMeta().getOrCreateProprietary().getFna(date)).contains("fna"); @@ -581,7 +591,9 @@ void doesRemoveQualifizierteMehrheitFromBeschliessendesOrganWhenNull() throws Ex .andExpect(jsonPath("organisationsEinheit").value("Andere Organisationseinheit")); final Norm normLoaded = NormMapper.mapToDomain( - normRepository.findFirstByEliExpressionOrderByEliManifestationDesc(eli).get() + normRepository + .findFirstByEliDokumentExpressionOrderByEliDokumentManifestationDesc(eli) + .get() ); assertThat(normLoaded.getMeta().getOrCreateProprietary().getFna(date)).contains("new-fna"); @@ -642,7 +654,9 @@ void createsProprietaryAndMetadatenDsAndUpdatesFna() throws Exception { .andExpect(jsonPath("organisationsEinheit").value("Organisationseinheit")); final Norm normLoaded = NormMapper.mapToDomain( - normRepository.findFirstByEliExpressionOrderByEliManifestationDesc(eli).get() + normRepository + .findFirstByEliDokumentExpressionOrderByEliDokumentManifestationDesc(eli) + .get() ); assertThat(normLoaded.getMeta().getOrCreateProprietary().getFna(date)).contains("new-fna"); diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/TimeBoundaryControllerIntegrationTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/TimeBoundaryControllerIntegrationTest.java index b77f07d01..29cb4306a 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/TimeBoundaryControllerIntegrationTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/integration/adapter/input/restapi/TimeBoundaryControllerIntegrationTest.java @@ -9,6 +9,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.Fixtures; import de.bund.digitalservice.ris.norms.domain.entity.Norm; import de.bund.digitalservice.ris.norms.domain.entity.Regelungstext; import de.bund.digitalservice.ris.norms.integration.BaseIntegrationTest; @@ -71,68 +72,25 @@ void itCallsGetTimeBoundariesAndReturns404() throws Exception { @Test void itCallsGetTimeBoundariesAndReturnsJson() throws Exception { // Given - final String eli = "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1"; - final String xml = - """ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - """.strip(); - - // When - var norm = Norm - .builder() - .regelungstexte(Set.of(new Regelungstext(XmlMapper.toDocument(xml)))) - .build(); + var norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); normRepository.save(NormMapper.mapToDto(norm)); // When // Then mockMvc - .perform(get("/api/v1/norms/{eli}/timeBoundaries", eli).accept(MediaType.APPLICATION_JSON)) + .perform( + get("/api/v1/norms/{eli}/timeBoundaries", norm.getExpressionEli()) + .accept(MediaType.APPLICATION_JSON) + ) .andExpect(status().isOk()) - .andExpect(jsonPath("$", hasSize(2))) - .andExpect(jsonPath("$[0].date", is("2023-12-30"))) + .andExpect(jsonPath("$", hasSize(4))) + .andExpect(jsonPath("$[0].date", is("1964-09-21"))) .andExpect(jsonPath("$[0].eventRefEid", is("meta-1_lebzykl-1_ereignis-2"))) - .andExpect(jsonPath("$[1].date", is("2024-01-01"))) - .andExpect(jsonPath("$[1].eventRefEid", is("meta-1_lebzykl-1_ereignis-3"))); + .andExpect(jsonPath("$[1].date", is("2017-03-23"))) + .andExpect(jsonPath("$[1].eventRefEid", is("meta-1_lebzykl-1_ereignis-4"))) + .andExpect(jsonPath("$[2].date", is("2019-01-01"))) + .andExpect(jsonPath("$[2].eventRefEid", is("meta-1_lebzykl-1_ereignis-5"))) + .andExpect(jsonPath("$[3].date", is("2017-03-01"))) + .andExpect(jsonPath("$[3].eventRefEid", is("meta-1_lebzykl-1_ereignis-6"))); } } @@ -175,92 +133,19 @@ void itCallsGetTimeBoundariesAmendedByAndReturns404() throws Exception { @Test void itCallsGetTimeBoundariesAmendedByAndReturnsEmpty() throws Exception { // Given - final String eli = "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1"; var amendedBy = "eli/bund/bgbl-1/2024/81/2024-03-05/1/deu/non-in-norm"; - var norm = Norm - .builder() - .regelungstexte( - Set.of( - new Regelungstext( - XmlMapper.toDocument( - """ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - """ - ) - ) - ) - ) - .build(); + var norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); normRepository.save(NormMapper.mapToDto(norm)); // When // Then mockMvc .perform( - get("/api/v1/norms/{eli}/timeBoundaries?amendedBy={amendedBy}", eli, amendedBy) + get( + "/api/v1/norms/{eli}/timeBoundaries?amendedBy={amendedBy}", + norm.getExpressionEli(), + amendedBy + ) .accept(MediaType.APPLICATION_JSON) ) .andExpect(status().isOk()) @@ -270,102 +155,26 @@ void itCallsGetTimeBoundariesAmendedByAndReturnsEmpty() throws Exception { @Test void itCallsGetTimeBoundariesAmendedByAndReturnsJson() throws Exception { // Given - final String eli = "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1"; - var amendedBy = "eli/bund/bgbl-1/2024/81/2024-03-05/1/deu/regelungstext-1"; + var amendedBy = "eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/regelungstext-1"; - var norm = Norm - .builder() - .regelungstexte( - Set.of( - new Regelungstext( - XmlMapper.toDocument( - """ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - """ - ) - ) - ) - ) - .build(); + var norm = Fixtures.loadNormFromDisk("NormWithPassiveModifications.xml"); normRepository.save(NormMapper.mapToDto(norm)); // When // Then mockMvc .perform( - get("/api/v1/norms/{eli}/timeBoundaries?amendedBy={amendedBy}", eli, amendedBy) + get( + "/api/v1/norms/{eli}/timeBoundaries?amendedBy={amendedBy}", + norm.getExpressionEli(), + amendedBy + ) .accept(MediaType.APPLICATION_JSON) ) .andExpect(status().isOk()) - .andExpect(jsonPath("$", hasSize(2))) - .andExpect(jsonPath("$[0].date", is("2024-01-01"))) - .andExpect(jsonPath("$[0].eventRefEid", is("meta-1_lebzykl-1_ereignis-3"))) - .andExpect(jsonPath("$[0].temporalGroupEid", is("meta-1_geltzeiten-1_geltungszeitgr-2"))) - .andExpect(jsonPath("$[1].date", is("2024-02-28"))) - .andExpect(jsonPath("$[1].eventRefEid", is("meta-1_lebzykl-1_ereignis-4"))) - .andExpect(jsonPath("$[1].temporalGroupEid", is("meta-1_geltzeiten-1_geltungszeitgr-3"))); + .andExpect(jsonPath("$", hasSize(1))) + .andExpect(jsonPath("$[0].date", is("2017-03-23"))) + .andExpect(jsonPath("$[0].eventRefEid", is("meta-1_lebzykl-1_ereignis-4"))) + .andExpect(jsonPath("$[0].temporalGroupEid", is("meta-1_geltzeiten-1_geltungszeitgr-2"))); } } @@ -408,130 +217,16 @@ void itCallsPutTimeBoundariesAndReturns404() throws Exception { ); } - @Test - void itCallsUpdateTimeBoundaries() throws Exception { - final String eli = "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1"; - final String xml = - """ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - """.strip(); - - // When - var norm = Norm - .builder() - .regelungstexte(Set.of(new Regelungstext(XmlMapper.toDocument(xml)))) - .build(); - normRepository.save(NormMapper.mapToDto(norm)); - - // Then - mockMvc - .perform( - put("/api/v1/norms/{eli}/timeBoundaries", eli) - .accept(MediaType.APPLICATION_JSON) - .contentType(MediaType.APPLICATION_JSON) - .content( - "[{\"date\": \"2023-12-30\", \"eventRefEid\": \"meta-1_lebzykl-1_ereignis-2\"},{\"date\": \"2024-01-01\", \"eventRefEid\": null}]" - ) - ) - .andExpect(status().isOk()) - .andExpect(jsonPath("$", hasSize(2))) - // still there - .andExpect(jsonPath("$[0].date", is("2023-12-30"))) - .andExpect(jsonPath("$[0].eventRefEid", is("meta-1_lebzykl-1_ereignis-2"))) - // expect new - .andExpect(jsonPath("$[1].date", is("2024-01-01"))) - .andExpect(jsonPath("$[1].eventRefEid", is("meta-1_lebzykl-1_ereignis-3"))); - } - @Test void itCallsUpdateTimeBoundariesDateNull() throws Exception { - final String eli = "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1"; - final String xml = - """ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - """.strip(); - // When - var norm = Norm - .builder() - .regelungstexte(Set.of(new Regelungstext(XmlMapper.toDocument(xml)))) - .build(); + var norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); normRepository.save(NormMapper.mapToDto(norm)); // Then mockMvc .perform( - put("/api/v1/norms/{eli}/timeBoundaries", eli) + put("/api/v1/norms/{eli}/timeBoundaries", norm.getExpressionEli()) .accept(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON) .content("[{\"date\": null, \"eventRefEid\": null}]") @@ -552,51 +247,9 @@ void itCallsUpdateTimeBoundariesDateNull() throws Exception { @Test void itCallsUpdateTimeBoundariesDateMalformed() throws Exception { final String eli = "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1"; - final String xml = - """ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - """.strip(); // When - var norm = Norm - .builder() - .regelungstexte(Set.of(new Regelungstext(XmlMapper.toDocument(xml)))) - .build(); + var norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); normRepository.save(NormMapper.mapToDto(norm)); // Then @@ -622,51 +275,9 @@ void itCallsUpdateTimeBoundariesDateMalformed() throws Exception { @Test void itCallsUpdateTimeBoundariesMultipleSameDates() throws Exception { final String eli = "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1"; - final String xml = - """ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - """.strip(); // When - var norm = Norm - .builder() - .regelungstexte(Set.of(new Regelungstext(XmlMapper.toDocument(xml)))) - .build(); + var norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); normRepository.save(NormMapper.mapToDto(norm)); // Then @@ -696,218 +307,6 @@ void itCallsUpdateTimeBoundariesMultipleSameDates() throws Exception { ); } - @Test - void itCallsUpdateTimeBoundariesDelete() throws Exception { - final String eli = "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1"; - final String xml = - """ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - """.strip(); - - // When - var norm = Norm - .builder() - .regelungstexte(Set.of(new Regelungstext(XmlMapper.toDocument(xml)))) - .build(); - normRepository.save(NormMapper.mapToDto(norm)); - - // Then - mockMvc - .perform( - put("/api/v1/norms/{eli}/timeBoundaries", eli) - .accept(MediaType.APPLICATION_JSON) - .contentType(MediaType.APPLICATION_JSON) - .content( - "[{\"date\": \"2023-12-30\", \"eventRefEid\": \"meta-1_lebzykl-1_ereignis-2\"}]" - ) - ) - .andExpect(status().isOk()) - .andExpect(jsonPath("$", hasSize(1))) - // still there - .andExpect(jsonPath("$[0].date", is("2023-12-30"))) - .andExpect(jsonPath("$[0].eventRefEid", is("meta-1_lebzykl-1_ereignis-2"))); - } - - @Test - void itCallsUpdateTimeBoundariesAddAndDelete() throws Exception { - final String eli = "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1"; - final String xml = - """ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - """.strip(); - - // When - var norm = Norm - .builder() - .regelungstexte(Set.of(new Regelungstext(XmlMapper.toDocument(xml)))) - .build(); - normRepository.save(NormMapper.mapToDto(norm)); - - // Then - mockMvc - .perform( - put("/api/v1/norms/{eli}/timeBoundaries", eli) - .accept(MediaType.APPLICATION_JSON) - .contentType(MediaType.APPLICATION_JSON) - .content("[{\"date\": \"2024-01-01\", \"eventRefEid\": null}]") - ) - .andExpect(status().isOk()) - .andExpect(jsonPath("$", hasSize(1))) - // expect new - .andExpect(jsonPath("$[0].date", is("2024-01-01"))) - .andExpect(jsonPath("$[0].eventRefEid", is("meta-1_lebzykl-1_ereignis-2"))); - } - - @Test - void itCallsUpdateTimeBoundariesAddAndDeleteWithTwo() throws Exception { - final String eli = "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/regelungstext-1"; - final String xml = - """ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - """.strip(); - - // When - var norm = Norm - .builder() - .regelungstexte(Set.of(new Regelungstext(XmlMapper.toDocument(xml)))) - .build(); - normRepository.save(NormMapper.mapToDto(norm)); - - // Then - mockMvc - .perform( - put("/api/v1/norms/{eli}/timeBoundaries", eli) - .accept(MediaType.APPLICATION_JSON) - .contentType(MediaType.APPLICATION_JSON) - .content( - "[{\"date\": \"2023-12-30\", \"eventRefEid\": \"meta-1_lebzykl-1_ereignis-2\"},{\"date\": \"2024-01-01\", \"eventRefEid\": null}]" - ) - ) - .andExpect(status().isOk()) - .andExpect(jsonPath("$", hasSize(2))) - // still there - .andExpect(jsonPath("$[0].date", is("2023-12-30"))) - .andExpect(jsonPath("$[0].eventRefEid", is("meta-1_lebzykl-1_ereignis-2"))) - // expect new - .andExpect(jsonPath("$[1].date", is("2024-01-01"))) - .andExpect(jsonPath("$[1].eventRefEid", is("meta-1_lebzykl-1_ereignis-3"))); - } - @Test void itCallsUpdateTimeBoundariesAddAndDeleteAndEdit() throws Exception { // the existing ones: @@ -949,17 +348,20 @@ void itCallsUpdateTimeBoundariesAddAndDeleteAndEdit() throws Exception { + + - - - - + + + + + loaded = normRepository.findByEliManifestation( + final Optional loaded = normRepository.findByEliDokumentManifestation( norm.getManifestationEli().toString() ); assertThat(loaded) diff --git a/backend/src/test/resources/de/bund/digitalservice/ris/norms/domain/entity/SimpleNorm.xml b/backend/src/test/resources/de/bund/digitalservice/ris/norms/domain/entity/SimpleNorm.xml index 7e1dbf8c4..6cf136602 100644 --- a/backend/src/test/resources/de/bund/digitalservice/ris/norms/domain/entity/SimpleNorm.xml +++ b/backend/src/test/resources/de/bund/digitalservice/ris/norms/domain/entity/SimpleNorm.xml @@ -36,6 +36,9 @@ + +