Skip to content

Commit eb1ad65

Browse files
committed
fixed tests
1 parent aede530 commit eb1ad65

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

client/src/main/java/com/microsoft/durabletask/DurableTaskGrpcClient.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,10 @@ public void rewindInstance(String instanceId, @Nullable String reason) {
425425
try {
426426
this.sidecarClient.rewindInstance(rewindRequestBuilder.build());
427427
} catch (StatusRuntimeException e) {
428+
if (e.getStatus().getCode() == Status.Code.NOT_FOUND) {
429+
throw new IllegalArgumentException(
430+
"No orchestration instance with ID '" + instanceId + "' was found.", e);
431+
}
428432
if (e.getStatus().getCode() == Status.Code.FAILED_PRECONDITION) {
429433
throw new IllegalStateException(
430434
"Orchestration instance '" + instanceId + "' is not in a failed state and cannot be rewound.", e);

client/src/test/java/com/microsoft/durabletask/DurableTaskGrpcClientTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ public void rewindInstance(RewindInstanceRequest request, StreamObserver<RewindI
424424
}
425425

426426
@Test
427-
void rewindInstance_notFound_throwsIllegalArgumentExceptionThroughHelper() throws IOException {
427+
void rewindInstance_notFound_throwsIllegalArgumentExceptionWithCustomMessage() throws IOException {
428428
DurableTaskClient client = createClientWithFakeService(new TaskHubSidecarServiceGrpc.TaskHubSidecarServiceImplBase() {
429429
@Override
430430
public void rewindInstance(RewindInstanceRequest request, StreamObserver<RewindInstanceResponse> responseObserver) {
@@ -437,8 +437,9 @@ public void rewindInstance(RewindInstanceRequest request, StreamObserver<RewindI
437437
client.rewindInstance("test-instance", null));
438438

439439
assertGrpcCause(ex, Status.Code.NOT_FOUND);
440-
// Now goes through the helper, so message contains the operation name
441-
assertTrue(ex.getMessage().contains("rewindInstance"));
440+
// rewindInstance has its own custom message for NOT_FOUND
441+
assertTrue(ex.getMessage().contains("No orchestration instance with ID"));
442+
assertTrue(ex.getMessage().contains("was found"));
442443
}
443444

444445
// -----------------------------------------------------------------------

0 commit comments

Comments
 (0)