Skip to content
Snippets Groups Projects
Commit fdbc71dc authored by OZGCloud's avatar OZGCloud
Browse files

OZG-4392 add method to check if command has error status

parent 79489b90
No related branches found
No related tags found
No related merge requests found
...@@ -50,7 +50,7 @@ public class GrpcOzgCloudCommandService implements OzgCloudCommandService { ...@@ -50,7 +50,7 @@ public class GrpcOzgCloudCommandService implements OzgCloudCommandService {
} }
} }
} }
if (command.getStatus() == OzgCloudCommandStatus.ERROR) { if (hasErrorStatus(command)) {
throw new TechnicalException("Command (id=%s) failed: %s".formatted(command.getId(), command.getErrorMessage())); throw new TechnicalException("Command (id=%s) failed: %s".formatted(command.getId(), command.getErrorMessage()));
} }
return command; return command;
...@@ -64,4 +64,8 @@ public class GrpcOzgCloudCommandService implements OzgCloudCommandService { ...@@ -64,4 +64,8 @@ public class GrpcOzgCloudCommandService implements OzgCloudCommandService {
CommandServiceBlockingStub getCommandServiceStub() { CommandServiceBlockingStub getCommandServiceStub() {
return commandServiceStub.withInterceptors(new OzgCloudCallContextAttachingInterceptor(contextProvider)); return commandServiceStub.withInterceptors(new OzgCloudCallContextAttachingInterceptor(contextProvider));
} }
boolean hasErrorStatus(OzgCloudCommand command) {
return command.getStatus() == OzgCloudCommandStatus.ERROR;
}
} }
...@@ -119,4 +119,17 @@ class GrpcOzgCloudCommandServiceTest { ...@@ -119,4 +119,17 @@ class GrpcOzgCloudCommandServiceTest {
} }
} }
@Nested
class TestStatus {
@Test
void shouldReturnTrueByError() {
var command = OzgCloudCommandTestFactory.createBuilder().status(OzgCloudCommandStatus.ERROR).build();
var result = service.hasErrorStatus(command);
assertThat(result).isTrue();
}
}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment