Skip to content
Snippets Groups Projects
Commit a6ec45af authored by Felix Reichenbach's avatar Felix Reichenbach
Browse files

OZG-7573 implement FileService

parent 04cd6e35
Branches
Tags
1 merge request!9Ozg 7573 forward vorgang
......@@ -30,13 +30,14 @@ import java.util.concurrent.CompletableFuture;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import de.ozgcloud.common.binaryfile.TempFileUtils;
@Service
class FileService {
@Async
public CompletableFuture<File> saveToFile(InputStream inputStream) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'saveToFile'");
return CompletableFuture.completedFuture(TempFileUtils.writeTmpFile(inputStream));
}
}
package de.ozgcloud.eingang.forwarder;
import static org.assertj.core.api.Assertions.*;
import java.io.ByteArrayInputStream;
import java.nio.file.Files;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.mockito.Spy;
import com.thedeanda.lorem.LoremIpsum;
import lombok.SneakyThrows;
class FileServiceTest {
@Spy
private FileService service;
@Nested
class TestSaveToFile {
private final byte[] content = LoremIpsum.getInstance().getWords(100).getBytes();
@Test
@SneakyThrows
void shouldReturnFutureOfFile() {
try (var inputStream = new ByteArrayInputStream(content);) {
var fileFuture = service.saveToFile(inputStream);
var fileContent = Files.readAllBytes(fileFuture.get().toPath());
assertThat(fileContent).isEqualTo(content);
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment