use of io.spine.test.aggregate.Project in project core-java by SpineEventEngine.
the class AggregateRepositoryShould method create_aggregate_with_default_state_if_no_aggregate_found.
// OK as the aggregate is created if missing.
@SuppressWarnings("OptionalGetWithoutIsPresent")
@Test
public void create_aggregate_with_default_state_if_no_aggregate_found() {
final ProjectAggregate aggregate = repository.find(Sample.messageOfType(ProjectId.class)).get();
final Project state = aggregate.getState();
assertTrue(isDefault(state));
}
use of io.spine.test.aggregate.Project in project core-java by SpineEventEngine.
the class AggregateShould method transform_current_state_to_snapshot_event.
@Test
public void transform_current_state_to_snapshot_event() {
dispatch(aggregate, env(createProject));
final Snapshot snapshot = aggregate.toSnapshot();
final Project state = unpack(snapshot.getState());
assertEquals(ID, state.getId());
assertEquals(Status.CREATED, state.getStatus());
}
use of io.spine.test.aggregate.Project in project core-java by SpineEventEngine.
the class FieldMasksShould method fail_to_mask_message_if_passed_type_does_not_match.
@Test(expected = IllegalArgumentException.class)
public void fail_to_mask_message_if_passed_type_does_not_match() {
final FieldMask mask = Given.fieldMask(Project.ID_FIELD_NUMBER);
final Project origin = Given.newProject("some-string");
FieldMasks.applyMask(mask, origin, Given.OTHER_TYPE);
}
use of io.spine.test.aggregate.Project in project core-java by SpineEventEngine.
the class FieldMasksShould method apply_only_non_empty_mask_to_single_item.
@Test
public void apply_only_non_empty_mask_to_single_item() {
final FieldMask emptyMask = Given.fieldMask();
final Project origin = Given.newProject("read_whole_message");
final Project clone = Project.newBuilder(origin).build();
final Project processed = FieldMasks.applyMask(emptyMask, origin, Given.TYPE);
// Check object itself was returned
assertTrue(processed == origin);
// Check object was not changed
assertTrue(processed.equals(clone));
}
use of io.spine.test.aggregate.Project in project core-java by SpineEventEngine.
the class FieldMasksShould method apply_mask_to_single_message.
@Test
public void apply_mask_to_single_message() {
final FieldMask fieldMask = Given.fieldMask(Project.ID_FIELD_NUMBER, Project.NAME_FIELD_NUMBER);
final Project original = Given.newProject("some-string-id");
final Project masked = FieldMasks.applyMask(fieldMask, original, Given.TYPE);
assertNotEquals(original, masked);
assertMatchesMask(masked, fieldMask);
}
Aggregations