use of io.spine.test.projection.Project in project core-java by SpineEventEngine.
the class ProjectionStorageShould method newState.
@Override
protected Message newState(I id) {
final String projectId = id.getClass().getName();
final Project state = Given.project(projectId, "Projection name " + projectId);
return state;
}
use of io.spine.test.projection.Project in project core-java by SpineEventEngine.
the class ProjectionStorageShould method checkProjectIdIsInList.
@SuppressWarnings("BreakStatement")
private static <I> Project checkProjectIdIsInList(EntityRecord project, List<I> ids) {
final Any packedState = project.getState();
final Project state = AnyPacker.unpack(packedState);
final ProjectId id = state.getId();
final String stringIdRepr = id.getId();
boolean isIdPresent = false;
for (I genericId : ids) {
isIdPresent = genericId.toString().equals(stringIdRepr);
if (isIdPresent) {
break;
}
}
assertTrue(isIdPresent);
return state;
}
use of io.spine.test.projection.Project in project core-java by SpineEventEngine.
the class ProjectionStorageShould method read_all_messages_with_field_mask.
@SuppressWarnings("MethodWithMultipleLoops")
@Test
public void read_all_messages_with_field_mask() {
final List<I> ids = fillStorage(5);
final String projectDescriptor = Project.getDescriptor().getFullName();
// clashes with non-related tests.
@SuppressWarnings("DuplicateStringLiteralInspection") final FieldMask fieldMask = maskForPaths(projectDescriptor + ".id", projectDescriptor + ".name");
final Map<I, EntityRecord> read = storage.readAll(fieldMask);
assertSize(ids.size(), read);
for (Map.Entry<I, EntityRecord> record : read.entrySet()) {
assertContains(record.getKey(), ids);
final Any packedState = record.getValue().getState();
final Project state = AnyPacker.unpack(packedState);
assertMatchesMask(state, fieldMask);
}
}
use of io.spine.test.projection.Project in project core-java by SpineEventEngine.
the class StandShould method trigger_subscription_callback_upon_update_of_projection.
@Test
public void trigger_subscription_callback_upon_update_of_projection() {
final Stand stand = prepareStandWithAggregateRepo(mock(StandStorage.class));
final Topic allProjects = requestFactory.topic().allOf(Project.class);
final MemoizeEntityUpdateCallback memoizeCallback = new MemoizeEntityUpdateCallback();
subscribeAndActivate(stand, allProjects, memoizeCallback);
assertNull(memoizeCallback.newEntityState);
final Map.Entry<ProjectId, Project> sampleData = fillSampleProjects(1).entrySet().iterator().next();
final ProjectId projectId = sampleData.getKey();
final Project project = sampleData.getValue();
final Version stateVersion = Tests.newVersionWithNumber(1);
stand.update(asEnvelope(projectId, project, stateVersion));
final Any packedState = AnyPacker.pack(project);
assertEquals(packedState, memoizeCallback.newEntityState);
}
Aggregations