From 29341874ad180dd93eac6c1bad8e9a51af016931 Mon Sep 17 00:00:00 2001 From: Yalz Date: Mon, 2 Dec 2024 12:53:51 +0100 Subject: [PATCH 1/3] chore: remove unreachable logic --- .../dcatserver/DcatCatalogPostgresRepository.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ldes-server-infra-postgres/postgres-admin-repository/src/main/java/be/vlaanderen/informatievlaanderen/ldes/server/admin/postgres/dcatserver/DcatCatalogPostgresRepository.java b/ldes-server-infra-postgres/postgres-admin-repository/src/main/java/be/vlaanderen/informatievlaanderen/ldes/server/admin/postgres/dcatserver/DcatCatalogPostgresRepository.java index 97c7876b5..6ff52b95b 100644 --- a/ldes-server-infra-postgres/postgres-admin-repository/src/main/java/be/vlaanderen/informatievlaanderen/ldes/server/admin/postgres/dcatserver/DcatCatalogPostgresRepository.java +++ b/ldes-server-infra-postgres/postgres-admin-repository/src/main/java/be/vlaanderen/informatievlaanderen/ldes/server/admin/postgres/dcatserver/DcatCatalogPostgresRepository.java @@ -43,11 +43,9 @@ public void deleteServerDcat(String id) { @Override public Optional findSingleDcatServer() { - List servers = repository.findAll().stream().map(converter::toDcatServer).toList(); - if (servers.size() > 1) { - throw new IllegalStateException("Multiple dcatServers found. There should be 0 or 1 record of this."); - } - - return servers.isEmpty() ? Optional.empty() : Optional.of(servers.get(0)); + return repository.findAll() + .stream() + .map(converter::toDcatServer) + .findFirst(); } } From 88e74ac4a25e2dba14e791020717fccc4a1316a9 Mon Sep 17 00:00:00 2001 From: Yalz Date: Mon, 2 Dec 2024 14:33:05 +0100 Subject: [PATCH 2/3] chore: remove unreachable logic --- .../DcatServerPostgresRepositoryTest.java | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/ldes-server-infra-postgres/postgres-admin-repository/src/test/java/be/vlaanderen/informatievlaanderen/ldes/server/admin/postgres/dcatserver/DcatServerPostgresRepositoryTest.java b/ldes-server-infra-postgres/postgres-admin-repository/src/test/java/be/vlaanderen/informatievlaanderen/ldes/server/admin/postgres/dcatserver/DcatServerPostgresRepositoryTest.java index b30181ee2..4bfe0ec71 100644 --- a/ldes-server-infra-postgres/postgres-admin-repository/src/test/java/be/vlaanderen/informatievlaanderen/ldes/server/admin/postgres/dcatserver/DcatServerPostgresRepositoryTest.java +++ b/ldes-server-infra-postgres/postgres-admin-repository/src/test/java/be/vlaanderen/informatievlaanderen/ldes/server/admin/postgres/dcatserver/DcatServerPostgresRepositoryTest.java @@ -15,7 +15,8 @@ import java.util.List; import java.util.Optional; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -96,16 +97,6 @@ void when_DbContainsElement_then_DeleteIt() { @Nested class FindSingleDcatServer { - @Test - void should_ThrowException_when_MoreThanOneResultFound() { - List entities = List.of( - new DcatCatalogEntity("id1", ""), - new DcatCatalogEntity("id2", "")); - when(dcatCatalogEntityRepository.findAll()).thenReturn(entities); - - assertThrows(IllegalStateException.class, () -> dcatServerRepository.findSingleDcatServer()); - } - @Test void should_ReturnEmpty_when_NoResultsFound() { List entities = List.of(); From d27714a8e39ee29192084050e5f9ac1cbb583b25 Mon Sep 17 00:00:00 2001 From: Yalz Date: Mon, 2 Dec 2024 14:49:47 +0100 Subject: [PATCH 3/3] chore: make flaky test fail less --- .../informatievlaanderen/ldes/server/FragmentationSteps.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ldes-server-integration-test/src/test/java/be/vlaanderen/informatievlaanderen/ldes/server/FragmentationSteps.java b/ldes-server-integration-test/src/test/java/be/vlaanderen/informatievlaanderen/ldes/server/FragmentationSteps.java index 1b0528c9c..8eb2e9b39 100644 --- a/ldes-server-integration-test/src/test/java/be/vlaanderen/informatievlaanderen/ldes/server/FragmentationSteps.java +++ b/ldes-server-integration-test/src/test/java/be/vlaanderen/informatievlaanderen/ldes/server/FragmentationSteps.java @@ -60,7 +60,7 @@ private void fetchFragment(String path) throws Exception { @And("I fetch the next fragment through the first {string}") public void iFetchTheNextFragmentThroughTheFirst(String relation) { - await().atMost(60, TimeUnit.SECONDS) + await().atMost(90, TimeUnit.SECONDS) .untilAsserted(() -> { fetchFragment(currentPath); assertNotNull(currentFragment);