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

OZG-7978 servicekonto: Cleanup test

parent f1360a3e
No related branches found
No related tags found
1 merge request!18OZG-7978 servicekonto: Catch runtime-exception in getPostfachAddressType
......@@ -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")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment