use of io.spine.server.aggregate.given.aggregate.FaultyAggregate in project core-java by SpineEventEngine.
the class AggregateShould method propagate_RuntimeException_when_handler_throws.
@Test
public void propagate_RuntimeException_when_handler_throws() {
ModelTests.clearModel();
final FaultyAggregate faultyAggregate = new FaultyAggregate(ID, true, false);
final Command command = Given.ACommand.createProject();
try {
dispatchCommand(faultyAggregate, env(command.getMessage()));
failNotThrows();
} catch (RuntimeException e) {
// We need it for checking.
@SuppressWarnings("ThrowableResultOfMethodCallIgnored") final Throwable cause = getRootCause(e);
assertTrue(cause instanceof IllegalStateException);
assertEquals(FaultyAggregate.BROKEN_HANDLER, cause.getMessage());
}
}
use of io.spine.server.aggregate.given.aggregate.FaultyAggregate in project core-java by SpineEventEngine.
the class AggregateShould method propagate_RuntimeException_when_applier_throws.
@Test
public void propagate_RuntimeException_when_applier_throws() {
ModelTests.clearModel();
final FaultyAggregate faultyAggregate = new FaultyAggregate(ID, false, true);
final Command command = Given.ACommand.createProject();
try {
dispatchCommand(faultyAggregate, env(command.getMessage()));
failNotThrows();
} catch (RuntimeException e) {
@SuppressWarnings("ThrowableResultOfMethodCallIgnored") final Throwable // because we need it for checking.
cause = getRootCause(e);
assertTrue(cause instanceof IllegalStateException);
assertEquals(FaultyAggregate.BROKEN_APPLIER, cause.getMessage());
}
}
use of io.spine.server.aggregate.given.aggregate.FaultyAggregate in project core-java by SpineEventEngine.
the class AggregateShould method propagate_RuntimeException_when_play_raises_exception.
@Test
public void propagate_RuntimeException_when_play_raises_exception() {
ModelTests.clearModel();
final FaultyAggregate faultyAggregate = new FaultyAggregate(ID, false, true);
try {
final Event event = event(projectCreated(ID, getClass().getSimpleName()), 1);
final AggregateTransaction tx = AggregateTransaction.start(faultyAggregate);
((Aggregate) faultyAggregate).play(AggregateStateRecord.newBuilder().addEvent(event).build());
tx.commit();
failNotThrows();
} catch (RuntimeException e) {
@SuppressWarnings("ThrowableResultOfMethodCallIgnored") final Throwable // because we need it for checking.
cause = getRootCause(e);
assertTrue(cause instanceof IllegalStateException);
assertEquals(FaultyAggregate.BROKEN_APPLIER, cause.getMessage());
}
}
Aggregations