use of io.spine.test.projection.Project in project core-java by SpineEventEngine.
the class StandShould method fillSampleProjects.
private static Map<ProjectId, Project> fillSampleProjects(int numberOfProjects) {
final Map<ProjectId, Project> sampleProjects = newHashMap();
@SuppressWarnings("UnsecureRandomNumberGeneration") final Random randomizer = new Random(Integer.MAX_VALUE);
for (int projectIndex = 0; projectIndex < numberOfProjects; projectIndex++) {
final int numericId = randomizer.nextInt();
final ProjectId customerId = projectIdFor(numericId);
final Project project = Project.newBuilder().setName(String.valueOf(numericId)).build();
sampleProjects.put(customerId, project);
}
return sampleProjects;
}
use of io.spine.test.projection.Project in project core-java by SpineEventEngine.
the class StandShould method fillSampleProjects.
private static void fillSampleProjects(Map<ProjectId, Project> sampleProjects, int numberOfProjects) {
for (int projectIndex = 0; projectIndex < numberOfProjects; projectIndex++) {
final Project project = Project.getDefaultInstance();
final ProjectId projectId = ProjectId.newBuilder().setId(UUID.randomUUID().toString()).build();
sampleProjects.put(projectId, project);
}
}
use of io.spine.test.projection.Project in project core-java by SpineEventEngine.
the class StandShould method doCheckReadingProjectsById.
private void doCheckReadingProjectsById(int numberOfProjects) {
// Define the types and values used as a test data.
final Map<ProjectId, Project> sampleProjects = newHashMap();
final TypeUrl projectType = TypeUrl.of(Project.class);
fillSampleProjects(sampleProjects, numberOfProjects);
final StandTestProjectionRepository projectionRepository = mock(StandTestProjectionRepository.class);
when(projectionRepository.getEntityStateType()).thenReturn(projectType);
setupExpectedFindAllBehaviour(sampleProjects, projectionRepository);
final Stand stand = prepareStandWithProjectionRepo(projectionRepository);
final Query readMultipleProjects = requestFactory.query().byIds(Project.class, sampleProjects.keySet());
final MemoizeQueryResponseObserver responseObserver = new MemoizeQueryResponseObserver();
stand.execute(readMultipleProjects, responseObserver);
final List<Any> messageList = checkAndGetMessageList(responseObserver);
assertEquals(sampleProjects.size(), messageList.size());
final Collection<Project> allCustomers = sampleProjects.values();
for (Any singleRecord : messageList) {
final Project unpackedSingleResult = unpack(singleRecord);
assertTrue(allCustomers.contains(unpackedSingleResult));
}
}
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;
}
Aggregations