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

Revert "OZG-4797 build bayernId service konto"

This reverts commit 8e874feb.
parent c1f6e3d6
Branches
Tags
No related merge requests found
......@@ -18,8 +18,7 @@ import de.ozgcloud.eingang.common.formdata.ServiceKonto.PostfachAddress;
public class ServiceKontoBuildHelper {
public static final int POSTFACH_ADDRESS_DEFAULT = 1;
public static final String POSTFACH_TYPE_OSI = "OSI";
public static final String POSTFACH_TYPE_BAYERN_ID = "BayernID";
public static final String POSTFACH_TYPE = "OSI";
public static final String POSTFACH_VERSION = "1.0";
public static final String REST_RESPONSE_NAME = "rest_response_name";
......@@ -38,7 +37,7 @@ public class ServiceKontoBuildHelper {
}
ServiceKonto buildDefault(String postfachId) {
return ServiceKonto.builder().type(POSTFACH_TYPE_OSI).postfachAddress(buildPostfachAddress(postfachId)).build();
return ServiceKonto.builder().type(POSTFACH_TYPE).postfachAddress(buildPostfachAddress(postfachId)).build();
}
@SuppressWarnings("unchecked")
......@@ -51,27 +50,31 @@ public class ServiceKontoBuildHelper {
ServiceKonto buildWithRestResponseNames(String postfachId, List<Map<String, Object>> restResponseNames) {
return ServiceKonto.builder()
.type(POSTFACH_TYPE_OSI)
.type(POSTFACH_TYPE)
.postfachAddresses(buildPostfachAddresses(buildIdentifier(postfachId), restResponseNames))
.build();
}
List<PostfachAddress> buildPostfachAddresses(PostfachAddressIdentifier identifier, List<Map<String, Object>> restResponseNames) {
return restResponseNames.stream().map(entry -> buildOsiPostfachV1Address(identifier, entry)).toList();
private PostfachAddressIdentifier buildIdentifier(String postfachId) {
return StringBasedIdentifier.builder().postfachId(postfachId).build();
}
PostfachAddress buildOsiPostfachV1Address(PostfachAddressIdentifier identifier, Map<String, Object> restResponseName) {
return buildOsiPostfachV1Address(identifier, getPostfachAddressType(restResponseName));
List<PostfachAddress> buildPostfachAddresses(PostfachAddressIdentifier identifier, List<Map<String, Object>> restResponseNames) {
return restResponseNames.stream().map(entry -> buildOsiPostfachV1Address(identifier, entry)).toList();
}
PostfachAddress buildOsiPostfachV1Address(PostfachAddressIdentifier identifier, int postfachAddressType) {
private PostfachAddress buildPostfachAddress(String postkorbHandle) {
return PostfachAddress.builder()
.type(postfachAddressType)
.type(POSTFACH_ADDRESS_DEFAULT)
.version(POSTFACH_VERSION)
.identifier(identifier)
.identifier(buildIdentifier(postkorbHandle))
.build();
}
PostfachAddress buildOsiPostfachV1Address(PostfachAddressIdentifier identifier, Map<String, Object> restResponseName) {
return buildOsiPostfachV1Address(identifier, getPostfachAddressType(restResponseName));
}
int getPostfachAddressType(Map<String, Object> restResponseName) {
return getMailboxType(restResponseName);
}
......@@ -85,20 +88,11 @@ public class ServiceKontoBuildHelper {
return ((List<Map<String, Object>>) restResponseName.get(REST_RESPONSE_NAME_MEMBER_SCOPE)).get(0);
}
public ServiceKonto buildBayernIdServiceKonto(String postfachId) {
return ServiceKonto.builder().type(POSTFACH_TYPE_BAYERN_ID).postfachAddress(buildPostfachAddress(postfachId)).build();
}
PostfachAddress buildPostfachAddress(String postkorbHandle) {
PostfachAddress buildOsiPostfachV1Address(PostfachAddressIdentifier identifier, int postfachAddressType) {
return PostfachAddress.builder()
.type(POSTFACH_ADDRESS_DEFAULT)
.type(postfachAddressType)
.version(POSTFACH_VERSION)
.identifier(buildIdentifier(postkorbHandle))
.identifier(identifier)
.build();
}
private PostfachAddressIdentifier buildIdentifier(String postfachId) {
return StringBasedIdentifier.builder().postfachId(postfachId).build();
}
}
\ No newline at end of file
......@@ -10,7 +10,6 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Spy;
import de.ozgcloud.eingang.common.formdata.FormData;
......@@ -24,12 +23,11 @@ import de.ozgcloud.eingang.semantik.enginebased.afm.AfmHeaderTestFactory;
class ServiceKontoBuildHelperTest {
@Spy
@InjectMocks
private ServiceKontoBuildHelper helper;
private ServiceKontoBuildHelper helper = new ServiceKontoBuildHelper();
@DisplayName("OSI service konto")
@DisplayName("service konto")
@Nested
class TestOsiServiceKonto {
class TestServiceKonto {
private static final FormData FORM_DATA = FormData.builder().formData(AfmHeaderTestFactory.createFormDataMap()).build();
......@@ -48,7 +46,7 @@ class ServiceKontoBuildHelperTest {
void shouldContainsType() {
var serviceKonto = getServiceKonto(FORM_DATA);
assertThat(serviceKonto.getType()).isEqualTo(ServiceKontoBuildHelper.POSTFACH_TYPE_OSI);
assertThat(serviceKonto.getType()).isEqualTo(ServiceKontoBuildHelper.POSTFACH_TYPE);
}
@Test
......@@ -141,31 +139,4 @@ 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