From 3b51b5b6c4c6da3d87bf496764fe9cd0730da37c Mon Sep 17 00:00:00 2001 From: kerr Date: Sat, 19 Dec 2020 06:41:16 +0800 Subject: [PATCH] Rename ActorProxy invoke to invokeMethod. (#420) Co-authored-by: Mukundan Sundararajan Co-authored-by: Artur Souza --- .../io/dapr/actors/client/ActorProxy.java | 12 +- .../io/dapr/actors/client/ActorProxyImpl.java | 28 ++-- .../actors/client/ActorProxyImplTest.java | 20 +-- .../runtime/ActorCustomSerializerTest.java | 6 +- .../dapr/actors/runtime/ActorNoStateTest.java | 12 +- .../actors/runtime/ActorStatefulTest.java | 122 +++++++++--------- .../dapr/actors/runtime/DerivedActorTest.java | 28 ++-- .../ThrowFromPreAndPostActorMethodsTest.java | 4 +- .../it/actors/ActorReminderFailoverIT.java | 8 +- .../it/actors/ActorReminderRecoveryIT.java | 4 +- .../java/io/dapr/it/actors/ActorStateIT.java | 30 ++--- .../dapr/it/actors/ActorTimerRecoveryIT.java | 4 +- .../actors/ActorTurnBasedConcurrencyIT.java | 14 +- .../io/dapr/it/actors/MyActorTestUtils.java | 2 +- 14 files changed, 147 insertions(+), 147 deletions(-) diff --git a/sdk-actors/src/main/java/io/dapr/actors/client/ActorProxy.java b/sdk-actors/src/main/java/io/dapr/actors/client/ActorProxy.java index 20d199e6d..d573a3185 100644 --- a/sdk-actors/src/main/java/io/dapr/actors/client/ActorProxy.java +++ b/sdk-actors/src/main/java/io/dapr/actors/client/ActorProxy.java @@ -36,7 +36,7 @@ public interface ActorProxy { * @param The type to be returned. * @return Asynchronous result with the Actor's response. */ - Mono invoke(String methodName, TypeRef type); + Mono invokeMethod(String methodName, TypeRef type); /** * Invokes an Actor method on Dapr. @@ -46,7 +46,7 @@ public interface ActorProxy { * @param The type to be returned. * @return Asynchronous result with the Actor's response. */ - Mono invoke(String methodName, Class clazz); + Mono invokeMethod(String methodName, Class clazz); /** * Invokes an Actor method on Dapr. @@ -57,7 +57,7 @@ public interface ActorProxy { * @param The type to be returned. * @return Asynchronous result with the Actor's response. */ - Mono invoke(String methodName, Object data, TypeRef type); + Mono invokeMethod(String methodName, Object data, TypeRef type); /** * Invokes an Actor method on Dapr. @@ -68,7 +68,7 @@ public interface ActorProxy { * @param The type to be returned. * @return Asynchronous result with the Actor's response. */ - Mono invoke(String methodName, Object data, Class clazz); + Mono invokeMethod(String methodName, Object data, Class clazz); /** * Invokes an Actor method on Dapr. @@ -76,7 +76,7 @@ public interface ActorProxy { * @param methodName Method name to invoke. * @return Asynchronous result with the Actor's response. */ - Mono invoke(String methodName); + Mono invokeMethod(String methodName); /** * Invokes an Actor method on Dapr. @@ -85,6 +85,6 @@ public interface ActorProxy { * @param data Object with the data. * @return Asynchronous result with the Actor's response. */ - Mono invoke(String methodName, Object data); + Mono invokeMethod(String methodName, Object data); } diff --git a/sdk-actors/src/main/java/io/dapr/actors/client/ActorProxyImpl.java b/sdk-actors/src/main/java/io/dapr/actors/client/ActorProxyImpl.java index 772d1353e..c8724412e 100644 --- a/sdk-actors/src/main/java/io/dapr/actors/client/ActorProxyImpl.java +++ b/sdk-actors/src/main/java/io/dapr/actors/client/ActorProxyImpl.java @@ -74,7 +74,7 @@ class ActorProxyImpl implements ActorProxy, InvocationHandler { * {@inheritDoc} */ @Override - public Mono invoke(String methodName, Object data, TypeRef type) { + public Mono invokeMethod(String methodName, Object data, TypeRef type) { return this.daprClient.invoke(actorType, actorId.toString(), methodName, this.serialize(data)) .filter(s -> s.length > 0) .map(s -> deserialize(s, type)); @@ -84,15 +84,15 @@ class ActorProxyImpl implements ActorProxy, InvocationHandler { * {@inheritDoc} */ @Override - public Mono invoke(String methodName, Object data, Class clazz) { - return this.invoke(methodName, data, TypeRef.get(clazz)); + public Mono invokeMethod(String methodName, Object data, Class clazz) { + return this.invokeMethod(methodName, data, TypeRef.get(clazz)); } /** * {@inheritDoc} */ @Override - public Mono invoke(String methodName, TypeRef type) { + public Mono invokeMethod(String methodName, TypeRef type) { return this.daprClient.invoke(actorType, actorId.toString(), methodName, null) .filter(s -> s.length > 0) .map(s -> deserialize(s, type)); @@ -102,15 +102,15 @@ class ActorProxyImpl implements ActorProxy, InvocationHandler { * {@inheritDoc} */ @Override - public Mono invoke(String methodName, Class clazz) { - return this.invoke(methodName, TypeRef.get(clazz)); + public Mono invokeMethod(String methodName, Class clazz) { + return this.invokeMethod(methodName, TypeRef.get(clazz)); } /** * {@inheritDoc} */ @Override - public Mono invoke(String methodName) { + public Mono invokeMethod(String methodName) { return this.daprClient.invoke(actorType, actorId.toString(), methodName, null).then(); } @@ -118,7 +118,7 @@ class ActorProxyImpl implements ActorProxy, InvocationHandler { * {@inheritDoc} */ @Override - public Mono invoke(String methodName, Object data) { + public Mono invokeMethod(String methodName, Object data) { return this.daprClient.invoke(actorType, actorId.toString(), methodName, this.serialize(data)).then(); } @@ -140,25 +140,25 @@ class ActorProxyImpl implements ActorProxy, InvocationHandler { if (method.getReturnType().equals(Mono.class)) { ActorMethod actorMethodAnnotation = method.getDeclaredAnnotation(ActorMethod.class); if (actorMethodAnnotation == null) { - return invoke(method.getName()); + return invokeMethod(method.getName()); } - return invoke(method.getName(), actorMethodAnnotation.returns()); + return invokeMethod(method.getName(), actorMethodAnnotation.returns()); } - return invoke(method.getName(), method.getReturnType()).block(); + return invokeMethod(method.getName(), method.getReturnType()).block(); } if (method.getReturnType().equals(Mono.class)) { ActorMethod actorMethodAnnotation = method.getDeclaredAnnotation(ActorMethod.class); if (actorMethodAnnotation == null) { - return invoke(method.getName(), args[0]); + return invokeMethod(method.getName(), args[0]); } - return invoke(method.getName(), args[0], actorMethodAnnotation.returns()); + return invokeMethod(method.getName(), args[0], actorMethodAnnotation.returns()); } - return invoke(method.getName(), args[0], method.getReturnType()).block(); + return invokeMethod(method.getName(), args[0], method.getReturnType()).block(); } /** diff --git a/sdk-actors/src/test/java/io/dapr/actors/client/ActorProxyImplTest.java b/sdk-actors/src/test/java/io/dapr/actors/client/ActorProxyImplTest.java index e772b3a4c..d6cf4ce09 100644 --- a/sdk-actors/src/test/java/io/dapr/actors/client/ActorProxyImplTest.java +++ b/sdk-actors/src/test/java/io/dapr/actors/client/ActorProxyImplTest.java @@ -49,7 +49,7 @@ public class ActorProxyImplTest { new DefaultObjectSerializer(), daprClient); - Mono result = actorProxy.invoke("getData", MyData.class); + Mono result = actorProxy.invokeMethod("getData", MyData.class); MyData myData = result.block(); Assert.assertNotNull(myData); Assert.assertEquals("valueA", myData.getPropertyA()); @@ -260,7 +260,7 @@ public class ActorProxyImplTest { new DefaultObjectSerializer(), daprClient); - Mono result = actorProxy.invoke("getData", MyData.class); + Mono result = actorProxy.invokeMethod("getData", MyData.class); MyData myData = result.block(); Assert.assertNull(myData); } @@ -277,7 +277,7 @@ public class ActorProxyImplTest { new DefaultObjectSerializer(), daprClient); - Mono result = actorProxy.invoke("getData", MyData.class); + Mono result = actorProxy.invokeMethod("getData", MyData.class); result.doOnSuccess(x -> Assert.fail("Not exception was throw")) @@ -302,7 +302,7 @@ public class ActorProxyImplTest { saveData.setPropertyA("valueA"); saveData.setPropertyB("valueB"); - Mono result = actorProxy.invoke("getData", saveData, MyData.class); + Mono result = actorProxy.invokeMethod("getData", saveData, MyData.class); MyData myData = result.block(); Assert.assertNotNull(myData); Assert.assertEquals("valueA", myData.getPropertyA()); @@ -326,7 +326,7 @@ public class ActorProxyImplTest { saveData.setPropertyA("valueA"); saveData.setPropertyB("valueB"); - Mono result = actorProxy.invoke("getData", saveData, MyData.class); + Mono result = actorProxy.invokeMethod("getData", saveData, MyData.class); result.doOnSuccess(x -> Assert.fail("Not exception was throw")) .doOnError(Throwable::printStackTrace @@ -350,7 +350,7 @@ public class ActorProxyImplTest { saveData.setPropertyA("valueA"); saveData.setPropertyB("valueB"); - Mono result = actorProxy.invoke("getData", saveData, MyData.class); + Mono result = actorProxy.invokeMethod("getData", saveData, MyData.class); MyData myData = result.block(); Assert.assertNull(myData); } @@ -373,7 +373,7 @@ public class ActorProxyImplTest { saveData.setPropertyB("valueB"); saveData.setMyData(saveData); - Mono result = actorProxy.invoke("getData", saveData, MyData.class); + Mono result = actorProxy.invokeMethod("getData", saveData, MyData.class); result.doOnSuccess(x -> Assert.fail("Not exception was throw")) .doOnError(Throwable::printStackTrace @@ -397,7 +397,7 @@ public class ActorProxyImplTest { new DefaultObjectSerializer(), daprClient); - Mono result = actorProxy.invoke("getData", saveData); + Mono result = actorProxy.invokeMethod("getData", saveData); Void emptyResponse = result.block(); Assert.assertNull(emptyResponse); } @@ -420,7 +420,7 @@ public class ActorProxyImplTest { new DefaultObjectSerializer(), daprClient); - Mono result = actorProxy.invoke("getData", saveData); + Mono result = actorProxy.invokeMethod("getData", saveData); Void emptyResponse = result.doOnError(Throwable::printStackTrace).block(); Assert.assertNull(emptyResponse); } @@ -437,7 +437,7 @@ public class ActorProxyImplTest { new DefaultObjectSerializer(), daprClient); - Mono result = actorProxy.invoke("getData"); + Mono result = actorProxy.invokeMethod("getData"); Void emptyResponse = result.block(); Assert.assertNull(emptyResponse); } diff --git a/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorCustomSerializerTest.java b/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorCustomSerializerTest.java index e96734e1d..2a5372359 100644 --- a/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorCustomSerializerTest.java +++ b/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorCustomSerializerTest.java @@ -98,7 +98,7 @@ public class ActorCustomSerializerTest { ActorProxy actorProxy = createActorProxy(); MyData d = new MyData("hi", 3); - MyData response = actorProxy.invoke("classInClassOut", d, MyData.class).block(); + MyData response = actorProxy.invokeMethod("classInClassOut", d, MyData.class).block(); Assert.assertEquals("hihi", response.getName()); Assert.assertEquals(6, response.getNum()); @@ -107,7 +107,7 @@ public class ActorCustomSerializerTest { @Test public void stringInStringOut() { ActorProxy actorProxy = createActorProxy(); - String response = actorProxy.invoke("stringInStringOut", "oi", String.class).block(); + String response = actorProxy.invokeMethod("stringInStringOut", "oi", String.class).block(); Assert.assertEquals("oioi", response); } @@ -115,7 +115,7 @@ public class ActorCustomSerializerTest { @Test public void intInIntOut() { ActorProxy actorProxy = createActorProxy(); - int response = actorProxy.invoke("intInIntOut", 2, int.class).block(); + int response = actorProxy.invokeMethod("intInIntOut", 2, int.class).block(); Assert.assertEquals(4, response); } diff --git a/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorNoStateTest.java b/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorNoStateTest.java index 75ec33f4b..1ed26a869 100644 --- a/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorNoStateTest.java +++ b/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorNoStateTest.java @@ -139,7 +139,7 @@ public class ActorNoStateTest { Assert.assertEquals( proxy.getActorId().toString(), - proxy.invoke("getMyId", String.class).block()); + proxy.invokeMethod("getMyId", String.class).block()); } @Test @@ -149,7 +149,7 @@ public class ActorNoStateTest { // these should only call the actor methods for ActorChild. The implementations in ActorParent will throw. Assert.assertEquals( "abcabc", - proxy.invoke("stringInStringOut", "abc", String.class).block()); + proxy.invokeMethod("stringInStringOut", "abc", String.class).block()); } @Test @@ -159,11 +159,11 @@ public class ActorNoStateTest { // these should only call the actor methods for ActorChild. The implementations in ActorParent will throw. Assert.assertEquals( false, - proxy.invoke("stringInBooleanOut", "hello world", Boolean.class).block()); + proxy.invokeMethod("stringInBooleanOut", "hello world", Boolean.class).block()); Assert.assertEquals( true, - proxy.invoke("stringInBooleanOut", "true", Boolean.class).block()); + proxy.invokeMethod("stringInBooleanOut", "true", Boolean.class).block()); } @Test(expected = IllegalMonitorStateException.class) @@ -171,7 +171,7 @@ public class ActorNoStateTest { ActorProxy actorProxy = createActorProxy(); // these should only call the actor methods for ActorChild. The implementations in ActorParent will throw. - actorProxy.invoke("stringInVoidOutIntentionallyThrows", "hello world").block(); + actorProxy.invokeMethod("stringInVoidOutIntentionallyThrows", "hello world").block(); } @Test @@ -180,7 +180,7 @@ public class ActorNoStateTest { MyData d = new MyData("hi", 3); // this should only call the actor methods for ActorChild. The implementations in ActorParent will throw. - MyData response = actorProxy.invoke("classInClassOut", d, MyData.class).block(); + MyData response = actorProxy.invokeMethod("classInClassOut", d, MyData.class).block(); Assert.assertEquals( "hihi", diff --git a/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorStatefulTest.java b/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorStatefulTest.java index 8ffb8583b..cd477a50c 100644 --- a/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorStatefulTest.java +++ b/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorStatefulTest.java @@ -289,33 +289,33 @@ public class ActorStatefulTest { public void happyGetSetDeleteContains() { ActorProxy proxy = newActorProxy(); Assert.assertEquals( - proxy.getActorId().toString(), proxy.invoke("getIdString", String.class).block()); - Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); + proxy.getActorId().toString(), proxy.invokeMethod("getIdString", String.class).block()); + Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block()); - proxy.invoke("setMessage", "hello world").block(); - Assert.assertTrue(proxy.invoke("hasMessage", Boolean.class).block()); + proxy.invokeMethod("setMessage", "hello world").block(); + Assert.assertTrue(proxy.invokeMethod("hasMessage", Boolean.class).block()); Assert.assertEquals( - "hello world", proxy.invoke("getMessage", String.class).block()); + "hello world", proxy.invokeMethod("getMessage", String.class).block()); Assert.assertEquals( executeSayMethod("hello world"), - proxy.invoke("setMessage", "hello world", String.class).block()); + proxy.invokeMethod("setMessage", "hello world", String.class).block()); - proxy.invoke("deleteMessage").block(); - Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); + proxy.invokeMethod("deleteMessage").block(); + Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block()); } @Test(expected = IllegalStateException.class) public void lazyGet() { ActorProxy proxy = newActorProxy(); - Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); - proxy.invoke("setMessage", "first message").block(); + Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block()); + proxy.invokeMethod("setMessage", "first message").block(); // Creates the mono plan but does not call it yet. - Mono getMessageCall = proxy.invoke("getMessage", String.class); + Mono getMessageCall = proxy.invokeMethod("getMessage", String.class); - proxy.invoke("deleteMessage").block(); + proxy.invokeMethod("deleteMessage").block(); // Call should fail because the message was deleted. getMessageCall.block(); @@ -324,96 +324,96 @@ public class ActorStatefulTest { @Test public void lazySet() { ActorProxy proxy = newActorProxy(); - Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); + Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block()); // Creates the mono plan but does not call it yet. - Mono setMessageCall = proxy.invoke("setMessage", "first message"); + Mono setMessageCall = proxy.invokeMethod("setMessage", "first message"); // No call executed yet, so message should not be set. - Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); + Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block()); setMessageCall.block(); // Now the message has been set. - Assert.assertTrue(proxy.invoke("hasMessage", Boolean.class).block()); + Assert.assertTrue(proxy.invokeMethod("hasMessage", Boolean.class).block()); } @Test public void lazyContains() { ActorProxy proxy = newActorProxy(); - Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); + Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block()); // Creates the mono plan but does not call it yet. - Mono hasMessageCall = proxy.invoke("hasMessage", Boolean.class); + Mono hasMessageCall = proxy.invokeMethod("hasMessage", Boolean.class); // Sets the message. - proxy.invoke("setMessage", "hello world").block(); + proxy.invokeMethod("setMessage", "hello world").block(); // Now we check if message is set. hasMessageCall.block(); // Now the message should be set. - Assert.assertTrue(proxy.invoke("hasMessage", Boolean.class).block()); + Assert.assertTrue(proxy.invokeMethod("hasMessage", Boolean.class).block()); } @Test public void lazyDelete() { ActorProxy proxy = newActorProxy(); - Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); + Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block()); - proxy.invoke("setMessage", "first message").block(); + proxy.invokeMethod("setMessage", "first message").block(); // Message is set. - Assert.assertTrue(proxy.invoke("hasMessage", Boolean.class).block()); + Assert.assertTrue(proxy.invokeMethod("hasMessage", Boolean.class).block()); // Created the mono plan but does not execute it yet. - Mono deleteMessageCall = proxy.invoke("deleteMessage"); + Mono deleteMessageCall = proxy.invokeMethod("deleteMessage"); // Message is still set. - Assert.assertTrue(proxy.invoke("hasMessage", Boolean.class).block()); + Assert.assertTrue(proxy.invokeMethod("hasMessage", Boolean.class).block()); deleteMessageCall.block(); // Now message is not set. - Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); + Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block()); } @Test public void lazyAdd() { ActorProxy proxy = newActorProxy(); - Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); + Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block()); - proxy.invoke("setMessage", "first message").block(); + proxy.invokeMethod("setMessage", "first message").block(); // Message is set. - Assert.assertTrue(proxy.invoke("hasMessage", Boolean.class).block()); + Assert.assertTrue(proxy.invokeMethod("hasMessage", Boolean.class).block()); // Created the mono plan but does not execute it yet. - Mono addMessageCall = proxy.invoke("addMessage", "second message"); + Mono addMessageCall = proxy.invokeMethod("addMessage", "second message"); // Message is still set. Assert.assertEquals("first message", - proxy.invoke("getMessage", String.class).block()); + proxy.invokeMethod("getMessage", String.class).block()); // Delete message - proxy.invoke("deleteMessage").block(); + proxy.invokeMethod("deleteMessage").block(); // Should work since previous message was deleted. addMessageCall.block(); // New message is still set. Assert.assertEquals("second message", - proxy.invoke("getMessage", String.class).block()); + proxy.invokeMethod("getMessage", String.class).block()); } @Test public void onActivateAndOnDeactivate() { ActorProxy proxy = newActorProxy(); - Assert.assertTrue(proxy.invoke("isActive", Boolean.class).block()); + Assert.assertTrue(proxy.invokeMethod("isActive", Boolean.class).block()); Assert.assertFalse(DEACTIVATED_ACTOR_IDS.contains(proxy.getActorId().toString())); - proxy.invoke("hasMessage", Boolean.class).block(); + proxy.invokeMethod("hasMessage", Boolean.class).block(); this.manager.deactivateActor(proxy.getActorId()).block(); @@ -424,15 +424,15 @@ public class ActorStatefulTest { public void onPreMethodAndOnPostMethod() { ActorProxy proxy = newActorProxy(); - proxy.invoke("hasMessage", Boolean.class).block(); + proxy.invokeMethod("hasMessage", Boolean.class).block(); MyMethodContext preContext = - proxy.invoke("getPreCallMethodContext", MyMethodContext.class).block(); + proxy.invokeMethod("getPreCallMethodContext", MyMethodContext.class).block(); Assert.assertEquals("hasMessage", preContext.getName()); Assert.assertEquals(ActorCallType.ACTOR_INTERFACE_METHOD.toString(), preContext.getType()); MyMethodContext postContext = - proxy.invoke("getPostCallMethodContext", MyMethodContext.class).block(); + proxy.invokeMethod("getPostCallMethodContext", MyMethodContext.class).block(); Assert.assertEquals("hasMessage", postContext.getName()); Assert.assertEquals(ActorCallType.ACTOR_INTERFACE_METHOD.toString(), postContext.getType()); } @@ -444,12 +444,12 @@ public class ActorStatefulTest { this.manager.invokeTimer(proxy.getActorId(), "mytimer", "{ \"callback\": \"hasMessage\" }".getBytes()).block(); MyMethodContext preContext = - proxy.invoke("getPreCallMethodContext", MyMethodContext.class).block(); + proxy.invokeMethod("getPreCallMethodContext", MyMethodContext.class).block(); Assert.assertEquals("mytimer", preContext.getName()); Assert.assertEquals(ActorCallType.TIMER_METHOD.toString(), preContext.getType()); MyMethodContext postContext = - proxy.invoke("getPostCallMethodContext", MyMethodContext.class).block(); + proxy.invokeMethod("getPostCallMethodContext", MyMethodContext.class).block(); Assert.assertEquals("mytimer", postContext.getName()); Assert.assertEquals(ActorCallType.TIMER_METHOD.toString(), postContext.getType()); } @@ -467,7 +467,7 @@ public class ActorStatefulTest { public void invokeTimerAfterUnregister() { ActorProxy proxy = newActorProxy(); - proxy.invoke("unregisterTimerAndReminder").block(); + proxy.invokeMethod("unregisterTimerAndReminder").block(); // This call succeeds because the SDK does not control register/unregister timer, the Dapr runtime does. this.manager.invokeTimer(proxy.getActorId(), "mytimer", "{ \"callback\": \"hasMessage\" }".getBytes()).block(); @@ -490,12 +490,12 @@ public class ActorStatefulTest { this.manager.invokeReminder(proxy.getActorId(), "myreminder", params).block(); MyMethodContext preContext = - proxy.invoke("getPreCallMethodContext", MyMethodContext.class).block(); + proxy.invokeMethod("getPreCallMethodContext", MyMethodContext.class).block(); Assert.assertEquals("myreminder", preContext.getName()); Assert.assertEquals(ActorCallType.REMINDER_METHOD.toString(), preContext.getType()); MyMethodContext postContext = - proxy.invoke("getPostCallMethodContext", MyMethodContext.class).block(); + proxy.invokeMethod("getPostCallMethodContext", MyMethodContext.class).block(); Assert.assertEquals("myreminder", postContext.getName()); Assert.assertEquals(ActorCallType.REMINDER_METHOD.toString(), postContext.getType()); } @@ -517,8 +517,8 @@ public class ActorStatefulTest { MyMethodContext expectedContext = new MyMethodContext().setName("MyName").setType("MyType"); - proxy.invoke("setMethodContext", expectedContext).block(); - MyMethodContext context = proxy.invoke("getMethodContext", MyMethodContext.class).block(); + proxy.invokeMethod("setMethodContext", expectedContext).block(); + MyMethodContext context = proxy.invokeMethod("getMethodContext", MyMethodContext.class).block(); Assert.assertEquals(expectedContext.getName(), context.getName()); Assert.assertEquals(expectedContext.getType(), context.getType()); @@ -528,8 +528,8 @@ public class ActorStatefulTest { public void intTypeRequestResponseInStateStore() { ActorProxy proxy = newActorProxy(); - Assert.assertEquals(1, (int)proxy.invoke("incrementAndGetCount", 1, int.class).block()); - Assert.assertEquals(6, (int)proxy.invoke("incrementAndGetCount", 5, int.class).block()); + Assert.assertEquals(1, (int)proxy.invokeMethod("incrementAndGetCount", 1, int.class).block()); + Assert.assertEquals(6, (int)proxy.invokeMethod("incrementAndGetCount", 5, int.class).block()); } @Test(expected = NumberFormatException.class) @@ -537,68 +537,68 @@ public class ActorStatefulTest { ActorProxy proxy = newActorProxy(); // Zero is a magic input that will make method throw an exception. - proxy.invoke("incrementAndGetCount", 0, int.class).block(); + proxy.invokeMethod("incrementAndGetCount", 0, int.class).block(); } @Test(expected = IllegalStateException.class) public void intTypeWithRuntimeException() { ActorProxy proxy = newActorProxy(); - proxy.invoke("getCountButThrowsException", int.class).block(); + proxy.invokeMethod("getCountButThrowsException", int.class).block(); } @Test(expected = IllegalStateException.class) public void actorRuntimeException() { ActorProxy proxy = newActorProxy(); - Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); + Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block()); - proxy.invoke("forceDuplicateException").block(); + proxy.invokeMethod("forceDuplicateException").block(); } @Test(expected = IllegalCharsetNameException.class) public void actorMethodException() { ActorProxy proxy = newActorProxy(); - Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); + Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block()); - proxy.invoke("throwsWithoutSaving").block(); + proxy.invokeMethod("throwsWithoutSaving").block(); - Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); + Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block()); } @Test public void rollbackChanges() { ActorProxy proxy = newActorProxy(); - Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); + Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block()); // Runs a method that will add one message but fail because tries to add a second one. - proxy.invoke("forceDuplicateException") + proxy.invokeMethod("forceDuplicateException") .onErrorResume(throwable -> Mono.empty()) .block(); // No message is set - Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); + Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block()); } @Test public void partialChanges() { ActorProxy proxy = newActorProxy(); - Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); + Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block()); // Runs a method that will add one message, commit but fail because tries to add a second one. - proxy.invoke("forcePartialChange") + proxy.invokeMethod("forcePartialChange") .onErrorResume(throwable -> Mono.empty()) .block(); // Message is set. - Assert.assertTrue(proxy.invoke("hasMessage", Boolean.class).block()); + Assert.assertTrue(proxy.invokeMethod("hasMessage", Boolean.class).block()); // It is first message and not the second due to a save() in the middle but an exception in the end. Assert.assertEquals("first message", - proxy.invoke("getMessage", String.class).block()); + proxy.invokeMethod("getMessage", String.class).block()); } private ActorProxy newActorProxy() { diff --git a/sdk-actors/src/test/java/io/dapr/actors/runtime/DerivedActorTest.java b/sdk-actors/src/test/java/io/dapr/actors/runtime/DerivedActorTest.java index d13532d05..09d377b31 100644 --- a/sdk-actors/src/test/java/io/dapr/actors/runtime/DerivedActorTest.java +++ b/sdk-actors/src/test/java/io/dapr/actors/runtime/DerivedActorTest.java @@ -223,7 +223,7 @@ public class DerivedActorTest { // these should only call the actor methods for ActorChild. The implementations in ActorParent will throw. Assert.assertEquals( "abcabc", - proxy.invoke("stringInStringOut", "abc", String.class).block()); + proxy.invokeMethod("stringInStringOut", "abc", String.class).block()); } @Test @@ -233,11 +233,11 @@ public class DerivedActorTest { // these should only call the actor methods for ActorChild. The implementations in ActorParent will throw. Assert.assertEquals( false, - proxy.invoke("stringInBooleanOut", "hello world", Boolean.class).block()); + proxy.invokeMethod("stringInBooleanOut", "hello world", Boolean.class).block()); Assert.assertEquals( true, - proxy.invoke("stringInBooleanOut", "true", Boolean.class).block()); + proxy.invokeMethod("stringInBooleanOut", "true", Boolean.class).block()); } @Test @@ -247,14 +247,14 @@ public class DerivedActorTest { // stringInVoidOut() has not been invoked so this is false Assert.assertEquals( false, - actorProxy.invoke("methodReturningVoidInvoked", Boolean.class).block()); + actorProxy.invokeMethod("methodReturningVoidInvoked", Boolean.class).block()); // these should only call the actor methods for ActorChild. The implementations in ActorParent will throw. - actorProxy.invoke("stringInVoidOut", "hello world").block(); + actorProxy.invokeMethod("stringInVoidOut", "hello world").block(); Assert.assertEquals( true, - actorProxy.invoke("methodReturningVoidInvoked", Boolean.class).block()); + actorProxy.invokeMethod("methodReturningVoidInvoked", Boolean.class).block()); } @Test(expected = IllegalMonitorStateException.class) @@ -262,7 +262,7 @@ public class DerivedActorTest { ActorProxy actorProxy = createActorProxyForActorChild(); // these should only call the actor methods for ActorChild. The implementations in ActorParent will throw. - actorProxy.invoke("stringInVoidOutIntentionallyThrows", "hello world").block(); + actorProxy.invokeMethod("stringInVoidOutIntentionallyThrows", "hello world").block(); } @Test @@ -271,7 +271,7 @@ public class DerivedActorTest { MyData d = new MyData("hi", 3); // this should only call the actor methods for ActorChild. The implementations in ActorParent will throw. - MyData response = actorProxy.invoke("classInClassOut", d, MyData.class).block(); + MyData response = actorProxy.invokeMethod("classInClassOut", d, MyData.class).block(); Assert.assertEquals( "hihi", @@ -288,26 +288,26 @@ public class DerivedActorTest { Assert.assertEquals( "www", - actorProxy.invoke("onlyImplementedInParentStringInStringOut", "w", String.class).block()); + actorProxy.invokeMethod("onlyImplementedInParentStringInStringOut", "w", String.class).block()); Assert.assertEquals( true, - actorProxy.invoke("onlyImplementedInParentStringInBooleanOut", "icecream", Boolean.class).block()); + actorProxy.invokeMethod("onlyImplementedInParentStringInBooleanOut", "icecream", Boolean.class).block()); // onlyImplementedInParentStringInVoidOut() has not been invoked so this is false Assert.assertEquals( false, - actorProxy.invoke("methodReturningVoidInvoked", Boolean.class).block()); + actorProxy.invokeMethod("methodReturningVoidInvoked", Boolean.class).block()); - actorProxy.invoke("onlyImplementedInParentStringInVoidOut", "icecream", Boolean.class).block(); + actorProxy.invokeMethod("onlyImplementedInParentStringInVoidOut", "icecream", Boolean.class).block(); // now it should return true. Assert.assertEquals( true, - actorProxy.invoke("methodReturningVoidInvoked", Boolean.class).block()); + actorProxy.invokeMethod("methodReturningVoidInvoked", Boolean.class).block()); MyData d = new MyData("hi", 3); - MyData response = actorProxy.invoke("onlyImplementedInParentClassInClassOut", d, MyData.class).block(); + MyData response = actorProxy.invokeMethod("onlyImplementedInParentClassInClassOut", d, MyData.class).block(); Assert.assertEquals( "hihihi", diff --git a/sdk-actors/src/test/java/io/dapr/actors/runtime/ThrowFromPreAndPostActorMethodsTest.java b/sdk-actors/src/test/java/io/dapr/actors/runtime/ThrowFromPreAndPostActorMethodsTest.java index 34260145f..dbd3c3c45 100644 --- a/sdk-actors/src/test/java/io/dapr/actors/runtime/ThrowFromPreAndPostActorMethodsTest.java +++ b/sdk-actors/src/test/java/io/dapr/actors/runtime/ThrowFromPreAndPostActorMethodsTest.java @@ -121,7 +121,7 @@ public class ThrowFromPreAndPostActorMethodsTest { // these should only call the actor methods for ActorChild. The implementations in ActorParent will throw. Assert.assertEquals( false, - proxy.invoke("stringInBooleanOut", "hello world", Boolean.class).block()); + proxy.invokeMethod("stringInBooleanOut", "hello world", Boolean.class).block()); } // IllegalMonitorStateException should be intentionally thrown. This type was chosen for this test just because @@ -133,7 +133,7 @@ public class ThrowFromPreAndPostActorMethodsTest { // these should only call the actor methods for ActorChild. The implementations in ActorParent will throw. Assert.assertEquals( true, - proxy.invoke("stringInBooleanOut", "true", Boolean.class).block()); + proxy.invokeMethod("stringInBooleanOut", "true", Boolean.class).block()); } private static ActorId newActorId() { diff --git a/sdk-tests/src/test/java/io/dapr/it/actors/ActorReminderFailoverIT.java b/sdk-tests/src/test/java/io/dapr/it/actors/ActorReminderFailoverIT.java index 65c37a430..8f10ba8c7 100644 --- a/sdk-tests/src/test/java/io/dapr/it/actors/ActorReminderFailoverIT.java +++ b/sdk-tests/src/test/java/io/dapr/it/actors/ActorReminderFailoverIT.java @@ -71,7 +71,7 @@ public class ActorReminderFailoverIT extends BaseIT { public void tearDown() { // call unregister logger.debug("Calling actor method 'stopReminder' to unregister reminder"); - proxy.invoke("stopReminder", "myReminder").block(); + proxy.invokeMethod("stopReminder", "myReminder").block(); } /** @@ -83,7 +83,7 @@ public class ActorReminderFailoverIT extends BaseIT { clientAppRun.use(); logger.debug("Invoking actor method 'startReminder' which will register a reminder"); - proxy.invoke("startReminder", "myReminder").block(); + proxy.invokeMethod("startReminder", "myReminder").block(); logger.debug("Pausing 7 seconds to allow reminder to fire"); Thread.sleep(7000); @@ -92,7 +92,7 @@ public class ActorReminderFailoverIT extends BaseIT { validateMethodCalls(logs, METHOD_NAME, 3); int originalActorHostIdentifier = Integer.parseInt( - proxy.invoke("getIdentifier", String.class).block()); + proxy.invokeMethod("getIdentifier", String.class).block()); if (originalActorHostIdentifier == firstAppRun.getHttpPort()) { firstAppRun.stop(); } @@ -110,7 +110,7 @@ public class ActorReminderFailoverIT extends BaseIT { validateMethodCalls(newLogs2, METHOD_NAME, countMethodCalls(newLogs, METHOD_NAME) + 4); int newActorHostIdentifier = Integer.parseInt( - proxy.invoke("getIdentifier", String.class).block()); + proxy.invokeMethod("getIdentifier", String.class).block()); assertNotEquals(originalActorHostIdentifier, newActorHostIdentifier); } diff --git a/sdk-tests/src/test/java/io/dapr/it/actors/ActorReminderRecoveryIT.java b/sdk-tests/src/test/java/io/dapr/it/actors/ActorReminderRecoveryIT.java index 8f862d5e1..fcca6e54a 100644 --- a/sdk-tests/src/test/java/io/dapr/it/actors/ActorReminderRecoveryIT.java +++ b/sdk-tests/src/test/java/io/dapr/it/actors/ActorReminderRecoveryIT.java @@ -59,7 +59,7 @@ public class ActorReminderRecoveryIT extends BaseIT { public void tearDown() { // call unregister logger.debug("Calling actor method 'stopReminder' to unregister reminder"); - proxy.invoke("stopReminder", "myReminder").block(); + proxy.invokeMethod("stopReminder", "myReminder").block(); } /** @@ -69,7 +69,7 @@ public class ActorReminderRecoveryIT extends BaseIT { @Test public void reminderRecoveryTest() throws Exception { logger.debug("Invoking actor method 'startReminder' which will register a reminder"); - proxy.invoke("startReminder", "myReminder").block(); + proxy.invokeMethod("startReminder", "myReminder").block(); logger.debug("Pausing 7 seconds to allow reminder to fire"); Thread.sleep(7000); diff --git a/sdk-tests/src/test/java/io/dapr/it/actors/ActorStateIT.java b/sdk-tests/src/test/java/io/dapr/it/actors/ActorStateIT.java index b2e6c0074..e827aba94 100644 --- a/sdk-tests/src/test/java/io/dapr/it/actors/ActorStateIT.java +++ b/sdk-tests/src/test/java/io/dapr/it/actors/ActorStateIT.java @@ -76,18 +76,18 @@ public class ActorStateIT extends BaseIT { // Validate conditional read works. callWithRetry(() -> { logger.debug("Invoking readMessage where data is not present yet ... "); - String result = proxy.invoke("readMessage", String.class).block(); + String result = proxy.invokeMethod("readMessage", String.class).block(); assertNull(result); }, 5000); callWithRetry(() -> { logger.debug("Invoking writeMessage ... "); - proxy.invoke("writeMessage", message).block(); + proxy.invokeMethod("writeMessage", message).block(); }, 5000); callWithRetry(() -> { logger.debug("Invoking readMessage where data is probably still cached ... "); - String result = proxy.invoke("readMessage", String.class).block(); + String result = proxy.invokeMethod("readMessage", String.class).block(); assertEquals(message, result); }, 5000); @@ -96,45 +96,45 @@ public class ActorStateIT extends BaseIT { mydata.value = "My data value."; callWithRetry(() -> { logger.debug("Invoking writeData with object ... "); - proxy.invoke("writeData", mydata).block(); + proxy.invokeMethod("writeData", mydata).block(); }, 5000); callWithRetry(() -> { logger.debug("Invoking readData where data is probably still cached ... "); - StatefulActor.MyData result = proxy.invoke("readData", StatefulActor.MyData.class).block(); + StatefulActor.MyData result = proxy.invokeMethod("readData", StatefulActor.MyData.class).block(); assertEquals(mydata.value, result.value); }, 5000); callWithRetry(() -> { logger.debug("Invoking writeName ... "); - proxy.invoke("writeName", name).block(); + proxy.invokeMethod("writeName", name).block(); }, 5000); callWithRetry(() -> { logger.debug("Invoking readName where data is probably still cached ... "); - String result = proxy.invoke("readName", String.class).block(); + String result = proxy.invokeMethod("readName", String.class).block(); assertEquals(name, result); }, 5000); callWithRetry(() -> { logger.debug("Invoking writeName with empty content... "); - proxy.invoke("writeName", "").block(); + proxy.invokeMethod("writeName", "").block(); }, 5000); callWithRetry(() -> { logger.debug("Invoking readName where empty content is probably still cached ... "); - String result = proxy.invoke("readName", String.class).block(); + String result = proxy.invokeMethod("readName", String.class).block(); assertEquals("", result); }, 5000); callWithRetry(() -> { logger.debug("Invoking writeBytes ... "); - proxy.invoke("writeBytes", bytes).block(); + proxy.invokeMethod("writeBytes", bytes).block(); }, 5000); callWithRetry(() -> { logger.debug("Invoking readBytes where data is probably still cached ... "); - byte[] result = proxy.invoke("readBytes", byte[].class).block(); + byte[] result = proxy.invokeMethod("readBytes", byte[].class).block(); assertArrayEquals(bytes, result); }, 5000); @@ -165,26 +165,26 @@ public class ActorStateIT extends BaseIT { callWithRetry(() -> { logger.debug("Invoking readMessage where data is not cached ... "); - String result = newProxy.invoke("readMessage", String.class).block(); + String result = newProxy.invokeMethod("readMessage", String.class).block(); assertEquals(message, result); }, 5000); callWithRetry(() -> { logger.debug("Invoking readData where data is not cached ... "); - StatefulActor.MyData result = newProxy.invoke("readData", StatefulActor.MyData.class).block(); + StatefulActor.MyData result = newProxy.invokeMethod("readData", StatefulActor.MyData.class).block(); assertEquals(mydata.value, result.value); }, 5000); logger.debug("Finished testing actor string state."); callWithRetry(() -> { logger.debug("Invoking readName where empty content is not cached ... "); - String result = newProxy.invoke("readName", String.class).block(); + String result = newProxy.invokeMethod("readName", String.class).block(); assertEquals("", result); }, 5000); callWithRetry(() -> { logger.debug("Invoking readBytes where content is not cached ... "); - byte[] result = newProxy.invoke("readBytes", byte[].class).block(); + byte[] result = newProxy.invokeMethod("readBytes", byte[].class).block(); assertArrayEquals(bytes, result); }, 5000); } diff --git a/sdk-tests/src/test/java/io/dapr/it/actors/ActorTimerRecoveryIT.java b/sdk-tests/src/test/java/io/dapr/it/actors/ActorTimerRecoveryIT.java index 245d8785e..0de929280 100644 --- a/sdk-tests/src/test/java/io/dapr/it/actors/ActorTimerRecoveryIT.java +++ b/sdk-tests/src/test/java/io/dapr/it/actors/ActorTimerRecoveryIT.java @@ -54,7 +54,7 @@ public class ActorTimerRecoveryIT extends BaseIT { ActorProxy proxy = proxyBuilder.build(actorId); logger.debug("Invoking actor method 'startTimer' which will register a timer"); - proxy.invoke("startTimer", "myTimer").block(); + proxy.invokeMethod("startTimer", "myTimer").block(); logger.debug("Pausing 7 seconds to allow timer to fire"); Thread.sleep(7000); @@ -80,7 +80,7 @@ public class ActorTimerRecoveryIT extends BaseIT { // call unregister logger.debug("Calling actor method 'stopTimer' to unregister timer"); - proxy.invoke("stopTimer", "myTimer").block(); + proxy.invokeMethod("stopTimer", "myTimer").block(); } } diff --git a/sdk-tests/src/test/java/io/dapr/it/actors/ActorTurnBasedConcurrencyIT.java b/sdk-tests/src/test/java/io/dapr/it/actors/ActorTurnBasedConcurrencyIT.java index 1cf0e74ad..9597605e2 100644 --- a/sdk-tests/src/test/java/io/dapr/it/actors/ActorTurnBasedConcurrencyIT.java +++ b/sdk-tests/src/test/java/io/dapr/it/actors/ActorTurnBasedConcurrencyIT.java @@ -89,13 +89,13 @@ public class ActorTurnBasedConcurrencyIT extends BaseIT { logger.debug("Invoking Say from Proxy"); callWithRetry(() -> { logger.debug("Invoking Say from Proxy"); - String sayResponse = proxy.invoke("say", "message", String.class).block(); + String sayResponse = proxy.invokeMethod("say", "message", String.class).block(); logger.debug("asserting not null response: [" + sayResponse + "]"); assertNotNull(sayResponse); }, 60000); logger.debug("Invoking actor method 'startTimer' which will register a timer"); - proxy.invoke("startTimer", "myTimer").block(); + proxy.invokeMethod("startTimer", "myTimer").block(); // invoke a bunch of calls in parallel to validate turn-based concurrency logger.debug("Invoking an actor method 'say' in parallel"); @@ -108,12 +108,12 @@ public class ActorTurnBasedConcurrencyIT extends BaseIT { // the actor method called below should reverse the input String msg = "message" + i; String reversedString = new StringBuilder(msg).reverse().toString(); - String output = proxy.invoke("say", "message" + i, String.class).block(); + String output = proxy.invokeMethod("say", "message" + i, String.class).block(); assertTrue(reversedString.equals(output)); }); logger.debug("Calling method to register reminder named " + REMINDER_NAME); - proxy.invoke("startReminder", REMINDER_NAME).block(); + proxy.invokeMethod("startReminder", REMINDER_NAME).block(); logger.debug("Pausing 7 seconds to allow timer and reminders to fire"); Thread.sleep(7000); @@ -126,14 +126,14 @@ public class ActorTurnBasedConcurrencyIT extends BaseIT { // call unregister logger.debug("Calling actor method 'stopTimer' to unregister timer"); - proxy.invoke("stopTimer", "myTimer").block(); + proxy.invokeMethod("stopTimer", "myTimer").block(); logger.debug("Calling actor method 'stopReminder' to unregister reminder"); - proxy.invoke("stopReminder", REMINDER_NAME).block(); + proxy.invokeMethod("stopReminder", REMINDER_NAME).block(); // make some more actor method calls and sleep a bit to see if the timer fires (it should not) sayMessages.parallelStream().forEach( i -> { - proxy.invoke("say", "message" + i, String.class).block(); + proxy.invokeMethod("say", "message" + i, String.class).block(); }); logger.debug("Pausing 5 seconds to allow time for timer and reminders to fire if there is a bug. They should not since we have unregistered them."); diff --git a/sdk-tests/src/test/java/io/dapr/it/actors/MyActorTestUtils.java b/sdk-tests/src/test/java/io/dapr/it/actors/MyActorTestUtils.java index bac5ba9f3..a95fa4a51 100644 --- a/sdk-tests/src/test/java/io/dapr/it/actors/MyActorTestUtils.java +++ b/sdk-tests/src/test/java/io/dapr/it/actors/MyActorTestUtils.java @@ -54,7 +54,7 @@ public class MyActorTestUtils { * @return List of call log. */ static List fetchMethodCallLogs(ActorProxy proxy) { - ArrayList logs = proxy.invoke("getCallLog", ArrayList.class).block(); + ArrayList logs = proxy.invokeMethod("getCallLog", ArrayList.class).block(); ArrayList trackers = new ArrayList(); for(String t : logs) { String[] toks = t.split("\\|");