diff --git a/semantik-adapter/src/test/java/de/ozgcloud/eingang/semantik/common/ServiceKontoFactoryTest.java b/semantik-adapter/src/test/java/de/ozgcloud/eingang/semantik/common/ServiceKontoFactoryTest.java index c62d3cd37b1d709b2c0e07a5f221733b8a2a03df..28ce6dec1cce38833bf1669fb9caa814ca66037d 100644 --- a/semantik-adapter/src/test/java/de/ozgcloud/eingang/semantik/common/ServiceKontoFactoryTest.java +++ b/semantik-adapter/src/test/java/de/ozgcloud/eingang/semantik/common/ServiceKontoFactoryTest.java @@ -31,6 +31,7 @@ import static org.mockito.Mockito.*; import java.util.List; import java.util.Map; +import org.assertj.core.api.InstanceOfAssertFactories; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; @@ -116,7 +117,7 @@ class ServiceKontoFactoryTest { } @Test - void shouldReturnPostfachAddresses() { + void shouldBuildPostfachAddresses() { var addresses = getPostfachAddresses(); assertThat(addresses).hasSize(1); @@ -127,10 +128,10 @@ class ServiceKontoFactoryTest { assertThat(addresses.get(0).getType()).isEqualTo(PostfachAddressTestFactory.POSTFACH_ADDRESS_TYPE); } - @DisplayName("should return with postfach address type") + @DisplayName("should build with postfach address type") @ParameterizedTest @ValueSource(ints = { 1, 2, 3 }) - void shouldReturnWithPostfachAddressType(int postfachAddressType) { + void shouldBuildWithPostfachAddressType(int postfachAddressType) { var formDataWithPostfachAddressType = FormDataUtils.from(FORM_DATA) .put(ServiceKontoFactory.REST_RESPONSE_NAME, List.of(Map.of( ServiceKontoFactory.REST_RESPONSE_NAME_MEMBER_SCOPE, @@ -139,13 +140,12 @@ class ServiceKontoFactoryTest { ) .build(); - var addresses = buildServiceKonto(formDataWithPostfachAddressType); + var serviceKonto = buildServiceKonto(formDataWithPostfachAddressType); - var types = addresses.getPostfachAddresses() - .stream() - .map(PostfachAddress::getType) - .toList(); - assertThat(types).containsExactly(postfachAddressType); + assertThat(serviceKonto) + .extracting(ServiceKonto::getPostfachAddresses, InstanceOfAssertFactories.list(PostfachAddress.class)) + .extracting(PostfachAddress::getType) + .containsExactly(postfachAddressType); } private List<PostfachAddress> getPostfachAddresses() { @@ -153,34 +153,31 @@ class ServiceKontoFactoryTest { } } - @DisplayName("with bad rest_response_name") + @DisplayName("with unexpected rest_response_name") @Nested - class TestWithBadRestResponseName { + class TestWithUnexpectedRestResponseName { - private final FormData formDataWithBadRestResponseName = FormDataUtils.from(FORM_DATA) + private final FormData formDataWithUnexpectedRestResponseName = FormDataUtils.from(FORM_DATA) .put(ServiceKontoFactory.REST_RESPONSE_NAME, List.of(Map.of())).build(); @DisplayName("should call buildOsiPostfachV1Address") @Test void shouldCallBuildOsiPostfachV1Address() { - getPostfachAddresses(); + buildServiceKonto(formDataWithUnexpectedRestResponseName); verify(factory).buildOsiPostfachV1Address(any(), anyInt()); } - @DisplayName("should return postfach address with default type") + @DisplayName("should build postfach address with default type") @Test - void shouldReturnPostfachAddressWithDefaultType() { - var addresses = getPostfachAddresses(); + void shouldBuildPostfachAddressWithDefaultType() { + var serviceKonto = buildServiceKonto(formDataWithUnexpectedRestResponseName); - assertThat(addresses) - .extracting("type") + assertThat(serviceKonto) + .extracting(ServiceKonto::getPostfachAddresses, InstanceOfAssertFactories.list(PostfachAddress.class)) + .extracting(PostfachAddress::getType) .containsExactly(POSTFACH_ADDRESS_DEFAULT); } - - private List<PostfachAddress> getPostfachAddresses() { - return buildServiceKonto(formDataWithBadRestResponseName).getPostfachAddresses(); - } } @DisplayName("without rest_response_name")