From 0b649fac1332b55d772c1a736b6fff369b9702af Mon Sep 17 00:00:00 2001 From: Arghya Sadhu Date: Fri, 11 Dec 2020 13:40:51 +0530 Subject: [PATCH] Rename methods and parameters for consistency across SDKs Signed-off-by: Arghya Sadhu --- .../invoke/grpc/HelloWorldClient.java | 2 +- .../io/dapr/examples/invoke/grpc/README.md | 4 +- .../examples/invoke/http/InvokeClient.java | 2 +- .../io/dapr/examples/invoke/http/README.md | 4 +- .../java/io/dapr/examples/state/README.md | 10 +- .../io/dapr/examples/state/StateClient.java | 8 +- .../dapr/examples/tracing/InvokeClient.java | 4 +- .../java/io/dapr/examples/tracing/README.md | 4 +- .../io/dapr/actors/client/ActorProxy.java | 12 +- .../io/dapr/actors/client/ActorProxyImpl.java | 36 ++-- .../io/dapr/actors/client/DaprClient.java | 2 +- .../io/dapr/actors/client/DaprGrpcClient.java | 2 +- .../io/dapr/actors/client/DaprHttpClient.java | 2 +- .../io/dapr/actors/runtime/AbstractActor.java | 8 +- .../io/dapr/actors/runtime/DaprClient.java | 12 +- .../dapr/actors/runtime/DaprGrpcClient.java | 12 +- .../dapr/actors/runtime/DaprHttpClient.java | 12 +- .../runtime/DaprStateAsyncProvider.java | 6 +- .../actors/client/ActorProxyImplTest.java | 56 +++--- .../io/dapr/actors/client/DaprClientStub.java | 2 +- .../actors/client/DaprGrpcClientTest.java | 8 +- .../actors/client/DaprHttpClientTest.java | 4 +- .../runtime/ActorCustomSerializerTest.java | 16 +- .../dapr/actors/runtime/ActorManagerTest.java | 8 +- .../dapr/actors/runtime/ActorNoStateTest.java | 24 +-- .../actors/runtime/ActorStatefulTest.java | 132 +++++++------- .../actors/runtime/DaprGrpcClientTest.java | 20 +-- .../actors/runtime/DaprHttpClientTest.java | 12 +- .../runtime/DaprStateAsyncProviderTest.java | 42 ++--- .../dapr/actors/runtime/DerivedActorTest.java | 38 ++-- .../ThrowFromPreAndPostActorMethodsTest.java | 14 +- .../actors/runtime/DaprClientHttpUtils.java | 2 +- .../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 +- .../io/dapr/it/binding/http/BindingIT.java | 2 +- .../it/methodinvoke/http/MethodInvokeIT.java | 24 +-- .../java/io/dapr/it/pubsub/http/PubSubIT.java | 4 +- .../dapr/it/state/AbstractStateClientIT.java | 10 +- .../io/dapr/it/state/GRPCStateClientIT.java | 2 +- .../io/dapr/it/state/HttpStateClientIT.java | 2 +- .../io/dapr/client/AbstractDaprClient.java | 169 +++++++++--------- .../main/java/io/dapr/client/DaprClient.java | 169 +++++++++--------- .../java/io/dapr/client/DaprClientGrpc.java | 18 +- .../java/io/dapr/client/DaprClientHttp.java | 18 +- ...sRequest.java => GetBulkStateRequest.java} | 112 ++++++------ ...r.java => GetBulkStateRequestBuilder.java} | 120 ++++++------- .../dapr/client/domain/GetSecretRequest.java | 10 +- .../domain/GetSecretRequestBuilder.java | 8 +- .../dapr/client/domain/GetStateRequest.java | 10 +- .../client/domain/GetStateRequestBuilder.java | 8 +- .../dapr/client/domain/SaveStateRequest.java | 10 +- .../domain/SaveStateRequestBuilder.java | 8 +- .../io/dapr/client/DaprClientGrpcTest.java | 98 +++++----- .../io/dapr/client/DaprClientHttpTest.java | 95 +++++----- .../java/io/dapr/runtime/DaprRuntimeTest.java | 2 +- 59 files changed, 741 insertions(+), 740 deletions(-) rename sdk/src/main/java/io/dapr/client/domain/{GetStatesRequest.java => GetBulkStateRequest.java} (72%) rename sdk/src/main/java/io/dapr/client/domain/{GetStatesRequestBuilder.java => GetBulkStateRequestBuilder.java} (57%) diff --git a/examples/src/main/java/io/dapr/examples/invoke/grpc/HelloWorldClient.java b/examples/src/main/java/io/dapr/examples/invoke/grpc/HelloWorldClient.java index 1a7c6a3e0b..e167274d0a 100644 --- a/examples/src/main/java/io/dapr/examples/invoke/grpc/HelloWorldClient.java +++ b/examples/src/main/java/io/dapr/examples/invoke/grpc/HelloWorldClient.java @@ -33,7 +33,7 @@ public static void main(String[] args) throws Exception { while (true) { String message = "Message #" + (count++); System.out.println("Sending message: " + message); - client.invokeService(serviceAppId, method, message, HttpExtension.NONE).block(); + client.invokeMethod(serviceAppId, method, message, HttpExtension.NONE).block(); System.out.println("Message sent: " + message); Thread.sleep(1000); diff --git a/examples/src/main/java/io/dapr/examples/invoke/grpc/README.md b/examples/src/main/java/io/dapr/examples/invoke/grpc/README.md index c86ce3de34..de4deccf35 100644 --- a/examples/src/main/java/io/dapr/examples/invoke/grpc/README.md +++ b/examples/src/main/java/io/dapr/examples/invoke/grpc/README.md @@ -96,7 +96,7 @@ private static class HelloWorldClient { while (true) { String message = "Message #" + (count++); System.out.println("Sending message: " + message); - client.invokeService(serviceAppId, method, message, HttpExtension.NONE).block(); + client.invokeMethod(serviceAppId, method, message, HttpExtension.NONE).block(); System.out.println("Message sent: " + message); Thread.sleep(1000); @@ -113,7 +113,7 @@ private static class HelloWorldClient { First, it creates an instance of `DaprClient` via `DaprClientBuilder`. The protocol used by DaprClient is transparent to the application. The HTTP and GRPC ports used by Dapr's sidecar are automatically chosen and exported as environment variables: `DAPR_HTTP_PORT` and `DAPR_GRPC_PORT`. Dapr's Java SDK references these environment variables when communicating to Dapr's sidecar. The Dapr client is also within a try-with-resource block to properly close the client at the end. -Finally, it will go through in an infinite loop and invoke the `say` method every second. Notice the use of `block()` on the return from `invokeService` - it is required to actually make the service invocation via a [Mono](https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html) object. +Finally, it will go through in an infinite loop and invoke the `say` method every second. Notice the use of `block()` on the return from `invokeMethod` - it is required to actually make the service invocation via a [Mono](https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html) object. Finally, open a new command line terminal and run the client code to send some messages. diff --git a/examples/src/main/java/io/dapr/examples/invoke/http/InvokeClient.java b/examples/src/main/java/io/dapr/examples/invoke/http/InvokeClient.java index 7965506562..1359e6acb0 100644 --- a/examples/src/main/java/io/dapr/examples/invoke/http/InvokeClient.java +++ b/examples/src/main/java/io/dapr/examples/invoke/http/InvokeClient.java @@ -32,7 +32,7 @@ public class InvokeClient { public static void main(String[] args) throws Exception { try (DaprClient client = (new DaprClientBuilder()).build()) { for (String message : args) { - byte[] response = client.invokeService(SERVICE_APP_ID, "say", message, HttpExtension.POST, null, + byte[] response = client.invokeMethod(SERVICE_APP_ID, "say", message, HttpExtension.POST, null, byte[].class).block(); System.out.println(new String(response)); } diff --git a/examples/src/main/java/io/dapr/examples/invoke/http/README.md b/examples/src/main/java/io/dapr/examples/invoke/http/README.md index 9434733d67..2fb26e65c7 100644 --- a/examples/src/main/java/io/dapr/examples/invoke/http/README.md +++ b/examples/src/main/java/io/dapr/examples/invoke/http/README.md @@ -113,7 +113,7 @@ private static final String SERVICE_APP_ID = "invokedemo"; public static void main(String[] args) throws Exception { try (DaprClient client = (new DaprClientBuilder()).build()) { for (String message : args) { - byte[] response = client.invokeService(SERVICE_APP_ID, "say", message, HttpExtension.POST, null, + byte[] response = client.invokeMethod(SERVICE_APP_ID, "say", message, HttpExtension.POST, null, byte[].class).block(); System.out.println(new String(response)); } @@ -127,7 +127,7 @@ public static void main(String[] args) throws Exception { } ``` -The class knows the app id for the remote application. It uses the the static `Dapr.getInstance().invokeService` method to invoke the remote method defining the parameters: The verb, application id, method name, and proper data and metadata, as well as the type of the expected return type. The returned payload for this method invocation is plain text and not a [JSON String](https://www.w3schools.com/js/js_json_datatypes.asp), so we expect `byte[]` to get the raw response and not try to deserialize it. +The class knows the app id for the remote application. It uses the the static `Dapr.getInstance().invokeMethod` method to invoke the remote method defining the parameters: The verb, application id, method name, and proper data and metadata, as well as the type of the expected return type. The returned payload for this method invocation is plain text and not a [JSON String](https://www.w3schools.com/js/js_json_datatypes.asp), so we expect `byte[]` to get the raw response and not try to deserialize it. Execute the follow script in order to run the InvokeClient example, passing two messages for the remote method: ```sh diff --git a/examples/src/main/java/io/dapr/examples/state/README.md b/examples/src/main/java/io/dapr/examples/state/README.md index 9cba5a35b4..73fed828f7 100644 --- a/examples/src/main/java/io/dapr/examples/state/README.md +++ b/examples/src/main/java/io/dapr/examples/state/README.md @@ -67,7 +67,7 @@ public class StateClient { operationList.add(new TransactionalStateOperation<>(TransactionalStateOperation.OperationType.UPSERT, new State<>(secondState, SECOND_KEY_NAME, ""))); - client.executeTransaction(STATE_STORE_NAME, operationList).block(); + client.executeStateTransaction(STATE_STORE_NAME, operationList).block(); // get multiple states Mono>> retrievedMessagesMono = client.getStates(STATE_STORE_NAME, @@ -85,7 +85,7 @@ public class StateClient { operationList.clear(); operationList.add(new TransactionalStateOperation<>(TransactionalStateOperation.OperationType.DELETE, new State<>(SECOND_KEY_NAME))); - mono = client.executeTransaction(STATE_STORE_NAME, operationList); + mono = client.executeStateTransaction(STATE_STORE_NAME, operationList); mono.block(); Mono>> retrievedDeletedMessageMono = client.getStates(STATE_STORE_NAME, @@ -105,10 +105,10 @@ The code uses the `DaprClient` created by the `DaprClientBuilder`. Notice that t This example performs multiple operations: * `client.saveState(...)` for persisting an instance of `MyClass`. * `client.getState(...)` operation in order to retrieve back the persisted state using the same key. -* `client.executeTransaction(...)` operation in order to update existing state and add new state. -* `client.getStates(...)` operation in order to retrieve back the persisted states using the same keys. +* `client.executeStateTransaction(...)` operation in order to update existing state and add new state. +* `client.getBulkState(...)` operation in order to retrieve back the persisted states using the same keys. * `client.deleteState(...)` operation to remove one of the persisted states. -* `client.executeTransaction(...)` operation in order to remove the other persisted state. +* `client.executeStateTransaction(...)` operation in order to remove the other persisted state. Finally, the code tries to retrieve the deleted states, which should not be found. diff --git a/examples/src/main/java/io/dapr/examples/state/StateClient.java b/examples/src/main/java/io/dapr/examples/state/StateClient.java index ad8535bbb7..db859821cf 100644 --- a/examples/src/main/java/io/dapr/examples/state/StateClient.java +++ b/examples/src/main/java/io/dapr/examples/state/StateClient.java @@ -70,10 +70,10 @@ public static void main(String[] args) throws Exception { operationList.add(new TransactionalStateOperation<>(TransactionalStateOperation.OperationType.UPSERT, new State<>(secondState, SECOND_KEY_NAME, ""))); - client.executeTransaction(STATE_STORE_NAME, operationList).block(); + client.executeStateTransaction(STATE_STORE_NAME, operationList).block(); // get multiple states - Mono>> retrievedMessagesMono = client.getStates(STATE_STORE_NAME, + Mono>> retrievedMessagesMono = client.getBulkState(STATE_STORE_NAME, Arrays.asList(FIRST_KEY_NAME, SECOND_KEY_NAME), MyClass.class); System.out.println("Retrieved messages using bulk get:"); retrievedMessagesMono.block().forEach(System.out::println); @@ -88,10 +88,10 @@ public static void main(String[] args) throws Exception { operationList.clear(); operationList.add(new TransactionalStateOperation<>(TransactionalStateOperation.OperationType.DELETE, new State<>(SECOND_KEY_NAME))); - mono = client.executeTransaction(STATE_STORE_NAME, operationList); + mono = client.executeStateTransaction(STATE_STORE_NAME, operationList); mono.block(); - Mono>> retrievedDeletedMessageMono = client.getStates(STATE_STORE_NAME, + Mono>> retrievedDeletedMessageMono = client.getBulkState(STATE_STORE_NAME, Arrays.asList(FIRST_KEY_NAME, SECOND_KEY_NAME), MyClass.class); System.out.println("Trying to retrieve deleted states: "); retrievedDeletedMessageMono.block().forEach(System.out::println); diff --git a/examples/src/main/java/io/dapr/examples/tracing/InvokeClient.java b/examples/src/main/java/io/dapr/examples/tracing/InvokeClient.java index 3deaa16dee..3f718e0b69 100644 --- a/examples/src/main/java/io/dapr/examples/tracing/InvokeClient.java +++ b/examples/src/main/java/io/dapr/examples/tracing/InvokeClient.java @@ -48,7 +48,7 @@ public static void main(String[] args) throws Exception { InvokeServiceRequestBuilder builder = new InvokeServiceRequestBuilder(SERVICE_APP_ID, "echo"); InvokeServiceRequest request = builder.withBody(message).withHttpExtension(HttpExtension.POST).withContext(Context.current()).build(); - client.invokeService(request, TypeRef.get(byte[].class)) + client.invokeMethod(request, TypeRef.get(byte[].class)) .map(r -> { System.out.println(new String(r.getObject())); return r; @@ -57,7 +57,7 @@ public static void main(String[] args) throws Exception { InvokeServiceRequest sleepRequest = new InvokeServiceRequestBuilder(SERVICE_APP_ID, "sleep") .withHttpExtension(HttpExtension.POST) .withContext(r.getContext()).build(); - return client.invokeService(sleepRequest, TypeRef.get(Void.class)); + return client.invokeMethod(sleepRequest, TypeRef.get(Void.class)); }).block(); } } diff --git a/examples/src/main/java/io/dapr/examples/tracing/README.md b/examples/src/main/java/io/dapr/examples/tracing/README.md index f473d714fe..0f40859928 100644 --- a/examples/src/main/java/io/dapr/examples/tracing/README.md +++ b/examples/src/main/java/io/dapr/examples/tracing/README.md @@ -159,7 +159,7 @@ private static final String SERVICE_APP_ID = "invokedemo"; InvokeServiceRequest sleepRequest = new InvokeServiceRequestBuilder(SERVICE_APP_ID, "sleep") .withHttpExtension(HttpExtension.POST) .withContext(r.getContext()).build(); - return client.invokeService(sleepRequest, TypeRef.get(Void.class)); + return client.invokeMethod(sleepRequest, TypeRef.get(Void.class)); }).block(); } } @@ -175,7 +175,7 @@ private static final String SERVICE_APP_ID = "invokedemo"; } ``` -The class knows the app id for the remote application. It uses `invokeService` method to invoke API calls on the service endpoint. The request object includes an instance of `io.opentelemetry.context.Context` for the proper tracing headers to be propagated. +The class knows the app id for the remote application. It uses `invokeMethod` method to invoke API calls on the service endpoint. The request object includes an instance of `io.opentelemetry.context.Context` for the proper tracing headers to be propagated. Execute the follow script in order to run the InvokeClient example, passing two messages for the remote method: ```sh 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 c76b08bfc0..20d199e6d5 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 invokeActorMethod(String methodName, TypeRef type); + Mono invoke(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 invokeActorMethod(String methodName, Class clazz); + Mono invoke(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 invokeActorMethod(String methodName, Object data, TypeRef type); + Mono invoke(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 invokeActorMethod(String methodName, Object data, Class clazz); + Mono invoke(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 invokeActorMethod(String methodName); + Mono invoke(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 invokeActorMethod(String methodName, Object data); + Mono invoke(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 d26e50754f..772d1353e5 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,8 +74,8 @@ public String getActorType() { * {@inheritDoc} */ @Override - public Mono invokeActorMethod(String methodName, Object data, TypeRef type) { - return this.daprClient.invokeActorMethod(actorType, actorId.toString(), methodName, this.serialize(data)) + public Mono invoke(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,16 +84,16 @@ public Mono invokeActorMethod(String methodName, Object data, TypeRef * {@inheritDoc} */ @Override - public Mono invokeActorMethod(String methodName, Object data, Class clazz) { - return this.invokeActorMethod(methodName, data, TypeRef.get(clazz)); + public Mono invoke(String methodName, Object data, Class clazz) { + return this.invoke(methodName, data, TypeRef.get(clazz)); } /** * {@inheritDoc} */ @Override - public Mono invokeActorMethod(String methodName, TypeRef type) { - return this.daprClient.invokeActorMethod(actorType, actorId.toString(), methodName, null) + public Mono invoke(String methodName, TypeRef type) { + return this.daprClient.invoke(actorType, actorId.toString(), methodName, null) .filter(s -> s.length > 0) .map(s -> deserialize(s, type)); } @@ -102,24 +102,24 @@ public Mono invokeActorMethod(String methodName, TypeRef type) { * {@inheritDoc} */ @Override - public Mono invokeActorMethod(String methodName, Class clazz) { - return this.invokeActorMethod(methodName, TypeRef.get(clazz)); + public Mono invoke(String methodName, Class clazz) { + return this.invoke(methodName, TypeRef.get(clazz)); } /** * {@inheritDoc} */ @Override - public Mono invokeActorMethod(String methodName) { - return this.daprClient.invokeActorMethod(actorType, actorId.toString(), methodName, null).then(); + public Mono invoke(String methodName) { + return this.daprClient.invoke(actorType, actorId.toString(), methodName, null).then(); } /** * {@inheritDoc} */ @Override - public Mono invokeActorMethod(String methodName, Object data) { - return this.daprClient.invokeActorMethod(actorType, actorId.toString(), methodName, this.serialize(data)).then(); + public Mono invoke(String methodName, Object data) { + return this.daprClient.invoke(actorType, actorId.toString(), methodName, this.serialize(data)).then(); } /** @@ -140,25 +140,25 @@ public Object invoke(Object proxy, Method method, Object[] args) { if (method.getReturnType().equals(Mono.class)) { ActorMethod actorMethodAnnotation = method.getDeclaredAnnotation(ActorMethod.class); if (actorMethodAnnotation == null) { - return invokeActorMethod(method.getName()); + return invoke(method.getName()); } - return invokeActorMethod(method.getName(), actorMethodAnnotation.returns()); + return invoke(method.getName(), actorMethodAnnotation.returns()); } - return invokeActorMethod(method.getName(), method.getReturnType()).block(); + return invoke(method.getName(), method.getReturnType()).block(); } if (method.getReturnType().equals(Mono.class)) { ActorMethod actorMethodAnnotation = method.getDeclaredAnnotation(ActorMethod.class); if (actorMethodAnnotation == null) { - return invokeActorMethod(method.getName(), args[0]); + return invoke(method.getName(), args[0]); } - return invokeActorMethod(method.getName(), args[0], actorMethodAnnotation.returns()); + return invoke(method.getName(), args[0], actorMethodAnnotation.returns()); } - return invokeActorMethod(method.getName(), args[0], method.getReturnType()).block(); + return invoke(method.getName(), args[0], method.getReturnType()).block(); } /** diff --git a/sdk-actors/src/main/java/io/dapr/actors/client/DaprClient.java b/sdk-actors/src/main/java/io/dapr/actors/client/DaprClient.java index 5871f4cdc0..5d803420f9 100644 --- a/sdk-actors/src/main/java/io/dapr/actors/client/DaprClient.java +++ b/sdk-actors/src/main/java/io/dapr/actors/client/DaprClient.java @@ -21,6 +21,6 @@ interface DaprClient { * @param jsonPayload Serialized body. * @return Asynchronous result with the Actor's response. */ - Mono invokeActorMethod(String actorType, String actorId, String methodName, byte[] jsonPayload); + Mono invoke(String actorType, String actorId, String methodName, byte[] jsonPayload); } diff --git a/sdk-actors/src/main/java/io/dapr/actors/client/DaprGrpcClient.java b/sdk-actors/src/main/java/io/dapr/actors/client/DaprGrpcClient.java index 3b64b1a80b..499068d96a 100644 --- a/sdk-actors/src/main/java/io/dapr/actors/client/DaprGrpcClient.java +++ b/sdk-actors/src/main/java/io/dapr/actors/client/DaprGrpcClient.java @@ -40,7 +40,7 @@ class DaprGrpcClient implements DaprClient { * {@inheritDoc} */ @Override - public Mono invokeActorMethod(String actorType, String actorId, String methodName, byte[] jsonPayload) { + public Mono invoke(String actorType, String actorId, String methodName, byte[] jsonPayload) { return Mono.fromCallable(DaprException.wrap(() -> { DaprProtos.InvokeActorRequest req = DaprProtos.InvokeActorRequest.newBuilder() diff --git a/sdk-actors/src/main/java/io/dapr/actors/client/DaprHttpClient.java b/sdk-actors/src/main/java/io/dapr/actors/client/DaprHttpClient.java index a12270beda..6fd2fdd89e 100644 --- a/sdk-actors/src/main/java/io/dapr/actors/client/DaprHttpClient.java +++ b/sdk-actors/src/main/java/io/dapr/actors/client/DaprHttpClient.java @@ -45,7 +45,7 @@ class DaprHttpClient implements DaprClient { * {@inheritDoc} */ @Override - public Mono invokeActorMethod(String actorType, String actorId, String methodName, byte[] jsonPayload) { + public Mono invoke(String actorType, String actorId, String methodName, byte[] jsonPayload) { String url = String.format(ACTOR_METHOD_RELATIVE_URL_FORMAT, actorType, actorId, methodName); Mono responseMono = this.client.invokeApi(DaprHttp.HttpMethods.POST.name(), url, null, jsonPayload, null, null); diff --git a/sdk-actors/src/main/java/io/dapr/actors/runtime/AbstractActor.java b/sdk-actors/src/main/java/io/dapr/actors/runtime/AbstractActor.java index 540b8cfe46..3d72aafc41 100644 --- a/sdk-actors/src/main/java/io/dapr/actors/runtime/AbstractActor.java +++ b/sdk-actors/src/main/java/io/dapr/actors/runtime/AbstractActor.java @@ -114,7 +114,7 @@ protected Mono registerReminder( try { byte[] data = this.actorRuntimeContext.getObjectSerializer().serialize(state); ActorReminderParams params = new ActorReminderParams(data, dueTime, period); - return this.actorRuntimeContext.getDaprClient().registerActorReminder( + return this.actorRuntimeContext.getDaprClient().registerReminder( this.actorRuntimeContext.getActorTypeInformation().getName(), this.id.toString(), reminderName, @@ -157,7 +157,7 @@ protected Mono registerActorTimer( byte[] data = this.actorRuntimeContext.getObjectSerializer().serialize(state); ActorTimerParams actorTimer = new ActorTimerParams(callback, data, dueTime, period); - return this.actorRuntimeContext.getDaprClient().registerActorTimer( + return this.actorRuntimeContext.getDaprClient().registerTimer( this.actorRuntimeContext.getActorTypeInformation().getName(), this.id.toString(), name, @@ -174,7 +174,7 @@ protected Mono registerActorTimer( * @return Asynchronous void response. */ protected Mono unregisterTimer(String timerName) { - return this.actorRuntimeContext.getDaprClient().unregisterActorTimer( + return this.actorRuntimeContext.getDaprClient().unregisterTimer( this.actorRuntimeContext.getActorTypeInformation().getName(), this.id.toString(), timerName); @@ -187,7 +187,7 @@ protected Mono unregisterTimer(String timerName) { * @return Asynchronous void response. */ protected Mono unregisterReminder(String reminderName) { - return this.actorRuntimeContext.getDaprClient().unregisterActorReminder( + return this.actorRuntimeContext.getDaprClient().unregisterReminder( this.actorRuntimeContext.getActorTypeInformation().getName(), this.id.toString(), reminderName); diff --git a/sdk-actors/src/main/java/io/dapr/actors/runtime/DaprClient.java b/sdk-actors/src/main/java/io/dapr/actors/runtime/DaprClient.java index 5da02ca109..878f3ab9fb 100644 --- a/sdk-actors/src/main/java/io/dapr/actors/runtime/DaprClient.java +++ b/sdk-actors/src/main/java/io/dapr/actors/runtime/DaprClient.java @@ -22,7 +22,7 @@ interface DaprClient { * @param keyName State name. * @return Asynchronous result with current state value. */ - Mono getActorState(String actorType, String actorId, String keyName); + Mono getState(String actorType, String actorId, String keyName); /** * Saves state batch to Dapr. @@ -32,7 +32,7 @@ interface DaprClient { * @param operations State transaction operations. * @return Asynchronous void result. */ - Mono saveActorStateTransactionally(String actorType, String actorId, List operations); + Mono saveStateTransactionally(String actorType, String actorId, List operations); /** * Register a reminder. @@ -43,7 +43,7 @@ interface DaprClient { * @param reminderParams Parameters for the reminder. * @return Asynchronous void result. */ - Mono registerActorReminder( + Mono registerReminder( String actorType, String actorId, String reminderName, @@ -57,7 +57,7 @@ Mono registerActorReminder( * @param reminderName Name of reminder to be unregistered. * @return Asynchronous void result. */ - Mono unregisterActorReminder(String actorType, String actorId, String reminderName); + Mono unregisterReminder(String actorType, String actorId, String reminderName); /** * Register a timer. @@ -68,7 +68,7 @@ Mono registerActorReminder( * @param timerParams Parameters for the timer. * @return Asynchronous void result. */ - Mono registerActorTimer(String actorType, String actorId, String timerName, ActorTimerParams timerParams); + Mono registerTimer(String actorType, String actorId, String timerName, ActorTimerParams timerParams); /** * Unregisters a timer. @@ -78,5 +78,5 @@ Mono registerActorReminder( * @param timerName Name of timer to be unregistered. * @return Asynchronous void result. */ - Mono unregisterActorTimer(String actorType, String actorId, String timerName); + Mono unregisterTimer(String actorType, String actorId, String timerName); } diff --git a/sdk-actors/src/main/java/io/dapr/actors/runtime/DaprGrpcClient.java b/sdk-actors/src/main/java/io/dapr/actors/runtime/DaprGrpcClient.java index 7f2de0579c..c29b406caf 100644 --- a/sdk-actors/src/main/java/io/dapr/actors/runtime/DaprGrpcClient.java +++ b/sdk-actors/src/main/java/io/dapr/actors/runtime/DaprGrpcClient.java @@ -66,7 +66,7 @@ class DaprGrpcClient implements DaprClient { * {@inheritDoc} */ @Override - public Mono getActorState(String actorType, String actorId, String keyName) { + public Mono getState(String actorType, String actorId, String keyName) { return Mono.fromCallable(() -> { DaprProtos.GetActorStateRequest req = DaprProtos.GetActorStateRequest.newBuilder() @@ -84,7 +84,7 @@ public Mono getActorState(String actorType, String actorId, String keyNa * {@inheritDoc} */ @Override - public Mono saveActorStateTransactionally( + public Mono saveStateTransactionally( String actorType, String actorId, List operations) { @@ -134,7 +134,7 @@ public Mono saveActorStateTransactionally( * {@inheritDoc} */ @Override - public Mono registerActorReminder( + public Mono registerReminder( String actorType, String actorId, String reminderName, @@ -160,7 +160,7 @@ public Mono registerActorReminder( * {@inheritDoc} */ @Override - public Mono unregisterActorReminder(String actorType, String actorId, String reminderName) { + public Mono unregisterReminder(String actorType, String actorId, String reminderName) { return Mono.fromCallable(() -> { DaprProtos.UnregisterActorReminderRequest req = DaprProtos.UnregisterActorReminderRequest.newBuilder() @@ -179,7 +179,7 @@ public Mono unregisterActorReminder(String actorType, String actorId, Stri * {@inheritDoc} */ @Override - public Mono registerActorTimer( + public Mono registerTimer( String actorType, String actorId, String timerName, @@ -206,7 +206,7 @@ public Mono registerActorTimer( * {@inheritDoc} */ @Override - public Mono unregisterActorTimer(String actorType, String actorId, String timerName) { + public Mono unregisterTimer(String actorType, String actorId, String timerName) { return Mono.fromCallable(() -> { DaprProtos.UnregisterActorTimerRequest req = DaprProtos.UnregisterActorTimerRequest.newBuilder() diff --git a/sdk-actors/src/main/java/io/dapr/actors/runtime/DaprHttpClient.java b/sdk-actors/src/main/java/io/dapr/actors/runtime/DaprHttpClient.java index f7abe68833..38cacf0e6e 100644 --- a/sdk-actors/src/main/java/io/dapr/actors/runtime/DaprHttpClient.java +++ b/sdk-actors/src/main/java/io/dapr/actors/runtime/DaprHttpClient.java @@ -74,7 +74,7 @@ class DaprHttpClient implements DaprClient { * {@inheritDoc} */ @Override - public Mono getActorState(String actorType, String actorId, String keyName) { + public Mono getState(String actorType, String actorId, String keyName) { String url = String.format(ACTOR_STATE_KEY_RELATIVE_URL_FORMAT, actorType, actorId, keyName); Mono responseMono = this.client.invokeApi(DaprHttp.HttpMethods.GET.name(), url, null, "", null, null); @@ -91,7 +91,7 @@ public Mono getActorState(String actorType, String actorId, String keyNa * {@inheritDoc} */ @Override - public Mono saveActorStateTransactionally( + public Mono saveStateTransactionally( String actorType, String actorId, List operations) { @@ -152,7 +152,7 @@ public Mono saveActorStateTransactionally( * {@inheritDoc} */ @Override - public Mono registerActorReminder( + public Mono registerReminder( String actorType, String actorId, String reminderName, @@ -168,7 +168,7 @@ public Mono registerActorReminder( * {@inheritDoc} */ @Override - public Mono unregisterActorReminder(String actorType, String actorId, String reminderName) { + public Mono unregisterReminder(String actorType, String actorId, String reminderName) { String url = String.format(ACTOR_REMINDER_RELATIVE_URL_FORMAT, actorType, actorId, reminderName); return this.client.invokeApi(DaprHttp.HttpMethods.DELETE.name(), url, null, null, null).then(); } @@ -177,7 +177,7 @@ public Mono unregisterActorReminder(String actorType, String actorId, Stri * {@inheritDoc} */ @Override - public Mono registerActorTimer( + public Mono registerTimer( String actorType, String actorId, String timerName, @@ -193,7 +193,7 @@ public Mono registerActorTimer( * {@inheritDoc} */ @Override - public Mono unregisterActorTimer(String actorType, String actorId, String timerName) { + public Mono unregisterTimer(String actorType, String actorId, String timerName) { String url = String.format(ACTOR_TIMER_RELATIVE_URL_FORMAT, actorType, actorId, timerName); return this.client.invokeApi(DaprHttp.HttpMethods.DELETE.name(), url, null, null, null).then(); } diff --git a/sdk-actors/src/main/java/io/dapr/actors/runtime/DaprStateAsyncProvider.java b/sdk-actors/src/main/java/io/dapr/actors/runtime/DaprStateAsyncProvider.java index 7fa621f6ac..e4882926b6 100644 --- a/sdk-actors/src/main/java/io/dapr/actors/runtime/DaprStateAsyncProvider.java +++ b/sdk-actors/src/main/java/io/dapr/actors/runtime/DaprStateAsyncProvider.java @@ -60,7 +60,7 @@ class DaprStateAsyncProvider { } Mono load(String actorType, ActorId actorId, String stateName, TypeRef type) { - Mono result = this.daprClient.getActorState(actorType, actorId.toString(), stateName); + Mono result = this.daprClient.getState(actorType, actorId.toString(), stateName); return result.flatMap(s -> { try { @@ -88,7 +88,7 @@ Mono load(String actorType, ActorId actorId, String stateName, TypeRef } Mono contains(String actorType, ActorId actorId, String stateName) { - Mono result = this.daprClient.getActorState(actorType, actorId.toString(), stateName); + Mono result = this.daprClient.getState(actorType, actorId.toString(), stateName); return result.map(s -> s.length > 0).defaultIfEmpty(false); } @@ -155,7 +155,7 @@ Mono apply(String actorType, ActorId actorId, ActorStateChange... stateCha operations.add(new ActorStateOperation(operationName, key, value)); } - return this.daprClient.saveActorStateTransactionally(actorType, actorId.toString(), operations); + return this.daprClient.saveStateTransactionally(actorType, actorId.toString(), operations); } } 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 5bbe2213d7..e772b3a4cc 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 @@ -40,7 +40,7 @@ public void invokeActorMethodWithoutDataWithReturnType() { Mono daprResponse = Mono.just( "{\n\t\t\"propertyA\": \"valueA\",\n\t\t\"propertyB\": \"valueB\"\n\t}".getBytes()); - when(daprClient.invokeActorMethod(anyString(), anyString(), anyString(), Mockito.isNull())) + when(daprClient.invoke(anyString(), anyString(), anyString(), Mockito.isNull())) .thenReturn(daprResponse); final ActorProxy actorProxy = new ActorProxyImpl( @@ -49,7 +49,7 @@ public void invokeActorMethodWithoutDataWithReturnType() { new DefaultObjectSerializer(), daprClient); - Mono result = actorProxy.invokeActorMethod("getData", MyData.class); + Mono result = actorProxy.invoke("getData", MyData.class); MyData myData = result.block(); Assert.assertNotNull(myData); Assert.assertEquals("valueA", myData.getPropertyA()); @@ -62,7 +62,7 @@ public void invokeActorMethodWithoutDataWithReturnTypeViaReflection() throws NoS Mono daprResponse = Mono.just( "{\n\t\t\"propertyA\": \"valueA\",\n\t\t\"propertyB\": \"valueB\"\n\t}".getBytes()); - when(daprClient.invokeActorMethod(anyString(), anyString(), anyString(), Mockito.isNull())) + when(daprClient.invoke(anyString(), anyString(), anyString(), Mockito.isNull())) .thenReturn(daprResponse); final ActorProxyImpl actorProxy = new ActorProxyImpl( @@ -83,7 +83,7 @@ public void invokeActorMethodWithoutDataWithReturnMonoTypeViaReflection() throws Mono daprResponse = Mono.just( "{\n\t\t\"propertyA\": \"valueA\",\n\t\t\"propertyB\": \"valueB\"\n\t}".getBytes()); - when(daprClient.invokeActorMethod(anyString(), anyString(), anyString(), Mockito.isNull())) + when(daprClient.invoke(anyString(), anyString(), anyString(), Mockito.isNull())) .thenReturn(daprResponse); final ActorProxyImpl actorProxy = new ActorProxyImpl( @@ -106,7 +106,7 @@ public void invokeActorMethodWithDataWithReturnTypeViaReflection() throws NoSuch Mono daprResponse = Mono.just( "\"OK\"".getBytes()); - when(daprClient.invokeActorMethod(anyString(), anyString(), anyString(), Mockito.eq("\"hello world\"".getBytes()))) + when(daprClient.invoke(anyString(), anyString(), anyString(), Mockito.eq("\"hello world\"".getBytes()))) .thenReturn(daprResponse); final ActorProxyImpl actorProxy = new ActorProxyImpl( @@ -129,7 +129,7 @@ public void invokeActorMethodWithDataWithReturnMonoTypeViaReflection() throws No Mono daprResponse = Mono.just( "\"OK\"".getBytes()); - when(daprClient.invokeActorMethod(anyString(), anyString(), anyString(), Mockito.eq("\"hello world\"".getBytes()))) + when(daprClient.invoke(anyString(), anyString(), anyString(), Mockito.eq("\"hello world\"".getBytes()))) .thenReturn(daprResponse); final ActorProxyImpl actorProxy = new ActorProxyImpl( @@ -152,7 +152,7 @@ public void invokeActorMethodWithoutDataWithoutReturnTypeViaReflection() throws final DaprClient daprClient = mock(DaprClient.class); Mono daprResponse = Mono.empty(); - when(daprClient.invokeActorMethod(anyString(), anyString(), anyString(), Mockito.isNull())) + when(daprClient.invoke(anyString(), anyString(), anyString(), Mockito.isNull())) .thenReturn(daprResponse); final ActorProxyImpl actorProxy = new ActorProxyImpl( @@ -170,7 +170,7 @@ public void invokeActorMethodWithoutDataWithoutReturnTypeMonoViaReflection() thr final DaprClient daprClient = mock(DaprClient.class); Mono daprResponse = Mono.empty(); - when(daprClient.invokeActorMethod(anyString(), anyString(), anyString(), Mockito.isNull())) + when(daprClient.invoke(anyString(), anyString(), anyString(), Mockito.isNull())) .thenReturn(daprResponse); final ActorProxyImpl actorProxy = new ActorProxyImpl( @@ -189,7 +189,7 @@ public void invokeActorMethodWithDataWithoutReturnTypeMonoViaReflection() throws final DaprClient daprClient = mock(DaprClient.class); Mono daprResponse = Mono.empty(); - when(daprClient.invokeActorMethod(anyString(), anyString(), anyString(), Mockito.eq("\"hello world\"".getBytes()))) + when(daprClient.invoke(anyString(), anyString(), anyString(), Mockito.eq("\"hello world\"".getBytes()))) .thenReturn(daprResponse); final ActorProxyImpl actorProxy = new ActorProxyImpl( @@ -231,7 +231,7 @@ public void invokeActorMethodWithDataWithoutReturnTypeViaReflection() throws NoS final DaprClient daprClient = mock(DaprClient.class); Mono daprResponse = Mono.empty(); - when(daprClient.invokeActorMethod(anyString(), anyString(), anyString(), Mockito.eq("\"hello world\"".getBytes()))) + when(daprClient.invoke(anyString(), anyString(), anyString(), Mockito.eq("\"hello world\"".getBytes()))) .thenReturn(daprResponse); final ActorProxyImpl actorProxy = new ActorProxyImpl( @@ -251,7 +251,7 @@ public void invokeActorMethodWithDataWithoutReturnTypeViaReflection() throws NoS @Test() public void invokeActorMethodWithoutDataWithEmptyReturnType() { final DaprClient daprClient = mock(DaprClient.class); - when(daprClient.invokeActorMethod(anyString(), anyString(), anyString(), Mockito.isNull())) + when(daprClient.invoke(anyString(), anyString(), anyString(), Mockito.isNull())) .thenReturn(Mono.just("".getBytes())); final ActorProxy actorProxy = new ActorProxyImpl( @@ -260,7 +260,7 @@ public void invokeActorMethodWithoutDataWithEmptyReturnType() { new DefaultObjectSerializer(), daprClient); - Mono result = actorProxy.invokeActorMethod("getData", MyData.class); + Mono result = actorProxy.invoke("getData", MyData.class); MyData myData = result.block(); Assert.assertNull(myData); } @@ -268,7 +268,7 @@ public void invokeActorMethodWithoutDataWithEmptyReturnType() { @Test(expected = RuntimeException.class) public void invokeActorMethodWithIncorrectReturnType() { final DaprClient daprClient = mock(DaprClient.class); - when(daprClient.invokeActorMethod(anyString(), anyString(), anyString(), Mockito.isNull())) + when(daprClient.invoke(anyString(), anyString(), anyString(), Mockito.isNull())) .thenReturn(Mono.just("{test}".getBytes())); final ActorProxy actorProxy = new ActorProxyImpl( @@ -277,7 +277,7 @@ public void invokeActorMethodWithIncorrectReturnType() { new DefaultObjectSerializer(), daprClient); - Mono result = actorProxy.invokeActorMethod("getData", MyData.class); + Mono result = actorProxy.invoke("getData", MyData.class); result.doOnSuccess(x -> Assert.fail("Not exception was throw")) @@ -288,7 +288,7 @@ public void invokeActorMethodWithIncorrectReturnType() { @Test() public void invokeActorMethodSavingDataWithReturnType() { final DaprClient daprClient = mock(DaprClient.class); - when(daprClient.invokeActorMethod(anyString(), anyString(), anyString(), Mockito.isNotNull())) + when(daprClient.invoke(anyString(), anyString(), anyString(), Mockito.isNotNull())) .thenReturn( Mono.just("{\n\t\t\"propertyA\": \"valueA\",\n\t\t\"propertyB\": \"valueB\"\n\t}".getBytes())); @@ -302,7 +302,7 @@ public void invokeActorMethodSavingDataWithReturnType() { saveData.setPropertyA("valueA"); saveData.setPropertyB("valueB"); - Mono result = actorProxy.invokeActorMethod("getData", saveData, MyData.class); + Mono result = actorProxy.invoke("getData", saveData, MyData.class); MyData myData = result.block(); Assert.assertNotNull(myData); Assert.assertEquals("valueA", myData.getPropertyA()); @@ -313,7 +313,7 @@ public void invokeActorMethodSavingDataWithReturnType() { @Test(expected = DaprException.class) public void invokeActorMethodSavingDataWithIncorrectReturnType() { final DaprClient daprClient = mock(DaprClient.class); - when(daprClient.invokeActorMethod(anyString(), anyString(), anyString(), Mockito.isNotNull())) + when(daprClient.invoke(anyString(), anyString(), anyString(), Mockito.isNotNull())) .thenReturn(Mono.just("{test}".getBytes())); final ActorProxy actorProxy = new ActorProxyImpl( @@ -326,7 +326,7 @@ public void invokeActorMethodSavingDataWithIncorrectReturnType() { saveData.setPropertyA("valueA"); saveData.setPropertyB("valueB"); - Mono result = actorProxy.invokeActorMethod("getData", saveData, MyData.class); + Mono result = actorProxy.invoke("getData", saveData, MyData.class); result.doOnSuccess(x -> Assert.fail("Not exception was throw")) .doOnError(Throwable::printStackTrace @@ -337,7 +337,7 @@ public void invokeActorMethodSavingDataWithIncorrectReturnType() { @Test() public void invokeActorMethodSavingDataWithEmptyReturnType() { final DaprClient daprClient = mock(DaprClient.class); - when(daprClient.invokeActorMethod(anyString(), anyString(), anyString(), Mockito.isNotNull())) + when(daprClient.invoke(anyString(), anyString(), anyString(), Mockito.isNotNull())) .thenReturn(Mono.just("".getBytes())); final ActorProxy actorProxy = new ActorProxyImpl( @@ -350,7 +350,7 @@ public void invokeActorMethodSavingDataWithEmptyReturnType() { saveData.setPropertyA("valueA"); saveData.setPropertyB("valueB"); - Mono result = actorProxy.invokeActorMethod("getData", saveData, MyData.class); + Mono result = actorProxy.invoke("getData", saveData, MyData.class); MyData myData = result.block(); Assert.assertNull(myData); } @@ -359,7 +359,7 @@ public void invokeActorMethodSavingDataWithEmptyReturnType() { @Test(expected = DaprException.class) public void invokeActorMethodSavingDataWithIncorrectInputType() { final DaprClient daprClient = mock(DaprClient.class); - when(daprClient.invokeActorMethod(anyString(), anyString(), anyString(), Mockito.isNotNull())) + when(daprClient.invoke(anyString(), anyString(), anyString(), Mockito.isNotNull())) .thenReturn(Mono.just("{test}".getBytes())); final ActorProxy actorProxy = new ActorProxyImpl( @@ -373,7 +373,7 @@ public void invokeActorMethodSavingDataWithIncorrectInputType() { saveData.setPropertyB("valueB"); saveData.setMyData(saveData); - Mono result = actorProxy.invokeActorMethod("getData", saveData, MyData.class); + Mono result = actorProxy.invoke("getData", saveData, MyData.class); result.doOnSuccess(x -> Assert.fail("Not exception was throw")) .doOnError(Throwable::printStackTrace @@ -388,7 +388,7 @@ public void invokeActorMethodWithDataWithVoidReturnType() { saveData.setPropertyB("valueB"); final DaprClient daprClient = mock(DaprClient.class); - when(daprClient.invokeActorMethod(anyString(), anyString(), anyString(), Mockito.isNotNull())) + when(daprClient.invoke(anyString(), anyString(), anyString(), Mockito.isNotNull())) .thenReturn(Mono.empty()); final ActorProxy actorProxy = new ActorProxyImpl( @@ -397,7 +397,7 @@ public void invokeActorMethodWithDataWithVoidReturnType() { new DefaultObjectSerializer(), daprClient); - Mono result = actorProxy.invokeActorMethod("getData", saveData); + Mono result = actorProxy.invoke("getData", saveData); Void emptyResponse = result.block(); Assert.assertNull(emptyResponse); } @@ -411,7 +411,7 @@ public void invokeActorMethodWithDataWithVoidIncorrectInputType() { saveData.setMyData(saveData); final DaprClient daprClient = mock(DaprClient.class); - when(daprClient.invokeActorMethod(anyString(), anyString(), anyString(), Mockito.isNotNull())) + when(daprClient.invoke(anyString(), anyString(), anyString(), Mockito.isNotNull())) .thenReturn(Mono.empty()); final ActorProxy actorProxy = new ActorProxyImpl( @@ -420,7 +420,7 @@ public void invokeActorMethodWithDataWithVoidIncorrectInputType() { new DefaultObjectSerializer(), daprClient); - Mono result = actorProxy.invokeActorMethod("getData", saveData); + Mono result = actorProxy.invoke("getData", saveData); Void emptyResponse = result.doOnError(Throwable::printStackTrace).block(); Assert.assertNull(emptyResponse); } @@ -428,7 +428,7 @@ public void invokeActorMethodWithDataWithVoidIncorrectInputType() { @Test() public void invokeActorMethodWithoutDataWithVoidReturnType() { final DaprClient daprClient = mock(DaprClient.class); - when(daprClient.invokeActorMethod(anyString(), anyString(), anyString(), Mockito.isNull())) + when(daprClient.invoke(anyString(), anyString(), anyString(), Mockito.isNull())) .thenReturn(Mono.empty()); final ActorProxy actorProxy = new ActorProxyImpl( @@ -437,7 +437,7 @@ public void invokeActorMethodWithoutDataWithVoidReturnType() { new DefaultObjectSerializer(), daprClient); - Mono result = actorProxy.invokeActorMethod("getData"); + Mono result = actorProxy.invoke("getData"); Void emptyResponse = result.block(); Assert.assertNull(emptyResponse); } diff --git a/sdk-actors/src/test/java/io/dapr/actors/client/DaprClientStub.java b/sdk-actors/src/test/java/io/dapr/actors/client/DaprClientStub.java index 374b61a316..7bff09f046 100644 --- a/sdk-actors/src/test/java/io/dapr/actors/client/DaprClientStub.java +++ b/sdk-actors/src/test/java/io/dapr/actors/client/DaprClientStub.java @@ -10,7 +10,7 @@ public class DaprClientStub implements DaprClient { @Override - public Mono invokeActorMethod(String actorType, String actorId, String methodName, byte[] jsonPayload) { + public Mono invoke(String actorType, String actorId, String methodName, byte[] jsonPayload) { return Mono.just(new byte[0]); } diff --git a/sdk-actors/src/test/java/io/dapr/actors/client/DaprGrpcClientTest.java b/sdk-actors/src/test/java/io/dapr/actors/client/DaprGrpcClientTest.java index a43f8adf1d..9869bc756c 100644 --- a/sdk-actors/src/test/java/io/dapr/actors/client/DaprGrpcClientTest.java +++ b/sdk-actors/src/test/java/io/dapr/actors/client/DaprGrpcClientTest.java @@ -54,7 +54,7 @@ public void invoke() { assertArrayEquals(payload, argument.getData().toByteArray()); return true; }))).thenReturn(settableFuture); - Mono result = client.invokeActorMethod(ACTOR_TYPE, ACTOR_ID, methodName, payload); + Mono result = client.invoke(ACTOR_TYPE, ACTOR_ID, methodName, payload); assertArrayEquals(response, result.block()); } @@ -73,7 +73,7 @@ public void invokeNullPayload() { assertArrayEquals(new byte[0], argument.getData().toByteArray()); return true; }))).thenReturn(settableFuture); - Mono result = client.invokeActorMethod(ACTOR_TYPE, ACTOR_ID, methodName, null); + Mono result = client.invoke(ACTOR_TYPE, ACTOR_ID, methodName, null); assertArrayEquals(response, result.block()); } @@ -91,7 +91,7 @@ public void invokeException() { assertArrayEquals(new byte[0], argument.getData().toByteArray()); return true; }))).thenReturn(settableFuture); - Mono result = client.invokeActorMethod(ACTOR_TYPE, ACTOR_ID, methodName, null); + Mono result = client.invoke(ACTOR_TYPE, ACTOR_ID, methodName, null); assertThrowsDaprException( ExecutionException.class, @@ -114,7 +114,7 @@ public void invokeNotHotMono() { assertArrayEquals(new byte[0], argument.getData().toByteArray()); return true; }))).thenReturn(settableFuture); - client.invokeActorMethod(ACTOR_TYPE, ACTOR_ID, methodName, null); + client.invoke(ACTOR_TYPE, ACTOR_ID, methodName, null); // No exception thrown because Mono is ignored here. } diff --git a/sdk-actors/src/test/java/io/dapr/actors/client/DaprHttpClientTest.java b/sdk-actors/src/test/java/io/dapr/actors/client/DaprHttpClientTest.java index 2fabe7ced7..c486db65a9 100644 --- a/sdk-actors/src/test/java/io/dapr/actors/client/DaprHttpClientTest.java +++ b/sdk-actors/src/test/java/io/dapr/actors/client/DaprHttpClientTest.java @@ -43,7 +43,7 @@ public void invokeActorMethod() { DaprHttp daprHttp = new DaprHttpProxy(Properties.SIDECAR_IP.get(), 3000, okHttpClient); DaprHttpClient = new DaprHttpClient(daprHttp); Mono mono = - DaprHttpClient.invokeActorMethod("DemoActor", "1", "Payment", "".getBytes()); + DaprHttpClient.invoke("DemoActor", "1", "Payment", "".getBytes()); assertEquals(new String(mono.block()), EXPECTED_RESULT); } @@ -58,7 +58,7 @@ public void invokeActorMethodError() { DaprHttp daprHttp = new DaprHttpProxy(Properties.SIDECAR_IP.get(), 3000, okHttpClient); DaprHttpClient = new DaprHttpClient(daprHttp); Mono mono = - DaprHttpClient.invokeActorMethod("DemoActor", "1", "Payment", "".getBytes()); + DaprHttpClient.invoke("DemoActor", "1", "Payment", "".getBytes()); assertThrowsDaprException( "ERR_SOMETHING", 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 d85ab428f2..e96734e1d5 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 void classInClassOut() { ActorProxy actorProxy = createActorProxy(); MyData d = new MyData("hi", 3); - MyData response = actorProxy.invokeActorMethod("classInClassOut", d, MyData.class).block(); + MyData response = actorProxy.invoke("classInClassOut", d, MyData.class).block(); Assert.assertEquals("hihi", response.getName()); Assert.assertEquals(6, response.getNum()); @@ -107,7 +107,7 @@ public void classInClassOut() { @Test public void stringInStringOut() { ActorProxy actorProxy = createActorProxy(); - String response = actorProxy.invokeActorMethod("stringInStringOut", "oi", String.class).block(); + String response = actorProxy.invoke("stringInStringOut", "oi", String.class).block(); Assert.assertEquals("oioi", response); } @@ -115,7 +115,7 @@ public void stringInStringOut() { @Test public void intInIntOut() { ActorProxy actorProxy = createActorProxy(); - int response = actorProxy.invokeActorMethod("intInIntOut", 2, int.class).block(); + int response = actorProxy.invoke("intInIntOut", 2, int.class).block(); Assert.assertEquals(4, response); } @@ -130,7 +130,7 @@ private ActorProxy createActorProxy() { // Mock daprClient for ActorProxy only, not for runtime. DaprClientStub daprClient = mock(DaprClientStub.class); - when(daprClient.invokeActorMethod( + when(daprClient.invoke( eq(context.getActorTypeInformation().getName()), eq(actorId.toString()), any(), @@ -153,10 +153,10 @@ private ActorProxy createActorProxy() { private static ActorRuntimeContext createContext() { DaprClient daprClient = mock(DaprClient.class); - when(daprClient.registerActorTimer(any(), any(), any(), any())).thenReturn(Mono.empty()); - when(daprClient.registerActorReminder(any(), any(), any(), any())).thenReturn(Mono.empty()); - when(daprClient.unregisterActorTimer(any(), any(), any())).thenReturn(Mono.empty()); - when(daprClient.unregisterActorReminder(any(), any(), any())).thenReturn(Mono.empty()); + when(daprClient.registerTimer(any(), any(), any(), any())).thenReturn(Mono.empty()); + when(daprClient.registerReminder(any(), any(), any(), any())).thenReturn(Mono.empty()); + when(daprClient.unregisterTimer(any(), any(), any())).thenReturn(Mono.empty()); + when(daprClient.unregisterReminder(any(), any(), any())).thenReturn(Mono.empty()); return new ActorRuntimeContext( mock(ActorRuntime.class), diff --git a/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorManagerTest.java b/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorManagerTest.java index f8eb562738..7b679b8df8 100644 --- a/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorManagerTest.java +++ b/sdk-actors/src/test/java/io/dapr/actors/runtime/ActorManagerTest.java @@ -287,10 +287,10 @@ private static String executeSayMethod(String something) { private static ActorRuntimeContext createContext(Class clazz) { DaprClient daprClient = mock(DaprClient.class); - when(daprClient.registerActorTimer(any(), any(), any(), any())).thenReturn(Mono.empty()); - when(daprClient.registerActorReminder(any(), any(), any(), any())).thenReturn(Mono.empty()); - when(daprClient.unregisterActorTimer(any(), any(), any())).thenReturn(Mono.empty()); - when(daprClient.unregisterActorReminder(any(), any(), any())).thenReturn(Mono.empty()); + when(daprClient.registerTimer(any(), any(), any(), any())).thenReturn(Mono.empty()); + when(daprClient.registerReminder(any(), any(), any(), any())).thenReturn(Mono.empty()); + when(daprClient.unregisterTimer(any(), any(), any())).thenReturn(Mono.empty()); + when(daprClient.unregisterReminder(any(), any(), any())).thenReturn(Mono.empty()); return new ActorRuntimeContext( mock(ActorRuntime.class), 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 fd5c99e72d..75ec33f4be 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 void actorId() { Assert.assertEquals( proxy.getActorId().toString(), - proxy.invokeActorMethod("getMyId", String.class).block()); + proxy.invoke("getMyId", String.class).block()); } @Test @@ -149,7 +149,7 @@ public void stringInStringOut() { // these should only call the actor methods for ActorChild. The implementations in ActorParent will throw. Assert.assertEquals( "abcabc", - proxy.invokeActorMethod("stringInStringOut", "abc", String.class).block()); + proxy.invoke("stringInStringOut", "abc", String.class).block()); } @Test @@ -159,11 +159,11 @@ public void stringInBooleanOut() { // these should only call the actor methods for ActorChild. The implementations in ActorParent will throw. Assert.assertEquals( false, - proxy.invokeActorMethod("stringInBooleanOut", "hello world", Boolean.class).block()); + proxy.invoke("stringInBooleanOut", "hello world", Boolean.class).block()); Assert.assertEquals( true, - proxy.invokeActorMethod("stringInBooleanOut", "true", Boolean.class).block()); + proxy.invoke("stringInBooleanOut", "true", Boolean.class).block()); } @Test(expected = IllegalMonitorStateException.class) @@ -171,7 +171,7 @@ public void stringInVoidOutIntentionallyThrows() { ActorProxy actorProxy = createActorProxy(); // these should only call the actor methods for ActorChild. The implementations in ActorParent will throw. - actorProxy.invokeActorMethod("stringInVoidOutIntentionallyThrows", "hello world").block(); + actorProxy.invoke("stringInVoidOutIntentionallyThrows", "hello world").block(); } @Test @@ -180,7 +180,7 @@ public void classInClassOut() { MyData d = new MyData("hi", 3); // this should only call the actor methods for ActorChild. The implementations in ActorParent will throw. - MyData response = actorProxy.invokeActorMethod("classInClassOut", d, MyData.class).block(); + MyData response = actorProxy.invoke("classInClassOut", d, MyData.class).block(); Assert.assertEquals( "hihi", @@ -218,7 +218,7 @@ private ActorProxy createActorProxy() { // Mock daprClient for ActorProxy only, not for runtime. DaprClientStub daprClient = mock(DaprClientStub.class); - when(daprClient.invokeActorMethod( + when(daprClient.invoke( eq(context.getActorTypeInformation().getName()), eq(actorId.toString()), any(), @@ -244,7 +244,7 @@ private T createActorProxy(Class clazz) { // Mock daprClient for ActorProxy only, not for runtime. DaprClientStub daprClient = mock(DaprClientStub.class); - when(daprClient.invokeActorMethod( + when(daprClient.invoke( eq(context.getActorTypeInformation().getName()), eq(actorId.toString()), any(), @@ -271,10 +271,10 @@ private T createActorProxy(Class clazz) { private static ActorRuntimeContext createContext() { DaprClient daprClient = mock(DaprClient.class); - when(daprClient.registerActorTimer(any(), any(), any(), any())).thenReturn(Mono.empty()); - when(daprClient.registerActorReminder(any(), any(), any(), any())).thenReturn(Mono.empty()); - when(daprClient.unregisterActorTimer(any(), any(), any())).thenReturn(Mono.empty()); - when(daprClient.unregisterActorReminder(any(), any(), any())).thenReturn(Mono.empty()); + when(daprClient.registerTimer(any(), any(), any(), any())).thenReturn(Mono.empty()); + when(daprClient.registerReminder(any(), any(), any(), any())).thenReturn(Mono.empty()); + when(daprClient.unregisterTimer(any(), any(), any())).thenReturn(Mono.empty()); + when(daprClient.unregisterReminder(any(), any(), any())).thenReturn(Mono.empty()); return new ActorRuntimeContext( mock(ActorRuntime.class), 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 7af99614b1..8ffb8583b4 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 MyMethodContext setName(String name) { public void happyGetSetDeleteContains() { ActorProxy proxy = newActorProxy(); Assert.assertEquals( - proxy.getActorId().toString(), proxy.invokeActorMethod("getIdString", String.class).block()); - Assert.assertFalse(proxy.invokeActorMethod("hasMessage", Boolean.class).block()); + proxy.getActorId().toString(), proxy.invoke("getIdString", String.class).block()); + Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); - proxy.invokeActorMethod("setMessage", "hello world").block(); - Assert.assertTrue(proxy.invokeActorMethod("hasMessage", Boolean.class).block()); + proxy.invoke("setMessage", "hello world").block(); + Assert.assertTrue(proxy.invoke("hasMessage", Boolean.class).block()); Assert.assertEquals( - "hello world", proxy.invokeActorMethod("getMessage", String.class).block()); + "hello world", proxy.invoke("getMessage", String.class).block()); Assert.assertEquals( executeSayMethod("hello world"), - proxy.invokeActorMethod("setMessage", "hello world", String.class).block()); + proxy.invoke("setMessage", "hello world", String.class).block()); - proxy.invokeActorMethod("deleteMessage").block(); - Assert.assertFalse(proxy.invokeActorMethod("hasMessage", Boolean.class).block()); + proxy.invoke("deleteMessage").block(); + Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); } @Test(expected = IllegalStateException.class) public void lazyGet() { ActorProxy proxy = newActorProxy(); - Assert.assertFalse(proxy.invokeActorMethod("hasMessage", Boolean.class).block()); - proxy.invokeActorMethod("setMessage", "first message").block(); + Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); + proxy.invoke("setMessage", "first message").block(); // Creates the mono plan but does not call it yet. - Mono getMessageCall = proxy.invokeActorMethod("getMessage", String.class); + Mono getMessageCall = proxy.invoke("getMessage", String.class); - proxy.invokeActorMethod("deleteMessage").block(); + proxy.invoke("deleteMessage").block(); // Call should fail because the message was deleted. getMessageCall.block(); @@ -324,96 +324,96 @@ public void lazyGet() { @Test public void lazySet() { ActorProxy proxy = newActorProxy(); - Assert.assertFalse(proxy.invokeActorMethod("hasMessage", Boolean.class).block()); + Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); // Creates the mono plan but does not call it yet. - Mono setMessageCall = proxy.invokeActorMethod("setMessage", "first message"); + Mono setMessageCall = proxy.invoke("setMessage", "first message"); // No call executed yet, so message should not be set. - Assert.assertFalse(proxy.invokeActorMethod("hasMessage", Boolean.class).block()); + Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); setMessageCall.block(); // Now the message has been set. - Assert.assertTrue(proxy.invokeActorMethod("hasMessage", Boolean.class).block()); + Assert.assertTrue(proxy.invoke("hasMessage", Boolean.class).block()); } @Test public void lazyContains() { ActorProxy proxy = newActorProxy(); - Assert.assertFalse(proxy.invokeActorMethod("hasMessage", Boolean.class).block()); + Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); // Creates the mono plan but does not call it yet. - Mono hasMessageCall = proxy.invokeActorMethod("hasMessage", Boolean.class); + Mono hasMessageCall = proxy.invoke("hasMessage", Boolean.class); // Sets the message. - proxy.invokeActorMethod("setMessage", "hello world").block(); + proxy.invoke("setMessage", "hello world").block(); // Now we check if message is set. hasMessageCall.block(); // Now the message should be set. - Assert.assertTrue(proxy.invokeActorMethod("hasMessage", Boolean.class).block()); + Assert.assertTrue(proxy.invoke("hasMessage", Boolean.class).block()); } @Test public void lazyDelete() { ActorProxy proxy = newActorProxy(); - Assert.assertFalse(proxy.invokeActorMethod("hasMessage", Boolean.class).block()); + Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); - proxy.invokeActorMethod("setMessage", "first message").block(); + proxy.invoke("setMessage", "first message").block(); // Message is set. - Assert.assertTrue(proxy.invokeActorMethod("hasMessage", Boolean.class).block()); + Assert.assertTrue(proxy.invoke("hasMessage", Boolean.class).block()); // Created the mono plan but does not execute it yet. - Mono deleteMessageCall = proxy.invokeActorMethod("deleteMessage"); + Mono deleteMessageCall = proxy.invoke("deleteMessage"); // Message is still set. - Assert.assertTrue(proxy.invokeActorMethod("hasMessage", Boolean.class).block()); + Assert.assertTrue(proxy.invoke("hasMessage", Boolean.class).block()); deleteMessageCall.block(); // Now message is not set. - Assert.assertFalse(proxy.invokeActorMethod("hasMessage", Boolean.class).block()); + Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); } @Test public void lazyAdd() { ActorProxy proxy = newActorProxy(); - Assert.assertFalse(proxy.invokeActorMethod("hasMessage", Boolean.class).block()); + Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); - proxy.invokeActorMethod("setMessage", "first message").block(); + proxy.invoke("setMessage", "first message").block(); // Message is set. - Assert.assertTrue(proxy.invokeActorMethod("hasMessage", Boolean.class).block()); + Assert.assertTrue(proxy.invoke("hasMessage", Boolean.class).block()); // Created the mono plan but does not execute it yet. - Mono addMessageCall = proxy.invokeActorMethod("addMessage", "second message"); + Mono addMessageCall = proxy.invoke("addMessage", "second message"); // Message is still set. Assert.assertEquals("first message", - proxy.invokeActorMethod("getMessage", String.class).block()); + proxy.invoke("getMessage", String.class).block()); // Delete message - proxy.invokeActorMethod("deleteMessage").block(); + proxy.invoke("deleteMessage").block(); // Should work since previous message was deleted. addMessageCall.block(); // New message is still set. Assert.assertEquals("second message", - proxy.invokeActorMethod("getMessage", String.class).block()); + proxy.invoke("getMessage", String.class).block()); } @Test public void onActivateAndOnDeactivate() { ActorProxy proxy = newActorProxy(); - Assert.assertTrue(proxy.invokeActorMethod("isActive", Boolean.class).block()); + Assert.assertTrue(proxy.invoke("isActive", Boolean.class).block()); Assert.assertFalse(DEACTIVATED_ACTOR_IDS.contains(proxy.getActorId().toString())); - proxy.invokeActorMethod("hasMessage", Boolean.class).block(); + proxy.invoke("hasMessage", Boolean.class).block(); this.manager.deactivateActor(proxy.getActorId()).block(); @@ -424,15 +424,15 @@ public void onActivateAndOnDeactivate() { public void onPreMethodAndOnPostMethod() { ActorProxy proxy = newActorProxy(); - proxy.invokeActorMethod("hasMessage", Boolean.class).block(); + proxy.invoke("hasMessage", Boolean.class).block(); MyMethodContext preContext = - proxy.invokeActorMethod("getPreCallMethodContext", MyMethodContext.class).block(); + proxy.invoke("getPreCallMethodContext", MyMethodContext.class).block(); Assert.assertEquals("hasMessage", preContext.getName()); Assert.assertEquals(ActorCallType.ACTOR_INTERFACE_METHOD.toString(), preContext.getType()); MyMethodContext postContext = - proxy.invokeActorMethod("getPostCallMethodContext", MyMethodContext.class).block(); + proxy.invoke("getPostCallMethodContext", MyMethodContext.class).block(); Assert.assertEquals("hasMessage", postContext.getName()); Assert.assertEquals(ActorCallType.ACTOR_INTERFACE_METHOD.toString(), postContext.getType()); } @@ -444,12 +444,12 @@ public void invokeTimer() { this.manager.invokeTimer(proxy.getActorId(), "mytimer", "{ \"callback\": \"hasMessage\" }".getBytes()).block(); MyMethodContext preContext = - proxy.invokeActorMethod("getPreCallMethodContext", MyMethodContext.class).block(); + proxy.invoke("getPreCallMethodContext", MyMethodContext.class).block(); Assert.assertEquals("mytimer", preContext.getName()); Assert.assertEquals(ActorCallType.TIMER_METHOD.toString(), preContext.getType()); MyMethodContext postContext = - proxy.invokeActorMethod("getPostCallMethodContext", MyMethodContext.class).block(); + proxy.invoke("getPostCallMethodContext", MyMethodContext.class).block(); Assert.assertEquals("mytimer", postContext.getName()); Assert.assertEquals(ActorCallType.TIMER_METHOD.toString(), postContext.getType()); } @@ -467,7 +467,7 @@ public void invokeTimerAfterDeactivate() { public void invokeTimerAfterUnregister() { ActorProxy proxy = newActorProxy(); - proxy.invokeActorMethod("unregisterTimerAndReminder").block(); + proxy.invoke("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 void invokeReminder() throws Exception { this.manager.invokeReminder(proxy.getActorId(), "myreminder", params).block(); MyMethodContext preContext = - proxy.invokeActorMethod("getPreCallMethodContext", MyMethodContext.class).block(); + proxy.invoke("getPreCallMethodContext", MyMethodContext.class).block(); Assert.assertEquals("myreminder", preContext.getName()); Assert.assertEquals(ActorCallType.REMINDER_METHOD.toString(), preContext.getType()); MyMethodContext postContext = - proxy.invokeActorMethod("getPostCallMethodContext", MyMethodContext.class).block(); + proxy.invoke("getPostCallMethodContext", MyMethodContext.class).block(); Assert.assertEquals("myreminder", postContext.getName()); Assert.assertEquals(ActorCallType.REMINDER_METHOD.toString(), postContext.getType()); } @@ -517,8 +517,8 @@ public void classTypeRequestResponseInStateStore() { MyMethodContext expectedContext = new MyMethodContext().setName("MyName").setType("MyType"); - proxy.invokeActorMethod("setMethodContext", expectedContext).block(); - MyMethodContext context = proxy.invokeActorMethod("getMethodContext", MyMethodContext.class).block(); + proxy.invoke("setMethodContext", expectedContext).block(); + MyMethodContext context = proxy.invoke("getMethodContext", MyMethodContext.class).block(); Assert.assertEquals(expectedContext.getName(), context.getName()); Assert.assertEquals(expectedContext.getType(), context.getType()); @@ -528,8 +528,8 @@ public void classTypeRequestResponseInStateStore() { public void intTypeRequestResponseInStateStore() { ActorProxy proxy = newActorProxy(); - Assert.assertEquals(1, (int)proxy.invokeActorMethod("incrementAndGetCount", 1, int.class).block()); - Assert.assertEquals(6, (int)proxy.invokeActorMethod("incrementAndGetCount", 5, int.class).block()); + Assert.assertEquals(1, (int)proxy.invoke("incrementAndGetCount", 1, int.class).block()); + Assert.assertEquals(6, (int)proxy.invoke("incrementAndGetCount", 5, int.class).block()); } @Test(expected = NumberFormatException.class) @@ -537,68 +537,68 @@ public void intTypeWithMethodException() { ActorProxy proxy = newActorProxy(); // Zero is a magic input that will make method throw an exception. - proxy.invokeActorMethod("incrementAndGetCount", 0, int.class).block(); + proxy.invoke("incrementAndGetCount", 0, int.class).block(); } @Test(expected = IllegalStateException.class) public void intTypeWithRuntimeException() { ActorProxy proxy = newActorProxy(); - proxy.invokeActorMethod("getCountButThrowsException", int.class).block(); + proxy.invoke("getCountButThrowsException", int.class).block(); } @Test(expected = IllegalStateException.class) public void actorRuntimeException() { ActorProxy proxy = newActorProxy(); - Assert.assertFalse(proxy.invokeActorMethod("hasMessage", Boolean.class).block()); + Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); - proxy.invokeActorMethod("forceDuplicateException").block(); + proxy.invoke("forceDuplicateException").block(); } @Test(expected = IllegalCharsetNameException.class) public void actorMethodException() { ActorProxy proxy = newActorProxy(); - Assert.assertFalse(proxy.invokeActorMethod("hasMessage", Boolean.class).block()); + Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); - proxy.invokeActorMethod("throwsWithoutSaving").block(); + proxy.invoke("throwsWithoutSaving").block(); - Assert.assertFalse(proxy.invokeActorMethod("hasMessage", Boolean.class).block()); + Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); } @Test public void rollbackChanges() { ActorProxy proxy = newActorProxy(); - Assert.assertFalse(proxy.invokeActorMethod("hasMessage", Boolean.class).block()); + Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); // Runs a method that will add one message but fail because tries to add a second one. - proxy.invokeActorMethod("forceDuplicateException") + proxy.invoke("forceDuplicateException") .onErrorResume(throwable -> Mono.empty()) .block(); // No message is set - Assert.assertFalse(proxy.invokeActorMethod("hasMessage", Boolean.class).block()); + Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); } @Test public void partialChanges() { ActorProxy proxy = newActorProxy(); - Assert.assertFalse(proxy.invokeActorMethod("hasMessage", Boolean.class).block()); + Assert.assertFalse(proxy.invoke("hasMessage", Boolean.class).block()); // Runs a method that will add one message, commit but fail because tries to add a second one. - proxy.invokeActorMethod("forcePartialChange") + proxy.invoke("forcePartialChange") .onErrorResume(throwable -> Mono.empty()) .block(); // Message is set. - Assert.assertTrue(proxy.invokeActorMethod("hasMessage", Boolean.class).block()); + Assert.assertTrue(proxy.invoke("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.invokeActorMethod("getMessage", String.class).block()); + proxy.invoke("getMessage", String.class).block()); } private ActorProxy newActorProxy() { @@ -607,7 +607,7 @@ private ActorProxy newActorProxy() { // Mock daprClient for ActorProxy only, not for runtime. DaprClientStub daprClient = mock(DaprClientStub.class); - when(daprClient.invokeActorMethod( + when(daprClient.invoke( eq(context.getActorTypeInformation().getName()), eq(actorId.toString()), any(), @@ -644,10 +644,10 @@ private static String executeSayMethod(String something) { private static ActorRuntimeContext createContext() { DaprClient daprClient = mock(DaprClient.class); - when(daprClient.registerActorTimer(any(), any(), any(), any())).thenReturn(Mono.empty()); - when(daprClient.registerActorReminder(any(), any(), any(), any())).thenReturn(Mono.empty()); - when(daprClient.unregisterActorTimer(any(), any(), any())).thenReturn(Mono.empty()); - when(daprClient.unregisterActorReminder(any(), any(), any())).thenReturn(Mono.empty()); + when(daprClient.registerTimer(any(), any(), any(), any())).thenReturn(Mono.empty()); + when(daprClient.registerReminder(any(), any(), any(), any())).thenReturn(Mono.empty()); + when(daprClient.unregisterTimer(any(), any(), any())).thenReturn(Mono.empty()); + when(daprClient.unregisterReminder(any(), any(), any())).thenReturn(Mono.empty()); return new ActorRuntimeContext( mock(ActorRuntime.class), diff --git a/sdk-actors/src/test/java/io/dapr/actors/runtime/DaprGrpcClientTest.java b/sdk-actors/src/test/java/io/dapr/actors/runtime/DaprGrpcClientTest.java index 2c01318c14..1e8cf0bcb8 100644 --- a/sdk-actors/src/test/java/io/dapr/actors/runtime/DaprGrpcClientTest.java +++ b/sdk-actors/src/test/java/io/dapr/actors/runtime/DaprGrpcClientTest.java @@ -56,7 +56,7 @@ public void getActorStateException() { ACTOR_ID, "MyKey" )))).thenReturn(settableFuture); - Mono result = client.getActorState(ACTOR_TYPE, ACTOR_ID, "MyKey"); + Mono result = client.getState(ACTOR_TYPE, ACTOR_ID, "MyKey"); Exception exception = assertThrows(Exception.class, () -> result.block()); assertTrue(exception.getCause().getCause() instanceof ArithmeticException); } @@ -72,7 +72,7 @@ public void getActorState() { ACTOR_ID, "MyKey" )))).thenReturn(settableFuture); - Mono result = client.getActorState(ACTOR_TYPE, ACTOR_ID, "MyKey"); + Mono result = client.getState(ACTOR_TYPE, ACTOR_ID, "MyKey"); assertArrayEquals(data, result.block()); } @@ -86,7 +86,7 @@ public void saveActorStateTransactionallyException() { ACTOR_ID, new ArrayList<>() )))).thenReturn(settableFuture); - Mono result = client.saveActorStateTransactionally(ACTOR_TYPE, ACTOR_ID, new ArrayList<>()); + Mono result = client.saveStateTransactionally(ACTOR_TYPE, ACTOR_ID, new ArrayList<>()); Exception exception = assertThrows(Exception.class, () -> result.block()); assertTrue(exception.getCause().getCause() instanceof ArithmeticException); } @@ -106,7 +106,7 @@ public void saveActorStateTransactionally() { ACTOR_ID, Arrays.asList(operations) )))).thenReturn(settableFuture); - Mono result = client.saveActorStateTransactionally(ACTOR_TYPE, ACTOR_ID, Arrays.asList(operations)); + Mono result = client.saveStateTransactionally(ACTOR_TYPE, ACTOR_ID, Arrays.asList(operations)); result.block(); } @@ -125,7 +125,7 @@ public void saveActorStateTransactionallyByteArray() { ACTOR_ID, Arrays.asList(operations) )))).thenReturn(settableFuture); - Mono result = client.saveActorStateTransactionally(ACTOR_TYPE, ACTOR_ID, Arrays.asList(operations)); + Mono result = client.saveStateTransactionally(ACTOR_TYPE, ACTOR_ID, Arrays.asList(operations)); result.block(); } @@ -136,7 +136,7 @@ public void saveActorStateTransactionallyInvalidValueType() { new ActorStateOperation("delete", "mykey", null), }; - Mono result = client.saveActorStateTransactionally(ACTOR_TYPE, ACTOR_ID, Arrays.asList(operations)); + Mono result = client.saveStateTransactionally(ACTOR_TYPE, ACTOR_ID, Arrays.asList(operations)); assertThrows(IllegalArgumentException.class, () -> result.block()); } @@ -161,7 +161,7 @@ public void registerActorReminder() { assertEquals(DurationUtils.convertDurationToDaprFormat(params.getPeriod()), argument.getPeriod()); return true; }))).thenReturn(settableFuture); - Mono result = client.registerActorReminder(ACTOR_TYPE, ACTOR_ID, reminderName, params); + Mono result = client.registerReminder(ACTOR_TYPE, ACTOR_ID, reminderName, params); result.block(); } @@ -178,7 +178,7 @@ public void unregisterActorReminder() { assertEquals(reminderName, argument.getName()); return true; }))).thenReturn(settableFuture); - Mono result = client.unregisterActorReminder(ACTOR_TYPE, ACTOR_ID, reminderName); + Mono result = client.unregisterReminder(ACTOR_TYPE, ACTOR_ID, reminderName); result.block(); } @@ -205,7 +205,7 @@ public void registerActorTimer() { assertEquals(DurationUtils.convertDurationToDaprFormat(params.getPeriod()), argument.getPeriod()); return true; }))).thenReturn(settableFuture); - Mono result = client.registerActorTimer(ACTOR_TYPE, ACTOR_ID, timerName, params); + Mono result = client.registerTimer(ACTOR_TYPE, ACTOR_ID, timerName, params); result.block(); } @@ -222,7 +222,7 @@ public void unregisterActorTimer() { assertEquals(timerName, argument.getName()); return true; }))).thenReturn(settableFuture); - Mono result = client.unregisterActorTimer(ACTOR_TYPE, ACTOR_ID, timerName); + Mono result = client.unregisterTimer(ACTOR_TYPE, ACTOR_ID, timerName); result.block(); } diff --git a/sdk-actors/src/test/java/io/dapr/actors/runtime/DaprHttpClientTest.java b/sdk-actors/src/test/java/io/dapr/actors/runtime/DaprHttpClientTest.java index 4cbe6e5078..81a0b7ea3f 100644 --- a/sdk-actors/src/test/java/io/dapr/actors/runtime/DaprHttpClientTest.java +++ b/sdk-actors/src/test/java/io/dapr/actors/runtime/DaprHttpClientTest.java @@ -54,7 +54,7 @@ public void getActorState() { .respond(EXPECTED_RESULT); DaprHttp daprHttp = new DaprHttpProxy(Properties.SIDECAR_IP.get(), 3000, okHttpClient); DaprHttpClient = new DaprHttpClient(daprHttp); - Mono mono = DaprHttpClient.getActorState("DemoActor", "1", "order"); + Mono mono = DaprHttpClient.getState("DemoActor", "1", "order"); assertEquals(new String(mono.block()), EXPECTED_RESULT); } @@ -67,7 +67,7 @@ public void saveActorStateTransactionally() { DaprHttp daprHttp = new DaprHttpProxy(Properties.SIDECAR_IP.get(), 3000, okHttpClient); DaprHttpClient = new DaprHttpClient(daprHttp); List ops = Collections.singletonList(new ActorStateOperation("UPSERT", "key", "value")); - Mono mono = DaprHttpClient.saveActorStateTransactionally("DemoActor", "1", ops); + Mono mono = DaprHttpClient.saveStateTransactionally("DemoActor", "1", ops); assertNull(mono.block()); } @@ -79,7 +79,7 @@ public void registerActorReminder() { DaprHttp daprHttp = new DaprHttpProxy(Properties.SIDECAR_IP.get(), 3000, okHttpClient); DaprHttpClient = new DaprHttpClient(daprHttp); Mono mono = - DaprHttpClient.registerActorReminder( + DaprHttpClient.registerReminder( "DemoActor", "1", "reminder", @@ -94,7 +94,7 @@ public void unregisterActorReminder() { .respond(EXPECTED_RESULT); DaprHttp daprHttp = new DaprHttpProxy(Properties.SIDECAR_IP.get(), 3000, okHttpClient); DaprHttpClient = new DaprHttpClient(daprHttp); - Mono mono = DaprHttpClient.unregisterActorReminder("DemoActor", "1", "reminder"); + Mono mono = DaprHttpClient.unregisterReminder("DemoActor", "1", "reminder"); assertNull(mono.block()); } @@ -127,7 +127,7 @@ public Response.Builder respond(Request request) { DaprHttp daprHttp = new DaprHttpProxy(Properties.SIDECAR_IP.get(), 3000, okHttpClient); DaprHttpClient = new DaprHttpClient(daprHttp); Mono mono = - DaprHttpClient.registerActorTimer( + DaprHttpClient.registerTimer( "DemoActor", "1", "timer", @@ -146,7 +146,7 @@ public void unregisterActorTimer() { .respond(EXPECTED_RESULT); DaprHttp daprHttp = new DaprHttpProxy(Properties.SIDECAR_IP.get(), 3000, okHttpClient); DaprHttpClient = new DaprHttpClient(daprHttp); - Mono mono = DaprHttpClient.unregisterActorTimer("DemoActor", "1", "timer"); + Mono mono = DaprHttpClient.unregisterTimer("DemoActor", "1", "timer"); assertNull(mono.block()); } } \ No newline at end of file diff --git a/sdk-actors/src/test/java/io/dapr/actors/runtime/DaprStateAsyncProviderTest.java b/sdk-actors/src/test/java/io/dapr/actors/runtime/DaprStateAsyncProviderTest.java index 62d0f956d7..75240a122e 100644 --- a/sdk-actors/src/test/java/io/dapr/actors/runtime/DaprStateAsyncProviderTest.java +++ b/sdk-actors/src/test/java/io/dapr/actors/runtime/DaprStateAsyncProviderTest.java @@ -78,7 +78,7 @@ public int hashCode() { public void happyCaseApply() { DaprClient daprClient = mock(DaprClient.class); when(daprClient - .saveActorStateTransactionally( + .saveStateTransactionally( eq("MyActor"), eq("123"), argThat(operations -> { @@ -133,41 +133,41 @@ public void happyCaseApply() { createUpdateChange("bytes", new byte[]{0x1})) .block(); - verify(daprClient).saveActorStateTransactionally(eq("MyActor"), eq("123"), any()); + verify(daprClient).saveStateTransactionally(eq("MyActor"), eq("123"), any()); } @Test public void happyCaseLoad() throws Exception { DaprClient daprClient = mock(DaprClient.class); when(daprClient - .getActorState(any(), any(), eq("name"))) + .getState(any(), any(), eq("name"))) .thenReturn(Mono.just(SERIALIZER.serialize("Jon Doe"))); when(daprClient - .getActorState(any(), any(), eq("zipcode"))) + .getState(any(), any(), eq("zipcode"))) .thenReturn(Mono.just(SERIALIZER.serialize(98021))); when(daprClient - .getActorState(any(), any(), eq("goals"))) + .getState(any(), any(), eq("goals"))) .thenReturn(Mono.just(SERIALIZER.serialize(98))); when(daprClient - .getActorState(any(), any(), eq("balance"))) + .getState(any(), any(), eq("balance"))) .thenReturn(Mono.just(SERIALIZER.serialize(46.55))); when(daprClient - .getActorState(any(), any(), eq("active"))) + .getState(any(), any(), eq("active"))) .thenReturn(Mono.just(SERIALIZER.serialize(true))); when(daprClient - .getActorState(any(), any(), eq("customer"))) + .getState(any(), any(), eq("customer"))) .thenReturn(Mono.just("{ \"id\": 1000, \"name\": \"Roxane\"}".getBytes())); when(daprClient - .getActorState(any(), any(), eq("anotherCustomer"))) + .getState(any(), any(), eq("anotherCustomer"))) .thenReturn(Mono.just("{ \"id\": 2000, \"name\": \"Max\"}".getBytes())); when(daprClient - .getActorState(any(), any(), eq("nullCustomer"))) + .getState(any(), any(), eq("nullCustomer"))) .thenReturn(Mono.empty()); when(daprClient - .getActorState(any(), any(), eq("bytes"))) + .getState(any(), any(), eq("bytes"))) .thenReturn(Mono.just("\"QQ==\"".getBytes())); when(daprClient - .getActorState(any(), any(), eq("emptyBytes"))) + .getState(any(), any(), eq("emptyBytes"))) .thenReturn(Mono.just(new byte[0])); DaprStateAsyncProvider provider = new DaprStateAsyncProvider(daprClient, SERIALIZER); @@ -203,33 +203,33 @@ public void happyCaseContains() { // Keys that exists. when(daprClient - .getActorState(any(), any(), eq("name"))) + .getState(any(), any(), eq("name"))) .thenReturn(Mono.just("Jon Doe".getBytes())); when(daprClient - .getActorState(any(), any(), eq("zipcode"))) + .getState(any(), any(), eq("zipcode"))) .thenReturn(Mono.just("98021".getBytes())); when(daprClient - .getActorState(any(), any(), eq("goals"))) + .getState(any(), any(), eq("goals"))) .thenReturn(Mono.just("98".getBytes())); when(daprClient - .getActorState(any(), any(), eq("balance"))) + .getState(any(), any(), eq("balance"))) .thenReturn(Mono.just("46.55".getBytes())); when(daprClient - .getActorState(any(), any(), eq("active"))) + .getState(any(), any(), eq("active"))) .thenReturn(Mono.just("true".getBytes())); when(daprClient - .getActorState(any(), any(), eq("customer"))) + .getState(any(), any(), eq("customer"))) .thenReturn(Mono.just("{ \"id\": \"3000\", \"name\": \"Ely\" }".getBytes())); // Keys that do not exist. when(daprClient - .getActorState(any(), any(), eq("Does not exist"))) + .getState(any(), any(), eq("Does not exist"))) .thenReturn(Mono.empty()); when(daprClient - .getActorState(any(), any(), eq("NAME"))) + .getState(any(), any(), eq("NAME"))) .thenReturn(Mono.empty()); when(daprClient - .getActorState(any(), any(), eq(null))) + .getState(any(), any(), eq(null))) .thenReturn(Mono.empty()); DaprStateAsyncProvider provider = new DaprStateAsyncProvider(daprClient, SERIALIZER); 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 3d59ae8c56..d13532d058 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 void stringInStringOut() { // these should only call the actor methods for ActorChild. The implementations in ActorParent will throw. Assert.assertEquals( "abcabc", - proxy.invokeActorMethod("stringInStringOut", "abc", String.class).block()); + proxy.invoke("stringInStringOut", "abc", String.class).block()); } @Test @@ -233,11 +233,11 @@ public void stringInBooleanOut() { // these should only call the actor methods for ActorChild. The implementations in ActorParent will throw. Assert.assertEquals( false, - proxy.invokeActorMethod("stringInBooleanOut", "hello world", Boolean.class).block()); + proxy.invoke("stringInBooleanOut", "hello world", Boolean.class).block()); Assert.assertEquals( true, - proxy.invokeActorMethod("stringInBooleanOut", "true", Boolean.class).block()); + proxy.invoke("stringInBooleanOut", "true", Boolean.class).block()); } @Test @@ -247,14 +247,14 @@ public void stringInVoidOut() { // stringInVoidOut() has not been invoked so this is false Assert.assertEquals( false, - actorProxy.invokeActorMethod("methodReturningVoidInvoked", Boolean.class).block()); + actorProxy.invoke("methodReturningVoidInvoked", Boolean.class).block()); // these should only call the actor methods for ActorChild. The implementations in ActorParent will throw. - actorProxy.invokeActorMethod("stringInVoidOut", "hello world").block(); + actorProxy.invoke("stringInVoidOut", "hello world").block(); Assert.assertEquals( true, - actorProxy.invokeActorMethod("methodReturningVoidInvoked", Boolean.class).block()); + actorProxy.invoke("methodReturningVoidInvoked", Boolean.class).block()); } @Test(expected = IllegalMonitorStateException.class) @@ -262,7 +262,7 @@ public void stringInVoidOutIntentionallyThrows() { ActorProxy actorProxy = createActorProxyForActorChild(); // these should only call the actor methods for ActorChild. The implementations in ActorParent will throw. - actorProxy.invokeActorMethod("stringInVoidOutIntentionallyThrows", "hello world").block(); + actorProxy.invoke("stringInVoidOutIntentionallyThrows", "hello world").block(); } @Test @@ -271,7 +271,7 @@ public void classInClassOut() { MyData d = new MyData("hi", 3); // this should only call the actor methods for ActorChild. The implementations in ActorParent will throw. - MyData response = actorProxy.invokeActorMethod("classInClassOut", d, MyData.class).block(); + MyData response = actorProxy.invoke("classInClassOut", d, MyData.class).block(); Assert.assertEquals( "hihi", @@ -288,26 +288,26 @@ public void testInheritedActorMethods() { Assert.assertEquals( "www", - actorProxy.invokeActorMethod("onlyImplementedInParentStringInStringOut", "w", String.class).block()); + actorProxy.invoke("onlyImplementedInParentStringInStringOut", "w", String.class).block()); Assert.assertEquals( true, - actorProxy.invokeActorMethod("onlyImplementedInParentStringInBooleanOut", "icecream", Boolean.class).block()); + actorProxy.invoke("onlyImplementedInParentStringInBooleanOut", "icecream", Boolean.class).block()); // onlyImplementedInParentStringInVoidOut() has not been invoked so this is false Assert.assertEquals( false, - actorProxy.invokeActorMethod("methodReturningVoidInvoked", Boolean.class).block()); + actorProxy.invoke("methodReturningVoidInvoked", Boolean.class).block()); - actorProxy.invokeActorMethod("onlyImplementedInParentStringInVoidOut", "icecream", Boolean.class).block(); + actorProxy.invoke("onlyImplementedInParentStringInVoidOut", "icecream", Boolean.class).block(); // now it should return true. Assert.assertEquals( true, - actorProxy.invokeActorMethod("methodReturningVoidInvoked", Boolean.class).block()); + actorProxy.invoke("methodReturningVoidInvoked", Boolean.class).block()); MyData d = new MyData("hi", 3); - MyData response = actorProxy.invokeActorMethod("onlyImplementedInParentClassInClassOut", d, MyData.class).block(); + MyData response = actorProxy.invoke("onlyImplementedInParentClassInClassOut", d, MyData.class).block(); Assert.assertEquals( "hihihi", @@ -327,7 +327,7 @@ private ActorProxy createActorProxyForActorChild() { // Mock daprClient for ActorProxy only, not for runtime. DaprClientStub daprClient = mock(DaprClientStub.class); - when(daprClient.invokeActorMethod( + when(daprClient.invoke( eq(context.getActorTypeInformation().getName()), eq(actorId.toString()), any(), @@ -350,10 +350,10 @@ private ActorProxy createActorProxyForActorChild() { private static ActorRuntimeContext createContext() { DaprClient daprClient = mock(DaprClient.class); - when(daprClient.registerActorTimer(any(), any(), any(), any())).thenReturn(Mono.empty()); - when(daprClient.registerActorReminder(any(), any(), any(), any())).thenReturn(Mono.empty()); - when(daprClient.unregisterActorTimer(any(), any(), any())).thenReturn(Mono.empty()); - when(daprClient.unregisterActorReminder(any(), any(), any())).thenReturn(Mono.empty()); + when(daprClient.registerTimer(any(), any(), any(), any())).thenReturn(Mono.empty()); + when(daprClient.registerReminder(any(), any(), any(), any())).thenReturn(Mono.empty()); + when(daprClient.unregisterTimer(any(), any(), any())).thenReturn(Mono.empty()); + when(daprClient.unregisterReminder(any(), any(), any())).thenReturn(Mono.empty()); return new ActorRuntimeContext( mock(ActorRuntime.class), 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 a0a418dec6..34260145f7 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 void stringInBooleanOut1() { // these should only call the actor methods for ActorChild. The implementations in ActorParent will throw. Assert.assertEquals( false, - proxy.invokeActorMethod("stringInBooleanOut", "hello world", Boolean.class).block()); + proxy.invoke("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 void stringInBooleanOut2() { // these should only call the actor methods for ActorChild. The implementations in ActorParent will throw. Assert.assertEquals( true, - proxy.invokeActorMethod("stringInBooleanOut", "true", Boolean.class).block()); + proxy.invoke("stringInBooleanOut", "true", Boolean.class).block()); } private static ActorId newActorId() { @@ -146,7 +146,7 @@ private ActorProxy createActorProxyForActorChild() { // Mock daprClient for ActorProxy only, not for runtime. DaprClientStub daprClient = mock(DaprClientStub.class); - when(daprClient.invokeActorMethod( + when(daprClient.invoke( eq(context.getActorTypeInformation().getName()), eq(actorId.toString()), any(), @@ -169,10 +169,10 @@ private ActorProxy createActorProxyForActorChild() { private static ActorRuntimeContext createContext() { DaprClient daprClient = mock(DaprClient.class); - when(daprClient.registerActorTimer(any(), any(), any(), any())).thenReturn(Mono.empty()); - when(daprClient.registerActorReminder(any(), any(), any(), any())).thenReturn(Mono.empty()); - when(daprClient.unregisterActorTimer(any(), any(), any())).thenReturn(Mono.empty()); - when(daprClient.unregisterActorReminder(any(), any(), any())).thenReturn(Mono.empty()); + when(daprClient.registerTimer(any(), any(), any(), any())).thenReturn(Mono.empty()); + when(daprClient.registerReminder(any(), any(), any(), any())).thenReturn(Mono.empty()); + when(daprClient.unregisterTimer(any(), any(), any())).thenReturn(Mono.empty()); + when(daprClient.unregisterReminder(any(), any(), any())).thenReturn(Mono.empty()); return new ActorRuntimeContext( mock(ActorRuntime.class), diff --git a/sdk-tests/src/test/java/io/dapr/actors/runtime/DaprClientHttpUtils.java b/sdk-tests/src/test/java/io/dapr/actors/runtime/DaprClientHttpUtils.java index 4f060d16c3..2faa404ff4 100644 --- a/sdk-tests/src/test/java/io/dapr/actors/runtime/DaprClientHttpUtils.java +++ b/sdk-tests/src/test/java/io/dapr/actors/runtime/DaprClientHttpUtils.java @@ -16,6 +16,6 @@ public static void unregisterActorReminder( String actorType, String actorId, String reminderName) throws Exception { - new DaprHttpClient(client).unregisterActorReminder(actorType, actorId, reminderName).block(); + new DaprHttpClient(client).unregisterReminder(actorType, actorId, reminderName).block(); } } 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 4cd0b1199e..65c37a4300 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 void init() throws Exception { public void tearDown() { // call unregister logger.debug("Calling actor method 'stopReminder' to unregister reminder"); - proxy.invokeActorMethod("stopReminder", "myReminder").block(); + proxy.invoke("stopReminder", "myReminder").block(); } /** @@ -83,7 +83,7 @@ public void reminderRecoveryTest() throws Exception { clientAppRun.use(); logger.debug("Invoking actor method 'startReminder' which will register a reminder"); - proxy.invokeActorMethod("startReminder", "myReminder").block(); + proxy.invoke("startReminder", "myReminder").block(); logger.debug("Pausing 7 seconds to allow reminder to fire"); Thread.sleep(7000); @@ -92,7 +92,7 @@ public void reminderRecoveryTest() throws Exception { validateMethodCalls(logs, METHOD_NAME, 3); int originalActorHostIdentifier = Integer.parseInt( - proxy.invokeActorMethod("getIdentifier", String.class).block()); + proxy.invoke("getIdentifier", String.class).block()); if (originalActorHostIdentifier == firstAppRun.getHttpPort()) { firstAppRun.stop(); } @@ -110,7 +110,7 @@ public void reminderRecoveryTest() throws Exception { validateMethodCalls(newLogs2, METHOD_NAME, countMethodCalls(newLogs, METHOD_NAME) + 4); int newActorHostIdentifier = Integer.parseInt( - proxy.invokeActorMethod("getIdentifier", String.class).block()); + proxy.invoke("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 f33c575340..8f862d5e18 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 void init() throws Exception { public void tearDown() { // call unregister logger.debug("Calling actor method 'stopReminder' to unregister reminder"); - proxy.invokeActorMethod("stopReminder", "myReminder").block(); + proxy.invoke("stopReminder", "myReminder").block(); } /** @@ -69,7 +69,7 @@ public void tearDown() { @Test public void reminderRecoveryTest() throws Exception { logger.debug("Invoking actor method 'startReminder' which will register a reminder"); - proxy.invokeActorMethod("startReminder", "myReminder").block(); + proxy.invoke("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 a715ac8fd0..b2e6c00744 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 void writeReadState() throws Exception { // Validate conditional read works. callWithRetry(() -> { logger.debug("Invoking readMessage where data is not present yet ... "); - String result = proxy.invokeActorMethod("readMessage", String.class).block(); + String result = proxy.invoke("readMessage", String.class).block(); assertNull(result); }, 5000); callWithRetry(() -> { logger.debug("Invoking writeMessage ... "); - proxy.invokeActorMethod("writeMessage", message).block(); + proxy.invoke("writeMessage", message).block(); }, 5000); callWithRetry(() -> { logger.debug("Invoking readMessage where data is probably still cached ... "); - String result = proxy.invokeActorMethod("readMessage", String.class).block(); + String result = proxy.invoke("readMessage", String.class).block(); assertEquals(message, result); }, 5000); @@ -96,45 +96,45 @@ public void writeReadState() throws Exception { mydata.value = "My data value."; callWithRetry(() -> { logger.debug("Invoking writeData with object ... "); - proxy.invokeActorMethod("writeData", mydata).block(); + proxy.invoke("writeData", mydata).block(); }, 5000); callWithRetry(() -> { logger.debug("Invoking readData where data is probably still cached ... "); - StatefulActor.MyData result = proxy.invokeActorMethod("readData", StatefulActor.MyData.class).block(); + StatefulActor.MyData result = proxy.invoke("readData", StatefulActor.MyData.class).block(); assertEquals(mydata.value, result.value); }, 5000); callWithRetry(() -> { logger.debug("Invoking writeName ... "); - proxy.invokeActorMethod("writeName", name).block(); + proxy.invoke("writeName", name).block(); }, 5000); callWithRetry(() -> { logger.debug("Invoking readName where data is probably still cached ... "); - String result = proxy.invokeActorMethod("readName", String.class).block(); + String result = proxy.invoke("readName", String.class).block(); assertEquals(name, result); }, 5000); callWithRetry(() -> { logger.debug("Invoking writeName with empty content... "); - proxy.invokeActorMethod("writeName", "").block(); + proxy.invoke("writeName", "").block(); }, 5000); callWithRetry(() -> { logger.debug("Invoking readName where empty content is probably still cached ... "); - String result = proxy.invokeActorMethod("readName", String.class).block(); + String result = proxy.invoke("readName", String.class).block(); assertEquals("", result); }, 5000); callWithRetry(() -> { logger.debug("Invoking writeBytes ... "); - proxy.invokeActorMethod("writeBytes", bytes).block(); + proxy.invoke("writeBytes", bytes).block(); }, 5000); callWithRetry(() -> { logger.debug("Invoking readBytes where data is probably still cached ... "); - byte[] result = proxy.invokeActorMethod("readBytes", byte[].class).block(); + byte[] result = proxy.invoke("readBytes", byte[].class).block(); assertArrayEquals(bytes, result); }, 5000); @@ -165,26 +165,26 @@ public void writeReadState() throws Exception { callWithRetry(() -> { logger.debug("Invoking readMessage where data is not cached ... "); - String result = newProxy.invokeActorMethod("readMessage", String.class).block(); + String result = newProxy.invoke("readMessage", String.class).block(); assertEquals(message, result); }, 5000); callWithRetry(() -> { logger.debug("Invoking readData where data is not cached ... "); - StatefulActor.MyData result = newProxy.invokeActorMethod("readData", StatefulActor.MyData.class).block(); + StatefulActor.MyData result = newProxy.invoke("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.invokeActorMethod("readName", String.class).block(); + String result = newProxy.invoke("readName", String.class).block(); assertEquals("", result); }, 5000); callWithRetry(() -> { logger.debug("Invoking readBytes where content is not cached ... "); - byte[] result = newProxy.invokeActorMethod("readBytes", byte[].class).block(); + byte[] result = newProxy.invoke("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 99c4c44ba8..245d8785ea 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 void timerRecoveryTest() throws Exception { ActorProxy proxy = proxyBuilder.build(actorId); logger.debug("Invoking actor method 'startTimer' which will register a timer"); - proxy.invokeActorMethod("startTimer", "myTimer").block(); + proxy.invoke("startTimer", "myTimer").block(); logger.debug("Pausing 7 seconds to allow timer to fire"); Thread.sleep(7000); @@ -80,7 +80,7 @@ public void timerRecoveryTest() throws Exception { // call unregister logger.debug("Calling actor method 'stopTimer' to unregister timer"); - proxy.invokeActorMethod("stopTimer", "myTimer").block(); + proxy.invoke("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 dd101ebf0f..1cf0e74ad6 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 void actorTest1() throws Exception { logger.debug("Invoking Say from Proxy"); callWithRetry(() -> { logger.debug("Invoking Say from Proxy"); - String sayResponse = proxy.invokeActorMethod("say", "message", String.class).block(); + String sayResponse = proxy.invoke("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.invokeActorMethod("startTimer", "myTimer").block(); + proxy.invoke("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 void actorTest1() throws Exception { // the actor method called below should reverse the input String msg = "message" + i; String reversedString = new StringBuilder(msg).reverse().toString(); - String output = proxy.invokeActorMethod("say", "message" + i, String.class).block(); + String output = proxy.invoke("say", "message" + i, String.class).block(); assertTrue(reversedString.equals(output)); }); logger.debug("Calling method to register reminder named " + REMINDER_NAME); - proxy.invokeActorMethod("startReminder", REMINDER_NAME).block(); + proxy.invoke("startReminder", REMINDER_NAME).block(); logger.debug("Pausing 7 seconds to allow timer and reminders to fire"); Thread.sleep(7000); @@ -126,14 +126,14 @@ public void actorTest1() throws Exception { // call unregister logger.debug("Calling actor method 'stopTimer' to unregister timer"); - proxy.invokeActorMethod("stopTimer", "myTimer").block(); + proxy.invoke("stopTimer", "myTimer").block(); logger.debug("Calling actor method 'stopReminder' to unregister reminder"); - proxy.invokeActorMethod("stopReminder", REMINDER_NAME).block(); + proxy.invoke("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.invokeActorMethod("say", "message" + i, String.class).block(); + proxy.invoke("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 fb58958107..bac5ba9f34 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 @@ static void validateMethodCalls(List logs, String methodName * @return List of call log. */ static List fetchMethodCallLogs(ActorProxy proxy) { - ArrayList logs = proxy.invokeActorMethod("getCallLog", ArrayList.class).block(); + ArrayList logs = proxy.invoke("getCallLog", ArrayList.class).block(); ArrayList trackers = new ArrayList(); for(String t : logs) { String[] toks = t.split("\\|"); diff --git a/sdk-tests/src/test/java/io/dapr/it/binding/http/BindingIT.java b/sdk-tests/src/test/java/io/dapr/it/binding/http/BindingIT.java index cb3b8c9413..2368e57836 100644 --- a/sdk-tests/src/test/java/io/dapr/it/binding/http/BindingIT.java +++ b/sdk-tests/src/test/java/io/dapr/it/binding/http/BindingIT.java @@ -95,7 +95,7 @@ public void inputOutputBinding() throws Exception { callWithRetry(() -> { System.out.println("Checking results ..."); final List messages = - client.invokeService( + client.invokeMethod( daprRun.getAppName(), "messages", null, diff --git a/sdk-tests/src/test/java/io/dapr/it/methodinvoke/http/MethodInvokeIT.java b/sdk-tests/src/test/java/io/dapr/it/methodinvoke/http/MethodInvokeIT.java index fd1f26dbf6..ceba12360c 100644 --- a/sdk-tests/src/test/java/io/dapr/it/methodinvoke/http/MethodInvokeIT.java +++ b/sdk-tests/src/test/java/io/dapr/it/methodinvoke/http/MethodInvokeIT.java @@ -74,21 +74,21 @@ public void testInvoke() throws Exception { for (int i = 0; i < NUM_MESSAGES; i++) { String message = String.format("This is message #%d", i); //Publishing messages - client.invokeService(daprRun.getAppName(), "messages", message.getBytes(), HttpExtension.POST).block(); + client.invokeMethod(daprRun.getAppName(), "messages", message.getBytes(), HttpExtension.POST).block(); System.out.println("Invoke method messages : " + message); } - Map messages = client.invokeService(daprRun.getAppName(), "messages", null, + Map messages = client.invokeMethod(daprRun.getAppName(), "messages", null, HttpExtension.GET, Map.class).block(); assertEquals(10, messages.size()); - client.invokeService(daprRun.getAppName(), "messages/1", null, HttpExtension.DELETE).block(); + client.invokeMethod(daprRun.getAppName(), "messages/1", null, HttpExtension.DELETE).block(); - messages = client.invokeService(daprRun.getAppName(), "messages", null, HttpExtension.GET, Map.class).block(); + messages = client.invokeMethod(daprRun.getAppName(), "messages", null, HttpExtension.GET, Map.class).block(); assertEquals(9, messages.size()); - client.invokeService(daprRun.getAppName(), "messages/2", "updated message".getBytes(), HttpExtension.PUT).block(); - messages = client.invokeService(daprRun.getAppName(), "messages", null, HttpExtension.GET, Map.class).block(); + client.invokeMethod(daprRun.getAppName(), "messages/2", "updated message".getBytes(), HttpExtension.PUT).block(); + messages = client.invokeMethod(daprRun.getAppName(), "messages", null, HttpExtension.GET, Map.class).block(); assertEquals("updated message", messages.get("2")); } } @@ -102,16 +102,16 @@ public void testInvokeWithObjects() throws Exception { person.setLastName(String.format("Last Name %d", i)); person.setBirthDate(new Date()); //Publishing messages - client.invokeService(daprRun.getAppName(), "persons", person, HttpExtension.POST).block(); + client.invokeMethod(daprRun.getAppName(), "persons", person, HttpExtension.POST).block(); System.out.println("Invoke method persons with parameter : " + person); } - List persons = Arrays.asList(client.invokeService(daprRun.getAppName(), "persons", null, HttpExtension.GET, Person[].class).block()); + List persons = Arrays.asList(client.invokeMethod(daprRun.getAppName(), "persons", null, HttpExtension.GET, Person[].class).block()); assertEquals(10, persons.size()); - client.invokeService(daprRun.getAppName(), "persons/1", null, HttpExtension.DELETE).block(); + client.invokeMethod(daprRun.getAppName(), "persons/1", null, HttpExtension.DELETE).block(); - persons = Arrays.asList(client.invokeService(daprRun.getAppName(), "persons", null, HttpExtension.GET, Person[].class).block()); + persons = Arrays.asList(client.invokeMethod(daprRun.getAppName(), "persons", null, HttpExtension.GET, Person[].class).block()); assertEquals(9, persons.size()); Person person = new Person(); @@ -119,9 +119,9 @@ public void testInvokeWithObjects() throws Exception { person.setLastName("Smith"); person.setBirthDate(Calendar.getInstance().getTime()); - client.invokeService(daprRun.getAppName(), "persons/2", person, HttpExtension.PUT).block(); + client.invokeMethod(daprRun.getAppName(), "persons/2", person, HttpExtension.PUT).block(); - persons = Arrays.asList(client.invokeService(daprRun.getAppName(), "persons", null, HttpExtension.GET, Person[].class).block()); + persons = Arrays.asList(client.invokeMethod(daprRun.getAppName(), "persons", null, HttpExtension.GET, Person[].class).block()); Person resultPerson = persons.get(1); assertEquals("John", resultPerson.getName()); assertEquals("Smith", resultPerson.getLastName()); diff --git a/sdk-tests/src/test/java/io/dapr/it/pubsub/http/PubSubIT.java b/sdk-tests/src/test/java/io/dapr/it/pubsub/http/PubSubIT.java index f2c0aa9507..6fea1431c6 100644 --- a/sdk-tests/src/test/java/io/dapr/it/pubsub/http/PubSubIT.java +++ b/sdk-tests/src/test/java/io/dapr/it/pubsub/http/PubSubIT.java @@ -95,7 +95,7 @@ public void testPubSub() throws Exception { callWithRetry(() -> { System.out.println("Checking results for topic " + TOPIC_NAME); - final List messages = client.invokeService(daprRun.getAppName(), "messages/testingtopic", null, HttpExtension.GET, List.class).block(); + final List messages = client.invokeMethod(daprRun.getAppName(), "messages/testingtopic", null, HttpExtension.GET, List.class).block(); assertEquals(11, messages.size()); for (int i = 0; i < NUM_MESSAGES; i++) { assertTrue(messages.toString(), messages.contains(String.format("This is message #%d on topic %s", i, TOPIC_NAME))); @@ -113,7 +113,7 @@ public void testPubSub() throws Exception { callWithRetry(() -> { System.out.println("Checking results for topic " + ANOTHER_TOPIC_NAME); - final List messages = client.invokeService(daprRun.getAppName(), "messages/anothertopic", null, HttpExtension.GET, List.class).block(); + final List messages = client.invokeMethod(daprRun.getAppName(), "messages/anothertopic", null, HttpExtension.GET, List.class).block(); assertEquals(10, messages.size()); for (int i = 0; i < NUM_MESSAGES; i++) { diff --git a/sdk-tests/src/test/java/io/dapr/it/state/AbstractStateClientIT.java b/sdk-tests/src/test/java/io/dapr/it/state/AbstractStateClientIT.java index eaf59c73b7..e0edf102d1 100644 --- a/sdk-tests/src/test/java/io/dapr/it/state/AbstractStateClientIT.java +++ b/sdk-tests/src/test/java/io/dapr/it/state/AbstractStateClientIT.java @@ -97,7 +97,7 @@ public void saveAndGetBulkStates() { //retrieves states in bulk. Mono>> response = - daprClient.getStates(STATE_STORE_NAME, Arrays.asList(stateKeyOne, stateKeyTwo, stateKeyThree), MyData.class); + daprClient.getBulkState(STATE_STORE_NAME, Arrays.asList(stateKeyOne, stateKeyTwo, stateKeyThree), MyData.class); List> result = response.block(); //Assert that the response is the correct one @@ -519,7 +519,7 @@ public void saveVerifyAndDeleteTransactionalStateString() { createState(stateKey, null, null, data)); //create of the deferred call to DAPR to execute the transaction - Mono saveResponse = daprClient.executeTransaction(STATE_STORE_NAME, Collections.singletonList(operation)); + Mono saveResponse = daprClient.executeStateTransaction(STATE_STORE_NAME, Collections.singletonList(operation)); //execute the save action saveResponse.block(); @@ -538,7 +538,7 @@ public void saveVerifyAndDeleteTransactionalStateString() { TransactionalStateOperation.OperationType.DELETE, createState(stateKey, null, null, data)); //create of the deferred call to DAPR to execute the transaction - Mono deleteResponse = daprClient.executeTransaction(STATE_STORE_NAME, Collections.singletonList(operation)); + Mono deleteResponse = daprClient.executeStateTransaction(STATE_STORE_NAME, Collections.singletonList(operation)); //execute the delete action deleteResponse.block(); @@ -568,7 +568,7 @@ public void saveVerifyAndDeleteTransactionalState() { Assert.assertNotNull(daprClient); //create of the deferred call to DAPR to execute the transaction - Mono saveResponse = daprClient.executeTransaction(STATE_STORE_NAME, Collections.singletonList(operation)); + Mono saveResponse = daprClient.executeStateTransaction(STATE_STORE_NAME, Collections.singletonList(operation)); //execute the save action saveResponse.block(); @@ -589,7 +589,7 @@ public void saveVerifyAndDeleteTransactionalState() { TransactionalStateOperation.OperationType.DELETE, createState(stateKey, null, null, data)); //create of the deferred call to DAPR to execute the transaction - Mono deleteResponse = daprClient.executeTransaction(STATE_STORE_NAME, Collections.singletonList(operation)); + Mono deleteResponse = daprClient.executeStateTransaction(STATE_STORE_NAME, Collections.singletonList(operation)); //execute the delete action deleteResponse.block(); diff --git a/sdk-tests/src/test/java/io/dapr/it/state/GRPCStateClientIT.java b/sdk-tests/src/test/java/io/dapr/it/state/GRPCStateClientIT.java index 40f12b4f62..1db1f5302e 100644 --- a/sdk-tests/src/test/java/io/dapr/it/state/GRPCStateClientIT.java +++ b/sdk-tests/src/test/java/io/dapr/it/state/GRPCStateClientIT.java @@ -73,7 +73,7 @@ public void getStatesStoreNotFound() { assertThrowsDaprException( "INVALID_ARGUMENT", "INVALID_ARGUMENT: state store unknown state store is not found", - () -> daprClient.getStates( + () -> daprClient.getBulkState( "unknown state store", Collections.singletonList(stateKey), byte[].class).block()); diff --git a/sdk-tests/src/test/java/io/dapr/it/state/HttpStateClientIT.java b/sdk-tests/src/test/java/io/dapr/it/state/HttpStateClientIT.java index 62f29aefb8..dfb44db72d 100644 --- a/sdk-tests/src/test/java/io/dapr/it/state/HttpStateClientIT.java +++ b/sdk-tests/src/test/java/io/dapr/it/state/HttpStateClientIT.java @@ -72,7 +72,7 @@ public void getStatesStoreNotFound() { assertThrowsDaprException( "ERR_STATE_STORE_NOT_FOUND", "ERR_STATE_STORE_NOT_FOUND: state store unknown%20state%20store is not found", - () -> daprClient.getStates( + () -> daprClient.getBulkState( "unknown state store", Collections.singletonList(stateKey), byte[].class).block()); diff --git a/sdk/src/main/java/io/dapr/client/AbstractDaprClient.java b/sdk/src/main/java/io/dapr/client/AbstractDaprClient.java index 35128f63c4..80c49e94ee 100644 --- a/sdk/src/main/java/io/dapr/client/AbstractDaprClient.java +++ b/sdk/src/main/java/io/dapr/client/AbstractDaprClient.java @@ -9,11 +9,11 @@ import io.dapr.client.domain.DeleteStateRequestBuilder; import io.dapr.client.domain.ExecuteStateTransactionRequest; import io.dapr.client.domain.ExecuteStateTransactionRequestBuilder; +import io.dapr.client.domain.GetBulkStateRequestBuilder; import io.dapr.client.domain.GetSecretRequest; import io.dapr.client.domain.GetSecretRequestBuilder; import io.dapr.client.domain.GetStateRequest; import io.dapr.client.domain.GetStateRequestBuilder; -import io.dapr.client.domain.GetStatesRequestBuilder; import io.dapr.client.domain.HttpExtension; import io.dapr.client.domain.InvokeBindingRequest; import io.dapr.client.domain.InvokeBindingRequestBuilder; @@ -72,155 +72,156 @@ abstract class AbstractDaprClient implements DaprClient { * {@inheritDoc} */ @Override - public Mono publishEvent(String pubsubName, String topic, Object data) { - return this.publishEvent(pubsubName, topic, data, null); + public Mono publishEvent(String pubsubName, String topicName, Object data) { + return this.publishEvent(pubsubName, topicName, data, null); } /** * {@inheritDoc} */ @Override - public Mono publishEvent(String pubsubName, String topic, Object data, Map metadata) { - PublishEventRequest req = new PublishEventRequestBuilder(pubsubName, topic, data).withMetadata(metadata).build(); + public Mono publishEvent(String pubsubName, String topicName, Object data, Map metadata) { + PublishEventRequest req = new PublishEventRequestBuilder(pubsubName, topicName, + data).withMetadata(metadata).build(); return this.publishEvent(req).then(); } /** * {@inheritDoc} */ - public Mono invokeService( + public Mono invokeMethod( String appId, - String method, - Object request, + String methodName, + Object data, HttpExtension httpExtension, Map metadata, TypeRef type) { - InvokeServiceRequestBuilder builder = new InvokeServiceRequestBuilder(appId, method); + InvokeServiceRequestBuilder builder = new InvokeServiceRequestBuilder(appId, methodName); InvokeServiceRequest req = builder - .withBody(request) + .withBody(data) .withHttpExtension(httpExtension) .withMetadata(metadata) .withContentType(objectSerializer.getContentType()) .build(); - return this.invokeService(req, type).map(r -> r.getObject()); + return this.invokeMethod(req, type).map(r -> r.getObject()); } /** * {@inheritDoc} */ @Override - public Mono invokeService( + public Mono invokeMethod( String appId, - String method, + String methodName, Object request, HttpExtension httpExtension, Map metadata, Class clazz) { - return this.invokeService(appId, method, request, httpExtension, metadata, TypeRef.get(clazz)); + return this.invokeMethod(appId, methodName, request, httpExtension, metadata, TypeRef.get(clazz)); } /** * {@inheritDoc} */ @Override - public Mono invokeService( - String appId, String method, HttpExtension httpExtension, Map metadata, TypeRef type) { - return this.invokeService(appId, method, null, httpExtension, metadata, type); + public Mono invokeMethod( + String appId, String methodName, HttpExtension httpExtension, Map metadata, TypeRef type) { + return this.invokeMethod(appId, methodName, null, httpExtension, metadata, type); } /** * {@inheritDoc} */ @Override - public Mono invokeService( - String appId, String method, HttpExtension httpExtension, Map metadata, Class clazz) { - return this.invokeService(appId, method, null, httpExtension, metadata, TypeRef.get(clazz)); + public Mono invokeMethod( + String appId, String methodName, HttpExtension httpExtension, Map metadata, Class clazz) { + return this.invokeMethod(appId, methodName, null, httpExtension, metadata, TypeRef.get(clazz)); } /** * {@inheritDoc} */ @Override - public Mono invokeService(String appId, String method, Object request, HttpExtension httpExtension, - TypeRef type) { - return this.invokeService(appId, method, request, httpExtension, null, type); + public Mono invokeMethod(String appId, String methodName, Object request, HttpExtension httpExtension, + TypeRef type) { + return this.invokeMethod(appId, methodName, request, httpExtension, null, type); } /** * {@inheritDoc} */ @Override - public Mono invokeService(String appId, String method, Object request, HttpExtension httpExtension, - Class clazz) { - return this.invokeService(appId, method, request, httpExtension, null, TypeRef.get(clazz)); + public Mono invokeMethod(String appId, String methodName, Object request, HttpExtension httpExtension, + Class clazz) { + return this.invokeMethod(appId, methodName, request, httpExtension, null, TypeRef.get(clazz)); } /** * {@inheritDoc} */ @Override - public Mono invokeService(String appId, String method, Object request, HttpExtension httpExtension) { - return this.invokeService(appId, method, request, httpExtension, null, TypeRef.BYTE_ARRAY).then(); + public Mono invokeMethod(String appId, String methodName, Object request, HttpExtension httpExtension) { + return this.invokeMethod(appId, methodName, request, httpExtension, null, TypeRef.BYTE_ARRAY).then(); } /** * {@inheritDoc} */ @Override - public Mono invokeService( - String appId, String method, Object request, HttpExtension httpExtension, Map metadata) { - return this.invokeService(appId, method, request, httpExtension, metadata, TypeRef.BYTE_ARRAY).then(); + public Mono invokeMethod( + String appId, String methodName, Object request, HttpExtension httpExtension, Map metadata) { + return this.invokeMethod(appId, methodName, request, httpExtension, metadata, TypeRef.BYTE_ARRAY).then(); } /** * {@inheritDoc} */ @Override - public Mono invokeService( - String appId, String method, HttpExtension httpExtension, Map metadata) { - return this.invokeService(appId, method, null, httpExtension, metadata, TypeRef.BYTE_ARRAY).then(); + public Mono invokeMethod( + String appId, String methodName, HttpExtension httpExtension, Map metadata) { + return this.invokeMethod(appId, methodName, null, httpExtension, metadata, TypeRef.BYTE_ARRAY).then(); } /** * {@inheritDoc} */ @Override - public Mono invokeService( - String appId, String method, byte[] request, HttpExtension httpExtension, Map metadata) { - return this.invokeService(appId, method, request, httpExtension, metadata, TypeRef.BYTE_ARRAY); + public Mono invokeMethod( + String appId, String methodName, byte[] request, HttpExtension httpExtension, Map metadata) { + return this.invokeMethod(appId, methodName, request, httpExtension, metadata, TypeRef.BYTE_ARRAY); } /** * {@inheritDoc} */ @Override - public Mono invokeBinding(String name, String operation, Object data) { - return this.invokeBinding(name, operation, data, null, TypeRef.BYTE_ARRAY).then(); + public Mono invokeBinding(String bindingName, String operation, Object data) { + return this.invokeBinding(bindingName, operation, data, null, TypeRef.BYTE_ARRAY).then(); } /** * {@inheritDoc} */ @Override - public Mono invokeBinding(String name, String operation, byte[] data, Map metadata) { - return this.invokeBinding(name, operation, data, metadata, TypeRef.BYTE_ARRAY); + public Mono invokeBinding(String bindingName, String operation, byte[] data, Map metadata) { + return this.invokeBinding(bindingName, operation, data, metadata, TypeRef.BYTE_ARRAY); } /** * {@inheritDoc} */ @Override - public Mono invokeBinding(String name, String operation, Object data, TypeRef type) { - return this.invokeBinding(name, operation, data, null, type); + public Mono invokeBinding(String bindingName, String operation, Object data, TypeRef type) { + return this.invokeBinding(bindingName, operation, data, null, type); } /** * {@inheritDoc} */ @Override - public Mono invokeBinding(String name, String operation, Object data, Class clazz) { - return this.invokeBinding(name, operation, data, null, TypeRef.get(clazz)); + public Mono invokeBinding(String bindingName, String operation, Object data, Class clazz) { + return this.invokeBinding(bindingName, operation, data, null, TypeRef.get(clazz)); } /** @@ -228,8 +229,8 @@ public Mono invokeBinding(String name, String operation, Object data, Cla */ @Override public Mono invokeBinding( - String name, String operation, Object data, Map metadata, TypeRef type) { - InvokeBindingRequest request = new InvokeBindingRequestBuilder(name, operation) + String bindingName, String operation, Object data, Map metadata, TypeRef type) { + InvokeBindingRequest request = new InvokeBindingRequestBuilder(bindingName, operation) .withData(data) .withMetadata(metadata) .build(); @@ -242,40 +243,40 @@ public Mono invokeBinding( */ @Override public Mono invokeBinding( - String name, String operation, Object data, Map metadata, Class clazz) { - return this.invokeBinding(name, operation, data, metadata, TypeRef.get(clazz)); + String bindingName, String operation, Object data, Map metadata, Class clazz) { + return this.invokeBinding(bindingName, operation, data, metadata, TypeRef.get(clazz)); } /** * {@inheritDoc} */ @Override - public Mono> getState(String stateStoreName, State state, TypeRef type) { - return this.getState(stateStoreName, state.getKey(), state.getEtag(), state.getOptions(), type); + public Mono> getState(String storeName, State state, TypeRef type) { + return this.getState(storeName, state.getKey(), state.getEtag(), state.getOptions(), type); } /** * {@inheritDoc} */ @Override - public Mono> getState(String stateStoreName, State state, Class clazz) { - return this.getState(stateStoreName, state.getKey(), state.getEtag(), state.getOptions(), TypeRef.get(clazz)); + public Mono> getState(String storeName, State state, Class clazz) { + return this.getState(storeName, state.getKey(), state.getEtag(), state.getOptions(), TypeRef.get(clazz)); } /** * {@inheritDoc} */ @Override - public Mono> getState(String stateStoreName, String key, TypeRef type) { - return this.getState(stateStoreName, key, null, null, type); + public Mono> getState(String storeName, String key, TypeRef type) { + return this.getState(storeName, key, null, null, type); } /** * {@inheritDoc} */ @Override - public Mono> getState(String stateStoreName, String key, Class clazz) { - return this.getState(stateStoreName, key, null, null, TypeRef.get(clazz)); + public Mono> getState(String storeName, String key, Class clazz) { + return this.getState(storeName, key, null, null, TypeRef.get(clazz)); } /** @@ -283,8 +284,8 @@ public Mono> getState(String stateStoreName, String key, Class c */ @Override public Mono> getState( - String stateStoreName, String key, String etag, StateOptions options, TypeRef type) { - GetStateRequest request = new GetStateRequestBuilder(stateStoreName, key) + String storeName, String key, String etag, StateOptions options, TypeRef type) { + GetStateRequest request = new GetStateRequestBuilder(storeName, key) .withEtag(etag) .withStateOptions(options) .build(); @@ -297,80 +298,80 @@ public Mono> getState( */ @Override public Mono> getState( - String stateStoreName, String key, String etag, StateOptions options, Class clazz) { - return this.getState(stateStoreName, key, etag, options, TypeRef.get(clazz)); + String storeName, String key, String etag, StateOptions options, Class clazz) { + return this.getState(storeName, key, etag, options, TypeRef.get(clazz)); } /** * {@inheritDoc} */ @Override - public Mono>> getStates(String stateStoreName, List keys, TypeRef type) { - return this.getStates(new GetStatesRequestBuilder(stateStoreName, keys).build(), type).map(r -> r.getObject()); + public Mono>> getBulkState(String storeName, List keys, TypeRef type) { + return this.getBulkState(new GetBulkStateRequestBuilder(storeName, keys).build(), type).map(r -> r.getObject()); } /** * {@inheritDoc} */ @Override - public Mono>> getStates(String stateStoreName, List keys, Class clazz) { - return this.getStates(stateStoreName, keys, TypeRef.get(clazz)); + public Mono>> getBulkState(String storeName, List keys, Class clazz) { + return this.getBulkState(storeName, keys, TypeRef.get(clazz)); } /** * {@inheritDoc} */ @Override - public Mono executeTransaction(String stateStoreName, - List> operations) { - ExecuteStateTransactionRequest request = new ExecuteStateTransactionRequestBuilder(stateStoreName) + public Mono executeStateTransaction(String storeName, + List> operations) { + ExecuteStateTransactionRequest request = new ExecuteStateTransactionRequestBuilder(storeName) .withTransactionalStates(operations) .build(); - return executeTransaction(request).then(); + return executeStateTransaction(request).then(); } /** * {@inheritDoc} */ @Override - public Mono saveStates(String stateStoreName, List> states) { - SaveStateRequest request = new SaveStateRequestBuilder(stateStoreName) + public Mono saveBulkState(String storeName, List> states) { + SaveStateRequest request = new SaveStateRequestBuilder(storeName) .withStates(states) .build(); - return this.saveStates(request).then(); + return this.saveBulkState(request).then(); } /** * {@inheritDoc} */ @Override - public Mono saveState(String stateStoreName, String key, Object value) { - return this.saveState(stateStoreName, key, null, value, null); + public Mono saveState(String storeName, String key, Object value) { + return this.saveState(storeName, key, null, value, null); } /** * {@inheritDoc} */ @Override - public Mono saveState(String stateStoreName, String key, String etag, Object value, StateOptions options) { + public Mono saveState(String storeName, String key, String etag, Object value, StateOptions options) { State state = new State<>(value, key, etag, options); - return this.saveStates(stateStoreName, Collections.singletonList(state)); + return this.saveBulkState(storeName, Collections.singletonList(state)); } /** * {@inheritDoc} */ @Override - public Mono deleteState(String stateStoreName, String key) { - return this.deleteState(stateStoreName, key, null, null); + public Mono deleteState(String storeName, String key) { + return this.deleteState(storeName, key, null, null); } /** * {@inheritDoc} */ @Override - public Mono deleteState(String stateStoreName, String key, String etag, StateOptions options) { - DeleteStateRequest request = new DeleteStateRequestBuilder(stateStoreName, key) + public Mono deleteState(String storeName, String key, String etag, StateOptions options) { + DeleteStateRequest request = new DeleteStateRequestBuilder(storeName, key) .withEtag(etag) .withStateOptions(options) .build(); @@ -381,8 +382,8 @@ public Mono deleteState(String stateStoreName, String key, String etag, St * {@inheritDoc} */ @Override - public Mono> getSecret(String secretStoreName, String key, Map metadata) { - GetSecretRequest request = new GetSecretRequestBuilder(secretStoreName, key) + public Mono> getSecret(String storeName, String key, Map metadata) { + GetSecretRequest request = new GetSecretRequestBuilder(storeName, key) .withMetadata(metadata) .build(); return getSecret(request).map(r -> r.getObject() == null ? new HashMap<>() : r.getObject()); @@ -392,8 +393,8 @@ public Mono> getSecret(String secretStoreName, String key, M * {@inheritDoc} */ @Override - public Mono> getSecret(String secretStoreName, String secretName) { - return this.getSecret(secretStoreName, secretName, null); + public Mono> getSecret(String storeName, String secretName) { + return this.getSecret(storeName, secretName, null); } } \ No newline at end of file diff --git a/sdk/src/main/java/io/dapr/client/DaprClient.java b/sdk/src/main/java/io/dapr/client/DaprClient.java index 81a4388459..f7c111f0a6 100644 --- a/sdk/src/main/java/io/dapr/client/DaprClient.java +++ b/sdk/src/main/java/io/dapr/client/DaprClient.java @@ -7,9 +7,9 @@ import io.dapr.client.domain.DeleteStateRequest; import io.dapr.client.domain.ExecuteStateTransactionRequest; +import io.dapr.client.domain.GetBulkStateRequest; import io.dapr.client.domain.GetSecretRequest; import io.dapr.client.domain.GetStateRequest; -import io.dapr.client.domain.GetStatesRequest; import io.dapr.client.domain.HttpExtension; import io.dapr.client.domain.InvokeBindingRequest; import io.dapr.client.domain.InvokeServiceRequest; @@ -22,7 +22,6 @@ import io.dapr.utils.TypeRef; import reactor.core.publisher.Mono; -import java.io.Closeable; import java.util.List; import java.util.Map; @@ -37,22 +36,22 @@ public interface DaprClient extends AutoCloseable { * Publish an event. * * @param pubsubName the pubsub name we will publish the event to - * @param topic the topic where the event will be published. + * @param topicName the topicName where the event will be published. * @param data the event's data to be published, use byte[] for skipping serialization. * @return a Mono plan of type Void. */ - Mono publishEvent(String pubsubName, String topic, Object data); + Mono publishEvent(String pubsubName, String topicName, Object data); /** * Publish an event. * * @param pubsubName the pubsub name we will publish the event to - * @param topic the topic where the event will be published. + * @param topicName the topicName where the event will be published. * @param data the event's data to be published, use byte[] for skipping serialization. * @param metadata The metadata for the published event. * @return a Mono plan of type Void. */ - Mono publishEvent(String pubsubName, String topic, Object data, Map metadata); + Mono publishEvent(String pubsubName, String topicName, Object data, Map metadata); /** * Publish an event. @@ -66,23 +65,23 @@ public interface DaprClient extends AutoCloseable { * Invoke a service method, using serialization. * * @param appId The Application ID where the service is. - * @param method The actual Method to be call in the application. - * @param request The request to be sent to invoke the service, use byte[] to skip serialization. + * @param methodName The actual Method to be call in the application. + * @param data The data to be sent to invoke the service, use byte[] to skip serialization. * @param httpExtension Additional fields that are needed if the receiving app is listening on * HTTP, {@link io.dapr.client.domain.HttpExtension#NONE} otherwise. - * @param metadata Metadata (in GRPC) or headers (in HTTP) to be sent in request. + * @param metadata Metadata (in GRPC) or headers (in HTTP) to be sent in data. * @param type The Type needed as return for the call. * @param The Type of the return, use byte[] to skip serialization. * @return A Mono Plan of type T. */ - Mono invokeService(String appId, String method, Object request, HttpExtension httpExtension, - Map metadata, TypeRef type); + Mono invokeMethod(String appId, String methodName, Object data, HttpExtension httpExtension, + Map metadata, TypeRef type); /** * Invoke a service method, using serialization. * * @param appId The Application ID where the service is. - * @param method The actual Method to be call in the application. + * @param methodName The actual Method to be call in the application. * @param request The request to be sent to invoke the service, use byte[] to skip serialization. * @param httpExtension Additional fields that are needed if the receiving app is listening on * HTTP, {@link HttpExtension#NONE} otherwise. @@ -91,14 +90,14 @@ Mono invokeService(String appId, String method, Object request, HttpExten * @param The Type of the return, use byte[] to skip serialization. * @return A Mono Plan of type T. */ - Mono invokeService(String appId, String method, Object request, HttpExtension httpExtension, - Map metadata, Class clazz); + Mono invokeMethod(String appId, String methodName, Object request, HttpExtension httpExtension, + Map metadata, Class clazz); /** * Invoke a service method, using serialization. * * @param appId The Application ID where the service is. - * @param method The actual Method to be call in the application. + * @param methodName The actual Method to be call in the application. * @param request The request to be sent to invoke the service, use byte[] to skip serialization. * @param httpExtension Additional fields that are needed if the receiving app is listening on * HTTP, {@link HttpExtension#NONE} otherwise. @@ -106,13 +105,14 @@ Mono invokeService(String appId, String method, Object request, HttpExten * @param The Type of the return, use byte[] to skip serialization. * @return A Mono Plan of type T. */ - Mono invokeService(String appId, String method, Object request, HttpExtension httpExtension, TypeRef type); + Mono invokeMethod(String appId, String methodName, Object request, HttpExtension httpExtension, + TypeRef type); /** * Invoke a service method, using serialization. * * @param appId The Application ID where the service is. - * @param method The actual Method to be call in the application. + * @param methodName The actual Method to be call in the application. * @param request The request to be sent to invoke the service, use byte[] to skip serialization. * @param httpExtension Additional fields that are needed if the receiving app is listening on * HTTP, {@link HttpExtension#NONE} otherwise. @@ -120,13 +120,14 @@ Mono invokeService(String appId, String method, Object request, HttpExten * @param The Type of the return, use byte[] to skip serialization. * @return A Mono Plan of type T. */ - Mono invokeService(String appId, String method, Object request, HttpExtension httpExtension, Class clazz); + Mono invokeMethod(String appId, String methodName, Object request, HttpExtension httpExtension, + Class clazz); /** * Invoke a service method, using serialization. * * @param appId The Application ID where the service is. - * @param method The actual Method to be call in the application. + * @param methodName The actual Method to be call in the application. * @param httpExtension Additional fields that are needed if the receiving app is listening on * HTTP, {@link HttpExtension#NONE} otherwise. * @param metadata Metadata (in GRPC) or headers (in HTTP) to be sent in request. @@ -134,14 +135,14 @@ Mono invokeService(String appId, String method, Object request, HttpExten * @param The Type of the return, use byte[] to skip serialization. * @return A Mono Plan of type T. */ - Mono invokeService(String appId, String method, HttpExtension httpExtension, Map metadata, - TypeRef type); + Mono invokeMethod(String appId, String methodName, HttpExtension httpExtension, Map metadata, + TypeRef type); /** * Invoke a service method, using serialization. * * @param appId The Application ID where the service is. - * @param method The actual Method to be call in the application. + * @param methodName The actual Method to be call in the application. * @param httpExtension Additional fields that are needed if the receiving app is listening on * HTTP, {@link HttpExtension#NONE} otherwise. * @param metadata Metadata (in GRPC) or headers (in HTTP) to be sent in request. @@ -149,60 +150,60 @@ Mono invokeService(String appId, String method, HttpExtension httpExtensi * @param The Type of the return, use byte[] to skip serialization. * @return A Mono Plan of type T. */ - Mono invokeService(String appId, String method, HttpExtension httpExtension, Map metadata, - Class clazz); + Mono invokeMethod(String appId, String methodName, HttpExtension httpExtension, Map metadata, + Class clazz); /** * Invoke a service method, using serialization. * * @param appId The Application ID where the service is. - * @param method The actual Method to be call in the application. + * @param methodName The actual Method to be call in the application. * @param request The request to be sent to invoke the service, use byte[] to skip serialization. * @param httpExtension Additional fields that are needed if the receiving app is listening on * HTTP, {@link HttpExtension#NONE} otherwise. * @param metadata Metadata (in GRPC) or headers (in HTTP) to be sent in request. * @return A Mono Plan of type Void. */ - Mono invokeService(String appId, String method, Object request, HttpExtension httpExtension, - Map metadata); + Mono invokeMethod(String appId, String methodName, Object request, HttpExtension httpExtension, + Map metadata); /** * Invoke a service method, using serialization. * * @param appId The Application ID where the service is. - * @param method The actual Method to be call in the application. + * @param methodName The actual Method to be call in the application. * @param request The request to be sent to invoke the service, use byte[] to skip serialization. * @param httpExtension Additional fields that are needed if the receiving app is listening on * HTTP, {@link HttpExtension#NONE} otherwise. * @return A Mono Plan of type Void. */ - Mono invokeService(String appId, String method, Object request, HttpExtension httpExtension); + Mono invokeMethod(String appId, String methodName, Object request, HttpExtension httpExtension); /** * Invoke a service method, using serialization. * * @param appId The Application ID where the service is. - * @param method The actual Method to be call in the application. + * @param methodName The actual Method to be call in the application. * @param httpExtension Additional fields that are needed if the receiving app is listening on * HTTP, {@link HttpExtension#NONE} otherwise. * @param metadata Metadata (in GRPC) or headers (in HTTP) to be sent in request. * @return A Mono Plan of type Void. */ - Mono invokeService(String appId, String method, HttpExtension httpExtension, Map metadata); + Mono invokeMethod(String appId, String methodName, HttpExtension httpExtension, Map metadata); /** * Invoke a service method, without using serialization. * * @param appId The Application ID where the service is. - * @param method The actual Method to be call in the application. + * @param methodName The actual Method to be call in the application. * @param request The request to be sent to invoke the service, use byte[] to skip serialization. * @param httpExtension Additional fields that are needed if the receiving app is listening on * HTTP, {@link HttpExtension#NONE} otherwise. * @param metadata Metadata (in GRPC) or headers (in HTTP) to be sent in request. * @return A Mono Plan of type byte[]. */ - Mono invokeService(String appId, String method, byte[] request, HttpExtension httpExtension, - Map metadata); + Mono invokeMethod(String appId, String methodName, byte[] request, HttpExtension httpExtension, + Map metadata); /** * Invoke a service method. @@ -212,57 +213,57 @@ Mono invokeService(String appId, String method, byte[] request, HttpExte * @param The Type of the return, use byte[] to skip serialization. * @return A Mono Plan of type T. */ - Mono> invokeService(InvokeServiceRequest invokeServiceRequest, TypeRef type); + Mono> invokeMethod(InvokeServiceRequest invokeServiceRequest, TypeRef type); /** * Invokes a Binding operation. * - * @param name The name of the biding to call. + * @param bindingName The bindingName of the biding to call. * @param operation The operation to be performed by the binding request processor. * @param data The data to be processed, use byte[] to skip serialization. * @return an empty Mono. */ - Mono invokeBinding(String name, String operation, Object data); + Mono invokeBinding(String bindingName, String operation, Object data); /** * Invokes a Binding operation, skipping serialization. * - * @param name The name of the biding to call. + * @param bindingName The name of the biding to call. * @param operation The operation to be performed by the binding request processor. * @param data The data to be processed, skipping serialization. * @param metadata The metadata map. * @return a Mono plan of type byte[]. */ - Mono invokeBinding(String name, String operation, byte[] data, Map metadata); + Mono invokeBinding(String bindingName, String operation, byte[] data, Map metadata); /** * Invokes a Binding operation. * - * @param name The name of the biding to call. + * @param bindingName The name of the biding to call. * @param operation The operation to be performed by the binding request processor. * @param data The data to be processed, use byte[] to skip serialization. * @param type The type being returned. * @param The type of the return * @return a Mono plan of type T. */ - Mono invokeBinding(String name, String operation, Object data, TypeRef type); + Mono invokeBinding(String bindingName, String operation, Object data, TypeRef type); /** * Invokes a Binding operation. * - * @param name The name of the biding to call. + * @param bindingName The name of the biding to call. * @param operation The operation to be performed by the binding request processor. * @param data The data to be processed, use byte[] to skip serialization. * @param clazz The type being returned. * @param The type of the return * @return a Mono plan of type T. */ - Mono invokeBinding(String name, String operation, Object data, Class clazz); + Mono invokeBinding(String bindingName, String operation, Object data, Class clazz); /** * Invokes a Binding operation. * - * @param name The name of the biding to call. + * @param bindingName The name of the biding to call. * @param operation The operation to be performed by the binding request processor. * @param data The data to be processed, use byte[] to skip serialization. * @param metadata The metadata map. @@ -270,12 +271,13 @@ Mono invokeService(String appId, String method, byte[] request, HttpExte * @param The type of the return * @return a Mono plan of type T. */ - Mono invokeBinding(String name, String operation, Object data, Map metadata, TypeRef type); + Mono invokeBinding(String bindingName, String operation, Object data, Map metadata, + TypeRef type); /** * Invokes a Binding operation. * - * @param name The name of the biding to call. + * @param bindingName The name of the biding to call. * @param operation The operation to be performed by the binding request processor. * @param data The data to be processed, use byte[] to skip serialization. * @param metadata The metadata map. @@ -283,7 +285,8 @@ Mono invokeService(String appId, String method, byte[] request, HttpExte * @param The type of the return * @return a Mono plan of type T. */ - Mono invokeBinding(String name, String operation, Object data, Map metadata, Class clazz); + Mono invokeBinding(String bindingName, String operation, Object data, Map metadata, + Class clazz); /** * Invokes a Binding operation. @@ -298,51 +301,51 @@ Mono invokeService(String appId, String method, byte[] request, HttpExte /** * Retrieve a State based on their key. * - * @param stateStoreName The name of the state store. + * @param storeName The name of the state store. * @param state State to be re-retrieved. * @param type The type of State needed as return. * @param The type of the return. * @return A Mono Plan for the requested State. */ - Mono> getState(String stateStoreName, State state, TypeRef type); + Mono> getState(String storeName, State state, TypeRef type); /** * Retrieve a State based on their key. * - * @param stateStoreName The name of the state store. + * @param storeName The name of the state store. * @param state State to be re-retrieved. * @param clazz The type of State needed as return. * @param The type of the return. * @return A Mono Plan for the requested State. */ - Mono> getState(String stateStoreName, State state, Class clazz); + Mono> getState(String storeName, State state, Class clazz); /** * Retrieve a State based on their key. * - * @param stateStoreName The name of the state store. + * @param storeName The name of the state store. * @param key The key of the State to be retrieved. * @param type The type of State needed as return. * @param The type of the return. * @return A Mono Plan for the requested State. */ - Mono> getState(String stateStoreName, String key, TypeRef type); + Mono> getState(String storeName, String key, TypeRef type); /** * Retrieve a State based on their key. * - * @param stateStoreName The name of the state store. + * @param storeName The name of the state store. * @param key The key of the State to be retrieved. * @param clazz The type of State needed as return. * @param The type of the return. * @return A Mono Plan for the requested State. */ - Mono> getState(String stateStoreName, String key, Class clazz); + Mono> getState(String storeName, String key, Class clazz); /** * Retrieve a State based on their key. * - * @param stateStoreName The name of the state store. + * @param storeName The name of the state store. * @param key The key of the State to be retrieved. * @param etag Optional etag for conditional get * @param options Optional settings for retrieve operation. @@ -350,12 +353,12 @@ Mono invokeService(String appId, String method, byte[] request, HttpExte * @param The Type of the return. * @return A Mono Plan for the requested State. */ - Mono> getState(String stateStoreName, String key, String etag, StateOptions options, TypeRef type); + Mono> getState(String storeName, String key, String etag, StateOptions options, TypeRef type); /** * Retrieve a State based on their key. * - * @param stateStoreName The name of the state store. + * @param storeName The name of the state store. * @param key The key of the State to be retrieved. * @param etag Optional etag for conditional get * @param options Optional settings for retrieve operation. @@ -363,7 +366,7 @@ Mono invokeService(String appId, String method, byte[] request, HttpExte * @param The Type of the return. * @return A Mono Plan for the requested State. */ - Mono> getState(String stateStoreName, String key, String etag, StateOptions options, Class clazz); + Mono> getState(String storeName, String key, String etag, StateOptions options, Class clazz); /** * Retrieve a State based on their key. @@ -378,24 +381,24 @@ Mono invokeService(String appId, String method, byte[] request, HttpExte /** * Retrieve bulk States based on their keys. * - * @param stateStoreName The name of the state store. + * @param storeName The name of the state store. * @param keys The keys of the State to be retrieved. * @param type The type of State needed as return. * @param The type of the return. * @return A Mono Plan for the requested State. */ - Mono>> getStates(String stateStoreName, List keys, TypeRef type); + Mono>> getBulkState(String storeName, List keys, TypeRef type); /** * Retrieve bulk States based on their keys. * - * @param stateStoreName The name of the state store. + * @param storeName The name of the state store. * @param keys The keys of the State to be retrieved. * @param clazz The type of State needed as return. * @param The type of the return. * @return A Mono Plan for the requested State. */ - Mono>> getStates(String stateStoreName, List keys, Class clazz); + Mono>> getBulkState(String storeName, List keys, Class clazz); /** * Retrieve bulk States based on their keys. @@ -405,16 +408,16 @@ Mono invokeService(String appId, String method, byte[] request, HttpExte * @param The Type of the return. * @return A Mono Plan for the requested State. */ - Mono>>> getStates(GetStatesRequest request, TypeRef type); + Mono>>> getBulkState(GetBulkStateRequest request, TypeRef type); /** Execute a transaction. * - * @param stateStoreName The name of the state store. + * @param storeName The name of the state store. * @param operations The operations to be performed. * @return a Mono plan of type Void */ - Mono executeTransaction(String stateStoreName, - List> operations); + Mono executeStateTransaction(String storeName, + List> operations); /** Execute a transaction. @@ -422,16 +425,16 @@ Mono executeTransaction(String stateStoreName, * @param request Request to execute transaction. * @return a Mono plan of type Response Void */ - Mono> executeTransaction(ExecuteStateTransactionRequest request); + Mono> executeStateTransaction(ExecuteStateTransactionRequest request); /** * Save/Update a list of states. * - * @param stateStoreName The name of the state store. + * @param storeName The name of the state store. * @param states The States to be saved. * @return a Mono plan of type Void. */ - Mono saveStates(String stateStoreName, List> states); + Mono saveBulkState(String storeName, List> states); /** * Save/Update a list of states. @@ -439,49 +442,49 @@ Mono executeTransaction(String stateStoreName, * @param request Request to save states. * @return a Mono plan of type Void. */ - Mono> saveStates(SaveStateRequest request); + Mono> saveBulkState(SaveStateRequest request); /** * Save/Update a state. * - * @param stateStoreName The name of the state store. + * @param storeName The name of the state store. * @param key The key of the state. * @param value The value of the state. * @return a Mono plan of type Void. */ - Mono saveState(String stateStoreName, String key, Object value); + Mono saveState(String storeName, String key, Object value); /** * Save/Update a state. * - * @param stateStoreName The name of the state store. + * @param storeName The name of the state store. * @param key The key of the state. * @param etag The etag to be used. * @param value The value of the state. * @param options The Options to use for each state. * @return a Mono plan of type Void. */ - Mono saveState(String stateStoreName, String key, String etag, Object value, StateOptions options); + Mono saveState(String storeName, String key, String etag, Object value, StateOptions options); /** * Delete a state. * - * @param stateStoreName The name of the state store. + * @param storeName The name of the state store. * @param key The key of the State to be removed. * @return a Mono plan of type Void. */ - Mono deleteState(String stateStoreName, String key); + Mono deleteState(String storeName, String key); /** * Delete a state. * - * @param stateStoreName The name of the state store. + * @param storeName The name of the state store. * @param key The key of the State to be removed. * @param etag Optional etag for conditional delete. * @param options Optional settings for state operation. * @return a Mono plan of type Void. */ - Mono deleteState(String stateStoreName, String key, String etag, StateOptions options); + Mono deleteState(String storeName, String key, String etag, StateOptions options); /** * Delete a state. @@ -494,21 +497,21 @@ Mono executeTransaction(String stateStoreName, /** * Fetches a secret from the configured vault. * - * @param secretStoreName Name of vault component in Dapr. + * @param storeName Name of vault component in Dapr. * @param secretName Secret to be fetched. * @param metadata Optional metadata. * @return Key-value pairs for the secret. */ - Mono> getSecret(String secretStoreName, String secretName, Map metadata); + Mono> getSecret(String storeName, String secretName, Map metadata); /** * Fetches a secret from the configured vault. * - * @param secretStoreName Name of vault component in Dapr. + * @param storeName Name of vault component in Dapr. * @param secretName Secret to be fetched. * @return Key-value pairs for the secret. */ - Mono> getSecret(String secretStoreName, String secretName); + Mono> getSecret(String storeName, String secretName); /** * Fetches a secret from the configured vault. diff --git a/sdk/src/main/java/io/dapr/client/DaprClientGrpc.java b/sdk/src/main/java/io/dapr/client/DaprClientGrpc.java index 4bb010da3f..061008f3ce 100644 --- a/sdk/src/main/java/io/dapr/client/DaprClientGrpc.java +++ b/sdk/src/main/java/io/dapr/client/DaprClientGrpc.java @@ -11,9 +11,9 @@ import com.google.protobuf.ByteString; import io.dapr.client.domain.DeleteStateRequest; import io.dapr.client.domain.ExecuteStateTransactionRequest; +import io.dapr.client.domain.GetBulkStateRequest; import io.dapr.client.domain.GetSecretRequest; import io.dapr.client.domain.GetStateRequest; -import io.dapr.client.domain.GetStatesRequest; import io.dapr.client.domain.HttpExtension; import io.dapr.client.domain.InvokeBindingRequest; import io.dapr.client.domain.InvokeServiceRequest; @@ -161,7 +161,7 @@ public Mono> publishEvent(PublishEventRequest request) { * {@inheritDoc} */ @Override - public Mono> invokeService(InvokeServiceRequest invokeServiceRequest, TypeRef type) { + public Mono> invokeMethod(InvokeServiceRequest invokeServiceRequest, TypeRef type) { try { String appId = invokeServiceRequest.getAppId(); String method = invokeServiceRequest.getMethod(); @@ -228,7 +228,7 @@ public Mono> invokeBinding(InvokeBindingRequest request, TypeRef @Override public Mono>> getState(GetStateRequest request, TypeRef type) { try { - final String stateStoreName = request.getStateStoreName(); + final String stateStoreName = request.getStoreName(); final String key = request.getKey(); final StateOptions options = request.getStateOptions(); // TODO(artursouza): handle etag once available in proto. @@ -263,9 +263,9 @@ public Mono>> getState(GetStateRequest request, TypeRef * {@inheritDoc} */ @Override - public Mono>>> getStates(GetStatesRequest request, TypeRef type) { + public Mono>>> getBulkState(GetBulkStateRequest request, TypeRef type) { try { - final String stateStoreName = request.getStateStoreName(); + final String stateStoreName = request.getStoreName(); final List keys = request.getKeys(); final int parallelism = request.getParallelism(); final Context context = request.getContext(); @@ -339,7 +339,7 @@ private State buildStateKeyValue( * {@inheritDoc} */ @Override - public Mono> executeTransaction(ExecuteStateTransactionRequest request) { + public Mono> executeStateTransaction(ExecuteStateTransactionRequest request) { try { final String stateStoreName = request.getStateStoreName(); final List> operations = request.getOperations(); @@ -374,9 +374,9 @@ public Mono> executeTransaction(ExecuteStateTransactionRequest re * {@inheritDoc} */ @Override - public Mono> saveStates(SaveStateRequest request) { + public Mono> saveBulkState(SaveStateRequest request) { try { - final String stateStoreName = request.getStateStoreName(); + final String stateStoreName = request.getStoreName(); final List> states = request.getStates(); final Context context = request.getContext(); if ((stateStoreName == null) || (stateStoreName.trim().isEmpty())) { @@ -522,7 +522,7 @@ private DaprProtos.InvokeServiceRequest buildInvokeServiceRequest( */ @Override public Mono>> getSecret(GetSecretRequest request) { - String secretStoreName = request.getSecretStoreName(); + String secretStoreName = request.getStoreName(); String key = request.getKey(); Map metadata = request.getMetadata(); Context context = request.getContext(); diff --git a/sdk/src/main/java/io/dapr/client/DaprClientHttp.java b/sdk/src/main/java/io/dapr/client/DaprClientHttp.java index 18fd07fa9f..d350e1796c 100644 --- a/sdk/src/main/java/io/dapr/client/DaprClientHttp.java +++ b/sdk/src/main/java/io/dapr/client/DaprClientHttp.java @@ -9,9 +9,9 @@ import com.google.common.base.Strings; import io.dapr.client.domain.DeleteStateRequest; import io.dapr.client.domain.ExecuteStateTransactionRequest; +import io.dapr.client.domain.GetBulkStateRequest; import io.dapr.client.domain.GetSecretRequest; import io.dapr.client.domain.GetStateRequest; -import io.dapr.client.domain.GetStatesRequest; import io.dapr.client.domain.HttpExtension; import io.dapr.client.domain.InvokeBindingRequest; import io.dapr.client.domain.InvokeServiceRequest; @@ -167,7 +167,7 @@ public Mono> publishEvent(PublishEventRequest request) { /** * {@inheritDoc} */ - public Mono> invokeService(InvokeServiceRequest invokeServiceRequest, TypeRef type) { + public Mono> invokeMethod(InvokeServiceRequest invokeServiceRequest, TypeRef type) { try { final String appId = invokeServiceRequest.getAppId(); final String method = invokeServiceRequest.getMethod(); @@ -279,9 +279,9 @@ public Mono> invokeBinding(InvokeBindingRequest request, TypeRef * {@inheritDoc} */ @Override - public Mono>>> getStates(GetStatesRequest request, TypeRef type) { + public Mono>>> getBulkState(GetBulkStateRequest request, TypeRef type) { try { - final String stateStoreName = request.getStateStoreName(); + final String stateStoreName = request.getStoreName(); final List keys = request.getKeys(); final int parallelism = request.getParallelism(); final Context context = request.getContext(); @@ -325,7 +325,7 @@ public Mono>>> getStates(GetStatesRequest request, Ty @Override public Mono>> getState(GetStateRequest request, TypeRef type) { try { - final String stateStoreName = request.getStateStoreName(); + final String stateStoreName = request.getStoreName(); final String key = request.getKey(); final StateOptions options = request.getStateOptions(); final String etag = request.getEtag(); @@ -372,7 +372,7 @@ public Mono>> getState(GetStateRequest request, TypeRef * {@inheritDoc} */ @Override - public Mono> executeTransaction(ExecuteStateTransactionRequest request) { + public Mono> executeStateTransaction(ExecuteStateTransactionRequest request) { try { final String stateStoreName = request.getStateStoreName(); final List> operations = request.getOperations(); @@ -421,9 +421,9 @@ public Mono> executeTransaction(ExecuteStateTransactionRequest re * {@inheritDoc} */ @Override - public Mono> saveStates(SaveStateRequest request) { + public Mono> saveBulkState(SaveStateRequest request) { try { - final String stateStoreName = request.getStateStoreName(); + final String stateStoreName = request.getStoreName(); final List> states = request.getStates(); final Context context = request.getContext(); if ((stateStoreName == null) || (stateStoreName.trim().isEmpty())) { @@ -557,7 +557,7 @@ private List> buildStates( */ @Override public Mono>> getSecret(GetSecretRequest request) { - String secretStoreName = request.getSecretStoreName(); + String secretStoreName = request.getStoreName(); String key = request.getKey(); Map metadata = request.getMetadata(); Context context = request.getContext(); diff --git a/sdk/src/main/java/io/dapr/client/domain/GetStatesRequest.java b/sdk/src/main/java/io/dapr/client/domain/GetBulkStateRequest.java similarity index 72% rename from sdk/src/main/java/io/dapr/client/domain/GetStatesRequest.java rename to sdk/src/main/java/io/dapr/client/domain/GetBulkStateRequest.java index e7a2eec2cc..402eee7731 100644 --- a/sdk/src/main/java/io/dapr/client/domain/GetStatesRequest.java +++ b/sdk/src/main/java/io/dapr/client/domain/GetBulkStateRequest.java @@ -1,56 +1,56 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ - -package io.dapr.client.domain; - -import io.opentelemetry.context.Context; - -import java.util.List; - -/** - * A request to get bulk state by keys. - */ -public class GetStatesRequest { - - private String stateStoreName; - - private List keys; - - private int parallelism; - - private Context context; - - public String getStateStoreName() { - return stateStoreName; - } - - void setStateStoreName(String stateStoreName) { - this.stateStoreName = stateStoreName; - } - - public List getKeys() { - return keys; - } - - void setKeys(List keys) { - this.keys = keys; - } - - public int getParallelism() { - return parallelism; - } - - void setParallelism(int parallelism) { - this.parallelism = parallelism; - } - - public Context getContext() { - return context; - } - - void setContext(Context context) { - this.context = context; - } -} +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ + +package io.dapr.client.domain; + +import io.opentelemetry.context.Context; + +import java.util.List; + +/** + * A request to get bulk state by keys. + */ +public class GetBulkStateRequest { + + private String storeName; + + private List keys; + + private int parallelism; + + private Context context; + + public String getStoreName() { + return storeName; + } + + void setStoreName(String storeName) { + this.storeName = storeName; + } + + public List getKeys() { + return keys; + } + + void setKeys(List keys) { + this.keys = keys; + } + + public int getParallelism() { + return parallelism; + } + + void setParallelism(int parallelism) { + this.parallelism = parallelism; + } + + public Context getContext() { + return context; + } + + void setContext(Context context) { + this.context = context; + } +} diff --git a/sdk/src/main/java/io/dapr/client/domain/GetStatesRequestBuilder.java b/sdk/src/main/java/io/dapr/client/domain/GetBulkStateRequestBuilder.java similarity index 57% rename from sdk/src/main/java/io/dapr/client/domain/GetStatesRequestBuilder.java rename to sdk/src/main/java/io/dapr/client/domain/GetBulkStateRequestBuilder.java index f74eb177c5..0a4ae94262 100644 --- a/sdk/src/main/java/io/dapr/client/domain/GetStatesRequestBuilder.java +++ b/sdk/src/main/java/io/dapr/client/domain/GetBulkStateRequestBuilder.java @@ -1,60 +1,60 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - */ - -package io.dapr.client.domain; - -import io.opentelemetry.context.Context; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -/** - * Builds a request to request states. - */ -public class GetStatesRequestBuilder { - - private final String stateStoreName; - - private final List keys; - - private int parallelism = 1; - - private Context context; - - public GetStatesRequestBuilder(String stateStoreName, List keys) { - this.stateStoreName = stateStoreName; - this.keys = keys == null ? null : Collections.unmodifiableList(keys); - } - - public GetStatesRequestBuilder(String stateStoreName, String... keys) { - this.stateStoreName = stateStoreName; - this.keys = keys == null ? null : Collections.unmodifiableList(Arrays.asList(keys)); - } - - public GetStatesRequestBuilder withParallelism(int parallelism) { - this.parallelism = parallelism; - return this; - } - - public GetStatesRequestBuilder withContext(Context context) { - this.context = context; - return this; - } - - /** - * Builds a request object. - * @return Request object. - */ - public GetStatesRequest build() { - GetStatesRequest request = new GetStatesRequest(); - request.setStateStoreName(this.stateStoreName); - request.setKeys(this.keys); - request.setParallelism(this.parallelism); - request.setContext(this.context); - return request; - } - -} +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + */ + +package io.dapr.client.domain; + +import io.opentelemetry.context.Context; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +/** + * Builds a request to request states. + */ +public class GetBulkStateRequestBuilder { + + private final String storeName; + + private final List keys; + + private int parallelism = 1; + + private Context context; + + public GetBulkStateRequestBuilder(String storeName, List keys) { + this.storeName = storeName; + this.keys = keys == null ? null : Collections.unmodifiableList(keys); + } + + public GetBulkStateRequestBuilder(String storeName, String... keys) { + this.storeName = storeName; + this.keys = keys == null ? null : Collections.unmodifiableList(Arrays.asList(keys)); + } + + public GetBulkStateRequestBuilder withParallelism(int parallelism) { + this.parallelism = parallelism; + return this; + } + + public GetBulkStateRequestBuilder withContext(Context context) { + this.context = context; + return this; + } + + /** + * Builds a request object. + * @return Request object. + */ + public GetBulkStateRequest build() { + GetBulkStateRequest request = new GetBulkStateRequest(); + request.setStoreName(this.storeName); + request.setKeys(this.keys); + request.setParallelism(this.parallelism); + request.setContext(this.context); + return request; + } + +} diff --git a/sdk/src/main/java/io/dapr/client/domain/GetSecretRequest.java b/sdk/src/main/java/io/dapr/client/domain/GetSecretRequest.java index c1c0d5a78f..dff7586b15 100644 --- a/sdk/src/main/java/io/dapr/client/domain/GetSecretRequest.java +++ b/sdk/src/main/java/io/dapr/client/domain/GetSecretRequest.java @@ -14,7 +14,7 @@ */ public class GetSecretRequest { - private String secretStoreName; + private String storeName; private String key; @@ -22,12 +22,12 @@ public class GetSecretRequest { private Context context; - public String getSecretStoreName() { - return secretStoreName; + public String getStoreName() { + return storeName; } - void setSecretStoreName(String secretStoreName) { - this.secretStoreName = secretStoreName; + void setStoreName(String storeName) { + this.storeName = storeName; } public String getKey() { diff --git a/sdk/src/main/java/io/dapr/client/domain/GetSecretRequestBuilder.java b/sdk/src/main/java/io/dapr/client/domain/GetSecretRequestBuilder.java index 47cbbbc045..b7dd11f159 100644 --- a/sdk/src/main/java/io/dapr/client/domain/GetSecretRequestBuilder.java +++ b/sdk/src/main/java/io/dapr/client/domain/GetSecretRequestBuilder.java @@ -15,7 +15,7 @@ */ public class GetSecretRequestBuilder { - private final String secretStoreName; + private final String storeName; private final String key; @@ -23,8 +23,8 @@ public class GetSecretRequestBuilder { private Context context; - public GetSecretRequestBuilder(String secretStoreName, String key) { - this.secretStoreName = secretStoreName; + public GetSecretRequestBuilder(String storeName, String key) { + this.storeName = storeName; this.key = key; } @@ -44,7 +44,7 @@ public GetSecretRequestBuilder withContext(Context context) { */ public GetSecretRequest build() { GetSecretRequest request = new GetSecretRequest(); - request.setSecretStoreName(this.secretStoreName); + request.setStoreName(this.storeName); request.setKey(this.key); request.setMetadata(this.metadata); request.setContext(this.context); diff --git a/sdk/src/main/java/io/dapr/client/domain/GetStateRequest.java b/sdk/src/main/java/io/dapr/client/domain/GetStateRequest.java index 6cf0cccf9f..90afcc7591 100644 --- a/sdk/src/main/java/io/dapr/client/domain/GetStateRequest.java +++ b/sdk/src/main/java/io/dapr/client/domain/GetStateRequest.java @@ -15,7 +15,7 @@ */ public class GetStateRequest { - private String stateStoreName; + private String storeName; private String key; @@ -27,12 +27,12 @@ public class GetStateRequest { private Context context; - public String getStateStoreName() { - return stateStoreName; + public String getStoreName() { + return storeName; } - void setStateStoreName(String stateStoreName) { - this.stateStoreName = stateStoreName; + void setStoreName(String storeName) { + this.storeName = storeName; } public String getKey() { diff --git a/sdk/src/main/java/io/dapr/client/domain/GetStateRequestBuilder.java b/sdk/src/main/java/io/dapr/client/domain/GetStateRequestBuilder.java index f6248857a2..36cbf4f35f 100644 --- a/sdk/src/main/java/io/dapr/client/domain/GetStateRequestBuilder.java +++ b/sdk/src/main/java/io/dapr/client/domain/GetStateRequestBuilder.java @@ -14,7 +14,7 @@ */ public class GetStateRequestBuilder { - private final String stateStoreName; + private final String storeName; private final String key; @@ -26,8 +26,8 @@ public class GetStateRequestBuilder { private Context context; - public GetStateRequestBuilder(String stateStoreName, String key) { - this.stateStoreName = stateStoreName; + public GetStateRequestBuilder(String storeName, String key) { + this.storeName = storeName; this.key = key; } @@ -57,7 +57,7 @@ public GetStateRequestBuilder withContext(Context context) { */ public GetStateRequest build() { GetStateRequest request = new GetStateRequest(); - request.setStateStoreName(this.stateStoreName); + request.setStoreName(this.storeName); request.setKey(this.key); request.setMetadata(this.metadata); request.setEtag(this.etag); diff --git a/sdk/src/main/java/io/dapr/client/domain/SaveStateRequest.java b/sdk/src/main/java/io/dapr/client/domain/SaveStateRequest.java index e4c8260f36..95598589a2 100644 --- a/sdk/src/main/java/io/dapr/client/domain/SaveStateRequest.java +++ b/sdk/src/main/java/io/dapr/client/domain/SaveStateRequest.java @@ -14,18 +14,18 @@ */ public class SaveStateRequest { - private String stateStoreName; + private String storeName; private List> states; private Context context; - public String getStateStoreName() { - return stateStoreName; + public String getStoreName() { + return storeName; } - void setStateStoreName(String stateStoreName) { - this.stateStoreName = stateStoreName; + void setStoreName(String storeName) { + this.storeName = storeName; } public List> getStates() { diff --git a/sdk/src/main/java/io/dapr/client/domain/SaveStateRequestBuilder.java b/sdk/src/main/java/io/dapr/client/domain/SaveStateRequestBuilder.java index f19ea80227..3e47e4a9fd 100644 --- a/sdk/src/main/java/io/dapr/client/domain/SaveStateRequestBuilder.java +++ b/sdk/src/main/java/io/dapr/client/domain/SaveStateRequestBuilder.java @@ -17,14 +17,14 @@ */ public class SaveStateRequestBuilder { - private final String stateStoreName; + private final String storeName; private List> states = new ArrayList<>(); private Context context; - public SaveStateRequestBuilder(String stateStoreName) { - this.stateStoreName = stateStoreName; + public SaveStateRequestBuilder(String storeName) { + this.storeName = storeName; } public SaveStateRequestBuilder withStates(State... states) { @@ -48,7 +48,7 @@ public SaveStateRequestBuilder withContext(Context context) { */ public SaveStateRequest build() { SaveStateRequest request = new SaveStateRequest(); - request.setStateStoreName(this.stateStoreName); + request.setStoreName(this.storeName); request.setStates(this.states); request.setContext(this.context); return request; diff --git a/sdk/src/test/java/io/dapr/client/DaprClientGrpcTest.java b/sdk/src/test/java/io/dapr/client/DaprClientGrpcTest.java index 42db5d3c26..e9dca38729 100644 --- a/sdk/src/test/java/io/dapr/client/DaprClientGrpcTest.java +++ b/sdk/src/test/java/io/dapr/client/DaprClientGrpcTest.java @@ -14,10 +14,10 @@ import io.dapr.client.domain.DeleteStateRequestBuilder; import io.dapr.client.domain.ExecuteStateTransactionRequest; import io.dapr.client.domain.ExecuteStateTransactionRequestBuilder; +import io.dapr.client.domain.GetBulkStateRequest; +import io.dapr.client.domain.GetBulkStateRequestBuilder; import io.dapr.client.domain.GetStateRequest; import io.dapr.client.domain.GetStateRequestBuilder; -import io.dapr.client.domain.GetStatesRequest; -import io.dapr.client.domain.GetStatesRequestBuilder; import io.dapr.client.domain.HttpExtension; import io.dapr.client.domain.Response; import io.dapr.client.domain.State; @@ -30,7 +30,6 @@ import io.dapr.v1.DaprGrpc; import io.dapr.v1.DaprProtos; import io.grpc.Status; -import io.grpc.StatusException; import io.grpc.StatusRuntimeException; import org.checkerframework.checker.nullness.compatqual.NullableDecl; import org.junit.After; @@ -58,7 +57,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.argThat; import static org.mockito.Mockito.doNothing; @@ -352,7 +350,7 @@ public void invokeBindingObjectNoHotMono() { public void invokeServiceVoidExceptionThrownTest() { when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class))) .thenThrow(RuntimeException.class); - Mono result = adapter.invokeService("appId", "method", "request", HttpExtension.NONE); + Mono result = adapter.invokeMethod("appId", "method", "request", HttpExtension.NONE); assertThrowsDaprException( RuntimeException.class, @@ -367,7 +365,7 @@ public void invokeServiceIllegalArgumentExceptionThrownTest() { when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class))) .thenReturn(settableFuture); // HttpExtension cannot be null - Mono result = adapter.invokeService("appId", "method", "request", null); + Mono result = adapter.invokeMethod("appId", "method", "request", null); assertThrowsDaprException( IllegalArgumentException.class, @@ -380,7 +378,7 @@ public void invokeServiceIllegalArgumentExceptionThrownTest() { public void invokeServiceEmptyRequestVoidExceptionThrownTest() { when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class))) .thenThrow(RuntimeException.class); - Mono result = adapter.invokeService("appId", "method", HttpExtension.NONE, (Map)null); + Mono result = adapter.invokeMethod("appId", "method", HttpExtension.NONE, (Map)null); assertThrowsDaprException( RuntimeException.class, @@ -398,7 +396,7 @@ public void invokeServiceVoidCallbackExceptionThrownTest() { settableFuture.setException(ex); when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class))) .thenReturn(settableFuture); - Mono result = adapter.invokeService("appId", "method", "request", HttpExtension.NONE); + Mono result = adapter.invokeMethod("appId", "method", "request", HttpExtension.NONE); assertThrowsDaprException( ExecutionException.class, @@ -416,7 +414,7 @@ public void invokeServiceVoidTest() throws Exception { addCallback(settableFuture, callback, directExecutor()); when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class))) .thenReturn(settableFuture); - Mono result = adapter.invokeService("appId", "method", "request", HttpExtension.NONE); + Mono result = adapter.invokeMethod("appId", "method", "request", HttpExtension.NONE); settableFuture.set(CommonProtos.InvokeResponse.newBuilder().setData(getAny("Value")).build()); result.block(); assertTrue(callback.wasCalled); @@ -432,7 +430,7 @@ public void invokeServiceVoidObjectTest() throws Exception { when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class))) .thenReturn(settableFuture); MyObject request = new MyObject(1, "Event"); - Mono result = adapter.invokeService("appId", "method", request, HttpExtension.NONE); + Mono result = adapter.invokeMethod("appId", "method", request, HttpExtension.NONE); settableFuture.set(CommonProtos.InvokeResponse.newBuilder().setData(getAny("Value")).build()); result.block(); assertTrue(callback.wasCalled); @@ -442,7 +440,7 @@ public void invokeServiceVoidObjectTest() throws Exception { public void invokeServiceExceptionThrownTest() { when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class))) .thenThrow(RuntimeException.class); - Mono result = adapter.invokeService("appId", "method", "request", HttpExtension.NONE, null, String.class); + Mono result = adapter.invokeMethod("appId", "method", "request", HttpExtension.NONE, null, String.class); assertThrowsDaprException( RuntimeException.class, @@ -455,7 +453,7 @@ public void invokeServiceExceptionThrownTest() { public void invokeServiceNoRequestClassExceptionThrownTest() { when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class))) .thenThrow(RuntimeException.class); - Mono result = adapter.invokeService("appId", "method", HttpExtension.NONE, (Map)null, String.class); + Mono result = adapter.invokeMethod("appId", "method", HttpExtension.NONE, (Map)null, String.class); assertThrowsDaprException( RuntimeException.class, @@ -468,7 +466,7 @@ public void invokeServiceNoRequestClassExceptionThrownTest() { public void invokeServiceNoRequestTypeRefExceptionThrownTest() { when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class))) .thenThrow(RuntimeException.class); - Mono result = adapter.invokeService("appId", "method", HttpExtension.NONE, (Map)null, TypeRef.STRING); + Mono result = adapter.invokeMethod("appId", "method", HttpExtension.NONE, (Map)null, TypeRef.STRING); assertThrowsDaprException( RuntimeException.class, @@ -485,7 +483,7 @@ public void invokeServiceCallbackExceptionThrownTest() { addCallback(settableFuture, callback, directExecutor()); when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class))) .thenReturn(settableFuture); - Mono result = adapter.invokeService("appId", "method", "request", HttpExtension.NONE, null, String.class); + Mono result = adapter.invokeMethod("appId", "method", "request", HttpExtension.NONE, null, String.class); settableFuture.setException(ex); assertThrowsDaprException( @@ -520,7 +518,7 @@ public void invokeServiceWithHttpExtensionTest() throws IOException { settableFuture.set(CommonProtos.InvokeResponse.newBuilder().setData(getAny(expected)).build()); when(client.invokeService(eq(request))) .thenReturn(settableFuture); - Mono result = adapter.invokeService("appId", "method", "request", httpExtension, null, String.class); + Mono result = adapter.invokeMethod("appId", "method", "request", httpExtension, null, String.class); String strOutput = result.block(); assertEquals(expected, strOutput); } @@ -535,7 +533,7 @@ public void invokeServiceTest() throws Exception { settableFuture.set(CommonProtos.InvokeResponse.newBuilder().setData(getAny(expected)).build()); when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class))) .thenReturn(settableFuture); - Mono result = adapter.invokeService("appId", "method", "request", HttpExtension.NONE, null, String.class); + Mono result = adapter.invokeMethod("appId", "method", "request", HttpExtension.NONE, null, String.class); String strOutput = result.block(); assertEquals(expected, strOutput); } @@ -550,7 +548,7 @@ public void invokeServiceObjectTest() throws Exception { settableFuture.set(CommonProtos.InvokeResponse.newBuilder().setData(getAny(object)).build()); when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class))) .thenReturn(settableFuture); - Mono result = adapter.invokeService("appId", "method", "request", HttpExtension.NONE, null, MyObject.class); + Mono result = adapter.invokeMethod("appId", "method", "request", HttpExtension.NONE, null, MyObject.class); MyObject resultObject = result.block(); assertEquals(object.id, resultObject.id); assertEquals(object.value, resultObject.value); @@ -560,7 +558,7 @@ public void invokeServiceObjectTest() throws Exception { public void invokeServiceNoRequestBodyExceptionThrownTest() { when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class))) .thenThrow(RuntimeException.class); - Mono result = adapter.invokeService("appId", "method", (Object)null, HttpExtension.NONE, String.class); + Mono result = adapter.invokeMethod("appId", "method", (Object)null, HttpExtension.NONE, String.class); assertThrowsDaprException( RuntimeException.class, @@ -577,7 +575,7 @@ public void invokeServiceNoRequestCallbackExceptionThrownTest() { addCallback(settableFuture, callback, directExecutor()); when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class))) .thenReturn(settableFuture); - Mono result = adapter.invokeService("appId", "method", (Object)null, HttpExtension.NONE, String.class); + Mono result = adapter.invokeMethod("appId", "method", (Object)null, HttpExtension.NONE, String.class); settableFuture.setException(ex); assertThrowsDaprException( @@ -598,7 +596,7 @@ public void invokeServiceNoRequestBodyTest() throws Exception { settableFuture.set(CommonProtos.InvokeResponse.newBuilder().setData(getAny(expected)).build()); when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class))) .thenReturn(settableFuture); - Mono result = adapter.invokeService("appId", "method", (Object)null, HttpExtension.NONE, String.class); + Mono result = adapter.invokeMethod("appId", "method", (Object)null, HttpExtension.NONE, String.class); String strOutput = result.block(); assertEquals(expected, strOutput); } @@ -614,7 +612,7 @@ public void invokeServiceNoRequestBodyObjectTest() throws Exception { settableFuture.set(CommonProtos.InvokeResponse.newBuilder().setData(getAny(object)).build()); when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class))) .thenReturn(settableFuture); - Mono result = adapter.invokeService("appId", "method", (Object)null, HttpExtension.NONE, MyObject.class); + Mono result = adapter.invokeMethod("appId", "method", (Object)null, HttpExtension.NONE, MyObject.class); MyObject resultObject = result.block(); assertEquals(object.id, resultObject.id); assertEquals(object.value, resultObject.value); @@ -626,7 +624,7 @@ public void invokeServiceByteRequestExceptionThrownTest() throws IOException { .thenThrow(RuntimeException.class); String request = "Request"; byte[] byteRequest = serializer.serialize(request); - Mono result = adapter.invokeService("appId", "method", byteRequest, HttpExtension.NONE, byte[].class); + Mono result = adapter.invokeMethod("appId", "method", byteRequest, HttpExtension.NONE, byte[].class); assertThrowsDaprException( RuntimeException.class, @@ -646,7 +644,7 @@ public void invokeServiceByteRequestCallbackExceptionThrownTest() throws IOExcep String request = "Request"; byte[] byteRequest = serializer.serialize(request); Mono result = - adapter.invokeService("appId", "method", byteRequest, HttpExtension.NONE,(HashMap) null); + adapter.invokeMethod("appId", "method", byteRequest, HttpExtension.NONE,(HashMap) null); settableFuture.setException(ex); assertThrowsDaprException( @@ -668,7 +666,7 @@ public void invokeByteRequestServiceTest() throws Exception { .thenReturn(settableFuture); String request = "Request"; byte[] byteRequest = serializer.serialize(request); - Mono result = adapter.invokeService( + Mono result = adapter.invokeMethod( "appId", "method", byteRequest, HttpExtension.NONE, (HashMap) null); byte[] byteOutput = result.block(); String strOutput = serializer.deserialize(byteOutput, String.class); @@ -687,7 +685,7 @@ public void invokeServiceByteRequestObjectTest() throws Exception { .thenReturn(settableFuture); String request = "Request"; byte[] byteRequest = serializer.serialize(request); - Mono result = adapter.invokeService("appId", "method", byteRequest, HttpExtension.NONE, byte[].class); + Mono result = adapter.invokeMethod("appId", "method", byteRequest, HttpExtension.NONE, byte[].class); byte[] byteOutput = result.block(); assertEquals(resultObj, serializer.deserialize(byteOutput, MyObject.class)); } @@ -696,7 +694,7 @@ public void invokeServiceByteRequestObjectTest() throws Exception { public void invokeServiceNoRequestNoClassBodyExceptionThrownTest() { when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class))) .thenThrow(RuntimeException.class); - Mono result = adapter.invokeService("appId", "method", (Object)null, HttpExtension.NONE); + Mono result = adapter.invokeMethod("appId", "method", (Object)null, HttpExtension.NONE); assertThrowsDaprException( RuntimeException.class, @@ -713,7 +711,7 @@ public void invokeServiceNoRequestNoClassCallbackExceptionThrownTest() { addCallback(settableFuture, callback, directExecutor()); when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class))) .thenReturn(settableFuture); - Mono result = adapter.invokeService("appId", "method", (Object)null, HttpExtension.NONE); + Mono result = adapter.invokeMethod("appId", "method", (Object)null, HttpExtension.NONE); settableFuture.setException(ex); assertThrowsDaprException( @@ -732,7 +730,7 @@ public void invokeServiceNoRequestNoClassBodyTest() throws Exception { addCallback(settableFuture, callback, directExecutor()); when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class))) .thenReturn(settableFuture); - Mono result = adapter.invokeService("appId", "method", (Object)null, HttpExtension.NONE); + Mono result = adapter.invokeMethod("appId", "method", (Object)null, HttpExtension.NONE); settableFuture.set(CommonProtos.InvokeResponse.newBuilder().setData(getAny(expected)).build()); result.block(); assertTrue(callback.wasCalled); @@ -750,7 +748,7 @@ public void invokeServiceNoRequestNoHotMono() throws Exception { settableFuture.set(CommonProtos.InvokeResponse.newBuilder().setData(getAny(expected)).build()); return settableFuture; }); - adapter.invokeService("appId", "method", (Object)null, HttpExtension.NONE); + adapter.invokeMethod("appId", "method", (Object)null, HttpExtension.NONE); // Do not call block() on mono above, so nothing should happen. assertFalse(callback.wasCalled); } @@ -766,7 +764,7 @@ public void invokeServiceNoRequestNoClassBodyObjectTest() throws Exception { settableFuture.set(CommonProtos.InvokeResponse.newBuilder().setData(getAny(resultObj)).build()); when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class))) .thenReturn(settableFuture); - Mono result = adapter.invokeService("appId", "method", (Object)null, HttpExtension.NONE); + Mono result = adapter.invokeMethod("appId", "method", (Object)null, HttpExtension.NONE); result.block(); assertTrue(callback.wasCalled); } @@ -945,26 +943,26 @@ public void getStatesIllegalArgumentExceptionTest() { State key = buildStateKey(null, "Key1", "ETag1", null); assertThrowsDaprException(IllegalArgumentException.class, () -> { // empty state store name - adapter.getStates("", Collections.singletonList("100"), String.class).block(); + adapter.getBulkState("", Collections.singletonList("100"), String.class).block(); }); assertThrowsDaprException(IllegalArgumentException.class, () -> { // null state store name - adapter.getStates(null, Collections.singletonList("100"), String.class).block(); + adapter.getBulkState(null, Collections.singletonList("100"), String.class).block(); }); assertThrowsDaprException(IllegalArgumentException.class, () -> { // null key // null pointer exception due to keys being converted to an unmodifiable list - adapter.getStates(STATE_STORE_NAME, null, String.class).block(); + adapter.getBulkState(STATE_STORE_NAME, null, String.class).block(); }); assertThrowsDaprException(IllegalArgumentException.class, () -> { // empty key list - adapter.getStates(STATE_STORE_NAME, Collections.emptyList(), String.class).block(); + adapter.getBulkState(STATE_STORE_NAME, Collections.emptyList(), String.class).block(); }); // negative parallelism - GetStatesRequest req = new GetStatesRequestBuilder(STATE_STORE_NAME, Collections.singletonList("100")) + GetBulkStateRequest req = new GetBulkStateRequestBuilder(STATE_STORE_NAME, Collections.singletonList("100")) .withParallelism(-1) .build(); - assertThrowsDaprException(IllegalArgumentException.class, () -> adapter.getStates(req, TypeRef.BOOLEAN).block()); + assertThrowsDaprException(IllegalArgumentException.class, () -> adapter.getBulkState(req, TypeRef.BOOLEAN).block()); } @Test @@ -988,7 +986,7 @@ public void getStatesString() throws IOException { settableFuture.set(responseEnvelope); return settableFuture; }); - List> result = adapter.getStates(STATE_STORE_NAME, Arrays.asList("100", "200"), String.class).block(); + List> result = adapter.getBulkState(STATE_STORE_NAME, Arrays.asList("100", "200"), String.class).block(); assertTrue(callback.wasCalled); assertEquals(2, result.size()); @@ -1023,7 +1021,7 @@ public void getStatesInteger() throws IOException { settableFuture.set(responseEnvelope); return settableFuture; }); - List> result = adapter.getStates(STATE_STORE_NAME, Arrays.asList("100", "200"), int.class).block(); + List> result = adapter.getBulkState(STATE_STORE_NAME, Arrays.asList("100", "200"), int.class).block(); assertTrue(callback.wasCalled); assertEquals(2, result.size()); @@ -1058,7 +1056,7 @@ public void getStatesBoolean() throws IOException { settableFuture.set(responseEnvelope); return settableFuture; }); - List> result = adapter.getStates(STATE_STORE_NAME, Arrays.asList("100", "200"), boolean.class).block(); + List> result = adapter.getBulkState(STATE_STORE_NAME, Arrays.asList("100", "200"), boolean.class).block(); assertTrue(callback.wasCalled); assertEquals(2, result.size()); @@ -1093,7 +1091,7 @@ public void getStatesByteArray() throws IOException { settableFuture.set(responseEnvelope); return settableFuture; }); - List> result = adapter.getStates(STATE_STORE_NAME, Arrays.asList("100", "200"), byte[].class).block(); + List> result = adapter.getBulkState(STATE_STORE_NAME, Arrays.asList("100", "200"), byte[].class).block(); assertTrue(callback.wasCalled); assertEquals(2, result.size()); @@ -1129,7 +1127,7 @@ public void getStatesObject() throws IOException { settableFuture.set(responseEnvelope); return settableFuture; }); - List> result = adapter.getStates(STATE_STORE_NAME, Arrays.asList("100", "200"), MyObject.class).block(); + List> result = adapter.getBulkState(STATE_STORE_NAME, Arrays.asList("100", "200"), MyObject.class).block(); assertTrue(callback.wasCalled); assertEquals(2, result.size()); @@ -1316,11 +1314,11 @@ public void executeTransactionIllegalArgumentExceptionTest() { key); assertThrowsDaprException(IllegalArgumentException.class, () -> { // empty state store name - adapter.executeTransaction("", Collections.singletonList(upsertOperation)).block(); + adapter.executeStateTransaction("", Collections.singletonList(upsertOperation)).block(); }); assertThrowsDaprException(IllegalArgumentException.class, () -> { // null state store name - adapter.executeTransaction(null, Collections.singletonList(upsertOperation)).block(); + adapter.executeStateTransaction(null, Collections.singletonList(upsertOperation)).block(); }); } @@ -1343,7 +1341,7 @@ public void executeTransactionSerializerExceptionTest() throws IOException { ExecuteStateTransactionRequest request = new ExecuteStateTransactionRequestBuilder(STATE_STORE_NAME) .withTransactionalStates(upsertOperation) .build(); - Mono> result = adapter.executeTransaction(request); + Mono> result = adapter.executeStateTransaction(request); assertThrowsDaprException( IOException.class, @@ -1376,7 +1374,7 @@ public void executeTransactionWithMetadataTest() { .withTransactionalStates(upsertOperation, deleteOperation) .withMetadata(metadata) .build(); - Mono> result = adapter.executeTransaction(request); + Mono> result = adapter.executeStateTransaction(request); settableFuture.set(Empty.newBuilder().build()); result.block(); assertTrue(callback.wasCalled); @@ -1401,7 +1399,7 @@ public void executeTransactionTest() { TransactionalStateOperation.OperationType.DELETE, new State<>("testKey") ); - Mono result = adapter.executeTransaction(STATE_STORE_NAME, Arrays.asList(upsertOperation, deleteOperation)); + Mono result = adapter.executeStateTransaction(STATE_STORE_NAME, Arrays.asList(upsertOperation, deleteOperation)); settableFuture.set(Empty.newBuilder().build()); result.block(); assertTrue(callback.wasCalled); @@ -1419,7 +1417,7 @@ public void executeTransactionExceptionThrownTest() { TransactionalStateOperation operation = new TransactionalStateOperation<>( TransactionalStateOperation.OperationType.UPSERT, stateKey); - Mono result = adapter.executeTransaction(STATE_STORE_NAME, Collections.singletonList(operation)); + Mono result = adapter.executeStateTransaction(STATE_STORE_NAME, Collections.singletonList(operation)); assertThrowsDaprException( RuntimeException.class, @@ -1444,7 +1442,7 @@ public void executeTransactionCallbackExceptionTest() { TransactionalStateOperation operation = new TransactionalStateOperation<>( TransactionalStateOperation.OperationType.UPSERT, stateKey); - Mono result = adapter.executeTransaction(STATE_STORE_NAME, Collections.singletonList(operation)); + Mono result = adapter.executeStateTransaction(STATE_STORE_NAME, Collections.singletonList(operation)); settableFuture.setException(ex); assertThrowsDaprException( @@ -1458,11 +1456,11 @@ public void executeTransactionCallbackExceptionTest() { public void saveStatesIllegalArgumentExceptionTest() { assertThrowsDaprException(IllegalArgumentException.class, () -> { // empty state store name - adapter.saveStates("", Collections.emptyList()).block(); + adapter.saveBulkState("", Collections.emptyList()).block(); }); assertThrowsDaprException(IllegalArgumentException.class, () -> { // empty state store name - adapter.saveStates(null, Collections.emptyList()).block(); + adapter.saveBulkState(null, Collections.emptyList()).block(); }); } diff --git a/sdk/src/test/java/io/dapr/client/DaprClientHttpTest.java b/sdk/src/test/java/io/dapr/client/DaprClientHttpTest.java index b902b7d204..3971229eac 100644 --- a/sdk/src/test/java/io/dapr/client/DaprClientHttpTest.java +++ b/sdk/src/test/java/io/dapr/client/DaprClientHttpTest.java @@ -7,7 +7,7 @@ import com.fasterxml.jackson.core.JsonParseException; import io.dapr.client.domain.DeleteStateRequestBuilder; import io.dapr.client.domain.GetStateRequestBuilder; -import io.dapr.client.domain.GetStatesRequestBuilder; +import io.dapr.client.domain.GetBulkStateRequestBuilder; import io.dapr.client.domain.HttpExtension; import io.dapr.client.domain.Response; import io.dapr.client.domain.State; @@ -25,7 +25,6 @@ import org.mockito.Mockito; import reactor.core.publisher.Mono; -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Base64; @@ -121,7 +120,7 @@ public void invokeServiceVerbNull() { daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient); daprClientHttp = new DaprClientHttp(daprHttp); assertThrowsDaprException(IllegalArgumentException.class, () -> - daprClientHttp.invokeService(null, "", "", null, null, (Class)null).block()); + daprClientHttp.invokeMethod(null, "", "", null, null, (Class)null).block()); } @Test @@ -133,31 +132,31 @@ public void invokeServiceIllegalArgumentException() { daprClientHttp = new DaprClientHttp(daprHttp); assertThrowsDaprException(IllegalArgumentException.class, () -> { // null HttpMethod - daprClientHttp.invokeService("1", "2", "3", new HttpExtension(null, null), null, (Class)null).block(); + daprClientHttp.invokeMethod("1", "2", "3", new HttpExtension(null, null), null, (Class)null).block(); }); assertThrowsDaprException(IllegalArgumentException.class, () -> { // null HttpExtension - daprClientHttp.invokeService("1", "2", "3", null, null, (Class)null).block(); + daprClientHttp.invokeMethod("1", "2", "3", null, null, (Class)null).block(); }); assertThrowsDaprException(IllegalArgumentException.class, () -> { // empty appId - daprClientHttp.invokeService("", "1", null, HttpExtension.GET, null, (Class)null).block(); + daprClientHttp.invokeMethod("", "1", null, HttpExtension.GET, null, (Class)null).block(); }); assertThrowsDaprException(IllegalArgumentException.class, () -> { // null appId, empty method - daprClientHttp.invokeService(null, "", null, HttpExtension.POST, null, (Class)null).block(); + daprClientHttp.invokeMethod(null, "", null, HttpExtension.POST, null, (Class)null).block(); }); assertThrowsDaprException(IllegalArgumentException.class, () -> { // empty method - daprClientHttp.invokeService("1", "", null, HttpExtension.PUT, null, (Class)null).block(); + daprClientHttp.invokeMethod("1", "", null, HttpExtension.PUT, null, (Class)null).block(); }); assertThrowsDaprException(IllegalArgumentException.class, () -> { // null method - daprClientHttp.invokeService("1", null, null, HttpExtension.DELETE, null, (Class)null).block(); + daprClientHttp.invokeMethod("1", null, null, HttpExtension.DELETE, null, (Class)null).block(); }); assertThrowsDaprException(JsonParseException.class, () -> { // invalid JSON response - daprClientHttp.invokeService("41", "badorder", null, HttpExtension.GET, null, String.class).block(); + daprClientHttp.invokeMethod("41", "badorder", null, HttpExtension.GET, null, String.class).block(); }); } @@ -171,7 +170,7 @@ public void invokeServiceMethodNull() { daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient); daprClientHttp = new DaprClientHttp(daprHttp); assertThrowsDaprException(IllegalArgumentException.class, () -> - daprClientHttp.invokeService("1", "", null, HttpExtension.POST, null, (Class)null).block()); + daprClientHttp.invokeMethod("1", "", null, HttpExtension.POST, null, (Class)null).block()); } @Test @@ -181,7 +180,7 @@ public void invokeService() { .respond("\"hello world\""); daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient); daprClientHttp = new DaprClientHttp(daprHttp); - Mono mono = daprClientHttp.invokeService("41", "neworder", null, HttpExtension.GET, null, String.class); + Mono mono = daprClientHttp.invokeMethod("41", "neworder", null, HttpExtension.GET, null, String.class); assertEquals("hello world", mono.block()); } @@ -192,7 +191,7 @@ public void invokeServiceNullResponse() { .respond(new byte[0]); daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient); daprClientHttp = new DaprClientHttp(daprHttp); - Mono mono = daprClientHttp.invokeService("41", "neworder", null, HttpExtension.GET, null, String.class); + Mono mono = daprClientHttp.invokeMethod("41", "neworder", null, HttpExtension.GET, null, String.class); assertNull(mono.block()); } @@ -203,7 +202,7 @@ public void simpleInvokeService() { .respond(EXPECTED_RESULT); daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient); daprClientHttp = new DaprClientHttp(daprHttp); - Mono mono = daprClientHttp.invokeService("41", "neworder", null, HttpExtension.GET, byte[].class); + Mono mono = daprClientHttp.invokeMethod("41", "neworder", null, HttpExtension.GET, byte[].class); assertEquals(new String(mono.block()), EXPECTED_RESULT); } @@ -215,7 +214,7 @@ public void invokeServiceWithMetadataMap() { .respond(EXPECTED_RESULT); daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient); daprClientHttp = new DaprClientHttp(daprHttp); - Mono mono = daprClientHttp.invokeService("41", "neworder", (byte[]) null, HttpExtension.GET, map); + Mono mono = daprClientHttp.invokeMethod("41", "neworder", (byte[]) null, HttpExtension.GET, map); String monoString = new String(mono.block()); assertEquals(monoString, EXPECTED_RESULT); } @@ -228,7 +227,7 @@ public void invokeServiceWithOutRequest() { .respond(EXPECTED_RESULT); daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient); daprClientHttp = new DaprClientHttp(daprHttp); - Mono mono = daprClientHttp.invokeService("41", "neworder", HttpExtension.GET, map); + Mono mono = daprClientHttp.invokeMethod("41", "neworder", HttpExtension.GET, map); assertNull(mono.block()); } @@ -240,7 +239,7 @@ public void invokeServiceWithRequest() { .respond(EXPECTED_RESULT); daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient); daprClientHttp = new DaprClientHttp(daprHttp); - Mono mono = daprClientHttp.invokeService("41", "neworder", "", HttpExtension.GET, map); + Mono mono = daprClientHttp.invokeMethod("41", "neworder", "", HttpExtension.GET, map); assertNull(mono.block()); } @@ -255,7 +254,7 @@ public void invokeServiceWithRequestAndQueryString() { Map queryString = new HashMap<>(); queryString.put("test", "1"); HttpExtension httpExtension = new HttpExtension(DaprHttp.HttpMethods.GET, queryString); - Mono mono = daprClientHttp.invokeService("41", "neworder", "", httpExtension, map); + Mono mono = daprClientHttp.invokeMethod("41", "neworder", "", httpExtension, map); assertNull(mono.block()); } @@ -267,7 +266,7 @@ public void invokeServiceNoHotMono() { .respond(500); daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient); daprClientHttp = new DaprClientHttp(daprHttp); - daprClientHttp.invokeService("41", "neworder", "", HttpExtension.GET, map); + daprClientHttp.invokeMethod("41", "neworder", "", HttpExtension.GET, map); // No exception should be thrown because did not call block() on mono above. } @@ -459,25 +458,25 @@ public void getStatesErrors() { daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient); daprClientHttp = new DaprClientHttp(daprHttp); assertThrowsDaprException(IllegalArgumentException.class, () -> { - daprClientHttp.getStates(STATE_STORE_NAME, null, String.class).block(); + daprClientHttp.getBulkState(STATE_STORE_NAME, null, String.class).block(); }); assertThrowsDaprException(IllegalArgumentException.class, () -> { - daprClientHttp.getStates(STATE_STORE_NAME, new ArrayList<>(), String.class).block(); + daprClientHttp.getBulkState(STATE_STORE_NAME, new ArrayList<>(), String.class).block(); }); assertThrowsDaprException(IllegalArgumentException.class, () -> { - daprClientHttp.getStates(null, Arrays.asList("100", "200"), String.class).block(); + daprClientHttp.getBulkState(null, Arrays.asList("100", "200"), String.class).block(); }); assertThrowsDaprException(IllegalArgumentException.class, () -> { - daprClientHttp.getStates("", Arrays.asList("100", "200"), String.class).block(); + daprClientHttp.getBulkState("", Arrays.asList("100", "200"), String.class).block(); }); assertThrowsDaprException(IllegalArgumentException.class, () -> { - daprClientHttp.getStates( - new GetStatesRequestBuilder(STATE_STORE_NAME, "100").withParallelism(-1).build(), + daprClientHttp.getBulkState( + new GetBulkStateRequestBuilder(STATE_STORE_NAME, "100").withParallelism(-1).build(), TypeRef.get(String.class)).block(); }); assertThrowsDaprException(JsonParseException.class, () -> { - daprClientHttp.getStates( - new GetStatesRequestBuilder(STATE_STORE_NAME, "100").build(), + daprClientHttp.getBulkState( + new GetBulkStateRequestBuilder(STATE_STORE_NAME, "100").build(), TypeRef.get(String.class)).block(); }); } @@ -491,7 +490,7 @@ public void getStatesString() { daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient); daprClientHttp = new DaprClientHttp(daprHttp); List> result = - daprClientHttp.getStates(STATE_STORE_NAME, Arrays.asList("100", "200"), String.class).block(); + daprClientHttp.getBulkState(STATE_STORE_NAME, Arrays.asList("100", "200"), String.class).block(); assertEquals(2, result.size()); assertEquals("100", result.stream().findFirst().get().getKey()); assertEquals("hello world", result.stream().findFirst().get().getValue()); @@ -512,7 +511,7 @@ public void getStatesInteger() { daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient); daprClientHttp = new DaprClientHttp(daprHttp); List> result = - daprClientHttp.getStates(STATE_STORE_NAME, Arrays.asList("100", "200"), int.class).block(); + daprClientHttp.getBulkState(STATE_STORE_NAME, Arrays.asList("100", "200"), int.class).block(); assertEquals(2, result.size()); assertEquals("100", result.stream().findFirst().get().getKey()); assertEquals(1234, (int)result.stream().findFirst().get().getValue()); @@ -534,7 +533,7 @@ public void getStatesBoolean() { daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient); daprClientHttp = new DaprClientHttp(daprHttp); List> result = - daprClientHttp.getStates(STATE_STORE_NAME, Arrays.asList("100", "200"), boolean.class).block(); + daprClientHttp.getBulkState(STATE_STORE_NAME, Arrays.asList("100", "200"), boolean.class).block(); assertNotNull(result); assertEquals(2, result.size()); assertEquals("100", result.stream().findFirst().get().getKey()); @@ -560,7 +559,7 @@ public void getStatesByteArray() { // JSON cannot differentiate if data returned is String or byte[], it is ambiguous. So we get base64 encoded back. // So, users should use String instead of byte[]. List> result = - daprClientHttp.getStates(STATE_STORE_NAME, Arrays.asList("100", "200"), String.class).block(); + daprClientHttp.getBulkState(STATE_STORE_NAME, Arrays.asList("100", "200"), String.class).block(); assertEquals(2, result.size()); assertEquals("100", result.stream().findFirst().get().getKey()); assertEquals(base64Value, result.stream().findFirst().get().getValue()); @@ -585,7 +584,7 @@ public void getStatesObject() { // JSON cannot differentiate if data returned is String or byte[], it is ambiguous. So we get base64 encoded back. // So, users should use String instead of byte[]. List> result = - daprClientHttp.getStates(STATE_STORE_NAME, Arrays.asList("100", "200"), MyObject.class).block(); + daprClientHttp.getBulkState(STATE_STORE_NAME, Arrays.asList("100", "200"), MyObject.class).block(); assertEquals(2, result.size()); assertEquals("100", result.stream().findFirst().get().getKey()); assertEquals(object, result.stream().findFirst().get().getValue()); @@ -693,7 +692,7 @@ public void saveStates() { .respond(EXPECTED_RESULT); daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient); daprClientHttp = new DaprClientHttp(daprHttp); - Mono mono = daprClientHttp.saveStates(STATE_STORE_NAME, stateKeyValueList); + Mono mono = daprClientHttp.saveBulkState(STATE_STORE_NAME, stateKeyValueList); assertNull(mono.block()); } @@ -702,9 +701,9 @@ public void saveStatesErrors() { daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient); daprClientHttp = new DaprClientHttp(daprHttp); assertThrowsDaprException(IllegalArgumentException.class, () -> - daprClientHttp.saveStates(null, null).block()); + daprClientHttp.saveBulkState(null, null).block()); assertThrowsDaprException(IllegalArgumentException.class, () -> - daprClientHttp.saveStates("", null).block()); + daprClientHttp.saveBulkState("", null).block()); } @Test @@ -712,9 +711,9 @@ public void saveStatesNull() { List> stateKeyValueList = new ArrayList<>(); daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient); daprClientHttp = new DaprClientHttp(daprHttp); - Mono mono = daprClientHttp.saveStates(STATE_STORE_NAME, null); + Mono mono = daprClientHttp.saveBulkState(STATE_STORE_NAME, null); assertNull(mono.block()); - Mono mono1 = daprClientHttp.saveStates(STATE_STORE_NAME, stateKeyValueList); + Mono mono1 = daprClientHttp.saveBulkState(STATE_STORE_NAME, stateKeyValueList); assertNull(mono1.block()); } @@ -727,7 +726,7 @@ public void saveStatesNullState() { .respond(EXPECTED_RESULT); daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient); daprClientHttp = new DaprClientHttp(daprHttp); - Mono mono1 = daprClientHttp.saveStates(STATE_STORE_NAME, stateKeyValueList); + Mono mono1 = daprClientHttp.saveBulkState(STATE_STORE_NAME, stateKeyValueList); assertNull(mono1.block()); } @@ -740,7 +739,7 @@ public void saveStatesEtagNull() { .respond(EXPECTED_RESULT); daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient); daprClientHttp = new DaprClientHttp(daprHttp); - Mono mono = daprClientHttp.saveStates(STATE_STORE_NAME, stateKeyValueList); + Mono mono = daprClientHttp.saveBulkState(STATE_STORE_NAME, stateKeyValueList); assertNull(mono.block()); } @@ -753,7 +752,7 @@ public void saveStatesEtagEmpty() { .respond(EXPECTED_RESULT); daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient); daprClientHttp = new DaprClientHttp(daprHttp); - Mono mono = daprClientHttp.saveStates(STATE_STORE_NAME, stateKeyValueList); + Mono mono = daprClientHttp.saveBulkState(STATE_STORE_NAME, stateKeyValueList); assertNull(mono.block()); } @@ -800,7 +799,7 @@ public void simpleExecuteTransaction() { TransactionalStateOperation deleteOperation = new TransactionalStateOperation<>( TransactionalStateOperation.OperationType.DELETE, new State<>("deleteKey")); - Mono mono = daprClientHttp.executeTransaction(STATE_STORE_NAME, Arrays.asList(upsertOperation, + Mono mono = daprClientHttp.executeStateTransaction(STATE_STORE_NAME, Arrays.asList(upsertOperation, deleteOperation)); assertNull(mono.block()); } @@ -824,7 +823,7 @@ public void simpleExecuteTransactionNullEtag() { TransactionalStateOperation deleteOperation = new TransactionalStateOperation<>( TransactionalStateOperation.OperationType.DELETE, new State<>("deleteKey")); - Mono mono = daprClientHttp.executeTransaction(STATE_STORE_NAME, Arrays.asList(upsertOperation, + Mono mono = daprClientHttp.executeStateTransaction(STATE_STORE_NAME, Arrays.asList(upsertOperation, deleteOperation)); assertNull(mono.block()); } @@ -848,7 +847,7 @@ public void simpleExecuteTransactionEmptyEtag() { TransactionalStateOperation deleteOperation = new TransactionalStateOperation<>( TransactionalStateOperation.OperationType.DELETE, new State<>("deleteKey")); - Mono mono = daprClientHttp.executeTransaction(STATE_STORE_NAME, Arrays.asList(upsertOperation, + Mono mono = daprClientHttp.executeStateTransaction(STATE_STORE_NAME, Arrays.asList(upsertOperation, deleteOperation)); assertNull(mono.block()); } @@ -875,7 +874,7 @@ public void simpleExecuteTransactionNullOperationAndNullState() { TransactionalStateOperation nullStateOperation = new TransactionalStateOperation<>( TransactionalStateOperation.OperationType.DELETE, null); - Mono mono = daprClientHttp.executeTransaction(STATE_STORE_NAME, Arrays.asList( + Mono mono = daprClientHttp.executeStateTransaction(STATE_STORE_NAME, Arrays.asList( null, nullStateOperation, upsertOperation, @@ -888,9 +887,9 @@ public void executeTransactionErrors() { daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient); daprClientHttp = new DaprClientHttp(daprHttp); assertThrowsDaprException(IllegalArgumentException.class, () -> - daprClientHttp.executeTransaction(null, null).block()); + daprClientHttp.executeStateTransaction(null, null).block()); assertThrowsDaprException(IllegalArgumentException.class, () -> - daprClientHttp.executeTransaction("", null).block()); + daprClientHttp.executeStateTransaction("", null).block()); } @Test @@ -900,9 +899,9 @@ public void simpleExecuteTransactionNull() { .respond(EXPECTED_RESULT); daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient); daprClientHttp = new DaprClientHttp(daprHttp); - Mono mono = daprClientHttp.executeTransaction(STATE_STORE_NAME, null); + Mono mono = daprClientHttp.executeStateTransaction(STATE_STORE_NAME, null); assertNull(mono.block()); - mono = daprClientHttp.executeTransaction(STATE_STORE_NAME, Collections.emptyList()); + mono = daprClientHttp.executeStateTransaction(STATE_STORE_NAME, Collections.emptyList()); assertNull(mono.block()); } diff --git a/sdk/src/test/java/io/dapr/runtime/DaprRuntimeTest.java b/sdk/src/test/java/io/dapr/runtime/DaprRuntimeTest.java index 6a4ca4a8e5..4122d0699e 100644 --- a/sdk/src/test/java/io/dapr/runtime/DaprRuntimeTest.java +++ b/sdk/src/test/java/io/dapr/runtime/DaprRuntimeTest.java @@ -220,7 +220,7 @@ public void invokeHappyCase() throws Exception { serializer.serialize(message.data), message.metadata) .map(r -> new DaprHttpStub.ResponseStub(r, null, 200))); - Mono response = client.invokeService(APP_ID, METHOD_NAME, message.data, HttpExtension.POST, + Mono response = client.invokeMethod(APP_ID, METHOD_NAME, message.data, HttpExtension.POST, message.metadata, byte[].class); Assert.assertArrayEquals(expectedResponse, response.block());