Skip to content
Snippets Groups Projects
Commit fc0062d3 authored by Jan Zickermann's avatar Jan Zickermann
Browse files

#1 KOP-3106 Filter out null orgIds

parent 18519a0b
Branches
Tags
1 merge request!17Resolve "router: NPE bei ZuständigerStelle ohne orgId"
...@@ -28,6 +28,7 @@ import java.io.IOException; ...@@ -28,6 +28,7 @@ import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Stream; import java.util.stream.Stream;
...@@ -102,6 +103,7 @@ public class VorgangService { ...@@ -102,6 +103,7 @@ public class VorgangService {
List<String> getOrganisationsEinheitIds(FormData formData) { List<String> getOrganisationsEinheitIds(FormData formData) {
return formData.getZustaendigeStelles().stream() return formData.getZustaendigeStelles().stream()
.map(ZustaendigeStelle::getOrganisationseinheitenId) .map(ZustaendigeStelle::getOrganisationseinheitenId)
.filter(Objects::nonNull)
.toList(); .toList();
} }
......
...@@ -306,6 +306,19 @@ class VorgangServiceTest { ...@@ -306,6 +306,19 @@ class VorgangServiceTest {
class TestGetOrganisationseinheitIds { class TestGetOrganisationseinheitIds {
private final FormData preservedFormData = FormDataTestFactory.create(); private final FormData preservedFormData = FormDataTestFactory.create();
@DisplayName("should filter out empty")
@Test
void shouldFilterOutEmpty() {
var formDataWithNullOrgId = FormDataTestFactory.createBuilder()
.clearZustaendigeStelles()
.zustaendigeStelles(List.of(ZustaendigeStelleTestFactory.createBuilder().organisationseinheitenId(null).build()))
.build();
var organisationseinheitIds = service.getOrganisationsEinheitIds(formDataWithNullOrgId);
assertThat(organisationseinheitIds).isEmpty();
}
@DisplayName("should return") @DisplayName("should return")
@Test @Test
void shouldReturn() { void shouldReturn() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment