diff --git a/backend/src/main/java/de/bund/digitalservice/ris/norms/application/service/BillToActService.java b/backend/src/main/java/de/bund/digitalservice/ris/norms/application/service/BillToActService.java index 8f51bdddf..ff560eec6 100644 --- a/backend/src/main/java/de/bund/digitalservice/ris/norms/application/service/BillToActService.java +++ b/backend/src/main/java/de/bund/digitalservice/ris/norms/application/service/BillToActService.java @@ -118,7 +118,7 @@ private void rewriteFbrExpression(Norm norm) { final LocalDate verkuendungsDate = LocalDate.parse(fRBRExpression.getFBRDate(), formatter); final DokumentExpressionEli expressionEli = DokumentExpressionEli.fromWorkEli( - norm.getWorkEli(), + norm.getRegelungstext1().getWorkEli(), verkuendungsDate, fRBRExpression.getFRBRVersionNumber().orElseThrow(), fRBRExpression.getFRBRlanguage().orElseThrow() diff --git a/backend/src/main/java/de/bund/digitalservice/ris/norms/domain/entity/Norm.java b/backend/src/main/java/de/bund/digitalservice/ris/norms/domain/entity/Norm.java index 276f037b3..00d5af919 100644 --- a/backend/src/main/java/de/bund/digitalservice/ris/norms/domain/entity/Norm.java +++ b/backend/src/main/java/de/bund/digitalservice/ris/norms/domain/entity/Norm.java @@ -2,7 +2,9 @@ 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.eli.DokumentWorkEli; +import de.bund.digitalservice.ris.norms.domain.entity.eli.NormExpressionEli; +import de.bund.digitalservice.ris.norms.domain.entity.eli.NormManifestationEli; +import de.bund.digitalservice.ris.norms.domain.entity.eli.NormWorkEli; import java.time.LocalDate; import java.util.*; import java.util.stream.Collectors; @@ -54,28 +56,52 @@ public Document getDocument() { * * @return The work Eli */ - public DokumentWorkEli getWorkEli() { - return getRegelungstext1().getWorkEli(); + public NormWorkEli getWorkEli() { + return getRegelungstext1().getWorkEli().asNormEli(); } /** * Returns the expression Eli of the {@link Norm}. * * @return The expression Eli + * @deprecated use {@link #getNormExpressionEli()} instead */ + @Deprecated(forRemoval = true) public DokumentExpressionEli getExpressionEli() { return getRegelungstext1().getExpressionEli(); } + /** + * Returns the expression Eli of the {@link Norm}. + * + * @return The expression Eli + */ + // TODO: (Malte Laukötter, 2025-01-17) rename to getExpressionEli once the deprecated method is removed. + public NormExpressionEli getNormExpressionEli() { + return getExpressionEli().asNormEli(); + } + /** * Returns the manifestation Eli of the {@link Norm}. * * @return The manifestation Eli + * @deprecated use {@link #getNormManifestationEli()} instead */ + @Deprecated(forRemoval = true) public DokumentManifestationEli getManifestationEli() { return getRegelungstext1().getManifestationEli(); } + /** + * Returns the expression Eli of the {@link Norm}. + * + * @return The expression Eli + */ + // TODO: (Malte Laukötter, 2025-01-17) rename to getManifestationEli once the deprecated method is removed. + public NormManifestationEli getNormManifestationEli() { + return getManifestationEli().asNormEli(); + } + /** * Returns the current version GUID as {@link UUID} from the {@link Norm}. * diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/domain/entity/Fixtures.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/domain/entity/Fixtures.java index ba80d808c..f32ef5a15 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/domain/entity/Fixtures.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/domain/entity/Fixtures.java @@ -35,10 +35,11 @@ public static Norm loadNormFromDisk(final String fileName, boolean validated) { return ldmlDeValidator.parseAndValidate(loadFile(fileName)); } - return Norm - .builder() - .regelungstexte(Set.of(new Regelungstext(XmlMapper.toDocument(loadFile(fileName))))) - .build(); + return Norm.builder().regelungstexte(Set.of(loadRegelungstextFromDisk(fileName))).build(); + } + + public static Regelungstext loadRegelungstextFromDisk(final String fileName) { + return new Regelungstext(XmlMapper.toDocument(loadFile(fileName))); } public static String loadTextFromDisk(final String fileName) { 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 5d23ae49f..e782946ef 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 @@ -5,7 +5,9 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import de.bund.digitalservice.ris.norms.domain.entity.eli.DokumentExpressionEli; -import de.bund.digitalservice.ris.norms.domain.entity.eli.DokumentWorkEli; +import de.bund.digitalservice.ris.norms.domain.entity.eli.NormExpressionEli; +import de.bund.digitalservice.ris.norms.domain.entity.eli.NormManifestationEli; +import de.bund.digitalservice.ris.norms.domain.entity.eli.NormWorkEli; import de.bund.digitalservice.ris.norms.utils.NodeCreator; import de.bund.digitalservice.ris.norms.utils.NodeParser; import de.bund.digitalservice.ris.norms.utils.XmlMapper; @@ -38,6 +40,21 @@ void getExpressionEli() { assertThat(actualEli).isEqualTo(expectedEli); } + @Test + void getNormExpressionEli() { + // given + Norm norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); + NormExpressionEli expectedEli = NormExpressionEli.fromString( + "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu" + ); + + // when + var actualEli = norm.getNormExpressionEli(); + + // then + assertThat(actualEli).isEqualTo(expectedEli); + } + @Test void getWorkEli() { // given @@ -47,8 +64,22 @@ void getWorkEli() { var actualEli = norm.getWorkEli(); // then - assertThat(actualEli) - .isEqualTo(DokumentWorkEli.fromString("eli/bund/bgbl-1/1964/s593/regelungstext-1")); + assertThat(actualEli).isEqualTo(NormWorkEli.fromString("eli/bund/bgbl-1/1964/s593")); + } + + @Test + void getManifestationEli() { + // given + Norm norm = Fixtures.loadNormFromDisk("SimpleNorm.xml"); + NormManifestationEli expectedEli = NormManifestationEli.fromString( + "eli/bund/bgbl-1/1964/s593/1964-08-05/1/deu/1964-08-05" + ); + + // when + var actualEli = norm.getNormManifestationEli(); + + // then + assertThat(actualEli).isEqualTo(expectedEli); } @Test diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/domain/entity/RegelungstextTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/domain/entity/RegelungstextTest.java new file mode 100644 index 000000000..013a5d8ce --- /dev/null +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/domain/entity/RegelungstextTest.java @@ -0,0 +1,22 @@ +package de.bund.digitalservice.ris.norms.domain.entity; + +import static org.assertj.core.api.Assertions.assertThat; + +import de.bund.digitalservice.ris.norms.domain.entity.eli.DokumentWorkEli; +import org.junit.jupiter.api.Test; + +class RegelungstextTest { + + @Test + void getWorkEli() { + // given + Regelungstext regelungstext = Fixtures.loadRegelungstextFromDisk("SimpleNorm.xml"); + + // when + var actualEli = regelungstext.getWorkEli(); + + // then + assertThat(actualEli) + .isEqualTo(DokumentWorkEli.fromString("eli/bund/bgbl-1/1964/s593/regelungstext-1")); + } +}