Skip to content
Snippets Groups Projects
Commit 4960695d authored by Krzysztof Witukiewicz's avatar Krzysztof Witukiewicz
Browse files

OZG-7262 OZG-7566 Notify callObserver about error

parent c5e7bcf5
No related branches found
No related tags found
1 merge request!6OZG-7262 OZG-7566 Notify callObserver about error
...@@ -143,7 +143,7 @@ public class GrpcBinaryFileServerDownloader<T> { ...@@ -143,7 +143,7 @@ public class GrpcBinaryFileServerDownloader<T> {
} catch (Exception e) { } catch (Exception e) {
closeOutputStream(); closeOutputStream();
closeInputStream(); closeInputStream();
throw new TechnicalException("Error occurred during downloading file content download.", e); callObserver.onError(new TechnicalException("Error occurred during downloading file content download.", e));
} }
} }
......
...@@ -26,7 +26,6 @@ package de.ozgcloud.common.binaryfile; ...@@ -26,7 +26,6 @@ package de.ozgcloud.common.binaryfile;
import com.google.protobuf.ByteString; import com.google.protobuf.ByteString;
import de.ozgcloud.common.errorhandling.TechnicalException; import de.ozgcloud.common.errorhandling.TechnicalException;
import de.ozgcloud.common.test.ReflectionTestUtils; import de.ozgcloud.common.test.ReflectionTestUtils;
import io.grpc.Context;
import io.grpc.stub.CallStreamObserver; import io.grpc.stub.CallStreamObserver;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
...@@ -407,11 +406,6 @@ class GrpcBinaryFileServerDownloaderTest { ...@@ -407,11 +406,6 @@ class GrpcBinaryFileServerDownloaderTest {
verify(callObserver).onCompleted(); verify(callObserver).onCompleted();
} }
@SneakyThrows
private boolean getRequestFinished() {
return ReflectionTestUtils.getField(downloader, "requestFinished", AtomicBoolean.class).get();
}
} }
@DisplayName("Handle safety") @DisplayName("Handle safety")
...@@ -436,20 +430,10 @@ class GrpcBinaryFileServerDownloaderTest { ...@@ -436,20 +430,10 @@ class GrpcBinaryFileServerDownloaderTest {
setOutputStreamField(outputStream); setOutputStreamField(outputStream);
} }
@SneakyThrows
@Test
void shouldThrowTechnicalException() {
assertThatThrownBy(this::handleSafety).isInstanceOf(TechnicalException.class).extracting(Throwable::getCause).isEqualTo(exception);
}
@SneakyThrows @SneakyThrows
@Test @Test
void shouldCloseOutputStream() { void shouldCloseOutputStream() {
try {
handleSafety(); handleSafety();
} catch (Exception e) {
// do nothing
}
verify(outputStream).close(); verify(outputStream).close();
} }
...@@ -457,15 +441,18 @@ class GrpcBinaryFileServerDownloaderTest { ...@@ -457,15 +441,18 @@ class GrpcBinaryFileServerDownloaderTest {
@SneakyThrows @SneakyThrows
@Test @Test
void shouldCloseInputStream() { void shouldCloseInputStream() {
try {
handleSafety(); handleSafety();
} catch (Exception e) {
// do nothing
}
verify(inputStream).close(); verify(inputStream).close();
} }
@Test
void shouldNotifyCallObserver() {
handleSafety();
verify(callObserver).onError(argThat(TechnicalException.class::isInstance));
}
private void handleSafety() { private void handleSafety() {
downloader.handleSafety(this::dummyMethodThrowingException); downloader.handleSafety(this::dummyMethodThrowingException);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment