Skip to content
Snippets Groups Projects
Commit 337fdce4 authored by OZG-Cloud Team's avatar OZG-Cloud Team
Browse files

OZG-6748 mantelantrag: Extend itcase

parent ad1f0a7f
No related branches found
No related tags found
No related merge requests found
package de.ozgcloud.eingang.semantik.formbased.mantelantrag;
import static de.ozgcloud.eingang.common.formdata.FormDataTestFactory.*;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
......@@ -7,78 +8,157 @@ import static org.mockito.Mockito.*;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import org.junit.jupiter.api.BeforeAll;
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.ArgumentCaptor;
import org.mockito.Captor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.springframework.test.context.TestPropertySource;
import de.ozgcloud.common.binaryfile.TempFileUtils;
import de.ozgcloud.common.test.TestUtils;
import de.ozgcloud.eingang.Application;
import de.ozgcloud.eingang.common.formdata.FormData;
import de.ozgcloud.eingang.common.formdata.IncomingFileTestFactory;
import de.ozgcloud.eingang.router.VorgangService;
import de.ozgcloud.eingang.router.VorgangRemoteService;
import de.ozgcloud.eingang.semantik.SemantikAdapter;
import de.ozgcloud.eingang.semantik.enginebased.formsolutions.FormSolutionsEngineBasedAdapterITCase;
import lombok.SneakyThrows;
@ActiveProfiles({ "local", "itcase" })
@SpringBootTest(classes = Application.class, properties = { "ozgcloud.xta.identifiers=afmsh:ozg-cloud-utopia-test" })
@SpringBootTest(classes = Application.class)
public class MantelantragITCase {
private static final String FILE_NAME_XDOMEA = "mantelantrag/4620-EH6C_b3c9168a-6ae9-4361-8b2f-6837bb341021_Geschaeftsgang.Geschaeftsgang.0201.xml";
private static final String FILE_NAME_MANTELANTRAG = "mantelantrag/4620-EH6C_7d703670-15b6-42b2-8cd1-88a7e4c494b9_Antrag_Max_Mustermann_SGBXII.xml";
@MockBean
VorgangService vorgangService;
VorgangRemoteService vorgangRemoteService;
@SpyBean
SemantikAdapter semantikAdapter;
@Nested
class TestZustaendigeStelle {
private FormData formData;
@Captor
ArgumentCaptor<FormData> formDataCaptor;
private static final String VORGANG_ID_1 = "vorgangId1";
private static final List<String> VORGANG_IDS = List.of(VORGANG_ID_1, "vorgangId2");
@Captor
ArgumentCaptor<Optional<String>> oeIdCaptor;
@Autowired
MantelantragZustaendigeStelleMapper mantelantragZustaendigeStelleMapper;
static List<String> XTA_IDENTIFIERS = Collections.emptyList();
@BeforeEach
void mock() {
doReturn(VORGANG_IDS).when(vorgangService).createVorgangs(any(FormData.class));
clearInvocations(vorgangRemoteService);
doReturn(VORGANG_ID).when(vorgangRemoteService).createVorgang(any(FormData.class), any());
formData = prepareTestData();
mantelantragZustaendigeStelleMapper.init();
}
@DisplayName("should return first vorgangId")
@DynamicPropertySource
static void dynamicProperties(DynamicPropertyRegistry registry) {
registry.add("ozgcloud.xta.identifiers", () -> XTA_IDENTIFIERS);
}
@DisplayName("with no matching zusstaendige stelle")
@Nested
class TestWithNoMatchingZusstaendigeStelle {
@BeforeAll
static void setup() {
XTA_IDENTIFIERS = List.of("afmsh:unknown");
}
@DisplayName("should create one vorgang with no matching zustaendigeStelle")
@Test
void shouldReturnFirstVorgangId() {
var result = semantikAdapter.processFormData(formData);
void shouldCreateOneVorgangWithNoMatchingZustaendigeStelle() {
semantikAdapter.processFormData(formData);
assertThat(result).isEqualTo(VORGANG_ID_1);
verify(vorgangRemoteService, times(1)).createVorgang(formDataCaptor.capture(), oeIdCaptor.capture());
assertThat(oeIdCaptor.getValue()).isEmpty();
}
}
@DisplayName("with one matching zustaendige stelle")
@Nested
@TestPropertySource(properties = "ozgcloud.xta.identifiers=afmsh:ozg-cloud-utopia-test")
class TestWithOneMatchingZustaendigeStelle {
@BeforeAll
static void setup() {
XTA_IDENTIFIERS = List.of("afmsh:ozg-cloud-utopia-test");
}
@DisplayName("should create one vorgang with no matching zustaendigeStelle")
@Test
void zustaendigeStelleIsUtopia() {
void shouldCreateOneVorgangWithNoMatchingZustaendigeStelle() {
semantikAdapter.processFormData(formData);
verify(vorgangService).createVorgangs(formDataCaptor.capture());
var firstZustaendigeStelle = formDataCaptor.getValue().getZustaendigeStelles().getFirst();
assertThat(firstZustaendigeStelle.getOrganisationseinheitenId()).isEqualTo("123");
verify(vorgangRemoteService, times(1)).createVorgang(formDataCaptor.capture(), oeIdCaptor.capture());
assertThat(oeIdCaptor.getValue()).contains("123");
}
}
@DisplayName("with two matching zustaendige stelle")
@Nested
class TestWithTwoMatchingZustaendigeStelle {
@BeforeAll
static void setup() {
XTA_IDENTIFIERS = List.of("afmsh:ozg-cloud-utopia-test", "gae:ozg-cloud-itcase-test");
}
@DisplayName("should create two vorangs with partially matching zustaendigeStelle")
@Test
void shouldCreateTwoVorangsWithPartiallyMatchingZustaendigeStelle() {
semantikAdapter.processFormData(formData);
verify(vorgangRemoteService, times(2)).createVorgang(formDataCaptor.capture(), oeIdCaptor.capture());
assertThat(oeIdCaptor.getAllValues()).contains(Optional.of("123"), Optional.of("444"));
}
}
@DisplayName("with three mathcing zustaendige stelle")
@Nested
class TestWithThreeMathcingZustaendigeStelle {
@BeforeAll
static void setup() {
XTA_IDENTIFIERS = List.of("afmsh:ozg-cloud-utopia-test", "gae:ozg-cloud-itcase-test", "afmsh:ozg-cloud-bad-segeberg-kreis");
}
@DisplayName("should create three vorgangs with matching zustaendigeStelle")
@Test
void shouldCreateThreeVorgangsWithMatchingZustaendigeStelle() {
semantikAdapter.processFormData(formData);
verify(vorgangRemoteService, times(3)).createVorgang(formDataCaptor.capture(), oeIdCaptor.capture());
assertThat(oeIdCaptor.getAllValues()).contains(Optional.of("123"), Optional.of("321"), Optional.of("444"));
}
}
@DisplayName("should return first vorgangId")
@Test
void shouldReturnFirstVorgangId() {
var result = semantikAdapter.processFormData(formData);
assertThat(result).isEqualTo(VORGANG_ID);
}
private FormData prepareTestData() {
......
......@@ -83,7 +83,7 @@
<zustellung_nachrichtenbroker2>afmsh:ozg-cloud-bad-segeberg-kreis</zustellung_nachrichtenbroker2>
<zustellung_email_ln2/>
<zustellung_webservice2/>
<kontaktsystem_oeid3/>
<kontaktsystem_oeid3>444</kontaktsystem_oeid3>
<OrganisationseinheitenBEZEICHNUNG3/>
<zust_strasse3/>
<zust_hausnummer3/>
......@@ -93,7 +93,7 @@
<zust_telefonnummer3/>
<zust_faxnummer3/>
<zust_emailadresse3/>
<zustellung_nachrichtenbroker3/>
<zustellung_nachrichtenbroker3>gae:ozg-cloud-itcase-test</zustellung_nachrichtenbroker3>>
<zustellung_email_ln3/>
<zustellung_webservice3/>
<grund>Hilfe</grund>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment