Skip to content

Commit

Permalink
adding coverage tests
Browse files Browse the repository at this point in the history
Signed-off-by: salaboy <Salaboy@gmail.com>
  • Loading branch information
salaboy committed Jun 24, 2024
1 parent 7d82e8c commit 732e7f1
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions sdk/src/test/java/io/dapr/client/DaprClientGrpcTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import io.dapr.client.domain.TransactionalStateOperation;
import io.dapr.client.domain.UnsubscribeConfigurationRequest;
import io.dapr.client.domain.UnsubscribeConfigurationResponse;
import io.dapr.exceptions.DaprError;
import io.dapr.exceptions.DaprException;
import io.dapr.serializer.DaprObjectSerializer;
import io.dapr.serializer.DefaultObjectSerializer;
import io.dapr.utils.TypeRef;
Expand Down Expand Up @@ -2117,7 +2119,29 @@ public void getMetadataTest() {
assertEquals("app", metadata.getId());
assertEquals("1.1x.x", metadata.getRuntimeVersion());
assertEquals(1, metadata.getComponents().size());
assertEquals(registeredComponents.getName(), metadata.getComponents().get(0).getName());
assertEquals(registeredComponents.getVersion(), metadata.getComponents().get(0).getVersion());
assertEquals(registeredComponents.getType(), metadata.getComponents().get(0).getType());
assertEquals(1, metadata.getSubscriptions().size());
assertEquals(pubsubSubscription.getPubsubName(), metadata.getSubscriptions().get(0).getPubsubname());
assertEquals(pubsubSubscription.getTopic(), metadata.getSubscriptions().get(0).getTopic());
assertEquals(1, metadata.getSubscriptions().get(0).getRules().size());
assertEquals(pubsubSubscription.getRules().getRules(0).getPath(), metadata.getSubscriptions().get(0).getRules().get(0).getPath());

}

@Test
public void getMetadataExceptionTest() {
doAnswer((Answer<Void>) invocation -> {
throw new RuntimeException();
}).when(daprStub).getMetadata(any(DaprProtos.GetMetadataRequest.class), any());

Mono<DaprMetadata> result = client.getMetadata();

assertThrowsDaprException(
RuntimeException.class,
"UNKNOWN",
"UNKNOWN: ",
() -> result.block());
}
}

0 comments on commit 732e7f1

Please sign in to comment.