diff --git a/ozgcloud-common-lib/src/main/java/de/ozgcloud/common/binaryfile/GrpcBinaryFileServerDownloader.java b/ozgcloud-common-lib/src/main/java/de/ozgcloud/common/binaryfile/GrpcBinaryFileServerDownloader.java index b992f4236a809f36e95dcf6811d6b80ad0675046..cb4a208c74dd7fa0e8ed29e6d45a2303d8dcafc6 100644 --- a/ozgcloud-common-lib/src/main/java/de/ozgcloud/common/binaryfile/GrpcBinaryFileServerDownloader.java +++ b/ozgcloud-common-lib/src/main/java/de/ozgcloud/common/binaryfile/GrpcBinaryFileServerDownloader.java @@ -143,7 +143,7 @@ public class GrpcBinaryFileServerDownloader<T> { } catch (Exception e) { closeOutputStream(); closeInputStream(); - throw new TechnicalException("Error occurred during downloading file content download.", e); + callObserver.onError(new TechnicalException("Error occurred during downloading file content download.", e)); } } 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 6050e6ba2d06a739e87ec479956dff4fecd707b8..483e38d5fb01cc09dfd9933d0fcc49bbb566f94e 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 @@ -26,7 +26,6 @@ package de.ozgcloud.common.binaryfile; import com.google.protobuf.ByteString; import de.ozgcloud.common.errorhandling.TechnicalException; import de.ozgcloud.common.test.ReflectionTestUtils; -import io.grpc.Context; import io.grpc.stub.CallStreamObserver; import lombok.SneakyThrows; import org.junit.jupiter.api.BeforeEach; @@ -407,11 +406,6 @@ class GrpcBinaryFileServerDownloaderTest { verify(callObserver).onCompleted(); } - - @SneakyThrows - private boolean getRequestFinished() { - return ReflectionTestUtils.getField(downloader, "requestFinished", AtomicBoolean.class).get(); - } } @DisplayName("Handle safety") @@ -436,20 +430,10 @@ class GrpcBinaryFileServerDownloaderTest { setOutputStreamField(outputStream); } - @SneakyThrows - @Test - void shouldThrowTechnicalException() { - assertThatThrownBy(this::handleSafety).isInstanceOf(TechnicalException.class).extracting(Throwable::getCause).isEqualTo(exception); - } - @SneakyThrows @Test void shouldCloseOutputStream() { - try { - handleSafety(); - } catch (Exception e) { - // do nothing - } + handleSafety(); verify(outputStream).close(); } @@ -457,15 +441,18 @@ class GrpcBinaryFileServerDownloaderTest { @SneakyThrows @Test void shouldCloseInputStream() { - try { - handleSafety(); - } catch (Exception e) { - // do nothing - } + handleSafety(); verify(inputStream).close(); } + @Test + void shouldNotifyCallObserver() { + handleSafety(); + + verify(callObserver).onError(argThat(TechnicalException.class::isInstance)); + } + private void handleSafety() { downloader.handleSafety(this::dummyMethodThrowingException); }