use of io.spine.client.TestActorRequestFactory in project core-java by SpineEventEngine.
the class StorageShould method store_command_with_error_and_generate_ID_if_needed.
@Test
public void store_command_with_error_and_generate_ID_if_needed() {
final TestActorRequestFactory factory = TestActorRequestFactory.newInstance(getClass());
final Command command = factory.createCommand(createProjectMessage());
final Error error = newError();
repository.store(command, error);
final List<CommandRecord> records = Lists.newArrayList(repository.iterator(ERROR));
assertEquals(1, records.size());
final String commandIdStr = Identifier.toString(records.get(0).getCommandId());
assertFalse(commandIdStr.isEmpty());
}
use of io.spine.client.TestActorRequestFactory in project core-java by SpineEventEngine.
the class AggregateMessageDispatcherShould method dispatch_command.
@Test
public void dispatch_command() {
final TestActorRequestFactory factory = TestActorRequestFactory.newInstance(getClass());
final int messageValue = 2017_07_28;
final UInt32Value message = UInt32Value.newBuilder().setValue(messageValue).build();
final CommandEnvelope commandEnvelope = CommandEnvelope.of(factory.createCommand(message));
final List<? extends Message> eventMessages = dispatchCommand(aggregate, commandEnvelope);
assertTrue(aggregate.getState().getValue().contains(String.valueOf(messageValue)));
assertEquals(1, eventMessages.size());
assertTrue(eventMessages.get(0) instanceof StringValue);
}
use of io.spine.client.TestActorRequestFactory in project core-java by SpineEventEngine.
the class CommandServiceShould method return_error_status_if_command_is_unsupported.
@Test
public void return_error_status_if_command_is_unsupported() {
final TestActorRequestFactory factory = TestActorRequestFactory.newInstance(getClass());
final Command unsupportedCmd = factory.createCommand(StringValue.getDefaultInstance());
service.post(unsupportedCmd, responseObserver);
assertTrue(responseObserver.isCompleted());
final Ack result = responseObserver.firstResponse();
assertNotNull(result);
assertTrue(isNotDefault(result));
final Status status = result.getStatus();
assertEquals(ERROR, status.getStatusCase());
final Error error = status.getError();
assertEquals(CommandValidationError.getDescriptor().getFullName(), error.getType());
}
use of io.spine.client.TestActorRequestFactory in project core-java by SpineEventEngine.
the class AggregateRepositoryShould method not_pass_command_rejection_to_onError.
@Test
public void not_pass_command_rejection_to_onError() {
final FailingAggregateRepository repository = new FailingAggregateRepository();
boundedContext.register(repository);
final TestActorRequestFactory requestFactory = TestActorRequestFactory.newInstance(getClass());
// Passing negative long value to `FailingAggregate` should cause a rejection.
final CommandEnvelope ce = CommandEnvelope.of(requestFactory.createCommand(UInt64Value.newBuilder().setValue(-100_000_000L).build()));
boundedContext.getCommandBus().post(ce.getCommand(), StreamObservers.<Ack>noOpObserver());
assertFalse(repository.isErrorLogged());
}
use of io.spine.client.TestActorRequestFactory in project core-java by SpineEventEngine.
the class Given method invalidProjectNameRejection.
public static Rejection invalidProjectNameRejection() {
final ProjectId projectId = newProjectId();
final ProjectRejections.InvalidProjectName invalidProjectName = ProjectRejections.InvalidProjectName.newBuilder().setProjectId(projectId).build();
final StringChange nameChange = StringChange.newBuilder().setNewValue("Too short").build();
final RjUpdateProjectName updateProjectName = RjUpdateProjectNameVBuilder.newBuilder().setId(projectId).setNameUpdate(nameChange).build();
final TenantId generatedTenantId = TenantId.newBuilder().setValue(newUuid()).build();
final TestActorRequestFactory factory = TestActorRequestFactory.newInstance(RejectionBusShould.class, generatedTenantId);
final Command command = factory.createCommand(updateProjectName);
return Rejections.createRejection(invalidProjectName, command);
}
Aggregations