Rename methods and parameters for consistency across SDKs (#410)

Signed-off-by: Arghya Sadhu <arghya88@gmail.com>
This commit is contained in:
Arghya Sadhu 2020-12-16 13:36:54 +05:30 committed by GitHub
parent de4c37e3a5
commit 11d9e3b0b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
59 changed files with 741 additions and 740 deletions

View File

@ -33,7 +33,7 @@ public 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);

View File

@ -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.

View File

@ -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));
}

View File

@ -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

View File

@ -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<List<State<MyClass>>> 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<List<State<MyClass>>> 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.

View File

@ -70,10 +70,10 @@ 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<List<State<MyClass>>> retrievedMessagesMono = client.getStates(STATE_STORE_NAME,
Mono<List<State<MyClass>>> 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 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<List<State<MyClass>>> retrievedDeletedMessageMono = client.getStates(STATE_STORE_NAME,
Mono<List<State<MyClass>>> 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);

View File

@ -48,7 +48,7 @@ public class InvokeClient {
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 class InvokeClient {
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();
}
}

View File

@ -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

View File

@ -36,7 +36,7 @@ public interface ActorProxy {
* @param <T> The type to be returned.
* @return Asynchronous result with the Actor's response.
*/
<T> Mono<T> invokeActorMethod(String methodName, TypeRef<T> type);
<T> Mono<T> invoke(String methodName, TypeRef<T> type);
/**
* Invokes an Actor method on Dapr.
@ -46,7 +46,7 @@ public interface ActorProxy {
* @param <T> The type to be returned.
* @return Asynchronous result with the Actor's response.
*/
<T> Mono<T> invokeActorMethod(String methodName, Class<T> clazz);
<T> Mono<T> invoke(String methodName, Class<T> clazz);
/**
* Invokes an Actor method on Dapr.
@ -57,7 +57,7 @@ public interface ActorProxy {
* @param <T> The type to be returned.
* @return Asynchronous result with the Actor's response.
*/
<T> Mono<T> invokeActorMethod(String methodName, Object data, TypeRef<T> type);
<T> Mono<T> invoke(String methodName, Object data, TypeRef<T> type);
/**
* Invokes an Actor method on Dapr.
@ -68,7 +68,7 @@ public interface ActorProxy {
* @param <T> The type to be returned.
* @return Asynchronous result with the Actor's response.
*/
<T> Mono<T> invokeActorMethod(String methodName, Object data, Class<T> clazz);
<T> Mono<T> invoke(String methodName, Object data, Class<T> 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<Void> invokeActorMethod(String methodName);
Mono<Void> 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<Void> invokeActorMethod(String methodName, Object data);
Mono<Void> invoke(String methodName, Object data);
}

View File

@ -74,8 +74,8 @@ class ActorProxyImpl implements ActorProxy, InvocationHandler {
* {@inheritDoc}
*/
@Override
public <T> Mono<T> invokeActorMethod(String methodName, Object data, TypeRef<T> type) {
return this.daprClient.invokeActorMethod(actorType, actorId.toString(), methodName, this.serialize(data))
public <T> Mono<T> invoke(String methodName, Object data, TypeRef<T> 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 @@ class ActorProxyImpl implements ActorProxy, InvocationHandler {
* {@inheritDoc}
*/
@Override
public <T> Mono<T> invokeActorMethod(String methodName, Object data, Class<T> clazz) {
return this.invokeActorMethod(methodName, data, TypeRef.get(clazz));
public <T> Mono<T> invoke(String methodName, Object data, Class<T> clazz) {
return this.invoke(methodName, data, TypeRef.get(clazz));
}
/**
* {@inheritDoc}
*/
@Override
public <T> Mono<T> invokeActorMethod(String methodName, TypeRef<T> type) {
return this.daprClient.invokeActorMethod(actorType, actorId.toString(), methodName, null)
public <T> Mono<T> invoke(String methodName, TypeRef<T> type) {
return this.daprClient.invoke(actorType, actorId.toString(), methodName, null)
.filter(s -> s.length > 0)
.map(s -> deserialize(s, type));
}
@ -102,24 +102,24 @@ class ActorProxyImpl implements ActorProxy, InvocationHandler {
* {@inheritDoc}
*/
@Override
public <T> Mono<T> invokeActorMethod(String methodName, Class<T> clazz) {
return this.invokeActorMethod(methodName, TypeRef.get(clazz));
public <T> Mono<T> invoke(String methodName, Class<T> clazz) {
return this.invoke(methodName, TypeRef.get(clazz));
}
/**
* {@inheritDoc}
*/
@Override
public Mono<Void> invokeActorMethod(String methodName) {
return this.daprClient.invokeActorMethod(actorType, actorId.toString(), methodName, null).then();
public Mono<Void> invoke(String methodName) {
return this.daprClient.invoke(actorType, actorId.toString(), methodName, null).then();
}
/**
* {@inheritDoc}
*/
@Override
public Mono<Void> invokeActorMethod(String methodName, Object data) {
return this.daprClient.invokeActorMethod(actorType, actorId.toString(), methodName, this.serialize(data)).then();
public Mono<Void> invoke(String methodName, Object data) {
return this.daprClient.invoke(actorType, actorId.toString(), methodName, this.serialize(data)).then();
}
/**
@ -140,25 +140,25 @@ class ActorProxyImpl implements ActorProxy, InvocationHandler {
if (method.getReturnType().equals(Mono.class)) {
ActorMethod actorMethodAnnotation = method.getDeclaredAnnotation(ActorMethod.class);
if (actorMethodAnnotation == null) {
return 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();
}
/**

View File

@ -21,6 +21,6 @@ interface DaprClient {
* @param jsonPayload Serialized body.
* @return Asynchronous result with the Actor's response.
*/
Mono<byte[]> invokeActorMethod(String actorType, String actorId, String methodName, byte[] jsonPayload);
Mono<byte[]> invoke(String actorType, String actorId, String methodName, byte[] jsonPayload);
}

View File

@ -40,7 +40,7 @@ class DaprGrpcClient implements DaprClient {
* {@inheritDoc}
*/
@Override
public Mono<byte[]> invokeActorMethod(String actorType, String actorId, String methodName, byte[] jsonPayload) {
public Mono<byte[]> invoke(String actorType, String actorId, String methodName, byte[] jsonPayload) {
return Mono.fromCallable(DaprException.wrap(() -> {
DaprProtos.InvokeActorRequest req =
DaprProtos.InvokeActorRequest.newBuilder()

View File

@ -45,7 +45,7 @@ class DaprHttpClient implements DaprClient {
* {@inheritDoc}
*/
@Override
public Mono<byte[]> invokeActorMethod(String actorType, String actorId, String methodName, byte[] jsonPayload) {
public Mono<byte[]> invoke(String actorType, String actorId, String methodName, byte[] jsonPayload) {
String url = String.format(ACTOR_METHOD_RELATIVE_URL_FORMAT, actorType, actorId, methodName);
Mono<DaprHttp.Response> responseMono =
this.client.invokeApi(DaprHttp.HttpMethods.POST.name(), url, null, jsonPayload, null, null);

View File

@ -114,7 +114,7 @@ public abstract class AbstractActor {
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 @@ public abstract class AbstractActor {
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 @@ public abstract class AbstractActor {
* @return Asynchronous void response.
*/
protected Mono<Void> 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 @@ public abstract class AbstractActor {
* @return Asynchronous void response.
*/
protected Mono<Void> unregisterReminder(String reminderName) {
return this.actorRuntimeContext.getDaprClient().unregisterActorReminder(
return this.actorRuntimeContext.getDaprClient().unregisterReminder(
this.actorRuntimeContext.getActorTypeInformation().getName(),
this.id.toString(),
reminderName);

View File

@ -22,7 +22,7 @@ interface DaprClient {
* @param keyName State name.
* @return Asynchronous result with current state value.
*/
Mono<byte[]> getActorState(String actorType, String actorId, String keyName);
Mono<byte[]> 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<Void> saveActorStateTransactionally(String actorType, String actorId, List<ActorStateOperation> operations);
Mono<Void> saveStateTransactionally(String actorType, String actorId, List<ActorStateOperation> operations);
/**
* Register a reminder.
@ -43,7 +43,7 @@ interface DaprClient {
* @param reminderParams Parameters for the reminder.
* @return Asynchronous void result.
*/
Mono<Void> registerActorReminder(
Mono<Void> registerReminder(
String actorType,
String actorId,
String reminderName,
@ -57,7 +57,7 @@ interface DaprClient {
* @param reminderName Name of reminder to be unregistered.
* @return Asynchronous void result.
*/
Mono<Void> unregisterActorReminder(String actorType, String actorId, String reminderName);
Mono<Void> unregisterReminder(String actorType, String actorId, String reminderName);
/**
* Register a timer.
@ -68,7 +68,7 @@ interface DaprClient {
* @param timerParams Parameters for the timer.
* @return Asynchronous void result.
*/
Mono<Void> registerActorTimer(String actorType, String actorId, String timerName, ActorTimerParams timerParams);
Mono<Void> registerTimer(String actorType, String actorId, String timerName, ActorTimerParams timerParams);
/**
* Unregisters a timer.
@ -78,5 +78,5 @@ interface DaprClient {
* @param timerName Name of timer to be unregistered.
* @return Asynchronous void result.
*/
Mono<Void> unregisterActorTimer(String actorType, String actorId, String timerName);
Mono<Void> unregisterTimer(String actorType, String actorId, String timerName);
}

View File

@ -66,7 +66,7 @@ class DaprGrpcClient implements DaprClient {
* {@inheritDoc}
*/
@Override
public Mono<byte[]> getActorState(String actorType, String actorId, String keyName) {
public Mono<byte[]> getState(String actorType, String actorId, String keyName) {
return Mono.fromCallable(() -> {
DaprProtos.GetActorStateRequest req =
DaprProtos.GetActorStateRequest.newBuilder()
@ -84,7 +84,7 @@ class DaprGrpcClient implements DaprClient {
* {@inheritDoc}
*/
@Override
public Mono<Void> saveActorStateTransactionally(
public Mono<Void> saveStateTransactionally(
String actorType,
String actorId,
List<ActorStateOperation> operations) {
@ -134,7 +134,7 @@ class DaprGrpcClient implements DaprClient {
* {@inheritDoc}
*/
@Override
public Mono<Void> registerActorReminder(
public Mono<Void> registerReminder(
String actorType,
String actorId,
String reminderName,
@ -160,7 +160,7 @@ class DaprGrpcClient implements DaprClient {
* {@inheritDoc}
*/
@Override
public Mono<Void> unregisterActorReminder(String actorType, String actorId, String reminderName) {
public Mono<Void> unregisterReminder(String actorType, String actorId, String reminderName) {
return Mono.fromCallable(() -> {
DaprProtos.UnregisterActorReminderRequest req =
DaprProtos.UnregisterActorReminderRequest.newBuilder()
@ -179,7 +179,7 @@ class DaprGrpcClient implements DaprClient {
* {@inheritDoc}
*/
@Override
public Mono<Void> registerActorTimer(
public Mono<Void> registerTimer(
String actorType,
String actorId,
String timerName,
@ -206,7 +206,7 @@ class DaprGrpcClient implements DaprClient {
* {@inheritDoc}
*/
@Override
public Mono<Void> unregisterActorTimer(String actorType, String actorId, String timerName) {
public Mono<Void> unregisterTimer(String actorType, String actorId, String timerName) {
return Mono.fromCallable(() -> {
DaprProtos.UnregisterActorTimerRequest req =
DaprProtos.UnregisterActorTimerRequest.newBuilder()

View File

@ -74,7 +74,7 @@ class DaprHttpClient implements DaprClient {
* {@inheritDoc}
*/
@Override
public Mono<byte[]> getActorState(String actorType, String actorId, String keyName) {
public Mono<byte[]> getState(String actorType, String actorId, String keyName) {
String url = String.format(ACTOR_STATE_KEY_RELATIVE_URL_FORMAT, actorType, actorId, keyName);
Mono<DaprHttp.Response> responseMono =
this.client.invokeApi(DaprHttp.HttpMethods.GET.name(), url, null, "", null, null);
@ -91,7 +91,7 @@ class DaprHttpClient implements DaprClient {
* {@inheritDoc}
*/
@Override
public Mono<Void> saveActorStateTransactionally(
public Mono<Void> saveStateTransactionally(
String actorType,
String actorId,
List<ActorStateOperation> operations) {
@ -152,7 +152,7 @@ class DaprHttpClient implements DaprClient {
* {@inheritDoc}
*/
@Override
public Mono<Void> registerActorReminder(
public Mono<Void> registerReminder(
String actorType,
String actorId,
String reminderName,
@ -168,7 +168,7 @@ class DaprHttpClient implements DaprClient {
* {@inheritDoc}
*/
@Override
public Mono<Void> unregisterActorReminder(String actorType, String actorId, String reminderName) {
public Mono<Void> 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 @@ class DaprHttpClient implements DaprClient {
* {@inheritDoc}
*/
@Override
public Mono<Void> registerActorTimer(
public Mono<Void> registerTimer(
String actorType,
String actorId,
String timerName,
@ -193,7 +193,7 @@ class DaprHttpClient implements DaprClient {
* {@inheritDoc}
*/
@Override
public Mono<Void> unregisterActorTimer(String actorType, String actorId, String timerName) {
public Mono<Void> 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();
}

View File

@ -60,7 +60,7 @@ class DaprStateAsyncProvider {
}
<T> Mono<T> load(String actorType, ActorId actorId, String stateName, TypeRef<T> type) {
Mono<byte[]> result = this.daprClient.getActorState(actorType, actorId.toString(), stateName);
Mono<byte[]> result = this.daprClient.getState(actorType, actorId.toString(), stateName);
return result.flatMap(s -> {
try {
@ -88,7 +88,7 @@ class DaprStateAsyncProvider {
}
Mono<Boolean> contains(String actorType, ActorId actorId, String stateName) {
Mono<byte[]> result = this.daprClient.getActorState(actorType, actorId.toString(), stateName);
Mono<byte[]> result = this.daprClient.getState(actorType, actorId.toString(), stateName);
return result.map(s -> s.length > 0).defaultIfEmpty(false);
}
@ -155,7 +155,7 @@ class DaprStateAsyncProvider {
operations.add(new ActorStateOperation(operationName, key, value));
}
return this.daprClient.saveActorStateTransactionally(actorType, actorId.toString(), operations);
return this.daprClient.saveStateTransactionally(actorType, actorId.toString(), operations);
}
}

View File

@ -40,7 +40,7 @@ public class ActorProxyImplTest {
Mono<byte[]> 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 class ActorProxyImplTest {
new DefaultObjectSerializer(),
daprClient);
Mono<MyData> result = actorProxy.invokeActorMethod("getData", MyData.class);
Mono<MyData> result = actorProxy.invoke("getData", MyData.class);
MyData myData = result.block();
Assert.assertNotNull(myData);
Assert.assertEquals("valueA", myData.getPropertyA());
@ -62,7 +62,7 @@ public class ActorProxyImplTest {
Mono<byte[]> 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 class ActorProxyImplTest {
Mono<byte[]> 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 class ActorProxyImplTest {
Mono<byte[]> 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 class ActorProxyImplTest {
Mono<byte[]> 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 class ActorProxyImplTest {
final DaprClient daprClient = mock(DaprClient.class);
Mono<byte[]> 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 class ActorProxyImplTest {
final DaprClient daprClient = mock(DaprClient.class);
Mono<byte[]> 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 class ActorProxyImplTest {
final DaprClient daprClient = mock(DaprClient.class);
Mono<byte[]> 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 class ActorProxyImplTest {
final DaprClient daprClient = mock(DaprClient.class);
Mono<byte[]> 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 class ActorProxyImplTest {
@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 class ActorProxyImplTest {
new DefaultObjectSerializer(),
daprClient);
Mono<MyData> result = actorProxy.invokeActorMethod("getData", MyData.class);
Mono<MyData> result = actorProxy.invoke("getData", MyData.class);
MyData myData = result.block();
Assert.assertNull(myData);
}
@ -268,7 +268,7 @@ public class ActorProxyImplTest {
@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 class ActorProxyImplTest {
new DefaultObjectSerializer(),
daprClient);
Mono<MyData> result = actorProxy.invokeActorMethod("getData", MyData.class);
Mono<MyData> result = actorProxy.invoke("getData", MyData.class);
result.doOnSuccess(x ->
Assert.fail("Not exception was throw"))
@ -288,7 +288,7 @@ public class ActorProxyImplTest {
@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 class ActorProxyImplTest {
saveData.setPropertyA("valueA");
saveData.setPropertyB("valueB");
Mono<MyData> result = actorProxy.invokeActorMethod("getData", saveData, MyData.class);
Mono<MyData> result = actorProxy.invoke("getData", saveData, MyData.class);
MyData myData = result.block();
Assert.assertNotNull(myData);
Assert.assertEquals("valueA", myData.getPropertyA());
@ -313,7 +313,7 @@ public class ActorProxyImplTest {
@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 class ActorProxyImplTest {
saveData.setPropertyA("valueA");
saveData.setPropertyB("valueB");
Mono<MyData> result = actorProxy.invokeActorMethod("getData", saveData, MyData.class);
Mono<MyData> result = actorProxy.invoke("getData", saveData, MyData.class);
result.doOnSuccess(x ->
Assert.fail("Not exception was throw"))
.doOnError(Throwable::printStackTrace
@ -337,7 +337,7 @@ public class ActorProxyImplTest {
@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 class ActorProxyImplTest {
saveData.setPropertyA("valueA");
saveData.setPropertyB("valueB");
Mono<MyData> result = actorProxy.invokeActorMethod("getData", saveData, MyData.class);
Mono<MyData> result = actorProxy.invoke("getData", saveData, MyData.class);
MyData myData = result.block();
Assert.assertNull(myData);
}
@ -359,7 +359,7 @@ public class ActorProxyImplTest {
@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 class ActorProxyImplTest {
saveData.setPropertyB("valueB");
saveData.setMyData(saveData);
Mono<MyData> result = actorProxy.invokeActorMethod("getData", saveData, MyData.class);
Mono<MyData> result = actorProxy.invoke("getData", saveData, MyData.class);
result.doOnSuccess(x ->
Assert.fail("Not exception was throw"))
.doOnError(Throwable::printStackTrace
@ -388,7 +388,7 @@ public class ActorProxyImplTest {
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 class ActorProxyImplTest {
new DefaultObjectSerializer(),
daprClient);
Mono<Void> result = actorProxy.invokeActorMethod("getData", saveData);
Mono<Void> result = actorProxy.invoke("getData", saveData);
Void emptyResponse = result.block();
Assert.assertNull(emptyResponse);
}
@ -411,7 +411,7 @@ public class ActorProxyImplTest {
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 class ActorProxyImplTest {
new DefaultObjectSerializer(),
daprClient);
Mono<Void> result = actorProxy.invokeActorMethod("getData", saveData);
Mono<Void> result = actorProxy.invoke("getData", saveData);
Void emptyResponse = result.doOnError(Throwable::printStackTrace).block();
Assert.assertNull(emptyResponse);
}
@ -428,7 +428,7 @@ public class ActorProxyImplTest {
@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 class ActorProxyImplTest {
new DefaultObjectSerializer(),
daprClient);
Mono<Void> result = actorProxy.invokeActorMethod("getData");
Mono<Void> result = actorProxy.invoke("getData");
Void emptyResponse = result.block();
Assert.assertNull(emptyResponse);
}

View File

@ -10,7 +10,7 @@ import reactor.core.publisher.Mono;
public class DaprClientStub implements DaprClient {
@Override
public Mono<byte[]> invokeActorMethod(String actorType, String actorId, String methodName, byte[] jsonPayload) {
public Mono<byte[]> invoke(String actorType, String actorId, String methodName, byte[] jsonPayload) {
return Mono.just(new byte[0]);
}

View File

@ -54,7 +54,7 @@ public class DaprGrpcClientTest {
assertArrayEquals(payload, argument.getData().toByteArray());
return true;
}))).thenReturn(settableFuture);
Mono<byte[]> result = client.invokeActorMethod(ACTOR_TYPE, ACTOR_ID, methodName, payload);
Mono<byte[]> result = client.invoke(ACTOR_TYPE, ACTOR_ID, methodName, payload);
assertArrayEquals(response, result.block());
}
@ -73,7 +73,7 @@ public class DaprGrpcClientTest {
assertArrayEquals(new byte[0], argument.getData().toByteArray());
return true;
}))).thenReturn(settableFuture);
Mono<byte[]> result = client.invokeActorMethod(ACTOR_TYPE, ACTOR_ID, methodName, null);
Mono<byte[]> result = client.invoke(ACTOR_TYPE, ACTOR_ID, methodName, null);
assertArrayEquals(response, result.block());
}
@ -91,7 +91,7 @@ public class DaprGrpcClientTest {
assertArrayEquals(new byte[0], argument.getData().toByteArray());
return true;
}))).thenReturn(settableFuture);
Mono<byte[]> result = client.invokeActorMethod(ACTOR_TYPE, ACTOR_ID, methodName, null);
Mono<byte[]> result = client.invoke(ACTOR_TYPE, ACTOR_ID, methodName, null);
assertThrowsDaprException(
ExecutionException.class,
@ -114,7 +114,7 @@ public class DaprGrpcClientTest {
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.
}

View File

@ -43,7 +43,7 @@ public class DaprHttpClientTest {
DaprHttp daprHttp = new DaprHttpProxy(Properties.SIDECAR_IP.get(), 3000, okHttpClient);
DaprHttpClient = new DaprHttpClient(daprHttp);
Mono<byte[]> 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 class DaprHttpClientTest {
DaprHttp daprHttp = new DaprHttpProxy(Properties.SIDECAR_IP.get(), 3000, okHttpClient);
DaprHttpClient = new DaprHttpClient(daprHttp);
Mono<byte[]> mono =
DaprHttpClient.invokeActorMethod("DemoActor", "1", "Payment", "".getBytes());
DaprHttpClient.invoke("DemoActor", "1", "Payment", "".getBytes());
assertThrowsDaprException(
"ERR_SOMETHING",

View File

@ -98,7 +98,7 @@ public class ActorCustomSerializerTest {
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 class ActorCustomSerializerTest {
@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 class ActorCustomSerializerTest {
@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 @@ public class ActorCustomSerializerTest {
// 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 @@ public class ActorCustomSerializerTest {
private static <T extends AbstractActor> 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),

View File

@ -287,10 +287,10 @@ public class ActorManagerTest {
private static <T extends AbstractActor> ActorRuntimeContext createContext(Class<T> 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),

View File

@ -139,7 +139,7 @@ public class ActorNoStateTest {
Assert.assertEquals(
proxy.getActorId().toString(),
proxy.invokeActorMethod("getMyId", String.class).block());
proxy.invoke("getMyId", String.class).block());
}
@Test
@ -149,7 +149,7 @@ public class ActorNoStateTest {
// these should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
Assert.assertEquals(
"abcabc",
proxy.invokeActorMethod("stringInStringOut", "abc", String.class).block());
proxy.invoke("stringInStringOut", "abc", String.class).block());
}
@Test
@ -159,11 +159,11 @@ public class ActorNoStateTest {
// these should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
Assert.assertEquals(
false,
proxy.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 class ActorNoStateTest {
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 class ActorNoStateTest {
MyData d = new MyData("hi", 3);
// this should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
MyData response = actorProxy.invokeActorMethod("classInClassOut", d, MyData.class).block();
MyData response = actorProxy.invoke("classInClassOut", d, MyData.class).block();
Assert.assertEquals(
"hihi",
@ -218,7 +218,7 @@ public class ActorNoStateTest {
// 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 @@ public class ActorNoStateTest {
// 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 @@ public class ActorNoStateTest {
private static <T extends AbstractActor> 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),

View File

@ -289,33 +289,33 @@ public class ActorStatefulTest {
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<String> getMessageCall = proxy.invokeActorMethod("getMessage", String.class);
Mono<String> 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 class ActorStatefulTest {
@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<Void> setMessageCall = proxy.invokeActorMethod("setMessage", "first message");
Mono<Void> 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<Boolean> hasMessageCall = proxy.invokeActorMethod("hasMessage", Boolean.class);
Mono<Boolean> 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<Void> deleteMessageCall = proxy.invokeActorMethod("deleteMessage");
Mono<Void> 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<Void> addMessageCall = proxy.invokeActorMethod("addMessage", "second message");
Mono<Void> 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 class ActorStatefulTest {
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 class ActorStatefulTest {
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 class ActorStatefulTest {
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 class ActorStatefulTest {
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 class ActorStatefulTest {
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 class ActorStatefulTest {
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 class ActorStatefulTest {
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 @@ public class ActorStatefulTest {
// 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 @@ public class ActorStatefulTest {
private static <T extends AbstractActor> 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),

View File

@ -56,7 +56,7 @@ public class DaprGrpcClientTest {
ACTOR_ID,
"MyKey"
)))).thenReturn(settableFuture);
Mono<byte[]> result = client.getActorState(ACTOR_TYPE, ACTOR_ID, "MyKey");
Mono<byte[]> 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 class DaprGrpcClientTest {
ACTOR_ID,
"MyKey"
)))).thenReturn(settableFuture);
Mono<byte[]> result = client.getActorState(ACTOR_TYPE, ACTOR_ID, "MyKey");
Mono<byte[]> result = client.getState(ACTOR_TYPE, ACTOR_ID, "MyKey");
assertArrayEquals(data, result.block());
}
@ -86,7 +86,7 @@ public class DaprGrpcClientTest {
ACTOR_ID,
new ArrayList<>()
)))).thenReturn(settableFuture);
Mono<Void> result = client.saveActorStateTransactionally(ACTOR_TYPE, ACTOR_ID, new ArrayList<>());
Mono<Void> 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 class DaprGrpcClientTest {
ACTOR_ID,
Arrays.asList(operations)
)))).thenReturn(settableFuture);
Mono<Void> result = client.saveActorStateTransactionally(ACTOR_TYPE, ACTOR_ID, Arrays.asList(operations));
Mono<Void> result = client.saveStateTransactionally(ACTOR_TYPE, ACTOR_ID, Arrays.asList(operations));
result.block();
}
@ -125,7 +125,7 @@ public class DaprGrpcClientTest {
ACTOR_ID,
Arrays.asList(operations)
)))).thenReturn(settableFuture);
Mono<Void> result = client.saveActorStateTransactionally(ACTOR_TYPE, ACTOR_ID, Arrays.asList(operations));
Mono<Void> result = client.saveStateTransactionally(ACTOR_TYPE, ACTOR_ID, Arrays.asList(operations));
result.block();
}
@ -136,7 +136,7 @@ public class DaprGrpcClientTest {
new ActorStateOperation("delete", "mykey", null),
};
Mono<Void> result = client.saveActorStateTransactionally(ACTOR_TYPE, ACTOR_ID, Arrays.asList(operations));
Mono<Void> result = client.saveStateTransactionally(ACTOR_TYPE, ACTOR_ID, Arrays.asList(operations));
assertThrows(IllegalArgumentException.class, () -> result.block());
}
@ -161,7 +161,7 @@ public class DaprGrpcClientTest {
assertEquals(DurationUtils.convertDurationToDaprFormat(params.getPeriod()), argument.getPeriod());
return true;
}))).thenReturn(settableFuture);
Mono<Void> result = client.registerActorReminder(ACTOR_TYPE, ACTOR_ID, reminderName, params);
Mono<Void> result = client.registerReminder(ACTOR_TYPE, ACTOR_ID, reminderName, params);
result.block();
}
@ -178,7 +178,7 @@ public class DaprGrpcClientTest {
assertEquals(reminderName, argument.getName());
return true;
}))).thenReturn(settableFuture);
Mono<Void> result = client.unregisterActorReminder(ACTOR_TYPE, ACTOR_ID, reminderName);
Mono<Void> result = client.unregisterReminder(ACTOR_TYPE, ACTOR_ID, reminderName);
result.block();
}
@ -205,7 +205,7 @@ public class DaprGrpcClientTest {
assertEquals(DurationUtils.convertDurationToDaprFormat(params.getPeriod()), argument.getPeriod());
return true;
}))).thenReturn(settableFuture);
Mono<Void> result = client.registerActorTimer(ACTOR_TYPE, ACTOR_ID, timerName, params);
Mono<Void> result = client.registerTimer(ACTOR_TYPE, ACTOR_ID, timerName, params);
result.block();
}
@ -222,7 +222,7 @@ public class DaprGrpcClientTest {
assertEquals(timerName, argument.getName());
return true;
}))).thenReturn(settableFuture);
Mono<Void> result = client.unregisterActorTimer(ACTOR_TYPE, ACTOR_ID, timerName);
Mono<Void> result = client.unregisterTimer(ACTOR_TYPE, ACTOR_ID, timerName);
result.block();
}

View File

@ -54,7 +54,7 @@ public class DaprHttpClientTest {
.respond(EXPECTED_RESULT);
DaprHttp daprHttp = new DaprHttpProxy(Properties.SIDECAR_IP.get(), 3000, okHttpClient);
DaprHttpClient = new DaprHttpClient(daprHttp);
Mono<byte[]> mono = DaprHttpClient.getActorState("DemoActor", "1", "order");
Mono<byte[]> mono = DaprHttpClient.getState("DemoActor", "1", "order");
assertEquals(new String(mono.block()), EXPECTED_RESULT);
}
@ -67,7 +67,7 @@ public class DaprHttpClientTest {
DaprHttp daprHttp = new DaprHttpProxy(Properties.SIDECAR_IP.get(), 3000, okHttpClient);
DaprHttpClient = new DaprHttpClient(daprHttp);
List<ActorStateOperation> ops = Collections.singletonList(new ActorStateOperation("UPSERT", "key", "value"));
Mono<Void> mono = DaprHttpClient.saveActorStateTransactionally("DemoActor", "1", ops);
Mono<Void> mono = DaprHttpClient.saveStateTransactionally("DemoActor", "1", ops);
assertNull(mono.block());
}
@ -79,7 +79,7 @@ public class DaprHttpClientTest {
DaprHttp daprHttp = new DaprHttpProxy(Properties.SIDECAR_IP.get(), 3000, okHttpClient);
DaprHttpClient = new DaprHttpClient(daprHttp);
Mono<Void> mono =
DaprHttpClient.registerActorReminder(
DaprHttpClient.registerReminder(
"DemoActor",
"1",
"reminder",
@ -94,7 +94,7 @@ public class DaprHttpClientTest {
.respond(EXPECTED_RESULT);
DaprHttp daprHttp = new DaprHttpProxy(Properties.SIDECAR_IP.get(), 3000, okHttpClient);
DaprHttpClient = new DaprHttpClient(daprHttp);
Mono<Void> mono = DaprHttpClient.unregisterActorReminder("DemoActor", "1", "reminder");
Mono<Void> mono = DaprHttpClient.unregisterReminder("DemoActor", "1", "reminder");
assertNull(mono.block());
}
@ -127,7 +127,7 @@ public class DaprHttpClientTest {
DaprHttp daprHttp = new DaprHttpProxy(Properties.SIDECAR_IP.get(), 3000, okHttpClient);
DaprHttpClient = new DaprHttpClient(daprHttp);
Mono<Void> mono =
DaprHttpClient.registerActorTimer(
DaprHttpClient.registerTimer(
"DemoActor",
"1",
"timer",
@ -146,7 +146,7 @@ public class DaprHttpClientTest {
.respond(EXPECTED_RESULT);
DaprHttp daprHttp = new DaprHttpProxy(Properties.SIDECAR_IP.get(), 3000, okHttpClient);
DaprHttpClient = new DaprHttpClient(daprHttp);
Mono<Void> mono = DaprHttpClient.unregisterActorTimer("DemoActor", "1", "timer");
Mono<Void> mono = DaprHttpClient.unregisterTimer("DemoActor", "1", "timer");
assertNull(mono.block());
}
}

View File

@ -78,7 +78,7 @@ public class DaprStateAsyncProviderTest {
public void happyCaseApply() {
DaprClient daprClient = mock(DaprClient.class);
when(daprClient
.saveActorStateTransactionally(
.saveStateTransactionally(
eq("MyActor"),
eq("123"),
argThat(operations -> {
@ -133,41 +133,41 @@ public class DaprStateAsyncProviderTest {
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 class DaprStateAsyncProviderTest {
// 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);

View File

@ -223,7 +223,7 @@ public class DerivedActorTest {
// these should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
Assert.assertEquals(
"abcabc",
proxy.invokeActorMethod("stringInStringOut", "abc", String.class).block());
proxy.invoke("stringInStringOut", "abc", String.class).block());
}
@Test
@ -233,11 +233,11 @@ public class DerivedActorTest {
// these should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
Assert.assertEquals(
false,
proxy.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 class DerivedActorTest {
// 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 class DerivedActorTest {
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 class DerivedActorTest {
MyData d = new MyData("hi", 3);
// this should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
MyData response = actorProxy.invokeActorMethod("classInClassOut", d, MyData.class).block();
MyData response = actorProxy.invoke("classInClassOut", d, MyData.class).block();
Assert.assertEquals(
"hihi",
@ -288,26 +288,26 @@ public class DerivedActorTest {
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 @@ public class DerivedActorTest {
// 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 @@ public class DerivedActorTest {
private static <T extends AbstractActor> 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),

View File

@ -121,7 +121,7 @@ public class ThrowFromPreAndPostActorMethodsTest {
// these should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
Assert.assertEquals(
false,
proxy.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 class ThrowFromPreAndPostActorMethodsTest {
// 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 @@ public class ThrowFromPreAndPostActorMethodsTest {
// 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 @@ public class ThrowFromPreAndPostActorMethodsTest {
private static <T extends AbstractActor> 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),

View File

@ -16,6 +16,6 @@ public class DaprClientHttpUtils {
String actorType,
String actorId,
String reminderName) throws Exception {
new DaprHttpClient(client).unregisterActorReminder(actorType, actorId, reminderName).block();
new DaprHttpClient(client).unregisterReminder(actorType, actorId, reminderName).block();
}
}

View File

@ -71,7 +71,7 @@ public class ActorReminderFailoverIT extends BaseIT {
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 class ActorReminderFailoverIT extends BaseIT {
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 class ActorReminderFailoverIT extends BaseIT {
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 class ActorReminderFailoverIT extends BaseIT {
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);
}

View File

@ -59,7 +59,7 @@ public class ActorReminderRecoveryIT extends BaseIT {
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 class ActorReminderRecoveryIT extends BaseIT {
@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);

View File

@ -76,18 +76,18 @@ public class ActorStateIT extends BaseIT {
// Validate conditional read works.
callWithRetry(() -> {
logger.debug("Invoking readMessage where data is not present yet ... ");
String result = proxy.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 class ActorStateIT extends BaseIT {
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 class ActorStateIT extends BaseIT {
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);
}

View File

@ -54,7 +54,7 @@ public class ActorTimerRecoveryIT extends BaseIT {
ActorProxy proxy = proxyBuilder.build(actorId);
logger.debug("Invoking actor method 'startTimer' which will register a timer");
proxy.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 class ActorTimerRecoveryIT extends BaseIT {
// call unregister
logger.debug("Calling actor method 'stopTimer' to unregister timer");
proxy.invokeActorMethod("stopTimer", "myTimer").block();
proxy.invoke("stopTimer", "myTimer").block();
}
}

View File

@ -89,13 +89,13 @@ public class ActorTurnBasedConcurrencyIT extends BaseIT {
logger.debug("Invoking Say from Proxy");
callWithRetry(() -> {
logger.debug("Invoking Say from Proxy");
String sayResponse = proxy.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 class ActorTurnBasedConcurrencyIT extends BaseIT {
// the actor method called below should reverse the input
String msg = "message" + i;
String reversedString = new StringBuilder(msg).reverse().toString();
String output = proxy.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 class ActorTurnBasedConcurrencyIT extends BaseIT {
// 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.");

View File

@ -54,7 +54,7 @@ public class MyActorTestUtils {
* @return List of call log.
*/
static List<MethodEntryTracker> fetchMethodCallLogs(ActorProxy proxy) {
ArrayList<String> logs = proxy.invokeActorMethod("getCallLog", ArrayList.class).block();
ArrayList<String> logs = proxy.invoke("getCallLog", ArrayList.class).block();
ArrayList<MethodEntryTracker> trackers = new ArrayList<MethodEntryTracker>();
for(String t : logs) {
String[] toks = t.split("\\|");

View File

@ -95,7 +95,7 @@ public class BindingIT extends BaseIT {
callWithRetry(() -> {
System.out.println("Checking results ...");
final List<String> messages =
client.invokeService(
client.invokeMethod(
daprRun.getAppName(),
"messages",
null,

View File

@ -74,21 +74,21 @@ public class MethodInvokeIT extends BaseIT {
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<Integer, String> messages = client.invokeService(daprRun.getAppName(), "messages", null,
Map<Integer, String> 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 class MethodInvokeIT extends BaseIT {
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<Person> persons = Arrays.asList(client.invokeService(daprRun.getAppName(), "persons", null, HttpExtension.GET, Person[].class).block());
List<Person> 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 class MethodInvokeIT extends BaseIT {
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());

View File

@ -95,7 +95,7 @@ public class PubSubIT extends BaseIT {
callWithRetry(() -> {
System.out.println("Checking results for topic " + TOPIC_NAME);
final List<String> messages = client.invokeService(daprRun.getAppName(), "messages/testingtopic", null, HttpExtension.GET, List.class).block();
final List<String> 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 class PubSubIT extends BaseIT {
callWithRetry(() -> {
System.out.println("Checking results for topic " + ANOTHER_TOPIC_NAME);
final List<String> messages = client.invokeService(daprRun.getAppName(), "messages/anothertopic", null, HttpExtension.GET, List.class).block();
final List<String> 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++) {

View File

@ -97,7 +97,7 @@ public abstract class AbstractStateClientIT extends BaseIT {
//retrieves states in bulk.
Mono<List<State<MyData>>> 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<State<MyData>> result = response.block();
//Assert that the response is the correct one
@ -519,7 +519,7 @@ public abstract class AbstractStateClientIT extends BaseIT {
createState(stateKey, null, null, data));
//create of the deferred call to DAPR to execute the transaction
Mono<Void> saveResponse = daprClient.executeTransaction(STATE_STORE_NAME, Collections.singletonList(operation));
Mono<Void> saveResponse = daprClient.executeStateTransaction(STATE_STORE_NAME, Collections.singletonList(operation));
//execute the save action
saveResponse.block();
@ -538,7 +538,7 @@ public abstract class AbstractStateClientIT extends BaseIT {
TransactionalStateOperation.OperationType.DELETE,
createState(stateKey, null, null, data));
//create of the deferred call to DAPR to execute the transaction
Mono<Void> deleteResponse = daprClient.executeTransaction(STATE_STORE_NAME, Collections.singletonList(operation));
Mono<Void> deleteResponse = daprClient.executeStateTransaction(STATE_STORE_NAME, Collections.singletonList(operation));
//execute the delete action
deleteResponse.block();
@ -568,7 +568,7 @@ public abstract class AbstractStateClientIT extends BaseIT {
Assert.assertNotNull(daprClient);
//create of the deferred call to DAPR to execute the transaction
Mono<Void> saveResponse = daprClient.executeTransaction(STATE_STORE_NAME, Collections.singletonList(operation));
Mono<Void> saveResponse = daprClient.executeStateTransaction(STATE_STORE_NAME, Collections.singletonList(operation));
//execute the save action
saveResponse.block();
@ -589,7 +589,7 @@ public abstract class AbstractStateClientIT extends BaseIT {
TransactionalStateOperation.OperationType.DELETE,
createState(stateKey, null, null, data));
//create of the deferred call to DAPR to execute the transaction
Mono<Void> deleteResponse = daprClient.executeTransaction(STATE_STORE_NAME, Collections.singletonList(operation));
Mono<Void> deleteResponse = daprClient.executeStateTransaction(STATE_STORE_NAME, Collections.singletonList(operation));
//execute the delete action
deleteResponse.block();

View File

@ -73,7 +73,7 @@ public class GRPCStateClientIT extends AbstractStateClientIT {
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());

View File

@ -72,7 +72,7 @@ public class HttpStateClientIT extends AbstractStateClientIT {
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());

View File

@ -9,11 +9,11 @@ import io.dapr.client.domain.DeleteStateRequest;
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<Void> publishEvent(String pubsubName, String topic, Object data) {
return this.publishEvent(pubsubName, topic, data, null);
public Mono<Void> publishEvent(String pubsubName, String topicName, Object data) {
return this.publishEvent(pubsubName, topicName, data, null);
}
/**
* {@inheritDoc}
*/
@Override
public Mono<Void> publishEvent(String pubsubName, String topic, Object data, Map<String, String> metadata) {
PublishEventRequest req = new PublishEventRequestBuilder(pubsubName, topic, data).withMetadata(metadata).build();
public Mono<Void> publishEvent(String pubsubName, String topicName, Object data, Map<String, String> metadata) {
PublishEventRequest req = new PublishEventRequestBuilder(pubsubName, topicName,
data).withMetadata(metadata).build();
return this.publishEvent(req).then();
}
/**
* {@inheritDoc}
*/
public <T> Mono<T> invokeService(
public <T> Mono<T> invokeMethod(
String appId,
String method,
Object request,
String methodName,
Object data,
HttpExtension httpExtension,
Map<String, String> metadata,
TypeRef<T> 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 <T> Mono<T> invokeService(
public <T> Mono<T> invokeMethod(
String appId,
String method,
String methodName,
Object request,
HttpExtension httpExtension,
Map<String, String> metadata,
Class<T> 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 <T> Mono<T> invokeService(
String appId, String method, HttpExtension httpExtension, Map<String, String> metadata, TypeRef<T> type) {
return this.invokeService(appId, method, null, httpExtension, metadata, type);
public <T> Mono<T> invokeMethod(
String appId, String methodName, HttpExtension httpExtension, Map<String, String> metadata, TypeRef<T> type) {
return this.invokeMethod(appId, methodName, null, httpExtension, metadata, type);
}
/**
* {@inheritDoc}
*/
@Override
public <T> Mono<T> invokeService(
String appId, String method, HttpExtension httpExtension, Map<String, String> metadata, Class<T> clazz) {
return this.invokeService(appId, method, null, httpExtension, metadata, TypeRef.get(clazz));
public <T> Mono<T> invokeMethod(
String appId, String methodName, HttpExtension httpExtension, Map<String, String> metadata, Class<T> clazz) {
return this.invokeMethod(appId, methodName, null, httpExtension, metadata, TypeRef.get(clazz));
}
/**
* {@inheritDoc}
*/
@Override
public <T> Mono<T> invokeService(String appId, String method, Object request, HttpExtension httpExtension,
TypeRef<T> type) {
return this.invokeService(appId, method, request, httpExtension, null, type);
public <T> Mono<T> invokeMethod(String appId, String methodName, Object request, HttpExtension httpExtension,
TypeRef<T> type) {
return this.invokeMethod(appId, methodName, request, httpExtension, null, type);
}
/**
* {@inheritDoc}
*/
@Override
public <T> Mono<T> invokeService(String appId, String method, Object request, HttpExtension httpExtension,
Class<T> clazz) {
return this.invokeService(appId, method, request, httpExtension, null, TypeRef.get(clazz));
public <T> Mono<T> invokeMethod(String appId, String methodName, Object request, HttpExtension httpExtension,
Class<T> clazz) {
return this.invokeMethod(appId, methodName, request, httpExtension, null, TypeRef.get(clazz));
}
/**
* {@inheritDoc}
*/
@Override
public Mono<Void> invokeService(String appId, String method, Object request, HttpExtension httpExtension) {
return this.invokeService(appId, method, request, httpExtension, null, TypeRef.BYTE_ARRAY).then();
public Mono<Void> 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<Void> invokeService(
String appId, String method, Object request, HttpExtension httpExtension, Map<String, String> metadata) {
return this.invokeService(appId, method, request, httpExtension, metadata, TypeRef.BYTE_ARRAY).then();
public Mono<Void> invokeMethod(
String appId, String methodName, Object request, HttpExtension httpExtension, Map<String, String> metadata) {
return this.invokeMethod(appId, methodName, request, httpExtension, metadata, TypeRef.BYTE_ARRAY).then();
}
/**
* {@inheritDoc}
*/
@Override
public Mono<Void> invokeService(
String appId, String method, HttpExtension httpExtension, Map<String, String> metadata) {
return this.invokeService(appId, method, null, httpExtension, metadata, TypeRef.BYTE_ARRAY).then();
public Mono<Void> invokeMethod(
String appId, String methodName, HttpExtension httpExtension, Map<String, String> metadata) {
return this.invokeMethod(appId, methodName, null, httpExtension, metadata, TypeRef.BYTE_ARRAY).then();
}
/**
* {@inheritDoc}
*/
@Override
public Mono<byte[]> invokeService(
String appId, String method, byte[] request, HttpExtension httpExtension, Map<String, String> metadata) {
return this.invokeService(appId, method, request, httpExtension, metadata, TypeRef.BYTE_ARRAY);
public Mono<byte[]> invokeMethod(
String appId, String methodName, byte[] request, HttpExtension httpExtension, Map<String, String> metadata) {
return this.invokeMethod(appId, methodName, request, httpExtension, metadata, TypeRef.BYTE_ARRAY);
}
/**
* {@inheritDoc}
*/
@Override
public Mono<Void> invokeBinding(String name, String operation, Object data) {
return this.invokeBinding(name, operation, data, null, TypeRef.BYTE_ARRAY).then();
public Mono<Void> invokeBinding(String bindingName, String operation, Object data) {
return this.invokeBinding(bindingName, operation, data, null, TypeRef.BYTE_ARRAY).then();
}
/**
* {@inheritDoc}
*/
@Override
public Mono<byte[]> invokeBinding(String name, String operation, byte[] data, Map<String, String> metadata) {
return this.invokeBinding(name, operation, data, metadata, TypeRef.BYTE_ARRAY);
public Mono<byte[]> invokeBinding(String bindingName, String operation, byte[] data, Map<String, String> metadata) {
return this.invokeBinding(bindingName, operation, data, metadata, TypeRef.BYTE_ARRAY);
}
/**
* {@inheritDoc}
*/
@Override
public <T> Mono<T> invokeBinding(String name, String operation, Object data, TypeRef<T> type) {
return this.invokeBinding(name, operation, data, null, type);
public <T> Mono<T> invokeBinding(String bindingName, String operation, Object data, TypeRef<T> type) {
return this.invokeBinding(bindingName, operation, data, null, type);
}
/**
* {@inheritDoc}
*/
@Override
public <T> Mono<T> invokeBinding(String name, String operation, Object data, Class<T> clazz) {
return this.invokeBinding(name, operation, data, null, TypeRef.get(clazz));
public <T> Mono<T> invokeBinding(String bindingName, String operation, Object data, Class<T> clazz) {
return this.invokeBinding(bindingName, operation, data, null, TypeRef.get(clazz));
}
/**
@ -228,8 +229,8 @@ abstract class AbstractDaprClient implements DaprClient {
*/
@Override
public <T> Mono<T> invokeBinding(
String name, String operation, Object data, Map<String, String> metadata, TypeRef<T> type) {
InvokeBindingRequest request = new InvokeBindingRequestBuilder(name, operation)
String bindingName, String operation, Object data, Map<String, String> metadata, TypeRef<T> type) {
InvokeBindingRequest request = new InvokeBindingRequestBuilder(bindingName, operation)
.withData(data)
.withMetadata(metadata)
.build();
@ -242,40 +243,40 @@ abstract class AbstractDaprClient implements DaprClient {
*/
@Override
public <T> Mono<T> invokeBinding(
String name, String operation, Object data, Map<String, String> metadata, Class<T> clazz) {
return this.invokeBinding(name, operation, data, metadata, TypeRef.get(clazz));
String bindingName, String operation, Object data, Map<String, String> metadata, Class<T> clazz) {
return this.invokeBinding(bindingName, operation, data, metadata, TypeRef.get(clazz));
}
/**
* {@inheritDoc}
*/
@Override
public <T> Mono<State<T>> getState(String stateStoreName, State<T> state, TypeRef<T> type) {
return this.getState(stateStoreName, state.getKey(), state.getEtag(), state.getOptions(), type);
public <T> Mono<State<T>> getState(String storeName, State<T> state, TypeRef<T> type) {
return this.getState(storeName, state.getKey(), state.getEtag(), state.getOptions(), type);
}
/**
* {@inheritDoc}
*/
@Override
public <T> Mono<State<T>> getState(String stateStoreName, State<T> state, Class<T> clazz) {
return this.getState(stateStoreName, state.getKey(), state.getEtag(), state.getOptions(), TypeRef.get(clazz));
public <T> Mono<State<T>> getState(String storeName, State<T> state, Class<T> clazz) {
return this.getState(storeName, state.getKey(), state.getEtag(), state.getOptions(), TypeRef.get(clazz));
}
/**
* {@inheritDoc}
*/
@Override
public <T> Mono<State<T>> getState(String stateStoreName, String key, TypeRef<T> type) {
return this.getState(stateStoreName, key, null, null, type);
public <T> Mono<State<T>> getState(String storeName, String key, TypeRef<T> type) {
return this.getState(storeName, key, null, null, type);
}
/**
* {@inheritDoc}
*/
@Override
public <T> Mono<State<T>> getState(String stateStoreName, String key, Class<T> clazz) {
return this.getState(stateStoreName, key, null, null, TypeRef.get(clazz));
public <T> Mono<State<T>> getState(String storeName, String key, Class<T> clazz) {
return this.getState(storeName, key, null, null, TypeRef.get(clazz));
}
/**
@ -283,8 +284,8 @@ abstract class AbstractDaprClient implements DaprClient {
*/
@Override
public <T> Mono<State<T>> getState(
String stateStoreName, String key, String etag, StateOptions options, TypeRef<T> type) {
GetStateRequest request = new GetStateRequestBuilder(stateStoreName, key)
String storeName, String key, String etag, StateOptions options, TypeRef<T> type) {
GetStateRequest request = new GetStateRequestBuilder(storeName, key)
.withEtag(etag)
.withStateOptions(options)
.build();
@ -297,80 +298,80 @@ abstract class AbstractDaprClient implements DaprClient {
*/
@Override
public <T> Mono<State<T>> getState(
String stateStoreName, String key, String etag, StateOptions options, Class<T> clazz) {
return this.getState(stateStoreName, key, etag, options, TypeRef.get(clazz));
String storeName, String key, String etag, StateOptions options, Class<T> clazz) {
return this.getState(storeName, key, etag, options, TypeRef.get(clazz));
}
/**
* {@inheritDoc}
*/
@Override
public <T> Mono<List<State<T>>> getStates(String stateStoreName, List<String> keys, TypeRef<T> type) {
return this.getStates(new GetStatesRequestBuilder(stateStoreName, keys).build(), type).map(r -> r.getObject());
public <T> Mono<List<State<T>>> getBulkState(String storeName, List<String> keys, TypeRef<T> type) {
return this.getBulkState(new GetBulkStateRequestBuilder(storeName, keys).build(), type).map(r -> r.getObject());
}
/**
* {@inheritDoc}
*/
@Override
public <T> Mono<List<State<T>>> getStates(String stateStoreName, List<String> keys, Class<T> clazz) {
return this.getStates(stateStoreName, keys, TypeRef.get(clazz));
public <T> Mono<List<State<T>>> getBulkState(String storeName, List<String> keys, Class<T> clazz) {
return this.getBulkState(storeName, keys, TypeRef.get(clazz));
}
/**
* {@inheritDoc}
*/
@Override
public Mono<Void> executeTransaction(String stateStoreName,
List<TransactionalStateOperation<?>> operations) {
ExecuteStateTransactionRequest request = new ExecuteStateTransactionRequestBuilder(stateStoreName)
public Mono<Void> executeStateTransaction(String storeName,
List<TransactionalStateOperation<?>> operations) {
ExecuteStateTransactionRequest request = new ExecuteStateTransactionRequestBuilder(storeName)
.withTransactionalStates(operations)
.build();
return executeTransaction(request).then();
return executeStateTransaction(request).then();
}
/**
* {@inheritDoc}
*/
@Override
public Mono<Void> saveStates(String stateStoreName, List<State<?>> states) {
SaveStateRequest request = new SaveStateRequestBuilder(stateStoreName)
public Mono<Void> saveBulkState(String storeName, List<State<?>> states) {
SaveStateRequest request = new SaveStateRequestBuilder(storeName)
.withStates(states)
.build();
return this.saveStates(request).then();
return this.saveBulkState(request).then();
}
/**
* {@inheritDoc}
*/
@Override
public Mono<Void> saveState(String stateStoreName, String key, Object value) {
return this.saveState(stateStoreName, key, null, value, null);
public Mono<Void> saveState(String storeName, String key, Object value) {
return this.saveState(storeName, key, null, value, null);
}
/**
* {@inheritDoc}
*/
@Override
public Mono<Void> saveState(String stateStoreName, String key, String etag, Object value, StateOptions options) {
public Mono<Void> 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<Void> deleteState(String stateStoreName, String key) {
return this.deleteState(stateStoreName, key, null, null);
public Mono<Void> deleteState(String storeName, String key) {
return this.deleteState(storeName, key, null, null);
}
/**
* {@inheritDoc}
*/
@Override
public Mono<Void> deleteState(String stateStoreName, String key, String etag, StateOptions options) {
DeleteStateRequest request = new DeleteStateRequestBuilder(stateStoreName, key)
public Mono<Void> deleteState(String storeName, String key, String etag, StateOptions options) {
DeleteStateRequest request = new DeleteStateRequestBuilder(storeName, key)
.withEtag(etag)
.withStateOptions(options)
.build();
@ -381,8 +382,8 @@ abstract class AbstractDaprClient implements DaprClient {
* {@inheritDoc}
*/
@Override
public Mono<Map<String, String>> getSecret(String secretStoreName, String key, Map<String, String> metadata) {
GetSecretRequest request = new GetSecretRequestBuilder(secretStoreName, key)
public Mono<Map<String, String>> getSecret(String storeName, String key, Map<String, String> 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 @@ abstract class AbstractDaprClient implements DaprClient {
* {@inheritDoc}
*/
@Override
public Mono<Map<String, String>> getSecret(String secretStoreName, String secretName) {
return this.getSecret(secretStoreName, secretName, null);
public Mono<Map<String, String>> getSecret(String storeName, String secretName) {
return this.getSecret(storeName, secretName, null);
}
}

View File

@ -7,9 +7,9 @@ package io.dapr.client;
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.client.domain.TransactionalStateOperation;
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<Void> publishEvent(String pubsubName, String topic, Object data);
Mono<Void> 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<Void> publishEvent(String pubsubName, String topic, Object data, Map<String, String> metadata);
Mono<Void> publishEvent(String pubsubName, String topicName, Object data, Map<String, String> 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 <T> The Type of the return, use byte[] to skip serialization.
* @return A Mono Plan of type T.
*/
<T> Mono<T> invokeService(String appId, String method, Object request, HttpExtension httpExtension,
Map<String, String> metadata, TypeRef<T> type);
<T> Mono<T> invokeMethod(String appId, String methodName, Object data, HttpExtension httpExtension,
Map<String, String> metadata, TypeRef<T> 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 @@ public interface DaprClient extends AutoCloseable {
* @param <T> The Type of the return, use byte[] to skip serialization.
* @return A Mono Plan of type T.
*/
<T> Mono<T> invokeService(String appId, String method, Object request, HttpExtension httpExtension,
Map<String, String> metadata, Class<T> clazz);
<T> Mono<T> invokeMethod(String appId, String methodName, Object request, HttpExtension httpExtension,
Map<String, String> metadata, Class<T> 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 @@ public interface DaprClient extends AutoCloseable {
* @param <T> The Type of the return, use byte[] to skip serialization.
* @return A Mono Plan of type T.
*/
<T> Mono<T> invokeService(String appId, String method, Object request, HttpExtension httpExtension, TypeRef<T> type);
<T> Mono<T> invokeMethod(String appId, String methodName, Object request, HttpExtension httpExtension,
TypeRef<T> 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 @@ public interface DaprClient extends AutoCloseable {
* @param <T> The Type of the return, use byte[] to skip serialization.
* @return A Mono Plan of type T.
*/
<T> Mono<T> invokeService(String appId, String method, Object request, HttpExtension httpExtension, Class<T> clazz);
<T> Mono<T> invokeMethod(String appId, String methodName, Object request, HttpExtension httpExtension,
Class<T> 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 @@ public interface DaprClient extends AutoCloseable {
* @param <T> The Type of the return, use byte[] to skip serialization.
* @return A Mono Plan of type T.
*/
<T> Mono<T> invokeService(String appId, String method, HttpExtension httpExtension, Map<String, String> metadata,
TypeRef<T> type);
<T> Mono<T> invokeMethod(String appId, String methodName, HttpExtension httpExtension, Map<String, String> metadata,
TypeRef<T> 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 @@ public interface DaprClient extends AutoCloseable {
* @param <T> The Type of the return, use byte[] to skip serialization.
* @return A Mono Plan of type T.
*/
<T> Mono<T> invokeService(String appId, String method, HttpExtension httpExtension, Map<String, String> metadata,
Class<T> clazz);
<T> Mono<T> invokeMethod(String appId, String methodName, HttpExtension httpExtension, Map<String, String> metadata,
Class<T> 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<Void> invokeService(String appId, String method, Object request, HttpExtension httpExtension,
Map<String, String> metadata);
Mono<Void> invokeMethod(String appId, String methodName, Object request, HttpExtension httpExtension,
Map<String, String> 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<Void> invokeService(String appId, String method, Object request, HttpExtension httpExtension);
Mono<Void> 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<Void> invokeService(String appId, String method, HttpExtension httpExtension, Map<String, String> metadata);
Mono<Void> invokeMethod(String appId, String methodName, HttpExtension httpExtension, Map<String, String> 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<byte[]> invokeService(String appId, String method, byte[] request, HttpExtension httpExtension,
Map<String, String> metadata);
Mono<byte[]> invokeMethod(String appId, String methodName, byte[] request, HttpExtension httpExtension,
Map<String, String> metadata);
/**
* Invoke a service method.
@ -212,57 +213,57 @@ public interface DaprClient extends AutoCloseable {
* @param <T> The Type of the return, use byte[] to skip serialization.
* @return A Mono Plan of type T.
*/
<T> Mono<Response<T>> invokeService(InvokeServiceRequest invokeServiceRequest, TypeRef<T> type);
<T> Mono<Response<T>> invokeMethod(InvokeServiceRequest invokeServiceRequest, TypeRef<T> 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<Void> invokeBinding(String name, String operation, Object data);
Mono<Void> 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<byte[]> invokeBinding(String name, String operation, byte[] data, Map<String, String> metadata);
Mono<byte[]> invokeBinding(String bindingName, String operation, byte[] data, Map<String, String> 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 <T> The type of the return
* @return a Mono plan of type T.
*/
<T> Mono<T> invokeBinding(String name, String operation, Object data, TypeRef<T> type);
<T> Mono<T> invokeBinding(String bindingName, String operation, Object data, TypeRef<T> 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 <T> The type of the return
* @return a Mono plan of type T.
*/
<T> Mono<T> invokeBinding(String name, String operation, Object data, Class<T> clazz);
<T> Mono<T> invokeBinding(String bindingName, String operation, Object data, Class<T> 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 @@ public interface DaprClient extends AutoCloseable {
* @param <T> The type of the return
* @return a Mono plan of type T.
*/
<T> Mono<T> invokeBinding(String name, String operation, Object data, Map<String, String> metadata, TypeRef<T> type);
<T> Mono<T> invokeBinding(String bindingName, String operation, Object data, Map<String, String> metadata,
TypeRef<T> 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 @@ public interface DaprClient extends AutoCloseable {
* @param <T> The type of the return
* @return a Mono plan of type T.
*/
<T> Mono<T> invokeBinding(String name, String operation, Object data, Map<String, String> metadata, Class<T> clazz);
<T> Mono<T> invokeBinding(String bindingName, String operation, Object data, Map<String, String> metadata,
Class<T> clazz);
/**
* Invokes a Binding operation.
@ -298,51 +301,51 @@ public interface DaprClient extends AutoCloseable {
/**
* 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 <T> The type of the return.
* @return A Mono Plan for the requested State.
*/
<T> Mono<State<T>> getState(String stateStoreName, State<T> state, TypeRef<T> type);
<T> Mono<State<T>> getState(String storeName, State<T> state, TypeRef<T> 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 <T> The type of the return.
* @return A Mono Plan for the requested State.
*/
<T> Mono<State<T>> getState(String stateStoreName, State<T> state, Class<T> clazz);
<T> Mono<State<T>> getState(String storeName, State<T> state, Class<T> 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 <T> The type of the return.
* @return A Mono Plan for the requested State.
*/
<T> Mono<State<T>> getState(String stateStoreName, String key, TypeRef<T> type);
<T> Mono<State<T>> getState(String storeName, String key, TypeRef<T> 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 <T> The type of the return.
* @return A Mono Plan for the requested State.
*/
<T> Mono<State<T>> getState(String stateStoreName, String key, Class<T> clazz);
<T> Mono<State<T>> getState(String storeName, String key, Class<T> 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 @@ public interface DaprClient extends AutoCloseable {
* @param <T> The Type of the return.
* @return A Mono Plan for the requested State.
*/
<T> Mono<State<T>> getState(String stateStoreName, String key, String etag, StateOptions options, TypeRef<T> type);
<T> Mono<State<T>> getState(String storeName, String key, String etag, StateOptions options, TypeRef<T> 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 @@ public interface DaprClient extends AutoCloseable {
* @param <T> The Type of the return.
* @return A Mono Plan for the requested State.
*/
<T> Mono<State<T>> getState(String stateStoreName, String key, String etag, StateOptions options, Class<T> clazz);
<T> Mono<State<T>> getState(String storeName, String key, String etag, StateOptions options, Class<T> clazz);
/**
* Retrieve a State based on their key.
@ -378,24 +381,24 @@ public interface DaprClient extends AutoCloseable {
/**
* 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 <T> The type of the return.
* @return A Mono Plan for the requested State.
*/
<T> Mono<List<State<T>>> getStates(String stateStoreName, List<String> keys, TypeRef<T> type);
<T> Mono<List<State<T>>> getBulkState(String storeName, List<String> keys, TypeRef<T> 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 <T> The type of the return.
* @return A Mono Plan for the requested State.
*/
<T> Mono<List<State<T>>> getStates(String stateStoreName, List<String> keys, Class<T> clazz);
<T> Mono<List<State<T>>> getBulkState(String storeName, List<String> keys, Class<T> clazz);
/**
* Retrieve bulk States based on their keys.
@ -405,16 +408,16 @@ public interface DaprClient extends AutoCloseable {
* @param <T> The Type of the return.
* @return A Mono Plan for the requested State.
*/
<T> Mono<Response<List<State<T>>>> getStates(GetStatesRequest request, TypeRef<T> type);
<T> Mono<Response<List<State<T>>>> getBulkState(GetBulkStateRequest request, TypeRef<T> 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<Void> executeTransaction(String stateStoreName,
List<TransactionalStateOperation<?>> operations);
Mono<Void> executeStateTransaction(String storeName,
List<TransactionalStateOperation<?>> operations);
/** Execute a transaction.
@ -422,16 +425,16 @@ public interface DaprClient extends AutoCloseable {
* @param request Request to execute transaction.
* @return a Mono plan of type Response Void
*/
Mono<Response<Void>> executeTransaction(ExecuteStateTransactionRequest request);
Mono<Response<Void>> 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<Void> saveStates(String stateStoreName, List<State<?>> states);
Mono<Void> saveBulkState(String storeName, List<State<?>> states);
/**
* Save/Update a list of states.
@ -439,49 +442,49 @@ public interface DaprClient extends AutoCloseable {
* @param request Request to save states.
* @return a Mono plan of type Void.
*/
Mono<Response<Void>> saveStates(SaveStateRequest request);
Mono<Response<Void>> 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<Void> saveState(String stateStoreName, String key, Object value);
Mono<Void> 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<Void> saveState(String stateStoreName, String key, String etag, Object value, StateOptions options);
Mono<Void> 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<Void> deleteState(String stateStoreName, String key);
Mono<Void> 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<Void> deleteState(String stateStoreName, String key, String etag, StateOptions options);
Mono<Void> deleteState(String storeName, String key, String etag, StateOptions options);
/**
* Delete a state.
@ -494,21 +497,21 @@ public interface DaprClient extends AutoCloseable {
/**
* 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<Map<String, String>> getSecret(String secretStoreName, String secretName, Map<String, String> metadata);
Mono<Map<String, String>> getSecret(String storeName, String secretName, Map<String, String> 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<Map<String, String>> getSecret(String secretStoreName, String secretName);
Mono<Map<String, String>> getSecret(String storeName, String secretName);
/**
* Fetches a secret from the configured vault.

View File

@ -11,9 +11,9 @@ import com.google.protobuf.Any;
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 class DaprClientGrpc extends AbstractDaprClient {
* {@inheritDoc}
*/
@Override
public <T> Mono<Response<T>> invokeService(InvokeServiceRequest invokeServiceRequest, TypeRef<T> type) {
public <T> Mono<Response<T>> invokeMethod(InvokeServiceRequest invokeServiceRequest, TypeRef<T> type) {
try {
String appId = invokeServiceRequest.getAppId();
String method = invokeServiceRequest.getMethod();
@ -228,7 +228,7 @@ public class DaprClientGrpc extends AbstractDaprClient {
@Override
public <T> Mono<Response<State<T>>> getState(GetStateRequest request, TypeRef<T> 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 class DaprClientGrpc extends AbstractDaprClient {
* {@inheritDoc}
*/
@Override
public <T> Mono<Response<List<State<T>>>> getStates(GetStatesRequest request, TypeRef<T> type) {
public <T> Mono<Response<List<State<T>>>> getBulkState(GetBulkStateRequest request, TypeRef<T> type) {
try {
final String stateStoreName = request.getStateStoreName();
final String stateStoreName = request.getStoreName();
final List<String> keys = request.getKeys();
final int parallelism = request.getParallelism();
final Context context = request.getContext();
@ -339,7 +339,7 @@ public class DaprClientGrpc extends AbstractDaprClient {
* {@inheritDoc}
*/
@Override
public Mono<Response<Void>> executeTransaction(ExecuteStateTransactionRequest request) {
public Mono<Response<Void>> executeStateTransaction(ExecuteStateTransactionRequest request) {
try {
final String stateStoreName = request.getStateStoreName();
final List<TransactionalStateOperation<?>> operations = request.getOperations();
@ -374,9 +374,9 @@ public class DaprClientGrpc extends AbstractDaprClient {
* {@inheritDoc}
*/
@Override
public Mono<Response<Void>> saveStates(SaveStateRequest request) {
public Mono<Response<Void>> saveBulkState(SaveStateRequest request) {
try {
final String stateStoreName = request.getStateStoreName();
final String stateStoreName = request.getStoreName();
final List<State<?>> states = request.getStates();
final Context context = request.getContext();
if ((stateStoreName == null) || (stateStoreName.trim().isEmpty())) {
@ -522,7 +522,7 @@ public class DaprClientGrpc extends AbstractDaprClient {
*/
@Override
public Mono<Response<Map<String, String>>> getSecret(GetSecretRequest request) {
String secretStoreName = request.getSecretStoreName();
String secretStoreName = request.getStoreName();
String key = request.getKey();
Map<String, String> metadata = request.getMetadata();
Context context = request.getContext();

View File

@ -9,9 +9,9 @@ import com.fasterxml.jackson.databind.JsonNode;
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 class DaprClientHttp extends AbstractDaprClient {
/**
* {@inheritDoc}
*/
public <T> Mono<Response<T>> invokeService(InvokeServiceRequest invokeServiceRequest, TypeRef<T> type) {
public <T> Mono<Response<T>> invokeMethod(InvokeServiceRequest invokeServiceRequest, TypeRef<T> type) {
try {
final String appId = invokeServiceRequest.getAppId();
final String method = invokeServiceRequest.getMethod();
@ -279,9 +279,9 @@ public class DaprClientHttp extends AbstractDaprClient {
* {@inheritDoc}
*/
@Override
public <T> Mono<Response<List<State<T>>>> getStates(GetStatesRequest request, TypeRef<T> type) {
public <T> Mono<Response<List<State<T>>>> getBulkState(GetBulkStateRequest request, TypeRef<T> type) {
try {
final String stateStoreName = request.getStateStoreName();
final String stateStoreName = request.getStoreName();
final List<String> keys = request.getKeys();
final int parallelism = request.getParallelism();
final Context context = request.getContext();
@ -325,7 +325,7 @@ public class DaprClientHttp extends AbstractDaprClient {
@Override
public <T> Mono<Response<State<T>>> getState(GetStateRequest request, TypeRef<T> 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 class DaprClientHttp extends AbstractDaprClient {
* {@inheritDoc}
*/
@Override
public Mono<Response<Void>> executeTransaction(ExecuteStateTransactionRequest request) {
public Mono<Response<Void>> executeStateTransaction(ExecuteStateTransactionRequest request) {
try {
final String stateStoreName = request.getStateStoreName();
final List<TransactionalStateOperation<?>> operations = request.getOperations();
@ -421,9 +421,9 @@ public class DaprClientHttp extends AbstractDaprClient {
* {@inheritDoc}
*/
@Override
public Mono<Response<Void>> saveStates(SaveStateRequest request) {
public Mono<Response<Void>> saveBulkState(SaveStateRequest request) {
try {
final String stateStoreName = request.getStateStoreName();
final String stateStoreName = request.getStoreName();
final List<State<?>> states = request.getStates();
final Context context = request.getContext();
if ((stateStoreName == null) || (stateStoreName.trim().isEmpty())) {
@ -557,7 +557,7 @@ public class DaprClientHttp extends AbstractDaprClient {
*/
@Override
public Mono<Response<Map<String, String>>> getSecret(GetSecretRequest request) {
String secretStoreName = request.getSecretStoreName();
String secretStoreName = request.getStoreName();
String key = request.getKey();
Map<String, String> metadata = request.getMetadata();
Context context = request.getContext();

View File

@ -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<String> keys;
private int parallelism;
private Context context;
public String getStateStoreName() {
return stateStoreName;
}
void setStateStoreName(String stateStoreName) {
this.stateStoreName = stateStoreName;
}
public List<String> getKeys() {
return keys;
}
void setKeys(List<String> 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<String> keys;
private int parallelism;
private Context context;
public String getStoreName() {
return storeName;
}
void setStoreName(String storeName) {
this.storeName = storeName;
}
public List<String> getKeys() {
return keys;
}
void setKeys(List<String> 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;
}
}

View File

@ -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<String> keys;
private int parallelism = 1;
private Context context;
public GetStatesRequestBuilder(String stateStoreName, List<String> 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<String> keys;
private int parallelism = 1;
private Context context;
public GetBulkStateRequestBuilder(String storeName, List<String> 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;
}
}

View File

@ -14,7 +14,7 @@ import java.util.Map;
*/
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() {

View File

@ -15,7 +15,7 @@ import java.util.Map;
*/
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 class GetSecretRequestBuilder {
*/
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);

View File

@ -15,7 +15,7 @@ import java.util.Map;
*/
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() {

View File

@ -14,7 +14,7 @@ import java.util.Map;
*/
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 class GetStateRequestBuilder {
*/
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);

View File

@ -14,18 +14,18 @@ import java.util.List;
*/
public class SaveStateRequest {
private String stateStoreName;
private String storeName;
private List<State<?>> 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<State<?>> getStates() {

View File

@ -17,14 +17,14 @@ import java.util.List;
*/
public class SaveStateRequestBuilder {
private final String stateStoreName;
private final String storeName;
private List<State<?>> 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 class SaveStateRequestBuilder {
*/
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;

View File

@ -14,10 +14,10 @@ import io.dapr.client.domain.DeleteStateRequest;
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.CommonProtos;
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.assertFalse;
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 class DaprClientGrpcTest {
public void invokeServiceVoidExceptionThrownTest() {
when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class)))
.thenThrow(RuntimeException.class);
Mono<Void> result = adapter.invokeService("appId", "method", "request", HttpExtension.NONE);
Mono<Void> result = adapter.invokeMethod("appId", "method", "request", HttpExtension.NONE);
assertThrowsDaprException(
RuntimeException.class,
@ -367,7 +365,7 @@ public class DaprClientGrpcTest {
when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class)))
.thenReturn(settableFuture);
// HttpExtension cannot be null
Mono<Void> result = adapter.invokeService("appId", "method", "request", null);
Mono<Void> result = adapter.invokeMethod("appId", "method", "request", null);
assertThrowsDaprException(
IllegalArgumentException.class,
@ -380,7 +378,7 @@ public class DaprClientGrpcTest {
public void invokeServiceEmptyRequestVoidExceptionThrownTest() {
when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class)))
.thenThrow(RuntimeException.class);
Mono<Void> result = adapter.invokeService("appId", "method", HttpExtension.NONE, (Map<String, String>)null);
Mono<Void> result = adapter.invokeMethod("appId", "method", HttpExtension.NONE, (Map<String, String>)null);
assertThrowsDaprException(
RuntimeException.class,
@ -398,7 +396,7 @@ public class DaprClientGrpcTest {
settableFuture.setException(ex);
when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class)))
.thenReturn(settableFuture);
Mono<Void> result = adapter.invokeService("appId", "method", "request", HttpExtension.NONE);
Mono<Void> result = adapter.invokeMethod("appId", "method", "request", HttpExtension.NONE);
assertThrowsDaprException(
ExecutionException.class,
@ -416,7 +414,7 @@ public class DaprClientGrpcTest {
addCallback(settableFuture, callback, directExecutor());
when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class)))
.thenReturn(settableFuture);
Mono<Void> result = adapter.invokeService("appId", "method", "request", HttpExtension.NONE);
Mono<Void> 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 class DaprClientGrpcTest {
when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class)))
.thenReturn(settableFuture);
MyObject request = new MyObject(1, "Event");
Mono<Void> result = adapter.invokeService("appId", "method", request, HttpExtension.NONE);
Mono<Void> 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 class DaprClientGrpcTest {
public void invokeServiceExceptionThrownTest() {
when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class)))
.thenThrow(RuntimeException.class);
Mono<String> result = adapter.invokeService("appId", "method", "request", HttpExtension.NONE, null, String.class);
Mono<String> result = adapter.invokeMethod("appId", "method", "request", HttpExtension.NONE, null, String.class);
assertThrowsDaprException(
RuntimeException.class,
@ -455,7 +453,7 @@ public class DaprClientGrpcTest {
public void invokeServiceNoRequestClassExceptionThrownTest() {
when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class)))
.thenThrow(RuntimeException.class);
Mono<String> result = adapter.invokeService("appId", "method", HttpExtension.NONE, (Map<String, String>)null, String.class);
Mono<String> result = adapter.invokeMethod("appId", "method", HttpExtension.NONE, (Map<String, String>)null, String.class);
assertThrowsDaprException(
RuntimeException.class,
@ -468,7 +466,7 @@ public class DaprClientGrpcTest {
public void invokeServiceNoRequestTypeRefExceptionThrownTest() {
when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class)))
.thenThrow(RuntimeException.class);
Mono<String> result = adapter.invokeService("appId", "method", HttpExtension.NONE, (Map<String, String>)null, TypeRef.STRING);
Mono<String> result = adapter.invokeMethod("appId", "method", HttpExtension.NONE, (Map<String, String>)null, TypeRef.STRING);
assertThrowsDaprException(
RuntimeException.class,
@ -485,7 +483,7 @@ public class DaprClientGrpcTest {
addCallback(settableFuture, callback, directExecutor());
when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class)))
.thenReturn(settableFuture);
Mono<String> result = adapter.invokeService("appId", "method", "request", HttpExtension.NONE, null, String.class);
Mono<String> result = adapter.invokeMethod("appId", "method", "request", HttpExtension.NONE, null, String.class);
settableFuture.setException(ex);
assertThrowsDaprException(
@ -520,7 +518,7 @@ public class DaprClientGrpcTest {
settableFuture.set(CommonProtos.InvokeResponse.newBuilder().setData(getAny(expected)).build());
when(client.invokeService(eq(request)))
.thenReturn(settableFuture);
Mono<String> result = adapter.invokeService("appId", "method", "request", httpExtension, null, String.class);
Mono<String> result = adapter.invokeMethod("appId", "method", "request", httpExtension, null, String.class);
String strOutput = result.block();
assertEquals(expected, strOutput);
}
@ -535,7 +533,7 @@ public class DaprClientGrpcTest {
settableFuture.set(CommonProtos.InvokeResponse.newBuilder().setData(getAny(expected)).build());
when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class)))
.thenReturn(settableFuture);
Mono<String> result = adapter.invokeService("appId", "method", "request", HttpExtension.NONE, null, String.class);
Mono<String> result = adapter.invokeMethod("appId", "method", "request", HttpExtension.NONE, null, String.class);
String strOutput = result.block();
assertEquals(expected, strOutput);
}
@ -550,7 +548,7 @@ public class DaprClientGrpcTest {
settableFuture.set(CommonProtos.InvokeResponse.newBuilder().setData(getAny(object)).build());
when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class)))
.thenReturn(settableFuture);
Mono<MyObject> result = adapter.invokeService("appId", "method", "request", HttpExtension.NONE, null, MyObject.class);
Mono<MyObject> 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 class DaprClientGrpcTest {
public void invokeServiceNoRequestBodyExceptionThrownTest() {
when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class)))
.thenThrow(RuntimeException.class);
Mono<String> result = adapter.invokeService("appId", "method", (Object)null, HttpExtension.NONE, String.class);
Mono<String> result = adapter.invokeMethod("appId", "method", (Object)null, HttpExtension.NONE, String.class);
assertThrowsDaprException(
RuntimeException.class,
@ -577,7 +575,7 @@ public class DaprClientGrpcTest {
addCallback(settableFuture, callback, directExecutor());
when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class)))
.thenReturn(settableFuture);
Mono<String> result = adapter.invokeService("appId", "method", (Object)null, HttpExtension.NONE, String.class);
Mono<String> result = adapter.invokeMethod("appId", "method", (Object)null, HttpExtension.NONE, String.class);
settableFuture.setException(ex);
assertThrowsDaprException(
@ -598,7 +596,7 @@ public class DaprClientGrpcTest {
settableFuture.set(CommonProtos.InvokeResponse.newBuilder().setData(getAny(expected)).build());
when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class)))
.thenReturn(settableFuture);
Mono<String> result = adapter.invokeService("appId", "method", (Object)null, HttpExtension.NONE, String.class);
Mono<String> result = adapter.invokeMethod("appId", "method", (Object)null, HttpExtension.NONE, String.class);
String strOutput = result.block();
assertEquals(expected, strOutput);
}
@ -614,7 +612,7 @@ public class DaprClientGrpcTest {
settableFuture.set(CommonProtos.InvokeResponse.newBuilder().setData(getAny(object)).build());
when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class)))
.thenReturn(settableFuture);
Mono<MyObject> result = adapter.invokeService("appId", "method", (Object)null, HttpExtension.NONE, MyObject.class);
Mono<MyObject> 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 class DaprClientGrpcTest {
.thenThrow(RuntimeException.class);
String request = "Request";
byte[] byteRequest = serializer.serialize(request);
Mono<byte[]> result = adapter.invokeService("appId", "method", byteRequest, HttpExtension.NONE, byte[].class);
Mono<byte[]> result = adapter.invokeMethod("appId", "method", byteRequest, HttpExtension.NONE, byte[].class);
assertThrowsDaprException(
RuntimeException.class,
@ -646,7 +644,7 @@ public class DaprClientGrpcTest {
String request = "Request";
byte[] byteRequest = serializer.serialize(request);
Mono<byte[]> result =
adapter.invokeService("appId", "method", byteRequest, HttpExtension.NONE,(HashMap<String, String>) null);
adapter.invokeMethod("appId", "method", byteRequest, HttpExtension.NONE,(HashMap<String, String>) null);
settableFuture.setException(ex);
assertThrowsDaprException(
@ -668,7 +666,7 @@ public class DaprClientGrpcTest {
.thenReturn(settableFuture);
String request = "Request";
byte[] byteRequest = serializer.serialize(request);
Mono<byte[]> result = adapter.invokeService(
Mono<byte[]> result = adapter.invokeMethod(
"appId", "method", byteRequest, HttpExtension.NONE, (HashMap<String, String>) null);
byte[] byteOutput = result.block();
String strOutput = serializer.deserialize(byteOutput, String.class);
@ -687,7 +685,7 @@ public class DaprClientGrpcTest {
.thenReturn(settableFuture);
String request = "Request";
byte[] byteRequest = serializer.serialize(request);
Mono<byte[]> result = adapter.invokeService("appId", "method", byteRequest, HttpExtension.NONE, byte[].class);
Mono<byte[]> 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 class DaprClientGrpcTest {
public void invokeServiceNoRequestNoClassBodyExceptionThrownTest() {
when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class)))
.thenThrow(RuntimeException.class);
Mono<Void> result = adapter.invokeService("appId", "method", (Object)null, HttpExtension.NONE);
Mono<Void> result = adapter.invokeMethod("appId", "method", (Object)null, HttpExtension.NONE);
assertThrowsDaprException(
RuntimeException.class,
@ -713,7 +711,7 @@ public class DaprClientGrpcTest {
addCallback(settableFuture, callback, directExecutor());
when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class)))
.thenReturn(settableFuture);
Mono<Void> result = adapter.invokeService("appId", "method", (Object)null, HttpExtension.NONE);
Mono<Void> result = adapter.invokeMethod("appId", "method", (Object)null, HttpExtension.NONE);
settableFuture.setException(ex);
assertThrowsDaprException(
@ -732,7 +730,7 @@ public class DaprClientGrpcTest {
addCallback(settableFuture, callback, directExecutor());
when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class)))
.thenReturn(settableFuture);
Mono<Void> result = adapter.invokeService("appId", "method", (Object)null, HttpExtension.NONE);
Mono<Void> 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 class DaprClientGrpcTest {
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 class DaprClientGrpcTest {
settableFuture.set(CommonProtos.InvokeResponse.newBuilder().setData(getAny(resultObj)).build());
when(client.invokeService(any(DaprProtos.InvokeServiceRequest.class)))
.thenReturn(settableFuture);
Mono<Void> result = adapter.invokeService("appId", "method", (Object)null, HttpExtension.NONE);
Mono<Void> result = adapter.invokeMethod("appId", "method", (Object)null, HttpExtension.NONE);
result.block();
assertTrue(callback.wasCalled);
}
@ -945,26 +943,26 @@ public class DaprClientGrpcTest {
State<String> 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 class DaprClientGrpcTest {
settableFuture.set(responseEnvelope);
return settableFuture;
});
List<State<String>> result = adapter.getStates(STATE_STORE_NAME, Arrays.asList("100", "200"), String.class).block();
List<State<String>> 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 class DaprClientGrpcTest {
settableFuture.set(responseEnvelope);
return settableFuture;
});
List<State<Integer>> result = adapter.getStates(STATE_STORE_NAME, Arrays.asList("100", "200"), int.class).block();
List<State<Integer>> 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 class DaprClientGrpcTest {
settableFuture.set(responseEnvelope);
return settableFuture;
});
List<State<Boolean>> result = adapter.getStates(STATE_STORE_NAME, Arrays.asList("100", "200"), boolean.class).block();
List<State<Boolean>> 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 class DaprClientGrpcTest {
settableFuture.set(responseEnvelope);
return settableFuture;
});
List<State<byte[]>> result = adapter.getStates(STATE_STORE_NAME, Arrays.asList("100", "200"), byte[].class).block();
List<State<byte[]>> 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 class DaprClientGrpcTest {
settableFuture.set(responseEnvelope);
return settableFuture;
});
List<State<MyObject>> result = adapter.getStates(STATE_STORE_NAME, Arrays.asList("100", "200"), MyObject.class).block();
List<State<MyObject>> 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 class DaprClientGrpcTest {
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 class DaprClientGrpcTest {
ExecuteStateTransactionRequest request = new ExecuteStateTransactionRequestBuilder(STATE_STORE_NAME)
.withTransactionalStates(upsertOperation)
.build();
Mono<Response<Void>> result = adapter.executeTransaction(request);
Mono<Response<Void>> result = adapter.executeStateTransaction(request);
assertThrowsDaprException(
IOException.class,
@ -1376,7 +1374,7 @@ public class DaprClientGrpcTest {
.withTransactionalStates(upsertOperation, deleteOperation)
.withMetadata(metadata)
.build();
Mono<Response<Void>> result = adapter.executeTransaction(request);
Mono<Response<Void>> result = adapter.executeStateTransaction(request);
settableFuture.set(Empty.newBuilder().build());
result.block();
assertTrue(callback.wasCalled);
@ -1401,7 +1399,7 @@ public class DaprClientGrpcTest {
TransactionalStateOperation.OperationType.DELETE,
new State<>("testKey")
);
Mono<Void> result = adapter.executeTransaction(STATE_STORE_NAME, Arrays.asList(upsertOperation, deleteOperation));
Mono<Void> 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 class DaprClientGrpcTest {
TransactionalStateOperation<String> operation = new TransactionalStateOperation<>(
TransactionalStateOperation.OperationType.UPSERT,
stateKey);
Mono<Void> result = adapter.executeTransaction(STATE_STORE_NAME, Collections.singletonList(operation));
Mono<Void> result = adapter.executeStateTransaction(STATE_STORE_NAME, Collections.singletonList(operation));
assertThrowsDaprException(
RuntimeException.class,
@ -1444,7 +1442,7 @@ public class DaprClientGrpcTest {
TransactionalStateOperation<String> operation = new TransactionalStateOperation<>(
TransactionalStateOperation.OperationType.UPSERT,
stateKey);
Mono<Void> result = adapter.executeTransaction(STATE_STORE_NAME, Collections.singletonList(operation));
Mono<Void> result = adapter.executeStateTransaction(STATE_STORE_NAME, Collections.singletonList(operation));
settableFuture.setException(ex);
assertThrowsDaprException(
@ -1458,11 +1456,11 @@ public class DaprClientGrpcTest {
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();
});
}

View File

@ -7,7 +7,7 @@ package io.dapr.client;
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.junit.Test;
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 class DaprClientHttpTest {
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 class DaprClientHttpTest {
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 class DaprClientHttpTest {
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 class DaprClientHttpTest {
.respond("\"hello world\"");
daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Mono<String> mono = daprClientHttp.invokeService("41", "neworder", null, HttpExtension.GET, null, String.class);
Mono<String> mono = daprClientHttp.invokeMethod("41", "neworder", null, HttpExtension.GET, null, String.class);
assertEquals("hello world", mono.block());
}
@ -192,7 +191,7 @@ public class DaprClientHttpTest {
.respond(new byte[0]);
daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Mono<String> mono = daprClientHttp.invokeService("41", "neworder", null, HttpExtension.GET, null, String.class);
Mono<String> mono = daprClientHttp.invokeMethod("41", "neworder", null, HttpExtension.GET, null, String.class);
assertNull(mono.block());
}
@ -203,7 +202,7 @@ public class DaprClientHttpTest {
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Mono<byte[]> mono = daprClientHttp.invokeService("41", "neworder", null, HttpExtension.GET, byte[].class);
Mono<byte[]> mono = daprClientHttp.invokeMethod("41", "neworder", null, HttpExtension.GET, byte[].class);
assertEquals(new String(mono.block()), EXPECTED_RESULT);
}
@ -215,7 +214,7 @@ public class DaprClientHttpTest {
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Mono<byte[]> mono = daprClientHttp.invokeService("41", "neworder", (byte[]) null, HttpExtension.GET, map);
Mono<byte[]> 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 class DaprClientHttpTest {
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Mono<Void> mono = daprClientHttp.invokeService("41", "neworder", HttpExtension.GET, map);
Mono<Void> mono = daprClientHttp.invokeMethod("41", "neworder", HttpExtension.GET, map);
assertNull(mono.block());
}
@ -240,7 +239,7 @@ public class DaprClientHttpTest {
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Mono<Void> mono = daprClientHttp.invokeService("41", "neworder", "", HttpExtension.GET, map);
Mono<Void> mono = daprClientHttp.invokeMethod("41", "neworder", "", HttpExtension.GET, map);
assertNull(mono.block());
}
@ -255,7 +254,7 @@ public class DaprClientHttpTest {
Map<String, String> queryString = new HashMap<>();
queryString.put("test", "1");
HttpExtension httpExtension = new HttpExtension(DaprHttp.HttpMethods.GET, queryString);
Mono<Void> mono = daprClientHttp.invokeService("41", "neworder", "", httpExtension, map);
Mono<Void> mono = daprClientHttp.invokeMethod("41", "neworder", "", httpExtension, map);
assertNull(mono.block());
}
@ -267,7 +266,7 @@ public class DaprClientHttpTest {
.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 class DaprClientHttpTest {
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 class DaprClientHttpTest {
daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
List<State<String>> 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 class DaprClientHttpTest {
daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
List<State<Integer>> 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 class DaprClientHttpTest {
daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
List<State<Boolean>> 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 class DaprClientHttpTest {
// 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<State<String>> 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 class DaprClientHttpTest {
// 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<State<MyObject>> 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 class DaprClientHttpTest {
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Mono<Void> mono = daprClientHttp.saveStates(STATE_STORE_NAME, stateKeyValueList);
Mono<Void> mono = daprClientHttp.saveBulkState(STATE_STORE_NAME, stateKeyValueList);
assertNull(mono.block());
}
@ -702,9 +701,9 @@ public class DaprClientHttpTest {
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 class DaprClientHttpTest {
List<State<?>> stateKeyValueList = new ArrayList<>();
daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Mono<Void> mono = daprClientHttp.saveStates(STATE_STORE_NAME, null);
Mono<Void> mono = daprClientHttp.saveBulkState(STATE_STORE_NAME, null);
assertNull(mono.block());
Mono<Void> mono1 = daprClientHttp.saveStates(STATE_STORE_NAME, stateKeyValueList);
Mono<Void> mono1 = daprClientHttp.saveBulkState(STATE_STORE_NAME, stateKeyValueList);
assertNull(mono1.block());
}
@ -727,7 +726,7 @@ public class DaprClientHttpTest {
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Mono<Void> mono1 = daprClientHttp.saveStates(STATE_STORE_NAME, stateKeyValueList);
Mono<Void> mono1 = daprClientHttp.saveBulkState(STATE_STORE_NAME, stateKeyValueList);
assertNull(mono1.block());
}
@ -740,7 +739,7 @@ public class DaprClientHttpTest {
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Mono<Void> mono = daprClientHttp.saveStates(STATE_STORE_NAME, stateKeyValueList);
Mono<Void> mono = daprClientHttp.saveBulkState(STATE_STORE_NAME, stateKeyValueList);
assertNull(mono.block());
}
@ -753,7 +752,7 @@ public class DaprClientHttpTest {
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Mono<Void> mono = daprClientHttp.saveStates(STATE_STORE_NAME, stateKeyValueList);
Mono<Void> mono = daprClientHttp.saveBulkState(STATE_STORE_NAME, stateKeyValueList);
assertNull(mono.block());
}
@ -800,7 +799,7 @@ public class DaprClientHttpTest {
TransactionalStateOperation<String> deleteOperation = new TransactionalStateOperation<>(
TransactionalStateOperation.OperationType.DELETE,
new State<>("deleteKey"));
Mono<Void> mono = daprClientHttp.executeTransaction(STATE_STORE_NAME, Arrays.asList(upsertOperation,
Mono<Void> mono = daprClientHttp.executeStateTransaction(STATE_STORE_NAME, Arrays.asList(upsertOperation,
deleteOperation));
assertNull(mono.block());
}
@ -824,7 +823,7 @@ public class DaprClientHttpTest {
TransactionalStateOperation<String> deleteOperation = new TransactionalStateOperation<>(
TransactionalStateOperation.OperationType.DELETE,
new State<>("deleteKey"));
Mono<Void> mono = daprClientHttp.executeTransaction(STATE_STORE_NAME, Arrays.asList(upsertOperation,
Mono<Void> mono = daprClientHttp.executeStateTransaction(STATE_STORE_NAME, Arrays.asList(upsertOperation,
deleteOperation));
assertNull(mono.block());
}
@ -848,7 +847,7 @@ public class DaprClientHttpTest {
TransactionalStateOperation<String> deleteOperation = new TransactionalStateOperation<>(
TransactionalStateOperation.OperationType.DELETE,
new State<>("deleteKey"));
Mono<Void> mono = daprClientHttp.executeTransaction(STATE_STORE_NAME, Arrays.asList(upsertOperation,
Mono<Void> mono = daprClientHttp.executeStateTransaction(STATE_STORE_NAME, Arrays.asList(upsertOperation,
deleteOperation));
assertNull(mono.block());
}
@ -875,7 +874,7 @@ public class DaprClientHttpTest {
TransactionalStateOperation<String> nullStateOperation = new TransactionalStateOperation<>(
TransactionalStateOperation.OperationType.DELETE,
null);
Mono<Void> mono = daprClientHttp.executeTransaction(STATE_STORE_NAME, Arrays.asList(
Mono<Void> mono = daprClientHttp.executeStateTransaction(STATE_STORE_NAME, Arrays.asList(
null,
nullStateOperation,
upsertOperation,
@ -888,9 +887,9 @@ public class DaprClientHttpTest {
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 class DaprClientHttpTest {
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Mono<Void> mono = daprClientHttp.executeTransaction(STATE_STORE_NAME, null);
Mono<Void> 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());
}

View File

@ -220,7 +220,7 @@ public class DaprRuntimeTest {
serializer.serialize(message.data),
message.metadata)
.map(r -> new DaprHttpStub.ResponseStub(r, null, 200)));
Mono<byte[]> response = client.invokeService(APP_ID, METHOD_NAME, message.data, HttpExtension.POST,
Mono<byte[]> response = client.invokeMethod(APP_ID, METHOD_NAME, message.data, HttpExtension.POST,
message.metadata, byte[].class);
Assert.assertArrayEquals(expectedResponse, response.block());