diff --git a/semantik-adapter/src/main/java/de/ozgcloud/eingang/semantik/enginebased/ServiceKontoBuildHelper.java b/semantik-adapter/src/main/java/de/ozgcloud/eingang/semantik/enginebased/ServiceKontoBuildHelper.java index 1ec87a0e456865b00b7edbddf0834dad0f8e9948..2cb43a42151681c158ec08a23e12da10f918cb29 100644 --- a/semantik-adapter/src/main/java/de/ozgcloud/eingang/semantik/enginebased/ServiceKontoBuildHelper.java +++ b/semantik-adapter/src/main/java/de/ozgcloud/eingang/semantik/enginebased/ServiceKontoBuildHelper.java @@ -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 diff --git a/semantik-adapter/src/test/java/de/ozgcloud/eingang/semantik/enginebased/ServiceKontoBuildHelperTest.java b/semantik-adapter/src/test/java/de/ozgcloud/eingang/semantik/enginebased/ServiceKontoBuildHelperTest.java index 8d49520d80e2d2ef27042b0dc2399202e44466c9..3f9a6243a7856e2c4abab007c66551c766bd5b40 100644 --- a/semantik-adapter/src/test/java/de/ozgcloud/eingang/semantik/enginebased/ServiceKontoBuildHelperTest.java +++ b/semantik-adapter/src/test/java/de/ozgcloud/eingang/semantik/enginebased/ServiceKontoBuildHelperTest.java @@ -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