use of io.spine.type.TypeUrl in project core-java by SpineEventEngine.
the class AggregateTestEnv method typeUrlOf.
/**
* Obtains the {@link TypeUrl} of the message from the provided event.
*/
public static TypeUrl typeUrlOf(Event event) {
final Any message = event.getMessage();
final TypeUrl result = TypeUrl.parse(message.getTypeUrl());
return result;
}
use of io.spine.type.TypeUrl in project core-java by SpineEventEngine.
the class StandShould method register_projection_repositories.
@Test
public void register_projection_repositories() {
final boolean multitenant = isMultitenant();
final BoundedContext boundedContext = BoundedContext.newBuilder().setMultitenant(multitenant).build();
final Stand stand = boundedContext.getStand();
checkTypesEmpty(stand);
final StandTestProjectionRepository standTestProjectionRepo = new StandTestProjectionRepository();
stand.registerTypeSupplier(standTestProjectionRepo);
checkHasExactlyOne(stand.getExposedTypes(), Project.getDescriptor());
final ImmutableSet<TypeUrl> knownAggregateTypes = stand.getExposedAggregateTypes();
// As we registered a projection repo, known aggregate types should be still empty.
assertTrue("For some reason an aggregate type was registered", knownAggregateTypes.isEmpty());
final StandTestProjectionRepository anotherTestProjectionRepo = new StandTestProjectionRepository();
stand.registerTypeSupplier(anotherTestProjectionRepo);
checkHasExactlyOne(stand.getExposedTypes(), Project.getDescriptor());
}
use of io.spine.type.TypeUrl in project core-java by SpineEventEngine.
the class StandStorageShould method checkByTypeRead.
// OK for this test.
@SuppressWarnings({ "MethodWithMultipleLoops", "ConstantConditions" })
private void checkByTypeRead(FieldMask fieldMask) {
final boolean withFieldMask = !fieldMask.equals(FieldMask.getDefaultInstance());
final StandStorage storage = getStorage();
final TypeUrl type = TypeUrl.from(Project.getDescriptor());
final int projectsCount = 4;
final List<AggregateStateId> projectIds = fill(storage, projectsCount, DEFAULT_ID_SUPPLIER);
final int tasksCount = 5;
for (int i = 0; i < tasksCount; i++) {
final TaskId genericId = TaskId.newBuilder().setId(i).build();
final AggregateStateId id = AggregateStateId.of(genericId, TypeUrl.from(Task.getDescriptor()));
final Task task = Task.newBuilder().setTaskId(genericId).setTitle("Test task").setDescription("With description").build();
final EntityRecord record = newRecord(task);
storage.write(id, record);
}
final Iterator<EntityRecord> readRecords = withFieldMask ? storage.readAllByType(TypeUrl.from(Project.getDescriptor()), fieldMask) : storage.readAllByType(TypeUrl.from(Project.getDescriptor()));
final Set<EntityRecord> readDistinct = Sets.newHashSet(readRecords);
assertSize(projectsCount, readDistinct);
for (EntityRecord record : readDistinct) {
final Any state = record.getState();
final Project project = AnyPacker.unpack(state);
final AggregateStateId restored = AggregateStateId.of(project.getId(), type);
assertContains(restored, projectIds);
if (withFieldMask) {
assertMatchesMask(project, fieldMask);
}
}
}
use of io.spine.type.TypeUrl in project core-java by SpineEventEngine.
the class SubscriptionService method selectBoundedContext.
private BoundedContext selectBoundedContext(Target target) {
final TypeUrl type = TypeUrl.parse(target.getType());
final BoundedContext result = typeToContextMap.get(type);
return result;
}
use of io.spine.type.TypeUrl in project core-java by SpineEventEngine.
the class CommandsShould method obtain_type_url_of_command.
@Test
public void obtain_type_url_of_command() {
final ActorRequestFactory factory = TestActorRequestFactory.newInstance(CommandsShould.class);
final StringValue message = toMessage(Identifier.newUuid());
final Command command = factory.command().create(message);
final TypeUrl typeUrl = CommandEnvelope.of(command).getTypeName().toUrl();
assertEquals(TypeUrl.of(StringValue.class), typeUrl);
}
Aggregations