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

OZG-4087 OZG-4144 implement service

parent a31755b4
No related branches found
No related tags found
No related merge requests found
package de.ozgcloud.xdomea;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import org.springframework.stereotype.Service;
import de.itvsh.kop.common.errorhandling.TechnicalException;
@Service
class XDomeaService {
public ByteArrayOutputStream createVorgangExport() {
ByteArrayOutputStream outputBytes = new ByteArrayOutputStream();
try (ZipOutputStream zipOutputStream = new ZipOutputStream(outputBytes)) {
putZipEntry("fake_file.txt", "data", zipOutputStream);
} catch (IOException ioe) {
throw new TechnicalException("Error creating zip file with Vorgang export", ioe);
}
return outputBytes;
}
private void putZipEntry(String fileName, String fileData, ZipOutputStream zipOutputStream) throws IOException {
ZipEntry entry = new ZipEntry(fileName);
zipOutputStream.putNextEntry(entry);
zipOutputStream.write(fileData.getBytes());
zipOutputStream.closeEntry();
}
}
package de.ozgcloud.xdomea;
import static org.assertj.core.api.Assertions.*;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
class XDomeaServiceTest {
private XDomeaService service = new XDomeaService();
@Nested
class TestCreateVorgangExport {
@Test
void shouldCreate() {
var zipBytesStream = service.createVorgangExport();
assertThat(zipBytesStream).isNotNull();
assertThat(zipBytesStream.toByteArray()).hasSizeGreaterThan(100);
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment