Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 55 additions & 1 deletion sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@
<scope>test</scope>
</dependency>
</dependencies>

<properties>
<skipITs>true</skipITs>
</properties>
<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -88,6 +90,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<skipITs>${skipITs}</skipITs>
</configuration>
<executions>
<execution>
<goals>
Expand All @@ -97,6 +102,55 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.4</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>CLASS</element>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.00</minimum>
</limit>
<limit>
<counter>BRANCH</counter>
<value>COVEREDRATIO</value>
<minimum>0.00</minimum>
</limit>
</limits>
<excludes>
<exclude>io.dapr.utils.Constants</exclude>
</excludes>
</rule>
</rules>
</configuration>
</execution>

</executions>
</plugin>
</plugins>
</build>
</project>
17 changes: 1 addition & 16 deletions sdk/src/main/java/io/dapr/actors/ActorId.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,7 @@ public static ActorId createRandom() {
return new ActorId(id.toString());
}

/**
* Determines whether two specified actorIds have the same id.
*
* @param id1 The first actorId to compare, or null
* @param id2 The second actorId to compare, or null.
* @return true if the id is same for both objects; otherwise, false.
*/
private static boolean equals(ActorId id1, ActorId id2) {
if (id1 == null && id2 == null) {
return true;
} else if (id2 == null || id1 == null) {
return false;
} else {
return hasEqualContent(id1, id2);
}
}


/**
* Compares if two actors have the same content.
Expand Down
24 changes: 12 additions & 12 deletions sdk/src/main/java/io/dapr/actors/client/ActorProxyImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ public String getActorType() {
public <T> Mono<T> invokeActorMethod(String methodName, Object data, Class<T> clazz) {
try {
Mono<String> result = this.daprClient.invokeActorMethod(
actorType,
actorId.toString(),
methodName,
this.wrap(data));
actorType,
actorId.toString(),
methodName,
this.wrap(data));

return result
.filter(s -> (s != null) && (!s.isEmpty()))
.map(s -> unwrap(s, clazz));
.filter(s -> (s != null) && (!s.isEmpty()))
.map(s -> unwrap(s, clazz));
} catch (IOException e) {
return Mono.error(e);
}
Expand All @@ -87,8 +87,8 @@ public <T> Mono<T> invokeActorMethod(String methodName, Object data, Class<T> cl
public <T> Mono<T> invokeActorMethod(String methodName, Class<T> clazz) {
Mono<String> result = this.daprClient.invokeActorMethod(actorType, actorId.toString(), methodName, null);
return result
.filter(s -> (s != null) && (!s.isEmpty()))
.map(s -> unwrap(s, clazz));
.filter(s -> (s != null) && (!s.isEmpty()))
.map(s -> unwrap(s, clazz));
}

/**
Expand All @@ -107,10 +107,10 @@ public Mono<Void> invokeActorMethod(String methodName) {
public Mono<Void> invokeActorMethod(String methodName, Object data) {
try {
Mono<String> result = this.daprClient.invokeActorMethod(
actorType,
actorId.toString(),
methodName,
this.wrap(data));
actorType,
actorId.toString(),
methodName,
this.wrap(data));
return result.then();
} catch (IOException e) {
return Mono.error(e);
Expand Down
3 changes: 2 additions & 1 deletion sdk/src/test/java/io/dapr/actors/ActorIdTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void verifyEqualsByActorId() {
List<Wrapper> values = createEqualsTestValues();
for (Wrapper w : values) {
ActorId a1 = (ActorId) w.item1;
ActorId a2 = (ActorId) w.item2;
Object a2 = w.item2;
Assert.assertEquals(w.expectedResult, a1.equals(a2));
}
}
Expand All @@ -65,6 +65,7 @@ private List<Wrapper> createEqualsTestValues() {
List<Wrapper> list = new ArrayList<Wrapper>();
list.add(new Wrapper(new ActorId("1"), null, false));
list.add(new Wrapper(new ActorId("1"), new ActorId("1"), true));
list.add(new Wrapper(new ActorId("1"), new Object(), false));
list.add(new Wrapper(new ActorId("1"), new ActorId("2"), false));

return list;
Expand Down
54 changes: 54 additions & 0 deletions sdk/src/test/java/io/dapr/actors/client/ActorProxyBuilderTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package io.dapr.actors.client;

import io.dapr.actors.ActorId;
import org.junit.Assert;
import org.junit.Test;

import static org.junit.Assert.*;

public class ActorProxyBuilderTest {

@Test(expected = IllegalArgumentException.class)
public void buildWithNullActorId() {
new ActorProxyBuilder()
.withActorId(null)
.withActorType("test")
.withPort(20)
.build();

}

@Test(expected = IllegalArgumentException.class)
public void buildWithEmptyActorType() {
new ActorProxyBuilder()
.withActorId(new ActorId("100"))
.withActorType("")
.withPort(20)
.build();

}

@Test(expected = IllegalArgumentException.class)
public void buildWithNullActorType() {
new ActorProxyBuilder()
.withActorId(new ActorId("100"))
.withActorType(null)
.withPort(20)
.build();

}

@Test()
public void build() {
ActorProxy actorProxy = new ActorProxyBuilder()
.withActorId(new ActorId("100"))
.withActorType("test")
.withPort(20)
.build();

Assert.assertNotNull(actorProxy);
Assert.assertEquals("test",actorProxy.getActorType());
Assert.assertEquals("100",actorProxy.getActorId().toString());

}
}
Loading