Search in sources :

Example 1 with Enrichment

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;
}
Also used : Enrichment(io.spine.core.Enrichment) Any(com.google.protobuf.Any)

Example 2 with Enrichment

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);
}
Also used : Enrichment(io.spine.core.Enrichment) Any(com.google.protobuf.Any) Test(org.junit.Test)

Example 3 with Enrichment

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));
}
Also used : Given.invalidProjectNameRejection(io.spine.server.rejection.given.Given.invalidProjectNameRejection) Rejection(io.spine.core.Rejection) Enrichment(io.spine.core.Enrichment) RejectionContext(io.spine.core.RejectionContext) ProjectRejections(io.spine.test.rejection.ProjectRejections) RejectionEnrichmentConsumer(io.spine.server.rejection.given.RejectionEnrichmentConsumer) Test(org.junit.Test)

Aggregations

Enrichment (io.spine.core.Enrichment)3 Any (com.google.protobuf.Any)2 Test (org.junit.Test)2 Rejection (io.spine.core.Rejection)1 RejectionContext (io.spine.core.RejectionContext)1 Given.invalidProjectNameRejection (io.spine.server.rejection.given.Given.invalidProjectNameRejection)1 RejectionEnrichmentConsumer (io.spine.server.rejection.given.RejectionEnrichmentConsumer)1 ProjectRejections (io.spine.test.rejection.ProjectRejections)1