diff --git a/backend/src/main/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/ArticleController.java b/backend/src/main/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/ArticleController.java index f65ba03e9..8affb975d 100644 --- a/backend/src/main/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/ArticleController.java +++ b/backend/src/main/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/ArticleController.java @@ -63,14 +63,8 @@ public ResponseEntity> getArticles( @RequestParam final Optional amendedBy, @RequestParam final Optional amendedAt ) { - final var query = new LoadArticlesFromDokumentUseCase.Query( - eli, - amendedBy.orElse(null), - amendedAt.orElse(null) - ); - final var articlesWithZf0 = loadArticlesFromDokumentUseCase - .loadArticlesFromDokument(query) + .loadArticlesFromDokument(new LoadArticlesFromDokumentUseCase.Query(eli)) .stream() .map(ArticleResponseMapper::fromNormArticle) .toList(); diff --git a/backend/src/main/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/ElementController.java b/backend/src/main/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/ElementController.java index effff0d07..139a9386a 100644 --- a/backend/src/main/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/ElementController.java +++ b/backend/src/main/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/ElementController.java @@ -94,9 +94,7 @@ public ResponseEntity> getElementList( @RequestParam final Optional amendedBy ) { List elements = loadElementsByTypeUseCase - .loadElementsByType( - new LoadElementsByTypeUseCase.Query(eli, Arrays.asList(type), amendedBy.orElse(null)) - ) + .loadElementsByType(new LoadElementsByTypeUseCase.Query(eli, Arrays.asList(type))) .stream() .map(ElementResponseMapper::fromElementNode) .toList(); diff --git a/backend/src/main/java/de/bund/digitalservice/ris/norms/application/port/input/LoadArticlesFromDokumentUseCase.java b/backend/src/main/java/de/bund/digitalservice/ris/norms/application/port/input/LoadArticlesFromDokumentUseCase.java index c075cd894..1eaa23f51 100644 --- a/backend/src/main/java/de/bund/digitalservice/ris/norms/application/port/input/LoadArticlesFromDokumentUseCase.java +++ b/backend/src/main/java/de/bund/digitalservice/ris/norms/application/port/input/LoadArticlesFromDokumentUseCase.java @@ -1,16 +1,14 @@ package de.bund.digitalservice.ris.norms.application.port.input; import de.bund.digitalservice.ris.norms.domain.entity.Article; +import de.bund.digitalservice.ris.norms.domain.entity.Dokument; import de.bund.digitalservice.ris.norms.domain.entity.eli.DokumentExpressionEli; import java.util.List; -import javax.annotation.Nullable; -/** Use case for getting a list of {@link Article}s from a Dokument (eg. {@link de.bund.digitalservice.ris.norms.domain.entity.Regelungstext}). */ +/** Use case for getting a list of {@link Article}s from a {@link Dokument}. */ public interface LoadArticlesFromDokumentUseCase { /** - * Load the list of articles from a dokument. Articles can be filtered based on whether they have - * pending (passive) modifications that originate from a specific law, or that will be applied at - * a specific date. + * Load the list of articles from a dokument. * * @param query Query used for identifying the articles * @return List of articles (can be empty) @@ -21,19 +19,6 @@ public interface LoadArticlesFromDokumentUseCase { * Contains the parameters needed for loading articles from a dokument. * * @param eli The ELI used to identify the dokument - * @param amendedBy ELI of an amending law. When specified, only articles with passive - * modifications from that amending law are included in the result. - * @param amendedAt eId of a lifecycle event. When specified, only articles with passive - * modifications that will be applied at the date of this lifecycle event will be included in - * the result. */ - record Query( - DokumentExpressionEli eli, - @Nullable DokumentExpressionEli amendedBy, - @Nullable String amendedAt - ) { - public Query(DokumentExpressionEli eli) { - this(eli, null, null); - } - } + record Query(DokumentExpressionEli eli) {} } diff --git a/backend/src/main/java/de/bund/digitalservice/ris/norms/application/port/input/LoadElementsByTypeUseCase.java b/backend/src/main/java/de/bund/digitalservice/ris/norms/application/port/input/LoadElementsByTypeUseCase.java index 6096092cb..322efcf8b 100644 --- a/backend/src/main/java/de/bund/digitalservice/ris/norms/application/port/input/LoadElementsByTypeUseCase.java +++ b/backend/src/main/java/de/bund/digitalservice/ris/norms/application/port/input/LoadElementsByTypeUseCase.java @@ -4,14 +4,12 @@ import de.bund.digitalservice.ris.norms.domain.entity.eli.DokumentExpressionEli; import de.bund.digitalservice.ris.norms.utils.exceptions.NormsAppException; import java.util.List; -import javax.annotation.Nullable; import org.w3c.dom.Node; /** Use case for getting a list of elements of certain types as {@link Node} from a dokument. */ public interface LoadElementsByTypeUseCase { /** - * Load the list of elements of certain types from the dokument. Elements can additionally be filtered - * to include only those touched by a specific amending command. + * Load the list of elements of certain types from the dokument. * * @return List of elements from the dokument * @param query Query used for identifying the elements @@ -24,18 +22,8 @@ public interface LoadElementsByTypeUseCase { * @param eli The ELI used to identify the dokument * @param elementType The types of the elements. While this is a list of strings, only certain * values are allowed. Check {@link ElementService.ElementType} for the supported types. - * @param amendedBy EId of an amending command. If provided, filters the list to include only - * elements touched by that amending command. */ - record Query( - DokumentExpressionEli eli, - List elementType, - @Nullable DokumentExpressionEli amendedBy - ) { - public Query(DokumentExpressionEli eli, List elementType) { - this(eli, elementType, null); - } - } + record Query(DokumentExpressionEli eli, List elementType) {} /** Indicates that at least one of the requested types is not supported. */ class UnsupportedElementTypeException diff --git a/backend/src/main/java/de/bund/digitalservice/ris/norms/application/service/ArticleService.java b/backend/src/main/java/de/bund/digitalservice/ris/norms/application/service/ArticleService.java index f8ecd2416..672268033 100644 --- a/backend/src/main/java/de/bund/digitalservice/ris/norms/application/service/ArticleService.java +++ b/backend/src/main/java/de/bund/digitalservice/ris/norms/application/service/ArticleService.java @@ -6,13 +6,9 @@ import de.bund.digitalservice.ris.norms.application.port.input.*; import de.bund.digitalservice.ris.norms.application.port.output.LoadRegelungstextPort; import de.bund.digitalservice.ris.norms.domain.entity.*; -import de.bund.digitalservice.ris.norms.domain.entity.eli.DokumentExpressionEli; import de.bund.digitalservice.ris.norms.utils.XmlMapper; -import java.util.Collections; import java.util.List; import java.util.Objects; -import java.util.Optional; -import java.util.function.Predicate; import org.springframework.stereotype.Service; /** Service for loading a norm's articles */ @@ -56,57 +52,11 @@ public String loadArticleHtml(final LoadArticleHtmlUseCase.Query query) { @Override public List
loadArticlesFromDokument(final LoadArticlesFromDokumentUseCase.Query query) { - final var amendedAt = query.amendedAt(); - final var amendedBy = query.amendedBy(); - final var regelungstext = loadRegelungstextPort .loadRegelungstext(new LoadRegelungstextPort.Command(query.eli())) .orElseThrow(() -> new RegelungstextNotFoundException(query.eli().toString())); - List
articles = regelungstext.getArticles(); - - // Filter list of articles by passive mods if at least one filter is specified - if (amendedBy != null || amendedAt != null) { - var filterPassiveMods = getPassiveModsAmendingByOrAt(regelungstext, amendedBy, amendedAt); - var passiveModFilter = createPassiveModFilter(filterPassiveMods); - articles = articles.stream().filter(passiveModFilter).toList(); - } - - return articles; - } - - private List getPassiveModsAmendingByOrAt( - final Regelungstext fromRegelungstext, - final DokumentExpressionEli amendingBy, - final String amendingAt - ) { - if (amendingBy == null && amendingAt == null) return List.of(); - - return fromRegelungstext - .getMeta() - .getAnalysis() - .map(Analysis::getPassiveModifications) - .orElse(Collections.emptyList()) - .stream() - .filter(passiveModification -> { - if (amendingBy == null) return true; - - return passiveModification - .getSourceHref() - .flatMap(Href::getExpressionEli) - .map(sourceEli -> sourceEli.equals(amendingBy)) - .orElse(false); - }) - .filter(passiveModification -> { - if (amendingAt == null) return true; - - return passiveModification - .getForcePeriodEid() - .flatMap(fromRegelungstext::getStartEventRefForTemporalGroup) - .map(startEventRef -> startEventRef.equals(amendingAt)) - .orElse(false); - }) - .toList(); + return regelungstext.getArticles(); } @Override @@ -132,24 +82,4 @@ public List loadSpecificArticlesXmlFromDokument( return articles.stream().map(a -> XmlMapper.toString(a.getElement())).toList(); } - - private Predicate
createPassiveModFilter(final List mods) { - return article -> - // If we filter by amendedAt or amendedBy: Those properties are found - // in the passive modifications we already collected above. What's left - // now is to only return the articles that are going to be modified by - // those passive modifications. - mods - .stream() - .map(TextualMod::getDestinationHref) - .flatMap(Optional::stream) - .map(Href::getEId) - .flatMap(Optional::stream) - .anyMatch(destinationEid -> - // Modifications can be either on the article itself or anywhere - // inside the article, hence the "contains" rather than exact - // matching. - destinationEid.contains(article.getEid()) - ); - } } diff --git a/backend/src/main/java/de/bund/digitalservice/ris/norms/application/service/ElementService.java b/backend/src/main/java/de/bund/digitalservice/ris/norms/application/service/ElementService.java index 0e60d20cd..8d4c91b45 100644 --- a/backend/src/main/java/de/bund/digitalservice/ris/norms/application/service/ElementService.java +++ b/backend/src/main/java/de/bund/digitalservice/ris/norms/application/service/ElementService.java @@ -4,18 +4,10 @@ import de.bund.digitalservice.ris.norms.application.exception.RegelungstextNotFoundException; import de.bund.digitalservice.ris.norms.application.port.input.*; import de.bund.digitalservice.ris.norms.application.port.output.LoadRegelungstextPort; -import de.bund.digitalservice.ris.norms.domain.entity.Analysis; -import de.bund.digitalservice.ris.norms.domain.entity.EId; -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.TextualMod; -import de.bund.digitalservice.ris.norms.domain.entity.eli.DokumentExpressionEli; import de.bund.digitalservice.ris.norms.utils.NodeParser; import de.bund.digitalservice.ris.norms.utils.XmlMapper; -import java.util.Collections; import java.util.List; -import java.util.Optional; -import javax.annotation.Nullable; import org.springframework.stereotype.Service; import org.w3c.dom.Node; @@ -120,52 +112,13 @@ public List loadElementsByType(LoadElementsByTypeUseCase.Query query) { .loadRegelungstext(new LoadRegelungstextPort.Command(query.eli())) .orElseThrow(() -> new RegelungstextNotFoundException(query.eli().toString())); - // Source EIDs from passive mods - final var passiveModsDestinationEids = getDestinationEidsFromPassiveMods( - regelungstext - .getMeta() - .getAnalysis() - .map(Analysis::getPassiveModifications) - .orElse(Collections.emptyList()), - query.amendedBy() - ); - return NodeParser .getNodesFromExpression(combinedXPaths, regelungstext.getDocument()) .stream() - .filter(element -> { // filter by "amendedBy") - // no amending law -> all elements are fine - if (query.amendedBy() == null) return true; - - var eId = EId.fromMandatoryNode(element).value(); - return passiveModsDestinationEids.stream().anyMatch(modEid -> modEid.contains(eId)); - }) .toList(); } private String getXPathForEid(String eid) { return String.format("//*[@eId='%s']", eid); } - - private List getDestinationEidsFromPassiveMods( - List mods, - @Nullable DokumentExpressionEli amendedBy - ) { - return mods - .stream() - .filter(passiveMod -> { - if (amendedBy == null) return true; - - return passiveMod - .getSourceHref() - .flatMap(Href::getExpressionEli) - .orElseThrow() - .equals(amendedBy); - }) - .map(TextualMod::getDestinationHref) - .flatMap(Optional::stream) - .map(Href::getEId) - .flatMap(Optional::stream) - .toList(); - } } 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 cc7dbb342..03dc5916f 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 @@ -99,96 +99,6 @@ void itReturnsArticles() throws Exception { ); } - @Test - void itReturnsArticlesFilteredByAmendedAt() throws Exception { - // Given - var regelungstext = Fixtures.loadRegelungstextFromDisk( - "NormWithMultiplePassiveModifications.xml" - ); - - when(loadRegelungstextUseCase.loadRegelungstext(any())).thenReturn(regelungstext); - - when(loadArticlesFromDokumentUseCase.loadArticlesFromDokument(any())) - .thenReturn( - regelungstext - .getArticles() - .stream() - .filter(article -> article.getEid().equals("hauptteil-1_art-1")) - .toList() - ); - - // When - mockMvc - .perform( - get( - "/api/v1/norms/eli/bund/bgbl-1/2023/413/2023-12-29/1/deu/regelungstext-1/articles?amendedAt=meta-1_lebzykl-1_ereignis-4" - ) - .accept(MediaType.APPLICATION_JSON) - ) - // Then - .andExpect(status().isOk()) - .andExpect(jsonPath("$[0]").exists()) - .andExpect(jsonPath("$[0].eid").value("hauptteil-1_art-1")) - .andExpect(jsonPath("$[1]").doesNotExist()); - - verify(loadArticlesFromDokumentUseCase, times(1)) - .loadArticlesFromDokument( - new LoadArticlesFromDokumentUseCase.Query( - DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/2023/413/2023-12-29/1/deu/regelungstext-1" - ), - null, - "meta-1_lebzykl-1_ereignis-4" - ) - ); - } - - @Test - void itReturnsArticlesFilteredByAmendedBy() throws Exception { - // Given - var regelungstext = Fixtures.loadRegelungstextFromDisk( - "NormWithPassiveModificationsInDifferentArticles.xml" - ); - - when(loadRegelungstextUseCase.loadRegelungstext(any())).thenReturn(regelungstext); - - when(loadArticlesFromDokumentUseCase.loadArticlesFromDokument(any())) - .thenReturn( - regelungstext - .getArticles() - .stream() - .filter(article -> article.getEid().equals("hauptteil-1_art-1")) - .toList() - ); - - // When - mockMvc - .perform( - get( - "/api/v1/norms/eli/bund/bgbl-1/2023/413/2023-12-29/1/deu/regelungstext-1/articles?amendedBy=eli/bund/bgbl-1/2017/s815/1995-03-15/1/deu/regelungstext-1" - ) - .accept(MediaType.APPLICATION_JSON) - ) - // Then - .andExpect(status().isOk()) - .andExpect(jsonPath("$[0]").exists()) - .andExpect(jsonPath("$[0].eid").value("hauptteil-1_art-1")) - .andExpect(jsonPath("$[1]").doesNotExist()); - - verify(loadArticlesFromDokumentUseCase, times(1)) - .loadArticlesFromDokument( - new LoadArticlesFromDokumentUseCase.Query( - DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/2023/413/2023-12-29/1/deu/regelungstext-1" - ), - DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/2017/s815/1995-03-15/1/deu/regelungstext-1" - ), - null - ) - ); - } - @Test void itReturnsUnprocessableEntityWhenMandatoryNodeIsMissing() throws Exception { // Given diff --git a/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/ElementControllerTest.java b/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/ElementControllerTest.java index f33b82114..fb6083df5 100644 --- a/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/ElementControllerTest.java +++ b/backend/src/test/java/de/bund/digitalservice/ris/norms/adapter/input/restapi/controller/ElementControllerTest.java @@ -190,10 +190,7 @@ void itReturnsOnlyTheElementsMatchingTheGivenAmendingLaw() throws Exception { DokumentExpressionEli.fromString( "eli/bund/bgbl-1/1990/s2954/2022-12-19/1/deu/regelungstext-1" ), - eq(List.of("preface", "preamble", "article", "conclusions")), - DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/2017/s815/1995-03-15/1/deu/regelungstext-1" - ) + eq(List.of("preface", "preamble", "article", "conclusions")) ) ) ) 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 264856050..d4358d6d7 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 @@ -119,79 +119,6 @@ void itReturnsArticlesFromNorm() { assertThat(articles.get(1).getEid()).isEqualTo("hauptteil-1_art-2"); } - @Test - void itFiltersArticlesByAmendedBy() { - // Given - final var eli = DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/1990/s2954/2022-12-19/1/deu/regelungstext-1" - ); - final var amendedBy = DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/2017/s815/1995-03-15/1/deu/regelungstext-1" - ); - final String amendedAt = null; - final var regelungstext = Fixtures.loadRegelungstextFromDisk( - "NormWithPassiveModificationsInDifferentArticles.xml" - ); - final var query = new LoadArticlesFromDokumentUseCase.Query(eli, amendedBy, amendedAt); - - when(loadRegelungstextPort.loadRegelungstext(any())).thenReturn(Optional.of(regelungstext)); - - // When - final var articles = articleService.loadArticlesFromDokument(query); - - // Then - assertThat(articles).hasSize(1); - assertThat(articles.getFirst().getEid()).isEqualTo("hauptteil-1_art-2"); - } - - @Test - void itFiltersArticlesByAmendedAt() { - // Given - final var eli = DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/1990/s2954/2022-12-19/1/deu/regelungstext-1" - ); - final DokumentExpressionEli amendedBy = null; - final var amendedAt = "meta-1_lebzykl-1_ereignis-4"; - final var regelungstext = Fixtures.loadRegelungstextFromDisk( - "NormWithMultiplePassiveModifications.xml" - ); - final var query = new LoadArticlesFromDokumentUseCase.Query(eli, amendedBy, amendedAt); - - when(loadRegelungstextPort.loadRegelungstext(any())).thenReturn(Optional.of(regelungstext)); - - // When - final var articles = articleService.loadArticlesFromDokument(query); - - // Then - assertThat(articles).hasSize(1); - assertThat(articles.getFirst().getEid()).isEqualTo("hauptteil-1_art-1"); - } - - @Test - void itFiltersArticlesByAmendedByAndAmendedAt() { - // Given - final var eli = DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/1990/s2954/2022-12-19/1/deu/regelungstext-1" - ); - final var amendedBy = DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/regelungstext-1" - ); - final var amendedAt = "meta-1_lebzykl-1_ereignis-4"; - final var regelungstext = Fixtures.loadRegelungstextFromDisk( - "NormWithMultiplePassiveModifications.xml" - ); - final var query = new LoadArticlesFromDokumentUseCase.Query(eli, amendedBy, amendedAt); - - when(loadRegelungstextPort.loadRegelungstext(any())).thenReturn(Optional.of(regelungstext)); - - // When - final var articles = articleService.loadArticlesFromDokument(query); - - // Then - assertThat(articles).hasSize(1); - assertThat(articles.getFirst().getEid()).isEqualTo("hauptteil-1_art-1"); - } - @Test void itThrowsWhenTheDokumentIsNotFound() { // Given @@ -224,76 +151,6 @@ void itReturnsEmptyListWhenTheNormHasNoArticles() { // Then assertThat(articles).isEmpty(); } - - @Test - void itReturnsEmptyListWhenAmendedByIsNotFound() { - // Given - final var eli = DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/1990/s2954/2022-12-19/1/deu/regelungstext-1" - ); - final var amendedBy = DokumentExpressionEli.fromString( - "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 regelungstext = Fixtures.loadRegelungstextFromDisk( - "NormWithMultiplePassiveModifications.xml" - ); - final var query = new LoadArticlesFromDokumentUseCase.Query(eli, amendedBy, amendedAt); - - when(loadRegelungstextPort.loadRegelungstext(any())).thenReturn(Optional.of(regelungstext)); - - // When - final var articles = articleService.loadArticlesFromDokument(query); - - // Then - assertThat(articles).isEmpty(); - } - - @Test - void itReturnsEmptyListWhenAmendedAtIsNotFound() { - // Given - final var eli = DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/1990/s2954/2022-12-19/1/deu/regelungstext-1" - ); - final var amendedBy = DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/regelungstext-1" - ); - final var amendedAt = "DOES-NOT-EXIST"; - final var regelungstext = Fixtures.loadRegelungstextFromDisk( - "NormWithMultiplePassiveModifications.xml" - ); - final var query = new LoadArticlesFromDokumentUseCase.Query(eli, amendedBy, amendedAt); - - when(loadRegelungstextPort.loadRegelungstext(any())).thenReturn(Optional.of(regelungstext)); - - // When - final var articles = articleService.loadArticlesFromDokument(query); - - // Then - assertThat(articles).isEmpty(); - } - - @Test - void itReturnsEmptyListWhenNormHasNoPassiveMods() { - // Given - final var eli = DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/regelungstext-1" - ); - final var amendedBy = DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/regelungstext-1" - ); - final var amendedAt = "meta-1_lebzykl-1_ereignis-4"; - final var regelungstext = Fixtures.loadRegelungstextFromDisk("NormWithMods.xml"); - final var query = new LoadArticlesFromDokumentUseCase.Query(eli, amendedBy, amendedAt); - - when(loadRegelungstextPort.loadRegelungstext(any())).thenReturn(Optional.of(regelungstext)); - - // When - final var articles = articleService.loadArticlesFromDokument(query); - - // Then - assertThat(articles).isEmpty(); - } } @Nested 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 063679a79..7ad6b8423 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 @@ -384,65 +384,6 @@ void throwsWhenNormDoesNotExist() { assertThatThrownBy(() -> service.loadElementsByType(query)) .isInstanceOf(RegelungstextNotFoundException.class); } - - @Test - void filtersReturnedElementsByAmendingNorm() { - // Given - var regelungstext = Fixtures.loadRegelungstextFromDisk( - "NormWithPassiveModificationsInDifferentArticles.xml" - ); - var eli = regelungstext.getExpressionEli(); - when(loadRegelungstextPort.loadRegelungstext(new LoadRegelungstextPort.Command(eli))) - .thenReturn(Optional.of(regelungstext)); - - // When - var elements = service.loadElementsByType( - new LoadElementsByTypeUseCase.Query( - eli, - List.of("preface", "preamble", "article", "conclusions"), - DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/2017/s815/1995-03-15/1/deu/regelungstext-1" - ) - ) - ); - - // Then - assertThat(elements).hasSize(1); - assertThat(elements.getFirst().getNodeName()).isEqualTo("akn:article"); - } - - @Test - void returnsEmptyListIfNoElementIsAffectedByTheAmendingNorm() { - // Given - var regelungstext = Fixtures.loadRegelungstextFromDisk( - "NormWithMultiplePassiveModifications.xml" - ); - var eli = regelungstext.getExpressionEli(); - when( - loadRegelungstextPort.loadRegelungstext( - new LoadRegelungstextPort.Command( - DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/1990/s2954/2022-12-19/1/deu/regelungstext-1" - ) - ) - ) - ) - .thenReturn(Optional.of(regelungstext)); - - // When - var elements = service.loadElementsByType( - new LoadElementsByTypeUseCase.Query( - eli, - List.of("preface", "preamble", "article", "conclusions"), - DokumentExpressionEli.fromString( - "eli/bund/bgbl-1/1000/1/1000-01-01/1/deu/regelungstext-1" - ) - ) - ); - - // Then - assertThat(elements).isEmpty(); - } } @Nested 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 928998885..d36e7e232 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 @@ -77,52 +77,6 @@ void itReturnsArticles() throws Exception { .andExpect(jsonPath("$[2]").doesNotExist()); } - @Test - void itReturnsArticlesFilteredByAmendedAt() throws Exception { - // Given - dokumentRepository.save( - DokumentMapper.mapToDto( - Fixtures.loadRegelungstextFromDisk("NormWithMultiplePassiveModifications.xml") - ) - ); - - // When // Then - mockMvc - .perform( - get( - "/api/v1/norms/eli/bund/bgbl-1/1990/s2954/2022-12-19/1/deu/regelungstext-1/articles?amendedAt=meta-1_lebzykl-1_ereignis-4" - ) - .accept(MediaType.APPLICATION_JSON) - ) - .andExpect(status().isOk()) - .andExpect(jsonPath("$[0]").exists()) - .andExpect(jsonPath("$[0].eid").value("hauptteil-1_art-1")) - .andExpect(jsonPath("$[1]").doesNotExist()); - } - - @Test - void itReturnsArticlesFilteredByAmendedBy() throws Exception { - // Given - dokumentRepository.save( - DokumentMapper.mapToDto( - Fixtures.loadRegelungstextFromDisk("NormWithPassiveModificationsInDifferentArticles.xml") - ) - ); - - // When // Then - mockMvc - .perform( - get( - "/api/v1/norms/eli/bund/bgbl-1/1990/s2954/2022-12-19/1/deu/regelungstext-1/articles?amendedBy=eli/bund/bgbl-1/2017/s815/1995-03-15/1/deu/regelungstext-1" - ) - .accept(MediaType.APPLICATION_JSON) - ) - .andExpect(status().isOk()) - .andExpect(jsonPath("$[0]").exists()) - .andExpect(jsonPath("$[0].eid").value("hauptteil-1_art-2")) - .andExpect(jsonPath("$[1]").doesNotExist()); - } - @Test void itReturnsEmptyListWhenTheNormHasNoArticles() throws Exception { // Given @@ -140,48 +94,6 @@ void itReturnsEmptyListWhenTheNormHasNoArticles() throws Exception { .andExpect(jsonPath("$[0]").doesNotExist()); } - @Test - void itReturnsEmptyListIfAmendedByIsNotFound() throws Exception { - // Given - dokumentRepository.save( - DokumentMapper.mapToDto( - Fixtures.loadRegelungstextFromDisk("NormWithMultiplePassiveModifications.xml") - ) - ); - - // When / Then - mockMvc - .perform( - get( - "/api/v1/norms/eli/bund/bgbl-1/1990/s2954/2022-12-19/1/deu/regelungstext-1/articles?amendedBy=eli/bund/DOES-NOT-EXIST/2017/s419/2017-03-15/1/deu/regelungstext-1&amendedAt=meta-1_lebzykl-1_ereignis-4" - ) - .accept(MediaType.APPLICATION_JSON) - ) - .andExpect(status().isOk()) - .andExpect(jsonPath("$[0]").doesNotExist()); - } - - @Test - void itReturnsEmptyListIfAmendedAtIsNotFound() throws Exception { - // Given - dokumentRepository.save( - DokumentMapper.mapToDto( - Fixtures.loadRegelungstextFromDisk("NormWithMultiplePassiveModifications.xml") - ) - ); - - // When / Then - mockMvc - .perform( - get( - "/api/v1/norms/eli/bund/bgbl-1/1990/s2954/2022-12-19/1/deu/regelungstext-1/articles?amendedBy=eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/regelungstext-1&amendedAt=DOES-NOT-EXIST" - ) - .accept(MediaType.APPLICATION_JSON) - ) - .andExpect(status().isOk()) - .andExpect(jsonPath("$[0]").doesNotExist()); - } - @Test void itReturnsNotFoundIfTheRegelungstextIsNotFound() throws Exception { // Given 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 b6a3004bb..d9966761a 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 @@ -472,62 +472,5 @@ void itReturnsEntriesWithBookPartChapterTitleSubtitleSectionAndSubsectionInforma ) .andExpect(jsonPath("$[6].type").value("subtitle")); } - - @Test - void itReturnsAnEmptyListIfNoElementIsAffectedByTheGivenAmendingLaw() throws Exception { - // Given - dokumentRepository.save( - DokumentMapper.mapToDto( - Fixtures.loadRegelungstextFromDisk("NormWithMultiplePassiveModifications.xml") - ) - ); - dokumentRepository.save( - DokumentMapper.mapToDto( - Fixtures.loadRegelungstextFromDisk("NormWithPrefacePreambleAndConclusions.xml") - ) - ); - - var url = - "/api/v1/norms/eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/regelungstext-1/elements" + - "?type=preface" + - "&type=preamble" + - "&type=article" + - "&type=conclusions" + - "&amendedBy=eli/bund/bgbl-1/2017/s419/2017-03-15/1/deu/regelungstext-1"; // amending norm eli - - // When - mockMvc - .perform(get(url)) - // Then - .andExpect(status().isOk()) - .andExpect(jsonPath("$[0]").doesNotExist()); - } - - @Test - void itReturnsOnlyTheElementsMatchingTheGivenAmendingLaw() throws Exception { - dokumentRepository.save( - DokumentMapper.mapToDto( - Fixtures.loadRegelungstextFromDisk("NormWithPassiveModificationsInDifferentArticles.xml") - ) - ); - - var url = - "/api/v1/norms/eli/bund/bgbl-1/1990/s2954/2022-12-19/1/deu/regelungstext-1/elements" + - "?type=preface" + - "&type=preamble" + - "&type=article" + - "&type=conclusions" + - "&amendedBy=eli/bund/bgbl-1/2017/s815/1995-03-15/1/deu/regelungstext-1"; // second - - // When - mockMvc - .perform(get(url)) - // Then - .andExpect(status().isOk()) - .andExpect(jsonPath("$[0].eid").exists()) - .andExpect(jsonPath("$[0].title").exists()) - .andExpect(jsonPath("$[0].type").exists()) - .andExpect(jsonPath("$[1]").doesNotExist()); - } } }