use of com.google.protobuf.StringValue in project core-java by SpineEventEngine.
the class IdentifiersShould method return_same_string_when_convert_string_wrapped_into_message.
@Test
public void return_same_string_when_convert_string_wrapped_into_message() {
final StringValue id = forString(TEST_ID);
final String result = idToString(id);
assertEquals(TEST_ID, result);
}
use of com.google.protobuf.StringValue in project core-java by SpineEventEngine.
the class IdentifiersShould method convert_to_string_message_id_wrapped_in_Any.
@Test
public void convert_to_string_message_id_wrapped_in_Any() {
final StringValue messageToWrap = forString(TEST_ID);
final Any any = AnyPacker.pack(messageToWrap);
final String result = idToString(any);
assertEquals(TEST_ID, result);
}
use of com.google.protobuf.StringValue in project core-java by SpineEventEngine.
the class IdentifiersShould method convert_to_string_message_id_with_string_field.
@Test
public void convert_to_string_message_id_with_string_field() {
final StringValue id = forString(TEST_ID);
final String result = idToString(id);
assertEquals(TEST_ID, result);
}
use of com.google.protobuf.StringValue in project core-java by SpineEventEngine.
the class AbstractCommandRouterShould method setUp.
@Before
public void setUp() {
final BoundedContext boundedContext = BoundedContext.newBuilder().build();
final CommandBus commandBus = boundedContext.getCommandBus();
// Register dispatcher for `StringValue` message type.
// Otherwise we won't be able to post.
commandBus.register(new CommandDispatcher<String>() {
@Override
public Set<CommandClass> getMessageClasses() {
return CommandClass.setOf(StringValue.class);
}
@Override
public String dispatch(CommandEnvelope envelope) {
// Do nothing.
return "Anonymous";
}
@Override
public void onError(CommandEnvelope envelope, RuntimeException exception) {
// Do nothing.
}
});
sourceMessage = toMessage(getClass().getSimpleName());
sourceContext = requestFactory.createCommandContext();
router = createRouter(commandBus, sourceMessage, sourceContext);
router.addAll(messages);
}
use of com.google.protobuf.StringValue in project core-java by SpineEventEngine.
the class CommandRouterOnErrorShould method throw_IllegalStateException_when_caught_error_when_posting.
@Test(expected = IllegalStateException.class)
public void throw_IllegalStateException_when_caught_error_when_posting() {
final BoundedContext boundedContext = BoundedContext.newBuilder().build();
final CommandBus commandBus = boundedContext.getCommandBus();
// Register dispatcher for `StringValue` message type.
// Fails each time of dispatch().
commandBus.register(new CommandDispatcher<Message>() {
@Override
public Set<CommandClass> getMessageClasses() {
return CommandClass.setOf(StringValue.class);
}
@Override
public Message dispatch(CommandEnvelope envelope) {
throw new IllegalStateException("I am faulty!");
}
@Override
public void onError(CommandEnvelope envelope, RuntimeException exception) {
// Do nothing.
}
});
final StringValue sourceMessage = toMessage(getClass().getSimpleName());
final CommandContext sourceContext = getRequestFactory().createCommandContext();
final CommandRouter router = createRouter(commandBus, sourceMessage, sourceContext);
router.addAll(getMessages());
router.routeAll();
}
Aggregations