Skip to content
Snippets Groups Projects
Commit 8e874feb authored by OZGCloud's avatar OZGCloud
Browse files

OZG-4797 build bayernId service konto

parent fc9fb5c8
No related branches found
No related tags found
No related merge requests found
...@@ -18,7 +18,8 @@ import de.ozgcloud.eingang.common.formdata.ServiceKonto.PostfachAddress; ...@@ -18,7 +18,8 @@ import de.ozgcloud.eingang.common.formdata.ServiceKonto.PostfachAddress;
public class ServiceKontoBuildHelper { public class ServiceKontoBuildHelper {
public static final int POSTFACH_ADDRESS_DEFAULT = 1; public static final int POSTFACH_ADDRESS_DEFAULT = 1;
public static final String POSTFACH_TYPE = "OSI"; public static final String POSTFACH_TYPE_OSI = "OSI";
public static final String POSTFACH_TYPE_BAYERN_ID = "BayernID";
public static final String POSTFACH_VERSION = "1.0"; public static final String POSTFACH_VERSION = "1.0";
public static final String REST_RESPONSE_NAME = "rest_response_name"; public static final String REST_RESPONSE_NAME = "rest_response_name";
...@@ -37,7 +38,7 @@ public class ServiceKontoBuildHelper { ...@@ -37,7 +38,7 @@ public class ServiceKontoBuildHelper {
} }
ServiceKonto buildDefault(String postfachId) { ServiceKonto buildDefault(String postfachId) {
return ServiceKonto.builder().type(POSTFACH_TYPE).postfachAddress(buildPostfachAddress(postfachId)).build(); return ServiceKonto.builder().type(POSTFACH_TYPE_OSI).postfachAddress(buildPostfachAddress(postfachId)).build();
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
...@@ -50,31 +51,27 @@ public class ServiceKontoBuildHelper { ...@@ -50,31 +51,27 @@ public class ServiceKontoBuildHelper {
ServiceKonto buildWithRestResponseNames(String postfachId, List<Map<String, Object>> restResponseNames) { ServiceKonto buildWithRestResponseNames(String postfachId, List<Map<String, Object>> restResponseNames) {
return ServiceKonto.builder() return ServiceKonto.builder()
.type(POSTFACH_TYPE) .type(POSTFACH_TYPE_OSI)
.postfachAddresses(buildPostfachAddresses(buildIdentifier(postfachId), restResponseNames)) .postfachAddresses(buildPostfachAddresses(buildIdentifier(postfachId), restResponseNames))
.build(); .build();
} }
private PostfachAddressIdentifier buildIdentifier(String postfachId) {
return StringBasedIdentifier.builder().postfachId(postfachId).build();
}
List<PostfachAddress> buildPostfachAddresses(PostfachAddressIdentifier identifier, List<Map<String, Object>> restResponseNames) { List<PostfachAddress> buildPostfachAddresses(PostfachAddressIdentifier identifier, List<Map<String, Object>> restResponseNames) {
return restResponseNames.stream().map(entry -> buildOsiPostfachV1Address(identifier, entry)).toList(); return restResponseNames.stream().map(entry -> buildOsiPostfachV1Address(identifier, entry)).toList();
} }
private PostfachAddress buildPostfachAddress(String postkorbHandle) { PostfachAddress buildOsiPostfachV1Address(PostfachAddressIdentifier identifier, Map<String, Object> restResponseName) {
return buildOsiPostfachV1Address(identifier, getPostfachAddressType(restResponseName));
}
PostfachAddress buildOsiPostfachV1Address(PostfachAddressIdentifier identifier, int postfachAddressType) {
return PostfachAddress.builder() return PostfachAddress.builder()
.type(POSTFACH_ADDRESS_DEFAULT) .type(postfachAddressType)
.version(POSTFACH_VERSION) .version(POSTFACH_VERSION)
.identifier(buildIdentifier(postkorbHandle)) .identifier(identifier)
.build(); .build();
} }
PostfachAddress buildOsiPostfachV1Address(PostfachAddressIdentifier identifier, Map<String, Object> restResponseName) {
return buildOsiPostfachV1Address(identifier, getPostfachAddressType(restResponseName));
}
int getPostfachAddressType(Map<String, Object> restResponseName) { int getPostfachAddressType(Map<String, Object> restResponseName) {
return getMailboxType(restResponseName); return getMailboxType(restResponseName);
} }
...@@ -88,11 +85,20 @@ public class ServiceKontoBuildHelper { ...@@ -88,11 +85,20 @@ public class ServiceKontoBuildHelper {
return ((List<Map<String, Object>>) restResponseName.get(REST_RESPONSE_NAME_MEMBER_SCOPE)).get(0); return ((List<Map<String, Object>>) restResponseName.get(REST_RESPONSE_NAME_MEMBER_SCOPE)).get(0);
} }
PostfachAddress buildOsiPostfachV1Address(PostfachAddressIdentifier identifier, int postfachAddressType) { public ServiceKonto buildBayernIdServiceKonto(String postfachId) {
return ServiceKonto.builder().type(POSTFACH_TYPE_BAYERN_ID).postfachAddress(buildPostfachAddress(postfachId)).build();
}
PostfachAddress buildPostfachAddress(String postkorbHandle) {
return PostfachAddress.builder() return PostfachAddress.builder()
.type(postfachAddressType) .type(POSTFACH_ADDRESS_DEFAULT)
.version(POSTFACH_VERSION) .version(POSTFACH_VERSION)
.identifier(identifier) .identifier(buildIdentifier(postkorbHandle))
.build(); .build();
} }
private PostfachAddressIdentifier buildIdentifier(String postfachId) {
return StringBasedIdentifier.builder().postfachId(postfachId).build();
}
} }
\ No newline at end of file
...@@ -10,6 +10,7 @@ import org.junit.jupiter.api.BeforeEach; ...@@ -10,6 +10,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Spy; import org.mockito.Spy;
import de.ozgcloud.eingang.common.formdata.FormData; import de.ozgcloud.eingang.common.formdata.FormData;
...@@ -23,11 +24,12 @@ import de.ozgcloud.eingang.semantik.enginebased.afm.AfmHeaderTestFactory; ...@@ -23,11 +24,12 @@ import de.ozgcloud.eingang.semantik.enginebased.afm.AfmHeaderTestFactory;
class ServiceKontoBuildHelperTest { class ServiceKontoBuildHelperTest {
@Spy @Spy
private ServiceKontoBuildHelper helper = new ServiceKontoBuildHelper(); @InjectMocks
private ServiceKontoBuildHelper helper;
@DisplayName("service konto") @DisplayName("OSI service konto")
@Nested @Nested
class TestServiceKonto { class TestOsiServiceKonto {
private static final FormData FORM_DATA = FormData.builder().formData(AfmHeaderTestFactory.createFormDataMap()).build(); private static final FormData FORM_DATA = FormData.builder().formData(AfmHeaderTestFactory.createFormDataMap()).build();
...@@ -46,7 +48,7 @@ class ServiceKontoBuildHelperTest { ...@@ -46,7 +48,7 @@ class ServiceKontoBuildHelperTest {
void shouldContainsType() { void shouldContainsType() {
var serviceKonto = getServiceKonto(FORM_DATA); var serviceKonto = getServiceKonto(FORM_DATA);
assertThat(serviceKonto.getType()).isEqualTo(ServiceKontoBuildHelper.POSTFACH_TYPE); assertThat(serviceKonto.getType()).isEqualTo(ServiceKontoBuildHelper.POSTFACH_TYPE_OSI);
} }
@Test @Test
...@@ -139,4 +141,31 @@ class ServiceKontoBuildHelperTest { ...@@ -139,4 +141,31 @@ class ServiceKontoBuildHelperTest {
} }
} }
} }
@Nested
class TestBayernIdServiceKonto {
private static final String POSTFACH_ID = "postfach-id";
private static final PostfachAddress POSTFACH_ADDRESS = PostfachAddressTestFactory.create();
@Test
void shouldSetType() {
var serviceKonto = buildBayernIdServiceKonto();
assertThat(serviceKonto.getType()).isEqualTo(ServiceKontoBuildHelper.POSTFACH_TYPE_BAYERN_ID);
}
@Test
void shouldSetPostfachAddress() {
doReturn(POSTFACH_ADDRESS).when(helper).buildPostfachAddress(any());
var serviceKonto = buildBayernIdServiceKonto();
assertThat(serviceKonto.getPostfachAddresses()).containsOnly(POSTFACH_ADDRESS);
}
ServiceKonto buildBayernIdServiceKonto() {
return helper.buildBayernIdServiceKonto(POSTFACH_ID);
}
}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment