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

Merge branch 'master' into OZG-5718-reset-bescheid-upload-in-progress

parents 8a495f5b 6a347acc
Branches
Tags
No related merge requests found
......@@ -24,18 +24,8 @@
import { EMPTY_STRING } from '@alfa-client/tech-shared';
import { Antragsteller, Vorgang, VorgangWithEingangResource } from '@alfa-client/vorgang-shared';
import { NavigationEnd } from '@angular/router';
import {
createAntragsteller,
createEingang,
createVorgangResource,
createVorgangWithEingangResource,
} from 'libs/vorgang-shared/test/vorgang';
import {
VORGANG_KEIN_AKTENZEICHEN_ZUGEWIESEN,
getAktenzeichenText,
getEmpfaenger,
isVorgangSearchRoute,
} from './vorgang-util';
import { createAntragsteller, createEingang, createVorgangResource, createVorgangWithEingangResource, } from 'libs/vorgang-shared/test/vorgang';
import { getAktenzeichenText, getEmpfaenger, isVorgangSearchRoute, VORGANG_KEIN_AKTENZEICHEN_ZUGEWIESEN, } from './vorgang-util';
describe('Vorgang Util', () => {
describe('getAktenzeichenText', () => {
......@@ -70,7 +60,7 @@ describe('Vorgang Util', () => {
const result: boolean = isVorgangSearchRoute(notSearchNavigationEnd);
expect(result).toBeTruthy();
expect(result).toBeFalsy();
});
});
......
......@@ -3,6 +3,8 @@ package de.ozgcloud.alfa.bescheid;
import java.util.List;
import de.ozgcloud.alfa.common.file.OzgFile;
import lombok.Builder;
@Builder
record BescheidExportInput(Bescheid bescheid, String organisationseinheitenId, List<OzgFile> files) {
}
package de.ozgcloud.alfa.bescheid;
import java.util.List;
import java.util.stream.Stream;
import org.springframework.stereotype.Service;
......@@ -32,16 +31,18 @@ public class ExportBescheidService {
}
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) {
return binaryFileService.getFiles(bescheid.getAttachments()).toList();
Stream<OzgFile> getAttachments(Bescheid bescheid) {
return binaryFileService.getFiles(bescheid.getAttachments());
}
void addBescheidExportData(BescheidExportInput input, BescheidExportData.BescheidExportDataBuilder builder) {
builder.dokumentType(buildDokumentType(input))
.file(getDocument(input.bescheid()))
.files(input.files());
}
......
......@@ -10,10 +10,17 @@ public class BescheidExportInputTestFactory {
public final static Bescheid BESCHEID = BescheidTestFactory.create();
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() {
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 {
class TestCreateBescheidExportInput {
private final VorgangWithEingang vorgang = VorgangWithEingangTestFactory.create();
private final Bescheid bescheid = BescheidTestFactory.create();
private final OzgFile document = OzgFileTestFactory.create();
private final OzgFile attachment = OzgFileTestFactory.create();
@BeforeEach
void setUpMocks() {
doReturn(BescheidExportInputTestFactory.ATTACHMENTS).when(service).getAttachments(bescheid);
doReturn(Stream.of(attachment)).when(service).getAttachments(bescheid);
doReturn(document).when(service).getDocument(bescheid);
}
@Test
......@@ -167,11 +170,19 @@ class ExportBescheidServiceTest {
verify(service).getAttachments(bescheid);
}
@Test
void shouldCallGetDocument() {
callService();
verify(service).getDocument(bescheid);
}
@Test
void shouldReturnInputData() {
var resultInput = callService();
assertThat(resultInput).usingRecursiveComparison().isEqualTo(BescheidExportInputTestFactory.create());
assertThat(resultInput).usingRecursiveComparison()
.isEqualTo(BescheidExportInputTestFactory.createBuilder().files(List.of(document, attachment)).build());
}
private BescheidExportInput callService() {
......@@ -243,7 +254,7 @@ class ExportBescheidServiceTest {
@Nested
class TestAddBescheidExportData {
private final List<OzgFile> attachments = BescheidExportInputTestFactory.ATTACHMENTS;
private final List<OzgFile> files = BescheidExportInputTestFactory.FILES;
private final OzgFile document = OzgFileTestFactory.create();
private final DokumentType dokumentType = DokumentTypeTestFactory.create();
private final BescheidExportInput exportInput = BescheidExportInputTestFactory.create();
......@@ -254,30 +265,14 @@ class ExportBescheidServiceTest {
@BeforeEach
void setUpMocks() {
doReturn(dokumentType).when(service).buildDokumentType(exportInput);
doReturn(document).when(service).getDocument(exportInput.bescheid());
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
void shouldAddAttachmentsToBuilder() {
callService();
verify(exportDataBuilder).files(attachments);
verify(exportDataBuilder).files(files);
}
@Test
......@@ -303,7 +298,7 @@ class ExportBescheidServiceTest {
class TestBuildDokumentType {
private final BescheidExportInput exportInput = BescheidExportInputTestFactory.create();
private final Bescheid bescheid = BescheidExportInputTestFactory.BESCHEID;
private final List<OzgFile> attachments = BescheidExportInputTestFactory.ATTACHMENTS;
private final List<OzgFile> files = BescheidExportInputTestFactory.FILES;
private final String fullName = UserProfileTestFactory.FULLNAME;
private MockedStatic<DokumentTypeBuilder> dokumentTypeBuilderMockedStatic;
......@@ -316,7 +311,7 @@ class ExportBescheidServiceTest {
dokumentTypeBuilderMockedStatic.when(DokumentTypeBuilder::builder).thenReturn(dokumentTypeBuilder);
when(dokumentTypeBuilder.withBescheid(bescheid)).thenReturn(dokumentTypeBuilder);
when(dokumentTypeBuilder.withFiles(attachments)).thenReturn(dokumentTypeBuilder);
when(dokumentTypeBuilder.withFiles(files)).thenReturn(dokumentTypeBuilder);
when(dokumentTypeBuilder.withFullName(fullName)).thenReturn(dokumentTypeBuilder);
when(dokumentTypeBuilder.withOrganisationseinheitenId(BescheidExportInputTestFactory.ORGANISATIONSEINHEITEN_ID))
.thenReturn(dokumentTypeBuilder);
......@@ -347,7 +342,7 @@ class ExportBescheidServiceTest {
void shouldBuildWithOzgFiles() {
callService();
verify(dokumentTypeBuilder).withFiles(attachments);
verify(dokumentTypeBuilder).withFiles(files);
}
@Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment