Search in sources :

Example 1 with RejectionEnrichmentConsumer

use of io.spine.server.rejection.given.RejectionEnrichmentConsumer 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)1 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 Test (org.junit.Test)1