use of io.spine.core.Enrichment in project core-java by SpineEventEngine.
the class GivenEnrichment method withOneAttribute.
/**
* Creates a new {@link Enrichment} with one {@linkplain Enrichment#getContainer() attribute}.
*
* <p>An enrichment attribute is invalid and has random values.
*
* @return a new enrichment instance
*/
public static Enrichment withOneAttribute() {
final String key = newUuid();
final Any value = pack(toMessage(newUuid()));
final Enrichment result = Enrichment.newBuilder().setContainer(Enrichment.Container.newBuilder().putItems(key, value).build()).build();
return result;
}
use of io.spine.core.Enrichment in project core-java by SpineEventEngine.
the class GivenEnrichmentShould method create_enrichment_with_one_attribute.
@Test
public void create_enrichment_with_one_attribute() {
final Enrichment enrichment = withOneAttribute();
final Map<String, Any> enrichmentAttributes = enrichment.getContainer().getItems();
assertSize(1, enrichmentAttributes);
}
use of io.spine.core.Enrichment in project core-java by SpineEventEngine.
the class RejectionEnricherShould method boolean_enrich_rejection.
@Test
public void boolean_enrich_rejection() {
final RejectionEnrichmentConsumer consumer = new RejectionEnrichmentConsumer();
rejectionBus.register(consumer);
final Rejection rejection = invalidProjectNameRejection();
rejectionBus.post(rejection);
final RejectionContext context = consumer.getContext();
final Enrichment enrichment = context.getEnrichment();
assertNotEquals(Enrichment.getDefaultInstance(), enrichment);
final Optional<ProjectRejections.ProjectInfo> optional = Enrichments.getEnrichment(ProjectRejections.ProjectInfo.class, context);
assertTrue(optional.isPresent());
assertTrue(optional.get().getProjectName().startsWith(PROJECT_NAME_PREFIX));
}
Aggregations