Skip to content

Commit

Permalink
updating tests and clients
Browse files Browse the repository at this point in the history
Signed-off-by: salaboy <Salaboy@gmail.com>
  • Loading branch information
salaboy committed Jun 11, 2024
1 parent 093f85d commit 837be4a
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 25 deletions.
7 changes: 1 addition & 6 deletions sdk/src/main/java/io/dapr/client/DaprClientGrpc.java
Original file line number Diff line number Diff line change
Expand Up @@ -1234,14 +1234,10 @@ private DaprMetadata buildDaprMetadata(
DaprProtos.GetMetadataResponse response) throws IOException {
List<RegisteredComponents> registeredComponentsList = response.getRegisteredComponentsList();

DaprMetadata daprMetadata = new DaprMetadata();
daprMetadata.setId(response.getId());
daprMetadata.setRuntimeVersion(response.getRuntimeVersion());
List<ComponentMetadata> components = new ArrayList<>();
for (RegisteredComponents rc : registeredComponentsList) {
components.add(new ComponentMetadata(rc.getName(), rc.getType(), rc.getVersion()));
}
daprMetadata.setComponents(components);

List<PubsubSubscription> subscriptionsList = response.getSubscriptionsList();
List<SubscriptionMetadata> subscriptions = new ArrayList<>();
Expand All @@ -1253,8 +1249,7 @@ private DaprMetadata buildDaprMetadata(
}
subscriptions.add(new SubscriptionMetadata(s.getTopic(), s.getPubsubName(), s.getDeadLetterTopic(), rules));
}
daprMetadata.setSubscriptions(subscriptions);

