@@ -110,13 +110,13 @@ public void happyCaseApply() {
110
110
if (operation .getOperationType () == null ) {
111
111
return false ;
112
112
}
113
- if (operation .getKey () == null ) {
113
+ if (operation .getState (). getName () == null ) {
114
114
return false ;
115
115
}
116
116
117
117
String opName = operation .getOperationType ();
118
- String key = operation .getKey ();
119
- Object value = operation .getValue ();
118
+ String key = operation .getState (). getName ();
119
+ Object value = operation .getState (). getValue ();
120
120
121
121
foundInsertName |= "upsert" .equals (opName ) &&
122
122
"name" .equals (key ) &&
@@ -153,58 +153,59 @@ public void happyCaseLoad() throws Exception {
153
153
DaprClient daprClient = mock (DaprClient .class );
154
154
when (daprClient
155
155
.getState (any (), any (), eq ("name" )))
156
- .thenReturn (Mono .just (SERIALIZER .serialize ("Jon Doe" )));
156
+ .thenReturn (Mono .just (new ActorState <>( "name" , SERIALIZER .serialize ("Jon Doe" ) )));
157
157
when (daprClient
158
158
.getState (any (), any (), eq ("zipcode" )))
159
- .thenReturn (Mono .just (SERIALIZER .serialize (98021 )));
159
+ .thenReturn (Mono .just (new ActorState <>( "zipcode" , SERIALIZER .serialize (98021 ) )));
160
160
when (daprClient
161
161
.getState (any (), any (), eq ("goals" )))
162
- .thenReturn (Mono .just (SERIALIZER .serialize (98 )));
162
+ .thenReturn (Mono .just (new ActorState <>( "goals" , SERIALIZER .serialize (98 ) )));
163
163
when (daprClient
164
164
.getState (any (), any (), eq ("balance" )))
165
- .thenReturn (Mono .just (SERIALIZER .serialize (46.55 )));
165
+ .thenReturn (Mono .just (new ActorState <>( "balance" , SERIALIZER .serialize (46.55 ) )));
166
166
when (daprClient
167
167
.getState (any (), any (), eq ("active" )))
168
- .thenReturn (Mono .just (SERIALIZER .serialize (true )));
168
+ .thenReturn (Mono .just (new ActorState <>( "active" , SERIALIZER .serialize (true ) )));
169
169
when (daprClient
170
170
.getState (any (), any (), eq ("customer" )))
171
- .thenReturn (Mono .just (" { \" id\" : 1000, \" name\" : \" Roxane\" }" .getBytes ()));
171
+ .thenReturn (Mono .just (new ActorState <>( "customer" , " { \" id\" : 1000, \" name\" : \" Roxane\" }" .getBytes () )));
172
172
when (daprClient
173
173
.getState (any (), any (), eq ("anotherCustomer" )))
174
- .thenReturn (Mono .just (" { \" id\" : 2000, \" name\" : \" Max\" }" .getBytes ()));
174
+ .thenReturn (Mono .just (new ActorState <>( "anotherCustomer" , " { \" id\" : 2000, \" name\" : \" Max\" }" .getBytes () )));
175
175
when (daprClient
176
176
.getState (any (), any (), eq ("nullCustomer" )))
177
177
.thenReturn (Mono .empty ());
178
178
when (daprClient
179
179
.getState (any (), any (), eq ("bytes" )))
180
- .thenReturn (Mono .just (" \" QQ==\" " .getBytes ()));
180
+ .thenReturn (Mono .just (new ActorState <>( "bytes" , " \" QQ==\" " .getBytes () )));
181
181
when (daprClient
182
182
.getState (any (), any (), eq ("emptyBytes" )))
183
- .thenReturn (Mono .just (new byte [0 ]));
183
+ .thenReturn (Mono .just (new ActorState <>( "emptyBytes" , new byte [0 ]) ));
184
184
185
185
DaprStateAsyncProvider provider = new DaprStateAsyncProvider (daprClient , SERIALIZER );
186
186
187
187
Assertions .assertEquals ("Jon Doe" ,
188
- provider .load ("MyActor" , new ActorId ("123" ), "name" , TypeRef .STRING ).block ());
188
+ provider .load ("MyActor" , new ActorId ("123" ), "name" , TypeRef .STRING ).block (). getValue () );
189
189
Assertions .assertEquals (98021 ,
190
- (int ) provider .load ("MyActor" , new ActorId ("123" ), "zipcode" , TypeRef .INT ).block ());
190
+ (int ) provider .load ("MyActor" , new ActorId ("123" ), "zipcode" , TypeRef .INT ).block (). getValue () );
191
191
Assertions .assertEquals (98 ,
192
- (int ) provider .load ("MyActor" , new ActorId ("123" ), "goals" , TypeRef .INT ).block ());
192
+ (int ) provider .load ("MyActor" , new ActorId ("123" ), "goals" , TypeRef .INT ).block (). getValue () );
193
193
Assertions .assertEquals (98 ,
194
- (int ) provider .load ("MyActor" , new ActorId ("123" ), "goals" , TypeRef .INT ).block ());
194
+ (int ) provider .load ("MyActor" , new ActorId ("123" ), "goals" , TypeRef .INT ).block (). getValue () );
195
195
Assertions .assertEquals (46.55 ,
196
- (double ) provider .load ("MyActor" , new ActorId ("123" ), "balance" , TypeRef .DOUBLE ).block (),
196
+ (double ) provider .load ("MyActor" , new ActorId ("123" ), "balance" , TypeRef .DOUBLE ).block (). getValue () ,
197
197
EPSILON );
198
198
Assertions .assertEquals (true ,
199
- (boolean ) provider .load ("MyActor" , new ActorId ("123" ), "active" , TypeRef .BOOLEAN ).block ());
199
+ (boolean ) provider .load ("MyActor" , new ActorId ("123" ), "active" , TypeRef .BOOLEAN ).block (). getValue () );
200
200
Assertions .assertEquals (new Customer ().setId (1000 ).setName ("Roxane" ),
201
- provider .load ("MyActor" , new ActorId ("123" ), "customer" , TypeRef .get (Customer .class )).block ());
201
+ provider .load ("MyActor" , new ActorId ("123" ), "customer" , TypeRef .get (Customer .class )).block (). getValue () );
202
202
Assertions .assertNotEquals (new Customer ().setId (1000 ).setName ("Roxane" ),
203
- provider .load ("MyActor" , new ActorId ("123" ), "anotherCustomer" , TypeRef .get (Customer .class )).block ());
203
+ provider .load (
204
+ "MyActor" , new ActorId ("123" ), "anotherCustomer" , TypeRef .get (Customer .class )).block ().getValue ());
204
205
Assertions .assertNull (
205
206
provider .load ("MyActor" , new ActorId ("123" ), "nullCustomer" , TypeRef .get (Customer .class )).block ());
206
207
Assertions .assertArrayEquals ("A" .getBytes (),
207
- provider .load ("MyActor" , new ActorId ("123" ), "bytes" , TypeRef .get (byte [].class )).block ());
208
+ provider .load ("MyActor" , new ActorId ("123" ), "bytes" , TypeRef .get (byte [].class )).block (). getValue () );
208
209
Assertions .assertNull (
209
210
provider .load ("MyActor" , new ActorId ("123" ), "emptyBytes" , TypeRef .get (byte [].class )).block ());
210
211
}
@@ -216,22 +217,28 @@ public void happyCaseContains() {
216
217
// Keys that exists.
217
218
when (daprClient
218
219
.getState (any (), any (), eq ("name" )))
219
- .thenReturn (Mono .just ("Jon Doe" .getBytes ()));
220
+ .thenReturn (Mono .just (
221
+ new ActorState <>("name" , "Jon Doe" .getBytes ())));
220
222
when (daprClient
221
223
.getState (any (), any (), eq ("zipcode" )))
222
- .thenReturn (Mono .just ("98021" .getBytes ()));
224
+ .thenReturn (Mono .just (
225
+ new ActorState <>("zipcode" , "98021" .getBytes ())));
223
226
when (daprClient
224
227
.getState (any (), any (), eq ("goals" )))
225
- .thenReturn (Mono .just ("98" .getBytes ()));
228
+ .thenReturn (Mono .just (
229
+ new ActorState <>("goals" , "98" .getBytes ())));
226
230
when (daprClient
227
231
.getState (any (), any (), eq ("balance" )))
228
- .thenReturn (Mono .just ("46.55" .getBytes ()));
232
+ .thenReturn (Mono .just (
233
+ new ActorState <>("balance" , "46.55" .getBytes ())));
229
234
when (daprClient
230
235
.getState (any (), any (), eq ("active" )))
231
- .thenReturn (Mono .just ("true" .getBytes ()));
236
+ .thenReturn (Mono .just (
237
+ new ActorState <>("active" , "true" .getBytes ())));
232
238
when (daprClient
233
239
.getState (any (), any (), eq ("customer" )))
234
- .thenReturn (Mono .just ("{ \" id\" : \" 3000\" , \" name\" : \" Ely\" }" .getBytes ()));
240
+ .thenReturn (Mono .just (
241
+ new ActorState <>("customer" , "{ \" id\" : \" 3000\" , \" name\" : \" Ely\" }" .getBytes ())));
235
242
236
243
// Keys that do not exist.
237
244
when (daprClient
@@ -257,15 +264,15 @@ public void happyCaseContains() {
257
264
Assertions .assertFalse (provider .contains ("MyActor" , new ActorId ("123" ), null ).block ());
258
265
}
259
266
260
- private final <T > ActorStateChange createInsertChange (String name , T value ) {
261
- return new ActorStateChange (name , value , ActorStateChangeKind .ADD );
267
+ private <T > ActorStateChange createInsertChange (String name , T value ) {
268
+ return new ActorStateChange (new ActorState ( name , value ) , ActorStateChangeKind .ADD );
262
269
}
263
270
264
- private final <T > ActorStateChange createUpdateChange (String name , T value ) {
265
- return new ActorStateChange (name , value , ActorStateChangeKind .UPDATE );
271
+ private <T > ActorStateChange createUpdateChange (String name , T value ) {
272
+ return new ActorStateChange (new ActorState ( name , value ) , ActorStateChangeKind .UPDATE );
266
273
}
267
274
268
- private final ActorStateChange createDeleteChange (String name ) {
269
- return new ActorStateChange (name , null , ActorStateChangeKind .REMOVE );
275
+ private ActorStateChange createDeleteChange (String name ) {
276
+ return new ActorStateChange (new ActorState ( name , null ) , ActorStateChangeKind .REMOVE );
270
277
}
271
278
}
0 commit comments