Skip to content

Commit 2101fdf

Browse files
committed
adding coverage tests
1 parent f685a13 commit 2101fdf

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

sdk/src/test/java/io/dapr/client/DaprClientGrpcTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import io.dapr.client.domain.TransactionalStateOperation;
3030
import io.dapr.client.domain.UnsubscribeConfigurationRequest;
3131
import io.dapr.client.domain.UnsubscribeConfigurationResponse;
32+
import io.dapr.exceptions.DaprError;
33+
import io.dapr.exceptions.DaprException;
3234
import io.dapr.serializer.DaprObjectSerializer;
3335
import io.dapr.serializer.DefaultObjectSerializer;
3436
import io.dapr.utils.TypeRef;
@@ -2117,7 +2119,29 @@ public void getMetadataTest() {
21172119
assertEquals("app", metadata.getId());
21182120
assertEquals("1.1x.x", metadata.getRuntimeVersion());
21192121
assertEquals(1, metadata.getComponents().size());
2122+
assertEquals(registeredComponents.getName(), metadata.getComponents().get(0).getName());
2123+
assertEquals(registeredComponents.getVersion(), metadata.getComponents().get(0).getVersion());
2124+
assertEquals(registeredComponents.getType(), metadata.getComponents().get(0).getType());
21202125
assertEquals(1, metadata.getSubscriptions().size());
2126+
assertEquals(pubsubSubscription.getPubsubName(), metadata.getSubscriptions().get(0).getPubsubname());
2127+
assertEquals(pubsubSubscription.getTopic(), metadata.getSubscriptions().get(0).getTopic());
2128+
assertEquals(1, metadata.getSubscriptions().get(0).getRules().size());
2129+
assertEquals(pubsubSubscription.getRules().getRules(0).getPath(), metadata.getSubscriptions().get(0).getRules().get(0).getPath());
21212130

21222131
}
2132+
2133+
@Test
2134+
public void getMetadataExceptionTest() {
2135+
doAnswer((Answer<Void>) invocation -> {
2136+
throw new RuntimeException();
2137+
}).when(daprStub).getMetadata(any(DaprProtos.GetMetadataRequest.class), any());
2138+
2139+
Mono<DaprMetadata> result = client.getMetadata();
2140+
2141+
assertThrowsDaprException(
2142+
RuntimeException.class,
2143+
"UNKNOWN",
2144+
"UNKNOWN: ",
2145+
() -> result.block());
2146+
}
21232147
}

0 commit comments

Comments
 (0)