return daprMetadata;
return new DaprMetadata(response.getId(), response.getRuntimeVersion(), components, subscriptions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
if (this == obj)
if (this == obj) {
return true;

Check warning on line 63 in sdk/src/main/java/io/dapr/client/domain/ComponentMetadata.java

View check run for this annotation

Codecov / codecov/patch

sdk/src/main/java/io/dapr/client/domain/ComponentMetadata.java#L63

Added line #L63 was not covered by tests
if (obj == null)
}
if (obj == null) {
return false;

Check warning on line 66 in sdk/src/main/java/io/dapr/client/domain/ComponentMetadata.java

View check run for this annotation

Codecov / codecov/patch

sdk/src/main/java/io/dapr/client/domain/ComponentMetadata.java#L66

Added line #L66 was not covered by tests
if (getClass() != obj.getClass())
}
if (getClass() != obj.getClass()) {
return false;

Check warning on line 69 in sdk/src/main/java/io/dapr/client/domain/ComponentMetadata.java

View check run for this annotation

Codecov / codecov/patch

sdk/src/main/java/io/dapr/client/domain/ComponentMetadata.java#L69

Added line #L69 was not covered by tests
}
ComponentMetadata other = (ComponentMetadata) obj;
return Objects.equals(name, other.name) && Objects.equals(type, other.type)
&& Objects.equals(version, other.version);
Expand Down
9 changes: 6 additions & 3 deletions sdk/src/main/java/io/dapr/client/domain/DaprMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,15 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
if (this == obj)
if (this == obj) {
return true;

Check warning on line 73 in sdk/src/main/java/io/dapr/client/domain/DaprMetadata.java

View check run for this annotation

Codecov / codecov/patch

sdk/src/main/java/io/dapr/client/domain/DaprMetadata.java#L73

Added line #L73 was not covered by tests
if (obj == null)
}
if (obj == null) {
return false;

Check warning on line 76 in sdk/src/main/java/io/dapr/client/domain/DaprMetadata.java

View check run for this annotation

Codecov / codecov/patch

sdk/src/main/java/io/dapr/client/domain/DaprMetadata.java#L76

Added line #L76 was not covered by tests
if (getClass() != obj.getClass())
}
if (getClass() != obj.getClass()) {
return false;

Check warning on line 79 in sdk/src/main/java/io/dapr/client/domain/DaprMetadata.java

View check run for this annotation

Codecov / codecov/patch

sdk/src/main/java/io/dapr/client/domain/DaprMetadata.java#L79

Added line #L79 was not covered by tests
}
DaprMetadata other = (DaprMetadata) obj;
return Objects.equals(id, other.id) && Objects.equals(runtimeVersion, other.runtimeVersion)
&& Objects.equals(components, other.components) && Objects.equals(subscriptions, other.subscriptions);
Expand Down
9 changes: 6 additions & 3 deletions sdk/src/main/java/io/dapr/client/domain/RuleMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
if (this == obj)
if (this == obj) {
return true;

Check warning on line 43 in sdk/src/main/java/io/dapr/client/domain/RuleMetadata.java

View check run for this annotation

Codecov / codecov/patch

sdk/src/main/java/io/dapr/client/domain/RuleMetadata.java#L43

Added line #L43 was not covered by tests
if (obj == null)
}
if (obj == null) {
return false;

Check warning on line 46 in sdk/src/main/java/io/dapr/client/domain/RuleMetadata.java

View check run for this annotation

Codecov / codecov/patch

sdk/src/main/java/io/dapr/client/domain/RuleMetadata.java#L46

Added line #L46 was not covered by tests
if (getClass() != obj.getClass())
}
if (getClass() != obj.getClass()) {
return false;

Check warning on line 49 in sdk/src/main/java/io/dapr/client/domain/RuleMetadata.java

View check run for this annotation

Codecov / codecov/patch

sdk/src/main/java/io/dapr/client/domain/RuleMetadata.java#L49

Added line #L49 was not covered by tests
}
RuleMetadata other = (RuleMetadata) obj;
return Objects.equals(path, other.path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,15 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
if (this == obj)
if (this == obj) {
return true;

Check warning on line 73 in sdk/src/main/java/io/dapr/client/domain/SubscriptionMetadata.java

View check run for this annotation

Codecov / codecov/patch

sdk/src/main/java/io/dapr/client/domain/SubscriptionMetadata.java#L73

Added line #L73 was not covered by tests
if (obj == null)
}
if (obj == null) {
return false;

Check warning on line 76 in sdk/src/main/java/io/dapr/client/domain/SubscriptionMetadata.java

View check run for this annotation

Codecov / codecov/patch

sdk/src/main/java/io/dapr/client/domain/SubscriptionMetadata.java#L76

Added line #L76 was not covered by tests
if (getClass() != obj.getClass())
}
if (getClass() != obj.getClass()) {
return false;

Check warning on line 79 in sdk/src/main/java/io/dapr/client/domain/SubscriptionMetadata.java

View check run for this annotation

Codecov / codecov/patch

sdk/src/main/java/io/dapr/client/domain/SubscriptionMetadata.java#L79

Added line #L79 was not covered by tests
}
SubscriptionMetadata other = (SubscriptionMetadata) obj;
return Objects.equals(topic, other.topic) && Objects.equals(pubsubname, other.pubsubname)
&& Objects.equals(deadLetterTopic, other.deadLetterTopic) && Objects.equals(rules, other.rules);
Expand Down
11 changes: 4 additions & 7 deletions sdk/src/test/java/io/dapr/client/DaprClientHttpTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,11 @@ public void metadataEndpoint() throws JsonProcessingException{
daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient);
DaprClientHttp daprClientHttp = new DaprClientHttp(daprHttp);

DaprMetadata metadata = new DaprMetadata();
metadata.setId("my-app");
metadata.setRuntimeVersion("1.1x.x");
metadata.setComponents(Collections.singletonList(new ComponentMetadata("statestore", "state.redis", "v1")));
metadata.setSubscriptions(Collections.singletonList(new SubscriptionMetadata("topic", "pubsub", "", Collections.singletonList(new RuleMetadata("/path")))));

ObjectMapper mapper = new ObjectMapper();
DaprMetadata metadata = new DaprMetadata("my-app", "1.1x.x",
Collections.singletonList(new ComponentMetadata("statestore", "state.redis", "v1")),
Collections.singletonList(new SubscriptionMetadata("topic", "pubsub", "", Collections.singletonList(new RuleMetadata("/path")))));

ObjectMapper mapper = new ObjectMapper();

mockInterceptor.addRule()
.get()
Expand Down

0 comments on commit 837be4a

Please sign in to comment.