diff --git a/alfa-xdomea/src/test/java/de/ozgcloud/alfa/export/ExportServiceITCase.java b/alfa-xdomea/src/test/java/de/ozgcloud/alfa/export/ExportServiceITCase.java new file mode 100644 index 0000000000000000000000000000000000000000..7f5909d46e0d2f6570859326f88c4d9990a8d869 --- /dev/null +++ b/alfa-xdomea/src/test/java/de/ozgcloud/alfa/export/ExportServiceITCase.java @@ -0,0 +1,62 @@ +package de.ozgcloud.alfa.export; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +import java.io.ByteArrayOutputStream; +import java.nio.charset.StandardCharsets; +import java.util.HexFormat; +import java.util.List; +import java.util.UUID; + +import org.apache.commons.lang3.RandomStringUtils; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.mock.mockito.SpyBean; + +import de.ozgcloud.alfa.common.binaryfile.FileId; +import de.ozgcloud.alfa.common.file.OzgFile; +import de.ozgcloud.alfa.common.file.OzgFileTestFactory; +import de.ozgcloud.alfa.file.ExportFileService; +import de.ozgcloud.alfa.vorgang.ExportVorgangService; +import de.ozgcloud.alfa.vorgang.VorgangWithEingangTestFactory; +import de.ozgcloud.common.test.ITCase; + +@ITCase +class ExportServiceITCase { + + @SpyBean + private ExportFileService exportFileService; + @SpyBean + private ExportVorgangService exportVorgangService; + @Autowired + private ExportService exportService; + + @Nested + class TestWriteExport { + + @BeforeEach + void setup() { + doReturn(VorgangWithEingangTestFactory.create()).when(exportVorgangService).getVorgang(anyString()); + doReturn(List.of(createOzgFile())).when(exportFileService).getAllPdfs(anyString()); + doNothing().when(exportFileService).writeOzgFile(any(), any()); + } + + @Test + void shouldNotThrowException() { + assertDoesNotThrow(() -> exportService.writeExport(UUID.randomUUID().toString(), UUID.randomUUID().toString(), new ByteArrayOutputStream())); + } + } + + private static OzgFile createOzgFile() { + return OzgFileTestFactory.createBuilder() + .id(FileId.from(createMongoDbObjectId())) + .build(); + } + + private static String createMongoDbObjectId() { + return HexFormat.of().formatHex(RandomStringUtils.randomAlphanumeric(24).getBytes(StandardCharsets.UTF_8)); + } +}