Make serializers optional + javadocs about default serializers. (#168)

This commit is contained in:
Artur Souza 2020-01-29 11:18:29 -08:00 committed by GitHub
parent 0bdf939f91
commit 45fe471c48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 128 additions and 58 deletions

View File

@ -35,7 +35,7 @@ public class DemoActorClient {
private static final ExecutorService POOL = Executors.newFixedThreadPool(NUM_ACTORS); private static final ExecutorService POOL = Executors.newFixedThreadPool(NUM_ACTORS);
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
ActorProxyBuilder builder = new ActorProxyBuilder("DemoActor", new DefaultObjectSerializer()); ActorProxyBuilder builder = new ActorProxyBuilder("DemoActor");
List<CompletableFuture<Void>> futures = new ArrayList<>(NUM_ACTORS); List<CompletableFuture<Void>> futures = new ArrayList<>(NUM_ACTORS);

View File

@ -25,7 +25,7 @@ public class OutputBindingExample {
} }
public static void main(String[] args) { public static void main(String[] args) {
DaprClient client = new DaprClientBuilder(new DefaultObjectSerializer(), new DefaultObjectSerializer()).build(); DaprClient client = new DaprClientBuilder().build();
final String BINDING_NAME = "bindingSample"; final String BINDING_NAME = "bindingSample";

View File

@ -101,7 +101,7 @@ In the `OutputBindingExample.java` file, you will find the `OutputBindingExample
public class OutputBindingExample { public class OutputBindingExample {
///... ///...
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
DaprClient client = new DaprClientBuilder(new DefaultObjectSerializer(), new DefaultObjectSerializer()).build(); DaprClient client = new DaprClientBuilder().build();
final String BINDING_NAME = "bindingSample"; final String BINDING_NAME = "bindingSample";
///... ///...
MyClass myClass = new MyClass(); MyClass myClass = new MyClass();

View File

@ -28,7 +28,7 @@ public class InvokeClient {
* @param args Messages to be sent as request for the invoke API. * @param args Messages to be sent as request for the invoke API.
*/ */
public static void main(String[] args) { public static void main(String[] args) {
DaprClient client = (new DaprClientBuilder(new DefaultObjectSerializer(), new DefaultObjectSerializer())).build(); DaprClient client = (new DaprClientBuilder()).build();
for (String message : args) { for (String message : args) {
client.invokeService(Verb.POST, SERVICE_APP_ID, "say", message, null, String.class).block(); client.invokeService(Verb.POST, SERVICE_APP_ID, "say", message, null, String.class).block();
} }

View File

@ -106,7 +106,7 @@ public class InvokeClient {
private static final String SERVICE_APP_ID = "invokedemo"; private static final String SERVICE_APP_ID = "invokedemo";
///... ///...
public static void main(String[] args) { public static void main(String[] args) {
DaprClient client = (new DaprClientBuilder(new DefaultObjectSerializer(), new DefaultObjectSerializer())).build(); DaprClient client = (new DaprClientBuilder()).build();
for (String message : args) { for (String message : args) {
client.invokeService(Verb.POST, SERVICE_APP_ID, "say", message, null, String.class).block(); client.invokeService(Verb.POST, SERVICE_APP_ID, "say", message, null, String.class).block();
} }

View File

@ -27,7 +27,7 @@ public class Publisher {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
//Creating the DaprClient: Using the default builder client produces an HTTP Dapr Client //Creating the DaprClient: Using the default builder client produces an HTTP Dapr Client
DaprClient client = new DaprClientBuilder(new DefaultObjectSerializer(), new DefaultObjectSerializer()).build(); DaprClient client = new DaprClientBuilder().build();
for (int i = 0; i < NUM_MESSAGES; i++) { for (int i = 0; i < NUM_MESSAGES; i++) {
String message = String.format("This is message #%d", i); String message = String.format("This is message #%d", i);
//Publishing messages //Publishing messages

View File

@ -88,7 +88,7 @@ public class Publisher {
private static final String TOPIC_NAME = "testingtopic"; private static final String TOPIC_NAME = "testingtopic";
///... ///...
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
DaprClient client = new DaprClientBuilder(new DefaultObjectSerializer(), new DefaultObjectSerializer()).build(); DaprClient client = new DaprClientBuilder().build();
for (int i = 0; i < NUM_MESSAGES; i++) { for (int i = 0; i < NUM_MESSAGES; i++) {
String message = String.format("This is message #%d", i); String message = String.format("This is message #%d", i);
client.publishEvent(TOPIC_NAME, message).block(); client.publishEvent(TOPIC_NAME, message).block();

View File

@ -39,7 +39,7 @@ public class OrderManager {
HttpServer httpServer = HttpServer.create(new InetSocketAddress(httpPort), 0); HttpServer httpServer = HttpServer.create(new InetSocketAddress(httpPort), 0);
DaprClient daprClient = DaprClient daprClient =
(new DaprClientBuilder(new DefaultObjectSerializer(), new DefaultObjectSerializer())).build(); (new DaprClientBuilder()).build();
httpServer.createContext("/order").setHandler(e -> { httpServer.createContext("/order").setHandler(e -> {
out.println("Fetching order!"); out.println("Fetching order!");

View File

@ -30,7 +30,7 @@ This example implements a service listening on port 3000, while using Dapr's sta
``` ```
DaprClient daprClient = DaprClient daprClient =
(new DaprClientBuilder(new DefaultObjectSerializer(), new DefaultObjectSerializer())).build(); (new DaprClientBuilder()).build();
httpServer.createContext("/order").setHandler(e -> { httpServer.createContext("/order").setHandler(e -> {
out.println("Fetching order!"); out.println("Fetching order!");

View File

@ -3,6 +3,7 @@ package io.dapr.actors.client;
import io.dapr.actors.ActorId; import io.dapr.actors.ActorId;
import io.dapr.client.DaprHttpBuilder; import io.dapr.client.DaprHttpBuilder;
import io.dapr.serializer.DaprObjectSerializer; import io.dapr.serializer.DaprObjectSerializer;
import io.dapr.serializer.DefaultObjectSerializer;
/** /**
* Builder to generate an ActorProxy instance. Builder can be reused for multiple instances. * Builder to generate an ActorProxy instance. Builder can be reused for multiple instances.
@ -22,24 +23,37 @@ public class ActorProxyBuilder {
/** /**
* Dapr's object serializer. * Dapr's object serializer.
*/ */
private final DaprObjectSerializer objectSerializer; private DaprObjectSerializer objectSerializer;
/** /**
* Instantiates a new builder for a given Actor type. * Instantiates a new builder for a given Actor type, using {@link DefaultObjectSerializer} by default.
*
* {@link DefaultObjectSerializer} is not recommended for production scenarios.
* *
* @param actorType Actor's type. * @param actorType Actor's type.
* @param objectSerializer Serializer for objects sent/received.
*/ */
public ActorProxyBuilder(String actorType, DaprObjectSerializer objectSerializer) { public ActorProxyBuilder(String actorType) {
if ((actorType == null) || actorType.isEmpty()) { if ((actorType == null) || actorType.isEmpty()) {
throw new IllegalArgumentException("ActorType is required."); throw new IllegalArgumentException("ActorType is required.");
} }
this.actorType = actorType;
this.objectSerializer = new DefaultObjectSerializer();
}
/**
* Instantiates a new builder for a given Actor type, using {@link DefaultObjectSerializer}.
*
* @param objectSerializer Serializer for objects sent/received.
* @return This instance.
*/
public ActorProxyBuilder withObjectSerializer(DaprObjectSerializer objectSerializer) {
if (objectSerializer == null) { if (objectSerializer == null) {
throw new IllegalArgumentException("Serializer is required."); throw new IllegalArgumentException("Serializer is required.");
} }
this.actorType = actorType;
this.objectSerializer = objectSerializer; this.objectSerializer = objectSerializer;
return this;
} }
/** /**

View File

@ -9,6 +9,7 @@ import io.dapr.actors.ActorId;
import io.dapr.actors.ActorTrace; import io.dapr.actors.ActorTrace;
import io.dapr.client.DaprHttpBuilder; import io.dapr.client.DaprHttpBuilder;
import io.dapr.serializer.DaprObjectSerializer; import io.dapr.serializer.DaprObjectSerializer;
import io.dapr.serializer.DefaultObjectSerializer;
import java.io.IOException; import java.io.IOException;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
@ -108,6 +109,31 @@ public class ActorRuntime {
return this.INTERNAL_SERIALIZER.serialize(this.config); return this.INTERNAL_SERIALIZER.serialize(this.config);
} }
/**
* Registers an actor with the runtime, using {@link DefaultObjectSerializer} and {@link DefaultActorFactory}.
*
* {@link DefaultObjectSerializer} is not recommended for production scenarios.
*
* @param clazz The type of actor.
* @param <T> Actor class type.
*/
public <T extends AbstractActor> void registerActor(Class<T> clazz) {
registerActor(clazz, new DefaultObjectSerializer(), new DefaultObjectSerializer());
}
/**
* Registers an actor with the runtime, using {@link DefaultObjectSerializer}.
*
* {@link DefaultObjectSerializer} is not recommended for production scenarios.
*
* @param clazz The type of actor.
* @param actorFactory An optional factory to create actors. This can be used for dependency injection.
* @param <T> Actor class type.
*/
public <T extends AbstractActor> void registerActor(Class<T> clazz, ActorFactory<T> actorFactory) {
registerActor(clazz, actorFactory, new DefaultObjectSerializer(), new DefaultObjectSerializer());
}
/** /**
* Registers an actor with the runtime. * Registers an actor with the runtime.
* *
@ -118,7 +144,7 @@ public class ActorRuntime {
*/ */
public <T extends AbstractActor> void registerActor( public <T extends AbstractActor> void registerActor(
Class<T> clazz, DaprObjectSerializer objectSerializer, DaprObjectSerializer stateSerializer) { Class<T> clazz, DaprObjectSerializer objectSerializer, DaprObjectSerializer stateSerializer) {
registerActor(clazz, null, objectSerializer, stateSerializer); registerActor(clazz, new DefaultActorFactory<T>(), objectSerializer, stateSerializer);
} }
/** /**
@ -137,21 +163,22 @@ public class ActorRuntime {
if (clazz == null) { if (clazz == null) {
throw new IllegalArgumentException("Class is required."); throw new IllegalArgumentException("Class is required.");
} }
if (actorFactory == null) {
throw new IllegalArgumentException("Actor factory is required.");
}
if (objectSerializer == null) { if (objectSerializer == null) {
throw new IllegalArgumentException("Serializer is required."); throw new IllegalArgumentException("Object serializer is required.");
} }
if (stateSerializer == null) { if (stateSerializer == null) {
throw new IllegalArgumentException("State objectSerializer is required."); throw new IllegalArgumentException("State serializer is required.");
} }
ActorTypeInformation<T> actorTypeInfo = ActorTypeInformation.create(clazz); ActorTypeInformation<T> actorTypeInfo = ActorTypeInformation.create(clazz);
ActorFactory<T> actualActorFactory = actorFactory != null ? actorFactory : new DefaultActorFactory<T>();
ActorRuntimeContext<T> context = new ActorRuntimeContext<>( ActorRuntimeContext<T> context = new ActorRuntimeContext<>(
this, this,
objectSerializer, objectSerializer,
actualActorFactory, actorFactory,
actorTypeInfo, actorTypeInfo,
this.daprClient, this.daprClient,
new DaprStateAsyncProvider(this.daprClient, stateSerializer)); new DaprStateAsyncProvider(this.daprClient, stateSerializer));

View File

@ -9,35 +9,36 @@ public class ActorProxyBuilderTest {
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void buildWithNullActorId() { public void buildWithNullActorId() {
new ActorProxyBuilder("test", new DefaultObjectSerializer()) new ActorProxyBuilder("test")
.build(null); .build(null);
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void buildWithEmptyActorType() { public void buildWithEmptyActorType() {
new ActorProxyBuilder("", new DefaultObjectSerializer()) new ActorProxyBuilder("")
.build(new ActorId("100")); .build(new ActorId("100"));
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void buildWithNullActorType() { public void buildWithNullActorType() {
new ActorProxyBuilder(null, new DefaultObjectSerializer()) new ActorProxyBuilder(null)
.build(new ActorId("100")); .build(new ActorId("100"));
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void buildWithNullSerializer() { public void buildWithNullSerializer() {
new ActorProxyBuilder("MyActor", null) new ActorProxyBuilder("MyActor")
.withObjectSerializer(null)
.build(new ActorId("100")); .build(new ActorId("100"));
} }
@Test() @Test()
public void build() { public void build() {
ActorProxyBuilder builder = new ActorProxyBuilder("test", new DefaultObjectSerializer()); ActorProxyBuilder builder = new ActorProxyBuilder("test");
ActorProxy actorProxy = builder.build(new ActorId("100")); ActorProxy actorProxy = builder.build(new ActorId("100"));
Assert.assertNotNull(actorProxy); Assert.assertNotNull(actorProxy);

View File

@ -67,21 +67,21 @@ public class ActorRuntimeTest {
@Test @Test
public void registerActor() throws Exception { public void registerActor() throws Exception {
this.runtime.registerActor(MyActorImpl.class, new DefaultObjectSerializer(), new DefaultObjectSerializer()); this.runtime.registerActor(MyActorImpl.class);
Assert.assertTrue(new String(this.runtime.serializeConfig()).contains(ACTOR_NAME)); Assert.assertTrue(new String(this.runtime.serializeConfig()).contains(ACTOR_NAME));
} }
@Test @Test
public void activateActor() throws Exception { public void activateActor() throws Exception {
String actorId = UUID.randomUUID().toString(); String actorId = UUID.randomUUID().toString();
this.runtime.registerActor(MyActorImpl.class, new DefaultObjectSerializer(), new DefaultObjectSerializer()); this.runtime.registerActor(MyActorImpl.class);
this.runtime.activate(ACTOR_NAME, actorId).block(); this.runtime.activate(ACTOR_NAME, actorId).block();
} }
@Test @Test
public void invokeActor() throws Exception { public void invokeActor() throws Exception {
String actorId = UUID.randomUUID().toString(); String actorId = UUID.randomUUID().toString();
this.runtime.registerActor(MyActorImpl.class, new DefaultObjectSerializer(), new DefaultObjectSerializer()); this.runtime.registerActor(MyActorImpl.class);
this.runtime.activate(ACTOR_NAME, actorId).block(); this.runtime.activate(ACTOR_NAME, actorId).block();
byte[] response = this.runtime.invoke(ACTOR_NAME, actorId, "say", null).block(); byte[] response = this.runtime.invoke(ACTOR_NAME, actorId, "say", null).block();
@ -92,7 +92,7 @@ public class ActorRuntimeTest {
@Test @Test
public void activateThendeactivateActor() throws Exception { public void activateThendeactivateActor() throws Exception {
String actorId = UUID.randomUUID().toString(); String actorId = UUID.randomUUID().toString();
this.runtime.registerActor(MyActorImpl.class, new DefaultObjectSerializer(), new DefaultObjectSerializer()); this.runtime.registerActor(MyActorImpl.class);
this.runtime.activate(ACTOR_NAME, actorId).block(); this.runtime.activate(ACTOR_NAME, actorId).block();
this.runtime.deactivate(ACTOR_NAME, actorId).block(); this.runtime.deactivate(ACTOR_NAME, actorId).block();
} }
@ -100,14 +100,14 @@ public class ActorRuntimeTest {
@Test @Test
public void deactivateActor() throws Exception { public void deactivateActor() throws Exception {
String actorId = UUID.randomUUID().toString(); String actorId = UUID.randomUUID().toString();
this.runtime.registerActor(MyActorImpl.class, new DefaultObjectSerializer(), new DefaultObjectSerializer()); this.runtime.registerActor(MyActorImpl.class);
this.runtime.deactivate(ACTOR_NAME, actorId).block(); this.runtime.deactivate(ACTOR_NAME, actorId).block();
} }
@Test @Test
public void lazyActivate() throws Exception { public void lazyActivate() throws Exception {
String actorId = UUID.randomUUID().toString(); String actorId = UUID.randomUUID().toString();
this.runtime.registerActor(MyActorImpl.class, new DefaultObjectSerializer(), new DefaultObjectSerializer()); this.runtime.registerActor(MyActorImpl.class);
this.runtime.activate(ACTOR_NAME, actorId).block(); this.runtime.activate(ACTOR_NAME, actorId).block();
this.runtime.invoke(ACTOR_NAME, actorId, "say", null) this.runtime.invoke(ACTOR_NAME, actorId, "say", null)
@ -120,7 +120,7 @@ public class ActorRuntimeTest {
@Test @Test
public void lazyDeactivate() throws Exception { public void lazyDeactivate() throws Exception {
String actorId = UUID.randomUUID().toString(); String actorId = UUID.randomUUID().toString();
this.runtime.registerActor(MyActorImpl.class, new DefaultObjectSerializer(), new DefaultObjectSerializer()); this.runtime.registerActor(MyActorImpl.class);
this.runtime.activate(ACTOR_NAME, actorId).block(); this.runtime.activate(ACTOR_NAME, actorId).block();
Mono<Void> deacticateCall = this.runtime.deactivate(ACTOR_NAME, actorId); Mono<Void> deacticateCall = this.runtime.deactivate(ACTOR_NAME, actorId);
@ -139,7 +139,7 @@ public class ActorRuntimeTest {
@Test @Test
public void lazyInvoke() throws Exception { public void lazyInvoke() throws Exception {
String actorId = UUID.randomUUID().toString(); String actorId = UUID.randomUUID().toString();
this.runtime.registerActor(MyActorImpl.class, new DefaultObjectSerializer(), new DefaultObjectSerializer()); this.runtime.registerActor(MyActorImpl.class);
Mono<byte[]> invokeCall = this.runtime.invoke(ACTOR_NAME, actorId, "say", null); Mono<byte[]> invokeCall = this.runtime.invoke(ACTOR_NAME, actorId, "say", null);

View File

@ -53,9 +53,8 @@ public class ActivationDeactivationIT extends BaseIT {
final AtomicInteger atomicInteger = new AtomicInteger(1); final AtomicInteger atomicInteger = new AtomicInteger(1);
String actorType = "DemoActorTest"; String actorType = "DemoActorTest";
DefaultObjectSerializer serializer = new DefaultObjectSerializer();
logger.debug("Creating proxy builder"); logger.debug("Creating proxy builder");
ActorProxyBuilder proxyBuilder = new ActorProxyBuilder(actorType, serializer); ActorProxyBuilder proxyBuilder = new ActorProxyBuilder(actorType);
logger.debug("Creating actorId"); logger.debug("Creating actorId");
ActorId actorId1 = new ActorId(Integer.toString(atomicInteger.getAndIncrement())); ActorId actorId1 = new ActorId(Integer.toString(atomicInteger.getAndIncrement()));
logger.debug("Building proxy"); logger.debug("Building proxy");

View File

@ -49,7 +49,7 @@ public class BindingIT extends BaseIT {
// TODO: figure out why this wait is needed for this scenario to work end-to-end. Kafka not up yet? // TODO: figure out why this wait is needed for this scenario to work end-to-end. Kafka not up yet?
Thread.sleep(120000); Thread.sleep(120000);
DaprClient client = new DaprClientBuilder(new DefaultObjectSerializer(), new DefaultObjectSerializer()).build(); DaprClient client = new DaprClientBuilder().build();
final String BINDING_NAME = "sample123"; final String BINDING_NAME = "sample123";

View File

@ -42,7 +42,7 @@ public class GRPCStateClientIT extends BaseIT {
5000 5000
); );
daprRun.switchToGRPC(); daprRun.switchToGRPC();
daprClient = new DaprClientBuilder(new DefaultObjectSerializer(), new DefaultObjectSerializer()).build(); daprClient = new DaprClientBuilder().build();
assertTrue(daprClient instanceof DaprClientGrpcAdapter); assertTrue(daprClient instanceof DaprClientGrpcAdapter);
} }

View File

@ -545,7 +545,7 @@ public class HttpStateClientIT extends BaseIT {
} }
private static DaprClient buildDaprClient() { private static DaprClient buildDaprClient() {
return new DaprClientBuilder(new DefaultObjectSerializer(), new DefaultObjectSerializer()).build(); return new DaprClientBuilder().build();
} }
} }

View File

@ -19,40 +19,65 @@ import okhttp3.OkHttpClient;
*/ */
public class DaprClientBuilder { public class DaprClientBuilder {
/**
* Serializer used for request and response objects in DaprClient.
*/
private final DaprObjectSerializer objectSerializer;
/**
* Serializer used for state objects in DaprClient.
*/
private final DaprObjectSerializer stateSerializer;
/** /**
* Determine if this builder will create GRPC clients instead of HTTP clients. * Determine if this builder will create GRPC clients instead of HTTP clients.
*/ */
private final boolean useGRPC; private final boolean useGRPC;
/**
* Serializer used for request and response objects in DaprClient.
*/
private DaprObjectSerializer objectSerializer;
/**
* Serializer used for state objects in DaprClient.
*/
private DaprObjectSerializer stateSerializer;
/** /**
* Creates a constructor for DaprClient. * Creates a constructor for DaprClient.
* *
* {@link DefaultObjectSerializer} is used for object and state serializers by defaul but is not recommended
* for production scenarios.
*/
public DaprClientBuilder() {
this.objectSerializer = new DefaultObjectSerializer();
this.stateSerializer = new DefaultObjectSerializer();
this.useGRPC = Properties.USE_GRPC.get();
}
/**
* Sets the serializer for objects to be sent and received from Dapr.
*
* See {@link DefaultObjectSerializer} as possible serializer for non-production scenarios. * See {@link DefaultObjectSerializer} as possible serializer for non-production scenarios.
* *
* @param objectSerializer Serializer for objects to be sent and received from Dapr. * @param objectSerializer Serializer for objects to be sent and received from Dapr.
* @param stateSerializer Serializer for objects to be persisted. * @return This instance.
*/ */
public DaprClientBuilder(DaprObjectSerializer objectSerializer, DaprObjectSerializer stateSerializer) { public DaprClientBuilder withObjectSerializer(DaprObjectSerializer objectSerializer) {
if (objectSerializer == null) { if (objectSerializer == null) {
throw new IllegalArgumentException("Serializer is required"); throw new IllegalArgumentException("Object serializer is required");
} }
this.objectSerializer = objectSerializer;
return this;
}
/**
* Sets the serializer for objects to be persisted.
*
* See {@link DefaultObjectSerializer} as possible serializer for non-production scenarios.
*
* @param stateSerializer Serializer for objects to be persisted.
* @return This instance.
*/
public DaprClientBuilder withStateSerializer(DaprObjectSerializer stateSerializer) {
if (stateSerializer == null) { if (stateSerializer == null) {
throw new IllegalArgumentException("State serializer is required"); throw new IllegalArgumentException("State serializer is required");
} }
this.objectSerializer = objectSerializer;
this.stateSerializer = stateSerializer; this.stateSerializer = stateSerializer;
this.useGRPC = Properties.USE_GRPC.get(); return this;
} }
/** /**

View File

@ -11,17 +11,21 @@ public class DaprClientBuilderTest {
public void build() { public void build() {
DaprObjectSerializer objectSerializer = mock(DaprObjectSerializer.class); DaprObjectSerializer objectSerializer = mock(DaprObjectSerializer.class);
DaprObjectSerializer stateSerializer = mock(DaprObjectSerializer.class); DaprObjectSerializer stateSerializer = mock(DaprObjectSerializer.class);
DaprClientBuilder daprClientBuilder = new DaprClientBuilder(objectSerializer, stateSerializer); DaprClientBuilder daprClientBuilder = new DaprClientBuilder();
daprClientBuilder.withObjectSerializer(objectSerializer);
daprClientBuilder.withStateSerializer(stateSerializer);
DaprClient daprClient = daprClientBuilder.build(); DaprClient daprClient = daprClientBuilder.build();
assertNotNull(daprClient); assertNotNull(daprClient);
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
public void buildException() { public void noObjectSerializer() {
DaprClientBuilder daprClientBuilder = new DaprClientBuilder(null,null); new DaprClientBuilder().withObjectSerializer(null);
DaprClient daprClient = daprClientBuilder.build();
assertNotNull(daprClient);
} }
@Test(expected = IllegalArgumentException.class)
public void noStateSerializer() {
new DaprClientBuilder().withStateSerializer(null);
}
} }