### Question:
DaprStateAsyncProvider { <T> Mono<T> load(String actorType, ActorId actorId, String stateName, TypeRef<T> type) { Mono<byte[]> result = this.daprClient.getActorState(actorType, actorId.toString(), stateName); return result.flatMap(s -> { try { T response = this.stateSerializer.deserialize(s, type); if (response == null) { return Mono.empty(); } return Mono.just(response); } catch (IOException e) { return Mono.error(new RuntimeException(e)); } }); } DaprStateAsyncProvider(DaprClient daprClient, DaprObjectSerializer stateSerializer);   }### Answer:
@Test public void happyCaseLoad() throws Exception { DaprClient daprClient = mock(DaprClient.class); when(daprClient .getActorState(any(), any(), eq("name"))) .thenReturn(Mono.just(SERIALIZER.serialize("Jon Doe"))); when(daprClient .getActorState(any(), any(), eq("zipcode"))) .thenReturn(Mono.just(SERIALIZER.serialize(98021))); when(daprClient .getActorState(any(), any(), eq("goals"))) .thenReturn(Mono.just(SERIALIZER.serialize(98))); when(daprClient .getActorState(any(), any(), eq("balance"))) .thenReturn(Mono.just(SERIALIZER.serialize(46.55))); when(daprClient .getActorState(any(), any(), eq("active"))) .thenReturn(Mono.just(SERIALIZER.serialize(true))); when(daprClient .getActorState(any(), any(), eq("customer"))) .thenReturn(Mono.just("{ \"id\": 1000, \"name\": \"Roxane\"}".getBytes())); when(daprClient .getActorState(any(), any(), eq("anotherCustomer"))) .thenReturn(Mono.just("{ \"id\": 2000, \"name\": \"Max\"}".getBytes())); when(daprClient .getActorState(any(), any(), eq("nullCustomer"))) .thenReturn(Mono.empty()); DaprStateAsyncProvider provider = new DaprStateAsyncProvider(daprClient, SERIALIZER); Assert.assertEquals("Jon Doe", provider.load("MyActor", new ActorId("123"), "name", TypeRef.STRING).block()); Assert.assertEquals(98021, (int)provider.load("MyActor", new ActorId("123"), "zipcode", TypeRef.INT).block()); Assert.assertEquals(98, (int) provider.load("MyActor", new ActorId("123"), "goals", TypeRef.INT).block()); Assert.assertEquals(98, (int) provider.load("MyActor", new ActorId("123"), "goals", TypeRef.INT).block()); Assert.assertEquals(46.55, (double) provider.load("MyActor", new ActorId("123"), "balance", TypeRef.DOUBLE).block(), EPSILON); Assert.assertEquals(true, (boolean) provider.load("MyActor", new ActorId("123"), "active", TypeRef.BOOLEAN).block()); Assert.assertEquals(new Customer().setId(1000).setName("Roxane"), provider.load("MyActor", new ActorId("123"), "customer", TypeRef.get(Customer.class)).block()); Assert.assertNotEquals(new Customer().setId(1000).setName("Roxane"), provider.load("MyActor", new ActorId("123"), "anotherCustomer", TypeRef.get(Customer.class)).block()); Assert.assertNull( provider.load("MyActor", new ActorId("123"), "nullCustomer", TypeRef.get(Customer.class)).block()); }