use of com.google.protobuf.StringValue in project core-java by SpineEventEngine.
the class Given method validEvent.
static Event validEvent() {
final Command cmd = validCommand();
final PrjProjectCreated eventMessage = PrjProjectCreated.newBuilder().setProjectId(ProjectId.newBuilder().setId("12345AD0")).build();
final StringValue producerId = toMessage(Given.class.getSimpleName());
final EventFactory eventFactory = EventFactory.on(CommandEnvelope.of(cmd), Identifier.pack(producerId));
final Event event = eventFactory.createEvent(eventMessage, Tests.<Version>nullRef());
final Event result = event.toBuilder().setContext(event.getContext().toBuilder().setEnrichment(Enrichment.newBuilder().setDoNotEnrich(true)).build()).build();
return result;
}
use of com.google.protobuf.StringValue in project core-java by SpineEventEngine.
the class StandPostShould method use_delivery_from_builder.
@SuppressWarnings("MagicNumber")
@Test
public void use_delivery_from_builder() {
final StandUpdateDelivery delivery = spy(new StandUpdateDelivery() {
@Override
protected boolean shouldPostponeDelivery(EntityStateEnvelope deliverable, Stand consumer) {
return false;
}
});
final Stand.Builder builder = Stand.newBuilder().setDelivery(delivery);
final Stand stand = builder.build();
Assert.assertNotNull(stand);
final Object id = Identifier.newUuid();
final StringValue state = StringValue.getDefaultInstance();
final VersionableEntity entity = mock(AbstractVersionableEntity.class);
when(entity.getState()).thenReturn(state);
when(entity.getId()).thenReturn(id);
when(entity.getVersion()).thenReturn(newVersion(17, Time.getCurrentTime()));
final CommandContext context = requestFactory.createCommandContext();
stand.post(context.getActorContext().getTenantId(), entity);
final EntityStateEnvelope envelope = EntityStateEnvelope.of(entity, context.getActorContext().getTenantId());
verify(delivery).deliverNow(eq(envelope), eq(Consumers.idOf(stand)));
}
use of com.google.protobuf.StringValue in project core-java by SpineEventEngine.
the class StandPostShould method deliver_updates.
// **** Positive scenarios (unit) ****
@SuppressWarnings({ "OverlyComplexAnonymousInnerClass", "ConstantConditions" })
@Test
public void deliver_updates() {
final AggregateRepository<ProjectId, Given.StandTestAggregate> repository = Given.aggregateRepo();
final ProjectId entityId = ProjectId.newBuilder().setId("PRJ-001").build();
final Given.StandTestAggregate entity = repository.create(entityId);
final StringValue state = entity.getState();
final Version version = entity.getVersion();
final Stand innerStand = Stand.newBuilder().build();
final Stand stand = spy(innerStand);
stand.post(requestFactory.createCommandContext().getActorContext().getTenantId(), entity);
final ArgumentMatcher<EntityStateEnvelope<?, ?>> argumentMatcher = new ArgumentMatcher<EntityStateEnvelope<?, ?>>() {
@Override
public boolean matches(EntityStateEnvelope<?, ?> argument) {
final boolean entityIdMatches = argument.getEntityId().equals(entityId);
final boolean versionMatches = version.equals(argument.getEntityVersion().orNull());
final boolean stateMatches = argument.getMessage().equals(state);
return entityIdMatches && versionMatches && stateMatches;
}
};
verify(stand).update(ArgumentMatchers.argThat(argumentMatcher));
}
use of com.google.protobuf.StringValue in project core-java by SpineEventEngine.
the class ColumnFiltersShould method create_ordering_filters_for_strings.
@Test
public void create_ordering_filters_for_strings() {
final String string = "abc";
final ColumnFilter filter = gt("stringColumn", string);
assertNotNull(filter);
assertEquals(GREATER_THAN, filter.getOperator());
final StringValue value = AnyPacker.unpack(filter.getValue());
assertEquals(string, value.getValue());
}
use of com.google.protobuf.StringValue in project core-java by SpineEventEngine.
the class CommandAttributeShould method set_and_get_message_attribute.
@Test
public void set_and_get_message_attribute() {
final CommandAttribute<StringValue> attr = new CommandAttribute<StringValue>("str-val") {
};
final StringValue value = toMessage(getClass().getName());
assertSetGet(attr, value);
}
Aggregations