From cf0635063f18e2d6a73924291df2709a7fb1e4ad Mon Sep 17 00:00:00 2001 From: Krzysztof Witukiewicz <krzysztof.witukiewicz@mgm-tp.com> Date: Fri, 7 Feb 2025 15:49:37 +0100 Subject: [PATCH] OZG-7262 OZG-7680 Remove unneeded code --- .../GrpcBinaryFileServerDownloaderTest.java | 70 +------------------ 1 file changed, 1 insertion(+), 69 deletions(-) diff --git a/ozgcloud-common-lib/src/test/java/de/ozgcloud/common/binaryfile/GrpcBinaryFileServerDownloaderTest.java b/ozgcloud-common-lib/src/test/java/de/ozgcloud/common/binaryfile/GrpcBinaryFileServerDownloaderTest.java index e2f860e..ba9b67a 100644 --- a/ozgcloud-common-lib/src/test/java/de/ozgcloud/common/binaryfile/GrpcBinaryFileServerDownloaderTest.java +++ b/ozgcloud-common-lib/src/test/java/de/ozgcloud/common/binaryfile/GrpcBinaryFileServerDownloaderTest.java @@ -27,7 +27,6 @@ import static org.assertj.core.api.Assertions.*; import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.*; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -40,7 +39,6 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Stream; -import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -486,7 +484,7 @@ class GrpcBinaryFileServerDownloaderTest { @ParameterizedTest @MethodSource("provideArguments") void shouldReturnValue(boolean requestFinished, boolean ready, boolean expected) { - ReflectionTestUtils.setField(downloader, "requestFinished", new AtomicBoolean(requestFinished)); + setRequestFinishedField(requestFinished); lenient().when(callObserver.isReady()).thenReturn(ready); var canSendChunks = downloader.canSendChunks(); @@ -635,72 +633,6 @@ class GrpcBinaryFileServerDownloaderTest { return (TechnicalException) ReflectionTestUtils.getField(downloader, "downloadError", AtomicReference.class).get(); } - private void setDownloadFinishedField(boolean downloadFinished) { - ReflectionTestUtils.setField(downloader, "downloadFinished", new AtomicBoolean(downloadFinished)); - } - - private boolean getDownloadFinished() { - return ReflectionTestUtils.getField(downloader, "downloadFinished", AtomicBoolean.class).get(); - } - private static class GrpcResponseDummy { } - - @Nested - class TestStreams { - - private static final int CHUNK_SIZE = 255 * 1024; - - private PipedInputStream inputStream; - private PipedOutputStream outputStream; - - @SneakyThrows - @BeforeEach - void init() { - outputStream = new PipedOutputStream(); - inputStream = new PipedInputStream(CHUNK_SIZE); - outputStream.connect(inputStream); - } - - @SneakyThrows - @Test - void shouldReadIncompleteFile() { - var fileBuffer = new byte[CHUNK_SIZE]; - var readBuffer = new byte[CHUNK_SIZE]; - try (FileInputStream fileInputStream = new FileInputStream("/Users/kwitukiewicz/Documents/books/__Debt__The_First_5_000_Years.pdf")) { - fileInputStream.read(fileBuffer, 0, 255); - outputStream.write(fileBuffer, 0, 1); - - var read = inputStream.read(readBuffer, 0, CHUNK_SIZE); - - assertThat(read).isEqualTo(1); - } - } - - @SneakyThrows - @Test - void shouldReadAfterOutputStreamWasClosed() { - var fileBuffer = new byte[CHUNK_SIZE]; - var readBuffer = new byte[CHUNK_SIZE * 2]; - try (FileInputStream fileInputStream = new FileInputStream("/Users/kwitukiewicz/Documents/books/__Debt__The_First_5_000_Years.pdf")) { - fileInputStream.read(fileBuffer, 0, fileBuffer.length); - outputStream.write(fileBuffer); - outputStream.close(); - - var read = inputStream.read(readBuffer); - - assertThat(read).isEqualTo(CHUNK_SIZE); - - read = inputStream.read(readBuffer); - assertThat(read).isEqualTo(-1); - } - } - - @SneakyThrows - @AfterEach - void cleanup() { - outputStream.close(); - inputStream.close(); - } - } } \ No newline at end of file -- GitLab