Resolving conflict for PR #110 (#130)

* Renaming State domain object.
Removing duplicate use of State Options.
Adding custom serialize and deserialize classes for StateOptions objects.

* #26 Refractor StateOptions to clean unused code

* Fixing merge issues.

* Fixing unit test for DaprClientHttpAdapterTest after refactoring.

Co-authored-by: Juan Jose Herrera <35985447+JuanJose-Herrera@users.noreply.github.com>
This commit is contained in:
Artur Souza 2020-01-20 11:34:54 -08:00 committed by GitHub
parent 449ae611dd
commit 47918cc009
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 217 additions and 147 deletions

View File

@ -4,7 +4,7 @@
*/
package io.dapr.client;
import io.dapr.client.domain.StateKeyValue;
import io.dapr.client.domain.State;
import io.dapr.client.domain.StateOptions;
import io.dapr.client.domain.Verb;
import reactor.core.publisher.Mono;
@ -116,27 +116,23 @@ public interface DaprClient {
/**
* Retrieve a State based on their key.
*
* @param state The key of the State to be retrieved.
* @param stateOptions The options for the call to use.
* @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<StateKeyValue<T>> getState(StateKeyValue<T> state, StateOptions stateOptions, Class<T> clazz);
<T> Mono<State<T>> getState(State<T> state, Class<T> clazz);
/**
* Save/Update a list of states.
*
* @param states the States to be saved.
* @param <T> the Type of the State.
* @return a Mono plan of type Void.
*/
<T> Mono<Void> saveStates(List<StateKeyValue<T>> states);
<T> Mono<Void> saveStates(List<State<T>> states);
/**
* Save/Update a state.
*
* @param key the key of the state.
* @param etag the etag to be used.
* @param value the value of the state.
@ -150,11 +146,10 @@ public interface DaprClient {
* Delete a state.
*
* @param state The key of the State to be removed.
* @param options The options of the state.
* @param <T> The Type of the key of the State.
* @return a Mono plan of type Void.
*/
<T> Mono<Void> deleteState(StateKeyValue<T> state, StateOptions options);
<T> Mono<Void> deleteState(State<T> state);
/**
* Invokes an Actor method on Dapr.

View File

@ -11,7 +11,7 @@ import com.google.protobuf.Duration;
import com.google.protobuf.Empty;
import io.dapr.DaprGrpc;
import io.dapr.DaprProtos;
import io.dapr.client.domain.StateKeyValue;
import io.dapr.client.domain.State;
import io.dapr.client.domain.StateOptions;
import io.dapr.client.domain.Verb;
import io.dapr.utils.ObjectSerializer;
@ -159,12 +159,12 @@ class DaprClientGrpcAdapter implements DaprClient {
* {@inheritDoc}
*/
@Override
public <T> Mono<StateKeyValue<T>> getState(StateKeyValue<T> state, StateOptions stateOptions, Class<T> clazz) {
public <T> Mono<State<T>> getState(State<T> state, Class<T> clazz) {
try {
DaprProtos.GetStateEnvelope.Builder builder = DaprProtos.GetStateEnvelope.newBuilder()
.setKey(state.getKey());
if (stateOptions != null && stateOptions.getConsistency() != null) {
builder.setConsistency(stateOptions.getConsistency().getValue());
if (state.getOptions() != null && state.getOptions().getConsistency() != null) {
builder.setConsistency(state.getOptions().getConsistency().getValue());
}
DaprProtos.GetStateEnvelope envelope = builder.build();
@ -176,27 +176,27 @@ class DaprClientGrpcAdapter implements DaprClient {
} catch (NullPointerException npe) {
return null;
}
return buildStateKeyValue(response, state.getKey(), stateOptions, clazz);
return buildStateKeyValue(response, state.getKey(), state.getOptions(), clazz);
}); } catch (Exception ex) {
return Mono.error(ex);
}
}
private <T> StateKeyValue<T> buildStateKeyValue(DaprProtos.GetStateResponseEnvelope response, String requestedKey, StateOptions stateOptions, Class<T> clazz) throws IOException {
private <T> State<T> buildStateKeyValue(DaprProtos.GetStateResponseEnvelope response, String requestedKey, StateOptions stateOptions, Class<T> clazz) throws IOException {
T value = objectSerializer.deserialize(Optional.ofNullable(response.getData().getValue().toByteArray()).orElse(null), clazz);
String etag = response.getEtag();
String key = requestedKey;
return new StateKeyValue<>(value, key, etag, stateOptions);
return new State<>(value, key, etag, stateOptions);
}
/**
* {@inheritDoc}
*/
@Override
public <T> Mono<Void> saveStates(List<StateKeyValue<T>> states) {
public <T> Mono<Void> saveStates(List<State<T>> states) {
try {
DaprProtos.SaveStateEnvelope.Builder builder = DaprProtos.SaveStateEnvelope.newBuilder();
for (StateKeyValue state : states) {
for (State state : states) {
builder.addRequests(buildStateRequest(state).build()); }
DaprProtos.SaveStateEnvelope envelope = builder.build();
@ -214,7 +214,7 @@ class DaprClientGrpcAdapter implements DaprClient {
}
}
private <T> DaprProtos.StateRequest.Builder buildStateRequest(StateKeyValue<T> state) throws IOException {
private <T> DaprProtos.StateRequest.Builder buildStateRequest(State<T> state) throws IOException {
byte[] byteState = objectSerializer.serialize(state.getValue());
Any data = Any.newBuilder().setValue(ByteString.copyFrom(byteState)).build();
DaprProtos.StateRequest.Builder stateBuilder = DaprProtos.StateRequest.newBuilder()
@ -259,19 +259,18 @@ class DaprClientGrpcAdapter implements DaprClient {
@Override
public <T> Mono<Void> saveState(String key, String etag, T value, StateOptions options) {
StateKeyValue<T> state = new StateKeyValue<>(value, key, etag, options);
State<T> state = new State<>(value, key, etag, options);
return saveStates(Arrays.asList(state));
}
/**
* if stateOptions param is passed it will overrside state.options.
* {@inheritDoc}
*/
@Override
public <T> Mono<Void> deleteState(StateKeyValue<T> state, StateOptions options) {
public <T> Mono<Void> deleteState(State<T> state) {
try {
DaprProtos.StateOptions.Builder optionBuilder = null;
StateOptions options = state.getOptions();
if (options != null) {
optionBuilder = DaprProtos.StateOptions.newBuilder();
DaprProtos.RetryPolicy.Builder retryPolicyBuilder = null;

View File

@ -4,7 +4,7 @@
*/
package io.dapr.client;
import io.dapr.client.domain.StateKeyValue;
import io.dapr.client.domain.State;
import io.dapr.client.domain.StateOptions;
import io.dapr.client.domain.Verb;
import io.dapr.utils.Constants;
@ -12,7 +12,6 @@ import io.dapr.utils.ObjectSerializer;
import reactor.core.publisher.Mono;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.*;
/**
@ -167,7 +166,7 @@ public class DaprClientHttpAdapter implements DaprClient {
* {@inheritDoc}
*/
@Override
public <T> Mono<StateKeyValue<T>> getState(StateKeyValue<T> state, StateOptions stateOptions, Class<T> clazz) {
public <T> Mono<State<T>> getState(State<T> state, Class<T> clazz) {
try {
if (state.getKey() == null) {
throw new IllegalArgumentException("Name cannot be null or empty.");
@ -180,12 +179,12 @@ public class DaprClientHttpAdapter implements DaprClient {
StringBuilder url = new StringBuilder(Constants.STATE_PATH)
.append("/")
.append(state.getKey());
Map<String, String> urlParameters = Optional.ofNullable(stateOptions).map(options -> options.getStateOptionsAsMap() ).orElse( new HashMap<>());;
Map<String, String> urlParameters = Optional.ofNullable(state.getOptions()).map(options -> options.getStateOptionsAsMap() ).orElse( new HashMap<>());;
return this.client
.invokeAPI(DaprHttp.HttpMethods.GET.name(), url.toString(), urlParameters, headers)
.flatMap(s -> {
try {
return Mono.just(buildStateKeyValue(s, state.getKey(), stateOptions, clazz));
return Mono.just(buildStateKeyValue(s, state.getKey(), state.getOptions(), clazz));
}catch (Exception ex){
return Mono.error(ex);
}
@ -199,14 +198,14 @@ public class DaprClientHttpAdapter implements DaprClient {
* {@inheritDoc}
*/
@Override
public <T> Mono<Void> saveStates(List<StateKeyValue<T>> states) {
public <T> Mono<Void> saveStates(List<State<T>> states) {
try {
if (states == null || states.isEmpty()) {
return Mono.empty();
}
final Map<String, String> headers = new HashMap<>();
final String etag = states.stream().filter(state -> null != state.getEtag() && !state.getEtag().trim().isEmpty())
.findFirst().orElse(new StateKeyValue<>(null, null, null, null)).getEtag();
.findFirst().orElse(new State<>(null, null, null, null)).getEtag();
if (etag != null && !etag.trim().isEmpty()) {
headers.put(Constants.HEADER_HTTP_ETAG_ID, etag);
}
@ -224,7 +223,7 @@ public class DaprClientHttpAdapter implements DaprClient {
*/
@Override
public <T> Mono<Void> saveState(String key, String etag, T value, StateOptions options) {
StateKeyValue<T> state = new StateKeyValue<>(value, key, etag, options);
State<T> state = new State<>(value, key, etag, options);
return saveStates(Arrays.asList(state));
}
@ -232,7 +231,7 @@ public class DaprClientHttpAdapter implements DaprClient {
* {@inheritDoc}
*/
@Override
public <T> Mono<Void> deleteState(StateKeyValue<T> state, StateOptions options) {
public <T> Mono<Void> deleteState(State<T> state) {
try {
if (state == null) {
throw new IllegalArgumentException("State cannot be null.");
@ -245,7 +244,7 @@ public class DaprClientHttpAdapter implements DaprClient {
headers.put(Constants.HEADER_HTTP_ETAG_ID, state.getEtag());
}
String url = Constants.STATE_PATH + "/" + state.getKey();
Map<String, String> urlParameters = Optional.ofNullable(options).map(stateOptions -> stateOptions.getStateOptionsAsMap() ).orElse( new HashMap<>());;
Map<String, String> urlParameters = Optional.ofNullable(state.getOptions()).map(stateOptions -> stateOptions.getStateOptionsAsMap()).orElse( new HashMap<>());;
return this.client.invokeAPI(DaprHttp.HttpMethods.DELETE.name(), url, urlParameters, headers).then();
} catch (Exception ex) {
return Mono.error(ex);
@ -338,14 +337,14 @@ public class DaprClientHttpAdapter implements DaprClient {
* @return A StateKeyValue instance
* @throws IOException If there's a issue deserialzing the response.
*/
private <T> StateKeyValue<T> buildStateKeyValue(DaprHttp.Response response, String requestedKey, StateOptions stateOptions, Class<T> clazz) throws IOException {
private <T> State<T> buildStateKeyValue(DaprHttp.Response response, String requestedKey, StateOptions stateOptions, Class<T> clazz) throws IOException {
T value = objectSerializer.deserialize(response.getBody(), clazz);
String key = requestedKey;
String etag = null;
if (response.getHeaders() != null && response.getHeaders().containsKey("Etag")) {
etag = objectSerializer.deserialize(response.getHeaders().get("Etag"), String.class);
}
return new StateKeyValue<>(value, key, etag, stateOptions);
return new State<>(value, key, etag, stateOptions);
}
}

View File

@ -8,7 +8,7 @@ package io.dapr.client.domain;
* This class reprent what a State is
* @param <T> The type of the value of the sate
*/
public class StateKeyValue<T> {
public class State<T> {
/**
* The value of the state
*/
@ -30,12 +30,27 @@ public class StateKeyValue<T> {
/**
* Create an inmutable state
* This Constructor MUST be used anytime you need to retrieve or delete a State.
* @param key - The key of the state
* @param etag - The etag of the state - Keep in mind that for some state stores (like reids) only numbers are supported.
* @param options - REQUIRED when saving a state.
*/
public State(String key, String etag, StateOptions options) {
this.value = null;
this.key = key;
this.etag = etag;
this.options = options;
}
/**
* Create an inmutable state
* This Constructor MUST be used anytime you want the state to be send for a Save operation.
* @param value - The value of the state
* @param key - The key of the state
* @param etag - The etag of the state - Keep in mind that for some state stores (like reids) only numbers are supported.
* @param options - REQUIRED when saving a state.
*/
public StateKeyValue(T value, String key, String etag, StateOptions options) {
public State(T value, String key, String etag, StateOptions options) {
this.value = value;
this.key = key;
this.etag = etag;
@ -77,9 +92,9 @@ public class StateKeyValue<T> {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof StateKeyValue)) return false;
if (!(o instanceof State)) return false;
StateKeyValue<?> that = (StateKeyValue<?>) o;
State<?> that = (State<?>) o;
if (getValue() != null ? !getValue().equals(that.getValue()) : that.getValue() != null) return false;
if (getKey() != null ? !getKey().equals(that.getKey()) : that.getKey() != null) return false;

View File

@ -4,9 +4,20 @@
*/
package io.dapr.client.domain;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.fasterxml.jackson.databind.exc.InvalidFormatException;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import io.dapr.utils.DurationUtils;
import java.io.IOException;
import java.time.Duration;
import java.util.Collections;
import java.util.HashMap;
@ -61,13 +72,13 @@ public class StateOptions {
return Collections.unmodifiableMap(Optional.ofNullable(mapOptions).orElse(Collections.EMPTY_MAP));
}
public static enum Consistency {
public enum Consistency {
EVENTUAL("eventual"),
STRONG("strong");
private final String value;
private Consistency(String value) {
Consistency(String value) {
this.value = value;
}
@ -76,15 +87,19 @@ public class StateOptions {
return this.value;
}
@JsonCreator
public static Consistency fromValue(String value) {
return Consistency.valueOf(value);
}
}
public static enum Concurrency {
public enum Concurrency {
FIRST_WRITE("first-write"),
LAST_WRITE ("last-write");
private final String value;
private Concurrency(String value) {
Concurrency(String value) {
this.value = value;
}
@ -93,24 +108,36 @@ public class StateOptions {
return this.value;
}
@JsonCreator
public static Concurrency fromValue(String value) {
return Concurrency.valueOf(value);
}
}
public static class RetryPolicy {
public static enum Pattern {
public enum Pattern {
LINEAR("linear"),
EXPONENTIAL("exponential");
private String value;
private Pattern(String value) {
Pattern(String value) {
this.value = value;
}
@JsonValue
public String getValue() {
return this.value;
}
@JsonCreator
public static Pattern fromValue(String value) {
return Pattern.valueOf(value);
}
}
@JsonSerialize(using = StateOptionDurationSerializer.class)
@JsonDeserialize(using = StateOptionDurationDeserializer.class)
private final Duration interval;
private final Integer threshold;
private final Pattern pattern;
@ -133,6 +160,41 @@ public class StateOptions {
public Pattern getPattern() {
return pattern;
}
}
public static class StateOptionDurationSerializer extends StdSerializer<Duration> {
public StateOptionDurationSerializer(Class<Duration> t) {
super(t);
}
@Override
public void serialize(Duration duration, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
String value = "";
if (duration != null && !duration.isZero() && !duration.isNegative()) {
value = DurationUtils.ConvertDurationToDaprFormat(duration);
}
jsonGenerator.writeString(value);
}
}
public static class StateOptionDurationDeserializer extends StdDeserializer<Duration> {
public StateOptionDurationDeserializer(Class<?> vc) {
super(vc);
}
@Override
public Duration deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
String durationStr = jsonParser.readValueAs(String.class);
Duration duration = null;
if (durationStr != null && !durationStr.trim().isEmpty()) {
try {
duration = DurationUtils.ConvertDurationFromDaprFormat(durationStr);
} catch (Exception ex) {
throw InvalidFormatException.from(jsonParser, "Unable to parse duration.", ex);
}
}
return duration;
}
}
}

View File

@ -7,7 +7,7 @@ import com.google.protobuf.ByteString;
import com.google.protobuf.Empty;
import io.dapr.DaprGrpc;
import io.dapr.DaprProtos;
import io.dapr.client.domain.StateKeyValue;
import io.dapr.client.domain.State;
import io.dapr.client.domain.StateOptions;
import io.dapr.client.domain.Verb;
import io.dapr.utils.ObjectSerializer;
@ -468,8 +468,8 @@ public class DaprClientGrpcAdapterTest {
@Test(expected = RuntimeException.class)
public void getStateExceptionThrownTest() {
when(client.getState(any(io.dapr.DaprProtos.GetStateEnvelope.class))).thenThrow(RuntimeException.class);
StateKeyValue<String> key = buildStateKey(null, "Key1", "ETag1", null);
Mono<StateKeyValue<String>> result = adater.getState(key, null, String.class);
State<String> key = buildStateKey(null, "Key1", "ETag1", null);
Mono<State<String>> result = adater.getState(key, String.class);
result.block();
}
@ -482,8 +482,8 @@ public class DaprClientGrpcAdapterTest {
addCallback(settableFuture, callback, directExecutor());
when(client.getState(any(io.dapr.DaprProtos.GetStateEnvelope.class)))
.thenReturn(settableFuture);
StateKeyValue<String> key = buildStateKey(null, "Key1", "ETag1", null);
Mono<StateKeyValue<String>> result = adater.getState(key, null, String.class);
State<String> key = buildStateKey(null, "Key1", "ETag1", null);
Mono<State<String>> result = adater.getState(key, String.class);
settableFuture.setException(ex);
result.block();
}
@ -493,15 +493,15 @@ public class DaprClientGrpcAdapterTest {
String etag = "ETag1";
String key = "key1";
String expectedValue = "Expected state";
StateKeyValue<String> expectedState = buildStateKey(expectedValue, key, etag, null);
State<String> expectedState = buildStateKey(expectedValue, key, etag, null);
DaprProtos.GetStateResponseEnvelope responseEnvelope = buildGetStateResponseEnvelope(expectedValue, etag);
SettableFuture<DaprProtos.GetStateResponseEnvelope> settableFuture = SettableFuture.create();
MockCallback<DaprProtos.GetStateResponseEnvelope> callback = new MockCallback<>(responseEnvelope);
addCallback(settableFuture, callback, directExecutor());
when(client.getState(any(io.dapr.DaprProtos.GetStateEnvelope.class)))
.thenReturn(settableFuture);
StateKeyValue<String> keyRequest = buildStateKey(null, key, etag, null);
Mono<StateKeyValue<String>> result = adater.getState(keyRequest, null, String.class);
State<String> keyRequest = buildStateKey(null, key, etag, null);
Mono<State<String>> result = adater.getState(keyRequest, String.class);
settableFuture.set(responseEnvelope);
assertEquals(expectedState, result.block());
}
@ -513,18 +513,18 @@ public class DaprClientGrpcAdapterTest {
MyObject expectedValue = new MyObject(1, "The Value");
StateOptions options = buildStateOptions(StateOptions.Consistency.STRONG, StateOptions.Concurrency.FIRST_WRITE,
Duration.ofDays(100), 1, StateOptions.RetryPolicy.Pattern.LINEAR);
StateKeyValue<MyObject> expectedState = buildStateKey(expectedValue, key, etag, options);
State<MyObject> expectedState = buildStateKey(expectedValue, key, etag, options);
DaprProtos.GetStateResponseEnvelope responseEnvelope = DaprProtos.GetStateResponseEnvelope.newBuilder()
.setData(getAny(expectedValue))
.setEtag(etag)
.build();
StateKeyValue<MyObject> keyRequest = buildStateKey(null, key, etag, options);
State<MyObject> keyRequest = buildStateKey(null, key, etag, options);
SettableFuture<DaprProtos.GetStateResponseEnvelope> settableFuture = SettableFuture.create();
MockCallback<DaprProtos.GetStateResponseEnvelope> callback = new MockCallback<>(responseEnvelope);
addCallback(settableFuture, callback, directExecutor());
when(client.getState(any(io.dapr.DaprProtos.GetStateEnvelope.class)))
.thenReturn(settableFuture);
Mono<StateKeyValue<MyObject>> result = adater.getState(keyRequest, options, MyObject.class);
Mono<State<MyObject>> result = adater.getState(keyRequest, MyObject.class);
settableFuture.set(responseEnvelope);
assertEquals(expectedState, result.block());
}
@ -536,18 +536,18 @@ public class DaprClientGrpcAdapterTest {
MyObject expectedValue = new MyObject(1, "The Value");
StateOptions options = new StateOptions(null, StateOptions.Concurrency.FIRST_WRITE,
new StateOptions.RetryPolicy(Duration.ofDays(100), 1, StateOptions.RetryPolicy.Pattern.LINEAR));
StateKeyValue<MyObject> expectedState = buildStateKey(expectedValue, key, etag, options);
State<MyObject> expectedState = buildStateKey(expectedValue, key, etag, options);
DaprProtos.GetStateResponseEnvelope responseEnvelope = DaprProtos.GetStateResponseEnvelope.newBuilder()
.setData(getAny(expectedValue))
.setEtag(etag)
.build();
StateKeyValue<MyObject> keyRequest = buildStateKey(null, key, etag, options);
State<MyObject> keyRequest = buildStateKey(null, key, etag, options);
SettableFuture<DaprProtos.GetStateResponseEnvelope> settableFuture = SettableFuture.create();
MockCallback<DaprProtos.GetStateResponseEnvelope> callback = new MockCallback<>(responseEnvelope);
addCallback(settableFuture, callback, directExecutor());
when(client.getState(any(io.dapr.DaprProtos.GetStateEnvelope.class)))
.thenReturn(settableFuture);
Mono<StateKeyValue<MyObject>> result = adater.getState(keyRequest, options, MyObject.class);
Mono<State<MyObject>> result = adater.getState(keyRequest, MyObject.class);
settableFuture.set(responseEnvelope);
assertEquals(expectedState, result.block());
}
@ -555,8 +555,8 @@ public class DaprClientGrpcAdapterTest {
@Test(expected = RuntimeException.class)
public void deleteStateExceptionThrowTest() {
when(client.deleteState(any(io.dapr.DaprProtos.DeleteStateEnvelope.class))).thenThrow(RuntimeException.class);
StateKeyValue<String> key = buildStateKey(null, "Key1", "ETag1", null);
Mono<Void> result = adater.deleteState(key, null);
State<String> key = buildStateKey(null, "Key1", "ETag1", null);
Mono<Void> result = adater.deleteState(key);
result.block();
}
@ -569,8 +569,8 @@ public class DaprClientGrpcAdapterTest {
addCallback(settableFuture, callback, directExecutor());
when(client.deleteState(any(io.dapr.DaprProtos.DeleteStateEnvelope.class)))
.thenReturn(settableFuture);
StateKeyValue<String> key = buildStateKey(null, "Key1", "ETag1", null);
Mono<Void> result = adater.deleteState(key, null);
State<String> key = buildStateKey(null, "Key1", "ETag1", null);
Mono<Void> result = adater.deleteState(key);
settableFuture.setException(ex);
result.block();
}
@ -584,8 +584,8 @@ public class DaprClientGrpcAdapterTest {
addCallback(settableFuture, callback, directExecutor());
when(client.deleteState(any(io.dapr.DaprProtos.DeleteStateEnvelope.class)))
.thenReturn(settableFuture);
StateKeyValue<String> stateKey = buildStateKey(null, key, etag, null);
Mono<Void> result = adater.deleteState(stateKey, null);
State<String> stateKey = buildStateKey(null, key, etag, null);
Mono<Void> result = adater.deleteState(stateKey);
settableFuture.set(Empty.newBuilder().build());
result.block();
assertTrue(callback.wasCalled);
@ -602,8 +602,8 @@ public class DaprClientGrpcAdapterTest {
addCallback(settableFuture, callback, directExecutor());
when(client.deleteState(any(io.dapr.DaprProtos.DeleteStateEnvelope.class)))
.thenReturn(settableFuture);
StateKeyValue<String> stateKey = buildStateKey(null, key, etag, options);
Mono<Void> result = adater.deleteState(stateKey, options);
State<String> stateKey = buildStateKey(null, key, etag, options);
Mono<Void> result = adater.deleteState(stateKey);
settableFuture.set(Empty.newBuilder().build());
result.block();
assertTrue(callback.wasCalled);
@ -620,8 +620,8 @@ public class DaprClientGrpcAdapterTest {
addCallback(settableFuture, callback, directExecutor());
when(client.deleteState(any(io.dapr.DaprProtos.DeleteStateEnvelope.class)))
.thenReturn(settableFuture);
StateKeyValue<String> stateKey = buildStateKey(null, key, etag, options);
Mono<Void> result = adater.deleteState(stateKey, options);
State<String> stateKey = buildStateKey(null, key, etag, options);
Mono<Void> result = adater.deleteState(stateKey);
settableFuture.set(Empty.newBuilder().build());
result.block();
assertTrue(callback.wasCalled);
@ -638,8 +638,8 @@ public class DaprClientGrpcAdapterTest {
addCallback(settableFuture, callback, directExecutor());
when(client.deleteState(any(io.dapr.DaprProtos.DeleteStateEnvelope.class)))
.thenReturn(settableFuture);
StateKeyValue<String> stateKey = buildStateKey(null, key, etag, options);
Mono<Void> result = adater.deleteState(stateKey, options);
State<String> stateKey = buildStateKey(null, key, etag, options);
Mono<Void> result = adater.deleteState(stateKey);
settableFuture.set(Empty.newBuilder().build());
result.block();
assertTrue(callback.wasCalled);
@ -656,8 +656,8 @@ public class DaprClientGrpcAdapterTest {
addCallback(settableFuture, callback, directExecutor());
when(client.deleteState(any(io.dapr.DaprProtos.DeleteStateEnvelope.class)))
.thenReturn(settableFuture);
StateKeyValue<String> stateKey = buildStateKey(null, key, etag, options);
Mono<Void> result = adater.deleteState(stateKey, options);
State<String> stateKey = buildStateKey(null, key, etag, options);
Mono<Void> result = adater.deleteState(stateKey);
settableFuture.set(Empty.newBuilder().build());
result.block();
assertTrue(callback.wasCalled);
@ -674,8 +674,8 @@ public class DaprClientGrpcAdapterTest {
addCallback(settableFuture, callback, directExecutor());
when(client.deleteState(any(io.dapr.DaprProtos.DeleteStateEnvelope.class)))
.thenReturn(settableFuture);
StateKeyValue<String> stateKey = buildStateKey(null, key, etag, options);
Mono<Void> result = adater.deleteState(stateKey, options);
State<String> stateKey = buildStateKey(null, key, etag, options);
Mono<Void> result = adater.deleteState(stateKey);
settableFuture.set(Empty.newBuilder().build());
result.block();
assertTrue(callback.wasCalled);
@ -692,8 +692,8 @@ public class DaprClientGrpcAdapterTest {
addCallback(settableFuture, callback, directExecutor());
when(client.deleteState(any(io.dapr.DaprProtos.DeleteStateEnvelope.class)))
.thenReturn(settableFuture);
StateKeyValue<String> stateKey = buildStateKey(null, key, etag, options);
Mono<Void> result = adater.deleteState(stateKey, options);
State<String> stateKey = buildStateKey(null, key, etag, options);
Mono<Void> result = adater.deleteState(stateKey);
settableFuture.set(Empty.newBuilder().build());
result.block();
assertTrue(callback.wasCalled);
@ -710,8 +710,8 @@ public class DaprClientGrpcAdapterTest {
addCallback(settableFuture, callback, directExecutor());
when(client.deleteState(any(io.dapr.DaprProtos.DeleteStateEnvelope.class)))
.thenReturn(settableFuture);
StateKeyValue<String> stateKey = buildStateKey(null, key, etag, options);
Mono<Void> result = adater.deleteState(stateKey, options);
State<String> stateKey = buildStateKey(null, key, etag, options);
Mono<Void> result = adater.deleteState(stateKey);
settableFuture.set(Empty.newBuilder().build());
result.block();
assertTrue(callback.wasCalled);
@ -876,8 +876,8 @@ public class DaprClientGrpcAdapterTest {
assertTrue(callback.wasCalled);
}
private <T> StateKeyValue<T> buildStateKey(T value, String key, String etag, StateOptions options) {
return new StateKeyValue(value, key, etag, options);
private <T> State<T> buildStateKey(T value, String key, String etag, StateOptions options) {
return new State(value, key, etag, options);
}
/**
@ -906,30 +906,30 @@ public class DaprClientGrpcAdapterTest {
String expectedValue1 = "Expected state 1";
String key2 = "key2";
String expectedValue2 = "Expected state 2";
StateKeyValue<String> expectedState1 = buildStateKey(expectedValue1, key1, etag, null);
State<String> expectedState1 = buildStateKey(expectedValue1, key1, etag, null);
Map<String, SettableFuture<DaprProtos.GetStateResponseEnvelope>> futuresMap = new HashMap<>();
futuresMap.put(key1, buildFutureGetStateEnvelop(expectedValue1, etag));
futuresMap.put(key2, buildFutureGetStateEnvelop(expectedValue2, etag));
when(client.getState(argThat(new GetStateEnvelopeKeyMatcher(key1)))).thenReturn(futuresMap.get(key1));
StateKeyValue<String> keyRequest1 = buildStateKey(null, key1, etag, null);
Mono<StateKeyValue<String>> resultGet1 = adater.getState(keyRequest1, null, String.class);
State<String> keyRequest1 = buildStateKey(null, key1, etag, null);
Mono<State<String>> resultGet1 = adater.getState(keyRequest1, String.class);
assertEquals(expectedState1, resultGet1.block());
StateKeyValue<String> keyRequest2 = buildStateKey(null, key2, etag, null);
Mono<StateKeyValue<String>> resultGet2 = adater.getState(keyRequest2, null, String.class);
State<String> keyRequest2 = buildStateKey(null, key2, etag, null);
Mono<State<String>> resultGet2 = adater.getState(keyRequest2, String.class);
SettableFuture<Empty> settableFutureDelete = SettableFuture.create();
MockCallback<Empty> callbackDelete = new MockCallback<>(Empty.newBuilder().build());
addCallback(settableFutureDelete, callbackDelete, directExecutor());
when(client.deleteState(any(io.dapr.DaprProtos.DeleteStateEnvelope.class)))
.thenReturn(settableFutureDelete);
Mono<Void> resultDelete = adater.deleteState(keyRequest2, null);
Mono<Void> resultDelete = adater.deleteState(keyRequest2);
settableFutureDelete.set(Empty.newBuilder().build());
resultDelete.block();
assertTrue(callbackDelete.wasCalled);
futuresMap.replace(key2, null);
when(client.getState(argThat(new GetStateEnvelopeKeyMatcher(key2)))).thenReturn(futuresMap.get(key2));
StateKeyValue<String> state2 = resultGet2.block();
State<String> state2 = resultGet2.block();
assertNull(state2);
}

View File

@ -4,7 +4,7 @@
*/
package io.dapr.client;
import io.dapr.client.domain.StateKeyValue;
import io.dapr.client.domain.State;
import io.dapr.client.domain.StateOptions;
import io.dapr.client.domain.Verb;
import io.dapr.utils.ObjectSerializer;
@ -216,49 +216,49 @@ public class DaprClientHttpAdapterTest {
@Test
public void getStates() {
StateKeyValue<String> stateKeyValue = new StateKeyValue("value", "key", "etag", null);
StateKeyValue<String> stateKeyNull = new StateKeyValue("value", null, "etag", null);
StateOptions stateOptions = mock(StateOptions.class);
State<String> stateKeyValue = new State("value", "key", "etag", stateOptions);
State<String> stateKeyNull = new State("value", null, "etag", stateOptions);
mockInterceptor.addRule()
.get("http://localhost:3000/v1.0/state/key")
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(3000, okHttpClient);
daprClientHttpAdapter = new DaprClientHttpAdapter(daprHttp);
assertThrows(IllegalArgumentException.class, () -> {
daprClientHttpAdapter.getState(stateKeyNull, null, String.class).block();
daprClientHttpAdapter.getState(stateKeyNull, String.class).block();
});
Mono<StateKeyValue<String>> mono = daprClientHttpAdapter.getState(stateKeyValue, stateOptions, String.class);
Mono<State<String>> mono = daprClientHttpAdapter.getState(stateKeyValue, String.class);
assertEquals(mono.block().getKey(), "key");
}
@Test
public void getStatesEmptyEtag() {
StateKeyValue<String> stateEmptyEtag = new StateKeyValue("value", "key", "", null);
State<String> stateEmptyEtag = new State("value", "key", "", null);
mockInterceptor.addRule()
.get("http://localhost:3000/v1.0/state/key")
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(3000, okHttpClient);
daprClientHttpAdapter = new DaprClientHttpAdapter(daprHttp);
Mono<StateKeyValue<String>> monoEmptyEtag = daprClientHttpAdapter.getState(stateEmptyEtag, null, String.class);
Mono<State<String>> monoEmptyEtag = daprClientHttpAdapter.getState(stateEmptyEtag, String.class);
assertEquals(monoEmptyEtag.block().getKey(), "key");
}
@Test
public void getStatesNullEtag() {
StateKeyValue<String> stateNullEtag = new StateKeyValue("value", "key", null, null);
State<String> stateNullEtag = new State("value", "key", null, null);
mockInterceptor.addRule()
.get("http://localhost:3000/v1.0/state/key")
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(3000, okHttpClient);
daprClientHttpAdapter = new DaprClientHttpAdapter(daprHttp);
Mono<StateKeyValue<String>> monoNullEtag = daprClientHttpAdapter.getState(stateNullEtag, null, String.class);
Mono<State<String>> monoNullEtag = daprClientHttpAdapter.getState(stateNullEtag, String.class);
assertEquals(monoNullEtag.block().getKey(), "key");
}
@Test
public void saveStates() {
StateKeyValue<String> stateKeyValue = new StateKeyValue("value", "key", "etag", null);
List<StateKeyValue<String>> stateKeyValueList = Arrays.asList(stateKeyValue);
State<String> stateKeyValue = new State("value", "key", "etag", null);
List<State<String>> stateKeyValueList = Arrays.asList(stateKeyValue);
mockInterceptor.addRule()
.post("http://localhost:3000/v1.0/state")
.respond(EXPECTED_RESULT);
@ -270,8 +270,8 @@ public class DaprClientHttpAdapterTest {
@Test
public void saveStatesNull() {
StateKeyValue<String> stateKeyValue = new StateKeyValue("value", "key", "", null);
List<StateKeyValue<String>> stateKeyValueList = new ArrayList();
State<String> stateKeyValue = new State("value", "key", "", null);
List<State<String>> stateKeyValueList = new ArrayList();
mockInterceptor.addRule()
.post("http://localhost:3000/v1.0/state")
.respond(EXPECTED_RESULT);
@ -285,8 +285,8 @@ public class DaprClientHttpAdapterTest {
@Test
public void saveStatesEtagNull() {
StateKeyValue<String> stateKeyValue = new StateKeyValue("value", "key", null, null);
List<StateKeyValue<String>> stateKeyValueList = Arrays.asList(stateKeyValue);
State<String> stateKeyValue = new State("value", "key", null, null);
List<State<String>> stateKeyValueList = Arrays.asList(stateKeyValue);
mockInterceptor.addRule()
.post("http://localhost:3000/v1.0/state")
.respond(EXPECTED_RESULT);
@ -298,8 +298,8 @@ public class DaprClientHttpAdapterTest {
@Test
public void saveStatesEtagEmpty() {
StateKeyValue<String> stateKeyValue = new StateKeyValue("value", "key", "", null);
List<StateKeyValue<String>> stateKeyValueList = Arrays.asList(stateKeyValue);
State<String> stateKeyValue = new State("value", "key", "", null);
List<State<String>> stateKeyValueList = Arrays.asList(stateKeyValue);
mockInterceptor.addRule()
.post("http://localhost:3000/v1.0/state")
.respond(EXPECTED_RESULT);
@ -324,58 +324,58 @@ public class DaprClientHttpAdapterTest {
@Test
public void deleteState() {
StateKeyValue<String> stateKeyValue = new StateKeyValue("value", "key", "etag", null);
StateOptions stateOptions = mock(StateOptions.class);
State<String> stateKeyValue = new State("value", "key", "etag", stateOptions);
mockInterceptor.addRule()
.delete("http://localhost:3000/v1.0/state/key")
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(3000, okHttpClient);
daprClientHttpAdapter = new DaprClientHttpAdapter(daprHttp);
Mono<Void> mono = daprClientHttpAdapter.deleteState(stateKeyValue, stateOptions);
Mono<Void> mono = daprClientHttpAdapter.deleteState(stateKeyValue);
assertNull(mono.block());
}
@Test
public void deleteStateNullEtag() {
StateKeyValue<String> stateKeyValue = new StateKeyValue("value", "key", null, null);
State<String> stateKeyValue = new State("value", "key", null, null);
mockInterceptor.addRule()
.delete("http://localhost:3000/v1.0/state/key")
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(3000, okHttpClient);
daprClientHttpAdapter = new DaprClientHttpAdapter(daprHttp);
Mono<Void> mono = daprClientHttpAdapter.deleteState(stateKeyValue, null);
Mono<Void> mono = daprClientHttpAdapter.deleteState(stateKeyValue);
assertNull(mono.block());
}
@Test
public void deleteStateEmptyEtag() {
StateKeyValue<String> stateKeyValue = new StateKeyValue("value", "key", "", null);
State<String> stateKeyValue = new State("value", "key", "", null);
mockInterceptor.addRule()
.delete("http://localhost:3000/v1.0/state/key")
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(3000, okHttpClient);
daprClientHttpAdapter = new DaprClientHttpAdapter(daprHttp);
Mono<Void> mono = daprClientHttpAdapter.deleteState(stateKeyValue, null);
Mono<Void> mono = daprClientHttpAdapter.deleteState(stateKeyValue);
assertNull(mono.block());
}
@Test
public void deleteStateIllegalArgumentException() {
StateKeyValue<String> stateKeyValueNull = new StateKeyValue("value", null, "etag", null);
StateKeyValue<String> stateKeyValueEmpty = new StateKeyValue("value", "", "etag", null);
State<String> stateKeyValueNull = new State("value", null, "etag", null);
State<String> stateKeyValueEmpty = new State("value", "", "etag", null);
mockInterceptor.addRule()
.delete("http://localhost:3000/v1.0/state/key")
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(3000, okHttpClient);
daprClientHttpAdapter = new DaprClientHttpAdapter(daprHttp);
assertThrows(IllegalArgumentException.class, () -> {
daprClientHttpAdapter.deleteState(null, null).block();
daprClientHttpAdapter.deleteState(null).block();
});
assertThrows(IllegalArgumentException.class, () -> {
daprClientHttpAdapter.deleteState(stateKeyValueNull, null).block();
daprClientHttpAdapter.deleteState(stateKeyValueNull).block();
});
assertThrows(IllegalArgumentException.class, () -> {
daprClientHttpAdapter.deleteState(stateKeyValueEmpty, null).block();
daprClientHttpAdapter.deleteState(stateKeyValueEmpty).block();
});
}

View File

@ -7,7 +7,7 @@ package io.dapr.it.state;
import io.dapr.client.DaprClient;
import io.dapr.client.DaprClientBuilder;
import io.dapr.client.domain.StateKeyValue;
import io.dapr.client.domain.State;
import io.dapr.client.domain.StateOptions;
import io.dapr.it.BaseIT;
import io.dapr.it.services.EmptyService;
@ -53,10 +53,10 @@ public class HttpStateClientIT extends BaseIT {
saveResponse.block();
//create of the deferred call to DAPR to get the state
Mono<StateKeyValue<MyData>> response = daprClient.getState(new StateKeyValue(null, stateKey, null, null), null, MyData.class);
Mono<State<MyData>> response = daprClient.getState(new State(stateKey, null, null), MyData.class);
//retrieve the state
StateKeyValue<MyData> myDataResponse = response.block();
State<MyData> myDataResponse = response.block();
//Assert that the response is the correct one
Assert.assertNotNull(myDataResponse.getEtag());
@ -93,9 +93,9 @@ public class HttpStateClientIT extends BaseIT {
saveResponse.block();
//Create deferred action to retrieve the action
Mono<StateKeyValue<MyData>> response = daprClient.getState(new StateKeyValue<MyData>(null, stateKey, null, null), null, MyData.class);
Mono<State<MyData>> response = daprClient.getState(new State<MyData>(stateKey, null, null), MyData.class);
//execute the retrieve of the state
StateKeyValue<MyData> myDataResponse = response.block();
State<MyData> myDataResponse = response.block();
//review that the update was success action
Assert.assertEquals("data in property A", myDataResponse.getValue().getPropertyA());
@ -120,21 +120,21 @@ public class HttpStateClientIT extends BaseIT {
saveResponse.block();
//Create deferred action to retrieve the state
Mono<StateKeyValue<MyData>> response = daprClient.getState(new StateKeyValue<MyData>(null, stateKey, null, null), null, MyData.class);
Mono<State<MyData>> response = daprClient.getState(new State<MyData>(stateKey, null, null), MyData.class);
//execute the retrieve of the state
StateKeyValue<MyData> myDataResponse = response.block();
State<MyData> myDataResponse = response.block();
//review that the state was saved correctly
Assert.assertEquals("data in property A", myDataResponse.getValue().getPropertyA());
Assert.assertEquals("data in property B", myDataResponse.getValue().getPropertyB());
//create deferred action to delete the state
Mono<Void> deleteResponse = daprClient.deleteState(new StateKeyValue<MyData>(null, stateKey, null, null), null);
Mono<Void> deleteResponse = daprClient.deleteState(new State<MyData>(stateKey, null, null));
//execute the delete action
deleteResponse.block();
//Create deferred action to retrieve the state
response = daprClient.getState(new StateKeyValue<MyData>(null, stateKey, null, null), null, MyData.class);
response = daprClient.getState(new State<MyData>(stateKey, null, null), MyData.class);
//execute the retrieve of the state
myDataResponse = response.block();
@ -160,9 +160,9 @@ public class HttpStateClientIT extends BaseIT {
saveResponse.block();
//Create deferred action to retrieve the state
Mono<StateKeyValue<MyData>> response = daprClient.getState(new StateKeyValue<MyData>(null, stateKey, null, null), null, MyData.class);
Mono<State<MyData>> response = daprClient.getState(new State<MyData>(stateKey, null, null), MyData.class);
//execute the action for retrieve the state and the etag
StateKeyValue<MyData> myDataResponse = response.block();
State<MyData> myDataResponse = response.block();
//review that the etag is not empty
Assert.assertNotNull(myDataResponse.getEtag());
@ -181,7 +181,7 @@ public class HttpStateClientIT extends BaseIT {
saveResponse.block();
response = daprClient.getState(new StateKeyValue<MyData>(null, stateKey, null, null), null, MyData.class);
response = daprClient.getState(new State<MyData>(stateKey, null, null), MyData.class);
//retrive the data wihout any etag
myDataResponse = response.block();
@ -213,9 +213,9 @@ public class HttpStateClientIT extends BaseIT {
saveResponse.block();
//Create deferred action to retrieve the state
Mono<StateKeyValue<MyData>> response = daprClient.getState(new StateKeyValue<MyData>(null, stateKey, null, null), null, MyData.class);
Mono<State<MyData>> response = daprClient.getState(new State<MyData>(stateKey, null, null), MyData.class);
//execute the action for retrieve the state and the etag
StateKeyValue<MyData> myDataResponse = response.block();
State<MyData> myDataResponse = response.block();
//review that the etag is not empty
Assert.assertNotNull(myDataResponse.getEtag());
@ -234,7 +234,7 @@ public class HttpStateClientIT extends BaseIT {
saveResponse.block();
response = daprClient.getState(new StateKeyValue<MyData>(null, stateKey, null, null), null, MyData.class);
response = daprClient.getState(new State<MyData>(stateKey, null, null), MyData.class);
//retrive the data wihout any etag
myDataResponse = response.block();
@ -263,9 +263,9 @@ public class HttpStateClientIT extends BaseIT {
saveResponse.block();
//Create deferred action to get the state with the etag
Mono<StateKeyValue<MyData>> response = daprClient.getState(new StateKeyValue<MyData>(null, stateKey, null, null), null, MyData.class);
Mono<State<MyData>> response = daprClient.getState(new State<MyData>(stateKey, null, null), MyData.class);
//execute the get state
StateKeyValue<MyData> myDataResponse = response.block();
State<MyData> myDataResponse = response.block();
Assert.assertNotNull(myDataResponse.getEtag());
Assert.assertNotNull(myDataResponse.getKey());
@ -274,12 +274,12 @@ public class HttpStateClientIT extends BaseIT {
Assert.assertEquals("data in property B", myDataResponse.getValue().getPropertyB());
//Create deferred action to delete an state sending the etag
Mono<Void> deleteResponse = daprClient.deleteState(new StateKeyValue<MyData>(null, stateKey, myDataResponse.getEtag(), null), null);
Mono<Void> deleteResponse = daprClient.deleteState(new State<MyData>(stateKey, myDataResponse.getEtag(), null));
//execute the delete of the state
deleteResponse.block();
//Create deferred action to get the sate without an etag
response = daprClient.getState(new StateKeyValue(null, stateKey, null, null), null, MyData.class);
response = daprClient.getState(new State(stateKey, null, null), MyData.class);
myDataResponse = response.block();
//Review that the response is null, because the state was deleted
@ -303,9 +303,9 @@ public class HttpStateClientIT extends BaseIT {
saveResponse.block();
//Create deferred action to get the state with the etag
Mono<StateKeyValue<MyData>> response = daprClient.getState(new StateKeyValue<MyData>(null, stateKey, null, null), null, MyData.class);
Mono<State<MyData>> response = daprClient.getState(new State<MyData>(stateKey, null, null), MyData.class);
//execute the get state
StateKeyValue<MyData> myDataResponse = response.block();
State<MyData> myDataResponse = response.block();
Assert.assertNotNull(myDataResponse.getEtag());
Assert.assertNotNull(myDataResponse.getKey());
@ -314,12 +314,12 @@ public class HttpStateClientIT extends BaseIT {
Assert.assertEquals("data in property B", myDataResponse.getValue().getPropertyB());
//Create deferred action to delete an state sending the incorrect etag
Mono<Void> deleteResponse = daprClient.deleteState(new StateKeyValue<MyData>(null, stateKey, "99999999999", null), null);
Mono<Void> deleteResponse = daprClient.deleteState(new State<MyData>(stateKey, "99999999999", null));
//execute the delete of the state, this should trhow an exception
deleteResponse.block();
//Create deferred action to get the sate without an etag
response = daprClient.getState(new StateKeyValue(null, stateKey, null, null), null, MyData.class);
response = daprClient.getState(new State(stateKey, null, null), MyData.class);
myDataResponse = response.block();
//Review that the response is null, because the state was deleted
@ -347,9 +347,9 @@ public class HttpStateClientIT extends BaseIT {
//crate deferred action to retrieve the state
Mono<StateKeyValue<MyData>> response = daprClient.getState(new StateKeyValue(null, stateKey, null, stateOptions), stateOptions, MyData.class);
Mono<State<MyData>> response = daprClient.getState(new State(stateKey, null, stateOptions), MyData.class);
//execute the retrieve of the state using options
StateKeyValue<MyData> myDataResponse = response.block();
State<MyData> myDataResponse = response.block();
Assert.assertNotNull(myDataResponse.getEtag());
Assert.assertNotNull(myDataResponse.getKey());
@ -373,8 +373,8 @@ public class HttpStateClientIT extends BaseIT {
//throws an exception, the state was already udpated
saveResponse.block();
response = daprClient.getState(new StateKeyValue(null, stateKey, null, null), stateOptions, MyData.class);
StateKeyValue<MyData> myLastDataResponse = response.block();
response = daprClient.getState(new State(stateKey, null, stateOptions), MyData.class);
State<MyData> myLastDataResponse = response.block();
Assert.assertNotNull(myLastDataResponse.getEtag());
Assert.assertNotNull(myLastDataResponse.getKey());
@ -405,9 +405,9 @@ public class HttpStateClientIT extends BaseIT {
//crate deferred action to retrieve the state
Mono<StateKeyValue<MyData>> response = daprClient.getState(new StateKeyValue(null, stateKey, null, stateOptions), stateOptions, MyData.class);
Mono<State<MyData>> response = daprClient.getState(new State(stateKey, null, stateOptions), MyData.class);
//execute the retrieve of the state using options
StateKeyValue<MyData> myDataResponse = response.block();
State<MyData> myDataResponse = response.block();
Assert.assertNotNull(myDataResponse.getEtag());
Assert.assertNotNull(myDataResponse.getKey());
@ -431,8 +431,8 @@ public class HttpStateClientIT extends BaseIT {
//update the state without an error
saveResponse.block();
response = daprClient.getState(new StateKeyValue(null, stateKey, null, null), stateOptions, MyData.class);
StateKeyValue<MyData> myLastDataResponse = response.block();
response = daprClient.getState(new State(stateKey, null, stateOptions), MyData.class);
State<MyData> myLastDataResponse = response.block();
Assert.assertNotNull(myLastDataResponse.getEtag());
Assert.assertNotNull(myLastDataResponse.getKey());