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

Merge pull request 'OZG-5665 List of OzgFiles to Set of OzgFiles' (#617) from...

Merge pull request 'OZG-5665 List of OzgFiles to Set of OzgFiles' (#617) from OZG-5665-xDomea-Bescheid-Dateien-Download into master

Reviewed-on: https://git.ozg-sh.de/ozgcloud-app/alfa/pulls/617


Reviewed-by: default avatarOZGCloud <ozgcloud@mgm-tp.com>
parents d47b4d4b 23f82f11
No related branches found
No related tags found
No related merge requests found
Showing
with 24 additions and 20 deletions
...@@ -29,6 +29,7 @@ import de.ozgcloud.alfa.common.binaryfile.FileId; ...@@ -29,6 +29,7 @@ import de.ozgcloud.alfa.common.binaryfile.FileId;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
...@@ -36,10 +37,13 @@ import lombok.NoArgsConstructor; ...@@ -36,10 +37,13 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PRIVATE)
@AllArgsConstructor(access = AccessLevel.PACKAGE) @AllArgsConstructor(access = AccessLevel.PACKAGE)
@Getter @Getter
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
public class OzgFile { public class OzgFile {
@JsonIgnore @JsonIgnore
@EqualsAndHashCode.Include
private FileId id; private FileId id;
@EqualsAndHashCode.Include
private String name; private String name;
private long size; private long size;
......
...@@ -259,12 +259,12 @@ class PostfachMailServiceTest { ...@@ -259,12 +259,12 @@ class PostfachMailServiceTest {
class TestCall { class TestCall {
private final Stream<PostfachMail> postfachMail = Stream.of(postfachNachricht); private final Stream<PostfachMail> postfachMail = Stream.of(postfachNachricht);
private final Stream<OzgFile> ozgFile = Stream.of(OzgFileTestFactory.create()); private final Stream<OzgFile> ozgFiles = Stream.of(OzgFileTestFactory.create());
@BeforeEach @BeforeEach
void mock() { void mock() {
when(remoteService.findPostfachMails(anyString())).thenReturn(postfachMail); when(remoteService.findPostfachMails(anyString())).thenReturn(postfachMail);
when(fileService.getFiles(anyList())).thenReturn(ozgFile); when(fileService.getFiles(anyList())).thenReturn(ozgFiles);
} }
@Test @Test
......
package de.ozgcloud.alfa.export; package de.ozgcloud.alfa.export;
import java.util.List; import java.util.Set;
import de.ozgcloud.alfa.common.file.OzgFile; import de.ozgcloud.alfa.common.file.OzgFile;
import de.xoev.xdomea.AbgabeAbgabe0401; import de.xoev.xdomea.AbgabeAbgabe0401;
...@@ -16,6 +16,6 @@ class ExportData { ...@@ -16,6 +16,6 @@ class ExportData {
private String exportFilename; private String exportFilename;
private AbgabeAbgabe0401 abgabe; private AbgabeAbgabe0401 abgabe;
private List<OzgFile> exportFiles; private Set<OzgFile> exportFiles;
} }
...@@ -6,8 +6,9 @@ import java.io.FileOutputStream; ...@@ -6,8 +6,9 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
...@@ -78,7 +79,7 @@ class ExportService { ...@@ -78,7 +79,7 @@ class ExportService {
postfachMailData.getAttachments().stream(), postfachMailData.getAttachments().stream(),
bescheidData.getFiles().stream()) bescheidData.getFiles().stream())
.flatMap(s -> s) .flatMap(s -> s)
.toList(); .collect(Collectors.toSet());
return ExportData.builder().abgabe(abgabe).exportFilename(buildXmlFilename(filenameId)).exportFiles(exportFiles).build(); return ExportData.builder().abgabe(abgabe).exportFilename(buildXmlFilename(filenameId)).exportFiles(exportFiles).build();
} }
...@@ -114,7 +115,7 @@ class ExportService { ...@@ -114,7 +115,7 @@ class ExportService {
zipOutputStream.closeEntry(); zipOutputStream.closeEntry();
} }
private void putFilesIntoZip(List<OzgFile> ozgFiles, ZipOutputStream zipOutputStream) { private void putFilesIntoZip(Set<OzgFile> ozgFiles, ZipOutputStream zipOutputStream) {
ozgFiles.forEach(ozgFile -> putOzgFileIntoZip(ozgFile, zipOutputStream)); ozgFiles.forEach(ozgFile -> putOzgFileIntoZip(ozgFile, zipOutputStream));
} }
......
...@@ -34,7 +34,7 @@ import de.xoev.xdomea.IdentifikationObjektType; ...@@ -34,7 +34,7 @@ import de.xoev.xdomea.IdentifikationObjektType;
class DokumentTypeBuilderTest { class DokumentTypeBuilderTest {
private final String fullName = UserProfileTestFactory.FULLNAME; private final String fullName = UserProfileTestFactory.FULLNAME;
private final Bescheid bescheid = BescheidTestFactory.create(); private final Bescheid bescheid = BescheidTestFactory.create();
private final OzgFile document = OzgFileTestFactory.create(); private final OzgFile document = OzgFileTestFactory.createWithUniqueId();
@Spy @Spy
private final DokumentTypeBuilder builder = DokumentTypeBuilder.builder() private final DokumentTypeBuilder builder = DokumentTypeBuilder.builder()
...@@ -149,7 +149,7 @@ class DokumentTypeBuilderTest { ...@@ -149,7 +149,7 @@ class DokumentTypeBuilderTest {
@Nested @Nested
class TestWithOneAnlage { class TestWithOneAnlage {
private final AnlageDokumentType anlageDokumentAttachment = AnlageDokumentTypeTestFactory.create(); private final AnlageDokumentType anlageDokumentAttachment = AnlageDokumentTypeTestFactory.create();
private final OzgFile attachment = OzgFileTestFactory.create(); private final OzgFile attachment = OzgFileTestFactory.createWithUniqueId();
@Test @Test
void shouldHaveOneAnlage() { void shouldHaveOneAnlage() {
...@@ -250,7 +250,7 @@ class DokumentTypeBuilderTest { ...@@ -250,7 +250,7 @@ class DokumentTypeBuilderTest {
@Mock @Mock
private AnlageDokumentTypeBuilder anlageDokumentTypeBuilder; private AnlageDokumentTypeBuilder anlageDokumentTypeBuilder;
private final AnlageDokumentType expectedAnlage = AnlageDokumentTypeTestFactory.create(); private final AnlageDokumentType expectedAnlage = AnlageDokumentTypeTestFactory.create();
private final OzgFile attachment = OzgFileTestFactory.create(); private final OzgFile attachment = OzgFileTestFactory.createWithUniqueId();
@BeforeEach @BeforeEach
void setUp() { void setUp() {
......
...@@ -154,8 +154,8 @@ class ExportBescheidServiceTest { ...@@ -154,8 +154,8 @@ 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 document = OzgFileTestFactory.createWithUniqueId();
private final OzgFile attachment = OzgFileTestFactory.create(); private final OzgFile attachment = OzgFileTestFactory.createWithUniqueId();
@BeforeEach @BeforeEach
void setUpMocks() { void setUpMocks() {
...@@ -243,7 +243,7 @@ class ExportBescheidServiceTest { ...@@ -243,7 +243,7 @@ class ExportBescheidServiceTest {
@Test @Test
void shouldReturnGottenOzgFiles() { void shouldReturnGottenOzgFiles() {
var expectedOzgFile = OzgFileTestFactory.create(); var expectedOzgFile = OzgFileTestFactory.createWithUniqueId();
when(binaryFileService.getFiles(fileIds)).thenReturn(Stream.of(expectedOzgFile)); when(binaryFileService.getFiles(fileIds)).thenReturn(Stream.of(expectedOzgFile));
var resultOzgFiles = service.getAttachments(bescheid); var resultOzgFiles = service.getAttachments(bescheid);
...@@ -255,7 +255,6 @@ class ExportBescheidServiceTest { ...@@ -255,7 +255,6 @@ class ExportBescheidServiceTest {
@Nested @Nested
class TestAddBescheidExportData { class TestAddBescheidExportData {
private final List<OzgFile> files = BescheidExportInputTestFactory.FILES; private final List<OzgFile> files = BescheidExportInputTestFactory.FILES;
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();
......
...@@ -16,7 +16,7 @@ import de.ozgcloud.alfa.common.file.OzgFileTestFactory; ...@@ -16,7 +16,7 @@ import de.ozgcloud.alfa.common.file.OzgFileTestFactory;
class PrimaerdokumentTypeBuilderTest { class PrimaerdokumentTypeBuilderTest {
private final PrimaerdokumentTypeBuilder builder = PrimaerdokumentTypeBuilder.builder().withOzgFile(OzgFileTestFactory.create()); private final PrimaerdokumentTypeBuilder builder = PrimaerdokumentTypeBuilder.builder().withOzgFile(OzgFileTestFactory.createWithUniqueId());
@Nested @Nested
class TestBuild { class TestBuild {
...@@ -26,7 +26,7 @@ class PrimaerdokumentTypeBuilderTest { ...@@ -26,7 +26,7 @@ class PrimaerdokumentTypeBuilderTest {
private static final String ERSTELLER = "Ersteller"; private static final String ERSTELLER = "Ersteller";
private static final String GENERATED_FILE_NAME = "file_name"; private static final String GENERATED_FILE_NAME = "file_name";
private static final ZonedDateTime CREATED_AT = ZonedDateTime.now(); private static final ZonedDateTime CREATED_AT = ZonedDateTime.now();
private final OzgFile ozgFile = OzgFileTestFactory.create(); private final OzgFile ozgFile = OzgFileTestFactory.createWithUniqueId();
@BeforeEach @BeforeEach
void setUp() { void setUp() {
......
package de.ozgcloud.alfa.export; package de.ozgcloud.alfa.export;
import java.util.List; import java.util.Set;
import de.ozgcloud.alfa.common.file.OzgFile; import de.ozgcloud.alfa.common.file.OzgFile;
import de.ozgcloud.alfa.common.file.OzgFileTestFactory; import de.ozgcloud.alfa.common.file.OzgFileTestFactory;
...@@ -20,6 +20,6 @@ class ExportDataTestFactory { ...@@ -20,6 +20,6 @@ class ExportDataTestFactory {
return ExportData.builder() return ExportData.builder()
.exportFilename(EXPORT_FILENAME) .exportFilename(EXPORT_FILENAME)
.abgabe(ABGABE) .abgabe(ABGABE)
.exportFiles(List.of(OZG_FILE)); .exportFiles(Set.of(OZG_FILE));
} }
} }
...@@ -136,8 +136,8 @@ class ExportServiceTest { ...@@ -136,8 +136,8 @@ class ExportServiceTest {
private final NkAbgabeType kopfType = NkAbgabeTypeTestFactory.create(); private final NkAbgabeType kopfType = NkAbgabeTypeTestFactory.create();
private final AbgabeAbgabe0401 abgabe = AbgabeAbgabe0401TestFactory.create(); private final AbgabeAbgabe0401 abgabe = AbgabeAbgabe0401TestFactory.create();
private final AkteType akteType = AkteTypeTestFactory.create(); private final AkteType akteType = AkteTypeTestFactory.create();
private final List<OzgFile> representations = List.of(OzgFileTestFactory.create()); private final List<OzgFile> representations = List.of(OzgFileTestFactory.createWithUniqueId());
private final List<OzgFile> attachments = List.of(OzgFileTestFactory.create()); private final List<OzgFile> attachments = List.of(OzgFileTestFactory.createWithUniqueId());
private final List<DokumentType> representationsDokumentTypes = List.of(DokumentTypeTestFactory.create()); private final List<DokumentType> representationsDokumentTypes = List.of(DokumentTypeTestFactory.create());
private final List<DokumentType> attachmentsDokumentTypes = List.of(DokumentTypeTestFactory.create()); private final List<DokumentType> attachmentsDokumentTypes = List.of(DokumentTypeTestFactory.create());
private final List<HistorienProtokollInformationType> historienProtokollInformationTypes = List.of( private final List<HistorienProtokollInformationType> historienProtokollInformationTypes = List.of(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment