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> {
} 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));
}
}
......
......@@ -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
}
verify(outputStream).close();
}
......@@ -457,15 +441,18 @@ class GrpcBinaryFileServerDownloaderTest {
@SneakyThrows
@Test
void shouldCloseInputStream() {
try {
handleSafety();
} catch (Exception e) {
// do nothing
}
verify(inputStream).close();
}
@Test
void shouldNotifyCallObserver() {
handleSafety();
verify(callObserver).onError(argThat(TechnicalException.class::isInstance));
}
private void handleSafety() {
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