use of io.spine.users.TenantId in project core-java by SpineEventEngine.
the class CommandStoreShould method set_command_status_to_failure_when_handler_throws_failure.
@Test
public void set_command_status_to_failure_when_handler_throws_failure() {
final TestFailure failure = new TestFailure();
final Command command = givenThrowingHandler(failure);
final CommandId commandId = command.getId();
final Message commandMessage = getMessage(command);
commandBus.post(command, responseObserver);
// Check that the logging was called.
verify(log).failureHandling(eq(failure), eq(commandMessage), eq(commandId));
// Check that the status has the correct code,
// and the failure matches the thrown failure.
final TenantId tenantId = command.getContext().getActorContext().getTenantId();
final ProcessingStatus status = getStatus(commandId, tenantId);
assertEquals(CommandStatus.FAILURE, status.getCode());
assertEquals(failure.toFailure(command).getMessage(), status.getFailure().getMessage());
}
use of io.spine.users.TenantId in project core-java by SpineEventEngine.
the class FailureBusShould method invalidProjectNameFailure.
private static Failure invalidProjectNameFailure() {
final ProjectId projectId = ProjectId.newBuilder().setId(newUuid()).build();
final ProjectFailures.InvalidProjectName invalidProjectName = ProjectFailures.InvalidProjectName.newBuilder().setProjectId(projectId).build();
final StringChange nameChange = StringChange.newBuilder().setNewValue("Too short").build();
final UpdateProjectName updateProjectName = UpdateProjectName.newBuilder().setId(projectId).setNameUpdate(nameChange).build();
final TenantId generatedTenantId = TenantId.newBuilder().setValue(newUuid()).build();
final TestActorRequestFactory factory = TestActorRequestFactory.newInstance(FailureBusShould.class, generatedTenantId);
final Command command = factory.createCommand(updateProjectName);
return Failures.createFailure(invalidProjectName, command);
}
use of io.spine.users.TenantId in project core-java by SpineEventEngine.
the class CommandFactoryShould method create_command_context.
@Test
public void create_command_context() {
final TenantId tenantId = newTenantUuid();
final UserId userId = newUserUuid();
final ZoneOffset zoneOffset = ZoneOffsets.ofHours(-3);
final int targetVersion = 100500;
final CommandContext commandContext = CommandFactory.createContext(tenantId, userId, zoneOffset, targetVersion);
final ActorContext actorContext = commandContext.getActorContext();
assertEquals(tenantId, actorContext.getTenantId());
assertEquals(userId, actorContext.getActor());
assertEquals(zoneOffset, actorContext.getZoneOffset());
assertEquals(targetVersion, commandContext.getTargetVersion());
}
use of io.spine.users.TenantId in project core-java by SpineEventEngine.
the class TenantFunction method execute.
/**
* Applies the function and returns the result.
*
* @return the result of the function
*/
@Nullable
public T execute() {
final TenantId currentTenant = tenantId();
final T result = apply(currentTenant);
return result;
}
use of io.spine.users.TenantId in project core-java by SpineEventEngine.
the class MultiTenantStandShould method setUp.
@Override
@Before
public void setUp() {
final TenantId tenantId = newTenantUuid();
setCurrentTenant(tenantId);
setMultitenant(true);
setRequestFactory(createRequestFactory(tenantId));
}
Aggregations