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

OZG-5665 Added BescheidDocument to fioles in xDomea Bescheid Export

parent 8f9608b0
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,8 @@ package de.ozgcloud.alfa.bescheid; ...@@ -3,6 +3,8 @@ package de.ozgcloud.alfa.bescheid;
import java.util.List; import java.util.List;
import de.ozgcloud.alfa.common.file.OzgFile; import de.ozgcloud.alfa.common.file.OzgFile;
import lombok.Builder;
@Builder
record BescheidExportInput(Bescheid bescheid, String organisationseinheitenId, List<OzgFile> files) { record BescheidExportInput(Bescheid bescheid, String organisationseinheitenId, List<OzgFile> files) {
} }
package de.ozgcloud.alfa.bescheid; package de.ozgcloud.alfa.bescheid;
import java.util.List;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -32,16 +31,18 @@ public class ExportBescheidService { ...@@ -32,16 +31,18 @@ public class ExportBescheidService {
} }
BescheidExportInput createBescheidExportInput(Bescheid bescheid, VorgangWithEingang vorgang) { BescheidExportInput createBescheidExportInput(Bescheid bescheid, VorgangWithEingang vorgang) {
return new BescheidExportInput(bescheid, vorgang.getOrganisationseinheitenID(), getAttachments(bescheid)); return BescheidExportInput.builder()
.bescheid(bescheid)
.organisationseinheitenId(vorgang.getOrganisationseinheitenID())
.files(Stream.concat(Stream.of(getDocument(bescheid)), getAttachments(bescheid)).toList()).build();
} }
List<OzgFile> getAttachments(Bescheid bescheid) { Stream<OzgFile> getAttachments(Bescheid bescheid) {
return binaryFileService.getFiles(bescheid.getAttachments()).toList(); return binaryFileService.getFiles(bescheid.getAttachments());
} }
void addBescheidExportData(BescheidExportInput input, BescheidExportData.BescheidExportDataBuilder builder) { void addBescheidExportData(BescheidExportInput input, BescheidExportData.BescheidExportDataBuilder builder) {
builder.dokumentType(buildDokumentType(input)) builder.dokumentType(buildDokumentType(input))
.file(getDocument(input.bescheid()))
.files(input.files()); .files(input.files());
} }
......
...@@ -10,10 +10,17 @@ public class BescheidExportInputTestFactory { ...@@ -10,10 +10,17 @@ public class BescheidExportInputTestFactory {
public final static Bescheid BESCHEID = BescheidTestFactory.create(); public final static Bescheid BESCHEID = BescheidTestFactory.create();
public final static String ORGANISATIONSEINHEITEN_ID = ZustaendigeStelleTestFactory.ORGANISATIONSEINHEITEN_ID; public final static String ORGANISATIONSEINHEITEN_ID = ZustaendigeStelleTestFactory.ORGANISATIONSEINHEITEN_ID;
public final static List<OzgFile> ATTACHMENTS = List.of(OzgFileTestFactory.createWithUniqueId()); public final static List<OzgFile> FILES = List.of(OzgFileTestFactory.createWithUniqueId());
public static BescheidExportInput create() { public static BescheidExportInput create() {
return new BescheidExportInput(BESCHEID, ORGANISATIONSEINHEITEN_ID, ATTACHMENTS); return createBuilder().build();
}
public static BescheidExportInput.BescheidExportInputBuilder createBuilder() {
return BescheidExportInput.builder()
.bescheid(BESCHEID)
.organisationseinheitenId(ORGANISATIONSEINHEITEN_ID)
.files(FILES);
} }
} }
...@@ -154,10 +154,13 @@ class ExportBescheidServiceTest { ...@@ -154,10 +154,13 @@ class ExportBescheidServiceTest {
class TestCreateBescheidExportInput { class TestCreateBescheidExportInput {
private final VorgangWithEingang vorgang = VorgangWithEingangTestFactory.create(); private final VorgangWithEingang vorgang = VorgangWithEingangTestFactory.create();
private final Bescheid bescheid = BescheidTestFactory.create(); private final Bescheid bescheid = BescheidTestFactory.create();
private final OzgFile document = OzgFileTestFactory.create();
private final OzgFile attachment = OzgFileTestFactory.create();
@BeforeEach @BeforeEach
void setUpMocks() { void setUpMocks() {
doReturn(BescheidExportInputTestFactory.ATTACHMENTS).when(service).getAttachments(bescheid); doReturn(Stream.of(attachment)).when(service).getAttachments(bescheid);
doReturn(document).when(service).getDocument(bescheid);
} }
@Test @Test
...@@ -167,11 +170,19 @@ class ExportBescheidServiceTest { ...@@ -167,11 +170,19 @@ class ExportBescheidServiceTest {
verify(service).getAttachments(bescheid); verify(service).getAttachments(bescheid);
} }
@Test
void shouldCallGetDocument() {
callService();
verify(service).getDocument(bescheid);
}
@Test @Test
void shouldReturnInputData() { void shouldReturnInputData() {
var resultInput = callService(); var resultInput = callService();
assertThat(resultInput).usingRecursiveComparison().isEqualTo(BescheidExportInputTestFactory.create()); assertThat(resultInput).usingRecursiveComparison()
.isEqualTo(BescheidExportInputTestFactory.createBuilder().files(List.of(document, attachment)).build());
} }
private BescheidExportInput callService() { private BescheidExportInput callService() {
...@@ -243,7 +254,7 @@ class ExportBescheidServiceTest { ...@@ -243,7 +254,7 @@ class ExportBescheidServiceTest {
@Nested @Nested
class TestAddBescheidExportData { class TestAddBescheidExportData {
private final List<OzgFile> attachments = BescheidExportInputTestFactory.ATTACHMENTS; private final List<OzgFile> files = BescheidExportInputTestFactory.FILES;
private final OzgFile document = OzgFileTestFactory.create(); private final OzgFile document = OzgFileTestFactory.create();
private final DokumentType dokumentType = DokumentTypeTestFactory.create(); private final DokumentType dokumentType = DokumentTypeTestFactory.create();
private final BescheidExportInput exportInput = BescheidExportInputTestFactory.create(); private final BescheidExportInput exportInput = BescheidExportInputTestFactory.create();
...@@ -254,30 +265,14 @@ class ExportBescheidServiceTest { ...@@ -254,30 +265,14 @@ class ExportBescheidServiceTest {
@BeforeEach @BeforeEach
void setUpMocks() { void setUpMocks() {
doReturn(dokumentType).when(service).buildDokumentType(exportInput); doReturn(dokumentType).when(service).buildDokumentType(exportInput);
doReturn(document).when(service).getDocument(exportInput.bescheid());
when(exportDataBuilder.dokumentType(dokumentType)).thenReturn(exportDataBuilder); when(exportDataBuilder.dokumentType(dokumentType)).thenReturn(exportDataBuilder);
when(exportDataBuilder.file(document)).thenReturn(exportDataBuilder);
}
@Test
void shouldGetDocument() {
callService();
verify(service).getDocument(exportInput.bescheid());
}
@Test
void shouldAddDocumentToBuilder() {
callService();
verify(exportDataBuilder).file(document);
} }
@Test @Test
void shouldAddAttachmentsToBuilder() { void shouldAddAttachmentsToBuilder() {
callService(); callService();
verify(exportDataBuilder).files(attachments); verify(exportDataBuilder).files(files);
} }
@Test @Test
...@@ -303,7 +298,7 @@ class ExportBescheidServiceTest { ...@@ -303,7 +298,7 @@ class ExportBescheidServiceTest {
class TestBuildDokumentType { class TestBuildDokumentType {
private final BescheidExportInput exportInput = BescheidExportInputTestFactory.create(); private final BescheidExportInput exportInput = BescheidExportInputTestFactory.create();
private final Bescheid bescheid = BescheidExportInputTestFactory.BESCHEID; private final Bescheid bescheid = BescheidExportInputTestFactory.BESCHEID;
private final List<OzgFile> attachments = BescheidExportInputTestFactory.ATTACHMENTS; private final List<OzgFile> attachments = BescheidExportInputTestFactory.FILES;
private final String fullName = UserProfileTestFactory.FULLNAME; private final String fullName = UserProfileTestFactory.FULLNAME;
private MockedStatic<DokumentTypeBuilder> dokumentTypeBuilderMockedStatic; private MockedStatic<DokumentTypeBuilder> dokumentTypeBuilderMockedStatic;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment