Search in sources :

Example 1 with MediatorConfigurationSupport

use of io.smallrye.reactive.messaging.providers.MediatorConfigurationSupport in project smallrye-reactive-messaging by smallrye.

the class MediatorConfigurationSupportTest method testSubscribers.

@Test
public void testSubscribers() {
    MediatorConfigurationSupport support = create("subscriberSubscriberOfMessage");
    MediatorConfigurationSupport.ValidationOutput output = support.validate(Shape.SUBSCRIBER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.STREAM_OF_MESSAGE);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.NONE);
    assertThat(output.getIngestedPayloadType()).isEqualTo(Person.class);
    assertThat(output.getUseBuilderTypes()).isFalse();
    support = create("subscriberSubscriberOfPayload");
    output = support.validate(Shape.SUBSCRIBER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.STREAM_OF_PAYLOAD);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.NONE);
    assertThat(output.getIngestedPayloadType()).isEqualTo(Person.class);
    assertThat(output.getUseBuilderTypes()).isFalse();
    support = create("subscriberSubscriberBuilderOfMessage");
    output = support.validate(Shape.SUBSCRIBER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.STREAM_OF_MESSAGE);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.NONE);
    assertThat(output.getIngestedPayloadType()).isEqualTo(Person.class);
    assertThat(output.getUseBuilderTypes()).isTrue();
    support = create("subscriberSubscriberBuilderOfPayload");
    output = support.validate(Shape.SUBSCRIBER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.STREAM_OF_PAYLOAD);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.NONE);
    assertThat(output.getIngestedPayloadType()).isEqualTo(Person.class);
    assertThat(output.getUseBuilderTypes()).isTrue();
    assertThatThrownBy(() -> create("subscriberSinkOfMessage").validate(Shape.SUBSCRIBER, null)).isInstanceOf(DefinitionException.class);
    support = create("subscriberSinkOfPayload");
    output = support.validate(Shape.SUBSCRIBER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.PAYLOAD);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.NONE);
    assertThat(output.getIngestedPayloadType()).isEqualTo(Person.class);
    assertThat(output.getUseBuilderTypes()).isFalse();
    support = create("subscriberSinkOfMessageCompletionStage");
    output = support.validate(Shape.SUBSCRIBER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.MESSAGE);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.NONE);
    assertThat(output.getIngestedPayloadType()).isEqualTo(Person.class);
    assertThat(output.getUseBuilderTypes()).isFalse();
    support = create("subscriberSinkOfPayloadCompletionStage");
    output = support.validate(Shape.SUBSCRIBER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.PAYLOAD);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.NONE);
    assertThat(output.getIngestedPayloadType()).isEqualTo(Person.class);
    assertThat(output.getUseBuilderTypes()).isFalse();
    support = create("subscriberSinkOfMessageUni");
    output = support.validate(Shape.SUBSCRIBER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.MESSAGE);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.NONE);
    assertThat(output.getIngestedPayloadType()).isEqualTo(Person.class);
    assertThat(output.getUseBuilderTypes()).isFalse();
    support = create("subscriberSinkOfPayloadUni");
    output = support.validate(Shape.SUBSCRIBER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.PAYLOAD);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.NONE);
    assertThat(output.getIngestedPayloadType()).isEqualTo(Person.class);
    assertThat(output.getUseBuilderTypes()).isFalse();
    support = create("subscriberSinkOfRawMessageCompletionStage");
    output = support.validate(Shape.SUBSCRIBER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.MESSAGE);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.NONE);
    assertThat(output.getIngestedPayloadType()).isEqualTo(null);
    assertThat(output.getUseBuilderTypes()).isFalse();
    support = create("subscriberSinkOfWildcardMessageCompletionStage");
    output = support.validate(Shape.SUBSCRIBER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.MESSAGE);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.NONE);
    assertThat(output.getIngestedPayloadType()).isEqualTo(null);
    assertThat(output.getUseBuilderTypes()).isFalse();
}
Also used : MediatorConfigurationSupport(io.smallrye.reactive.messaging.providers.MediatorConfigurationSupport) Test(org.junit.jupiter.api.Test)

Example 2 with MediatorConfigurationSupport

use of io.smallrye.reactive.messaging.providers.MediatorConfigurationSupport in project smallrye-reactive-messaging by smallrye.

the class MediatorConfigurationSupportTest method testProcessMerge.

@Test
void testProcessMerge() {
    MediatorConfigurationSupport support = new MediatorConfigurationSupport("mymethod", String.class, new Class[] { String.class }, null, null);
    assertThat(support.processMerge(Arrays.asList("a", "b"), () -> Merge.Mode.MERGE)).isEqualTo(Merge.Mode.MERGE);
    assertThatThrownBy(() -> support.processMerge(Collections.emptyList(), () -> Merge.Mode.MERGE)).isInstanceOf(DefinitionException.class);
    assertThatThrownBy(() -> support.processMerge(null, () -> Merge.Mode.MERGE)).isInstanceOf(DefinitionException.class);
    assertThat(support.processMerge(Collections.emptyList(), () -> null)).isEqualTo(null);
}
Also used : MediatorConfigurationSupport(io.smallrye.reactive.messaging.providers.MediatorConfigurationSupport) Test(org.junit.jupiter.api.Test)

Example 3 with MediatorConfigurationSupport

use of io.smallrye.reactive.messaging.providers.MediatorConfigurationSupport in project smallrye-reactive-messaging by smallrye.

the class MediatorConfigurationSupportTest method testProcessSuppliedAcknowledgement.

@Test
void testProcessSuppliedAcknowledgement() {
    MediatorConfigurationSupport support = new MediatorConfigurationSupport("mymethod", String.class, new Class[] { String.class }, null, null);
    assertThat(support.processSuppliedAcknowledgement(Collections.singletonList("hello"), () -> Acknowledgment.Strategy.MANUAL)).isEqualTo(Acknowledgment.Strategy.MANUAL);
    assertThat(support.processSuppliedAcknowledgement(Collections.singletonList("hello"), () -> null)).isNull();
    assertThat(support.processSuppliedAcknowledgement(Collections.emptyList(), () -> null)).isNull();
    assertThatThrownBy(() -> support.processSuppliedAcknowledgement(Collections.emptyList(), () -> Acknowledgment.Strategy.MANUAL)).isInstanceOf(DefinitionException.class);
}
Also used : MediatorConfigurationSupport(io.smallrye.reactive.messaging.providers.MediatorConfigurationSupport) Test(org.junit.jupiter.api.Test)

Example 4 with MediatorConfigurationSupport

use of io.smallrye.reactive.messaging.providers.MediatorConfigurationSupport in project smallrye-reactive-messaging by smallrye.

the class MediatorConfigurationSupportTest method testPublishers.

@Test
public void testPublishers() {
    MediatorConfigurationSupport support = create("publisherPublisherOfMessage");
    MediatorConfigurationSupport.ValidationOutput output = support.validate(Shape.PUBLISHER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.NONE);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.STREAM_OF_MESSAGE);
    assertThat(output.getIngestedPayloadType()).isNull();
    assertThat(output.getUseBuilderTypes()).isFalse();
    support = create("publisherMultiOfMessage");
    output = support.validate(Shape.PUBLISHER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.NONE);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.STREAM_OF_MESSAGE);
    assertThat(output.getIngestedPayloadType()).isNull();
    assertThat(output.getUseBuilderTypes()).isFalse();
    support = create("publisherPublisherOfPayload");
    output = support.validate(Shape.PUBLISHER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.NONE);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.STREAM_OF_PAYLOAD);
    assertThat(output.getIngestedPayloadType()).isNull();
    assertThat(output.getUseBuilderTypes()).isFalse();
    support = create("publisherMultiOfPayload");
    output = support.validate(Shape.PUBLISHER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.NONE);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.STREAM_OF_PAYLOAD);
    assertThat(output.getIngestedPayloadType()).isNull();
    assertThat(output.getUseBuilderTypes()).isFalse();
    support = create("publisherPublisherBuilderOfMessage");
    output = support.validate(Shape.PUBLISHER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.NONE);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.STREAM_OF_MESSAGE);
    assertThat(output.getIngestedPayloadType()).isNull();
    assertThat(output.getUseBuilderTypes()).isTrue();
    support = create("publisherPublisherBuilderOfPayload");
    output = support.validate(Shape.PUBLISHER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.NONE);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.STREAM_OF_PAYLOAD);
    assertThat(output.getIngestedPayloadType()).isNull();
    assertThat(output.getUseBuilderTypes()).isTrue();
    support = create("publisherGeneratePayload");
    output = support.validate(Shape.PUBLISHER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.NONE);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.INDIVIDUAL_PAYLOAD);
    assertThat(output.getIngestedPayloadType()).isNull();
    assertThat(output.getUseBuilderTypes()).isFalse();
    support = create("publisherGenerateMessage");
    output = support.validate(Shape.PUBLISHER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.NONE);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.INDIVIDUAL_MESSAGE);
    assertThat(output.getIngestedPayloadType()).isNull();
    assertThat(output.getUseBuilderTypes()).isFalse();
    support = create("publisherGenerateCompletionStagePayload");
    output = support.validate(Shape.PUBLISHER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.NONE);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.COMPLETION_STAGE_OF_PAYLOAD);
    assertThat(output.getIngestedPayloadType()).isNull();
    assertThat(output.getUseBuilderTypes()).isFalse();
    support = create("publisherGenerateCompletionStageMessage");
    output = support.validate(Shape.PUBLISHER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.NONE);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.COMPLETION_STAGE_OF_MESSAGE);
    assertThat(output.getIngestedPayloadType()).isNull();
    assertThat(output.getUseBuilderTypes()).isFalse();
    support = create("publisherGenerateUniPayload");
    output = support.validate(Shape.PUBLISHER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.NONE);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.UNI_OF_PAYLOAD);
    assertThat(output.getIngestedPayloadType()).isNull();
    assertThat(output.getUseBuilderTypes()).isFalse();
    support = create("publisherGenerateUniMessage");
    output = support.validate(Shape.PUBLISHER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.NONE);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.UNI_OF_MESSAGE);
    assertThat(output.getIngestedPayloadType()).isNull();
    assertThat(output.getUseBuilderTypes()).isFalse();
}
Also used : MediatorConfigurationSupport(io.smallrye.reactive.messaging.providers.MediatorConfigurationSupport) Test(org.junit.jupiter.api.Test)

Example 5 with MediatorConfigurationSupport

use of io.smallrye.reactive.messaging.providers.MediatorConfigurationSupport in project quarkus by quarkusio.

the class MediatorConfigurationSupportTest method testSubscribers.

@Test
public void testSubscribers() {
    MediatorConfigurationSupport support = create("subscriberSubscriberOfMessage");
    MediatorConfigurationSupport.ValidationOutput output = support.validate(Shape.SUBSCRIBER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.STREAM_OF_MESSAGE);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.NONE);
    assertThat(output.getIngestedPayloadType()).isEqualTo(Person.class);
    assertThat(output.getUseBuilderTypes()).isFalse();
    support = create("subscriberSubscriberOfPayload");
    output = support.validate(Shape.SUBSCRIBER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.STREAM_OF_PAYLOAD);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.NONE);
    assertThat(output.getIngestedPayloadType()).isEqualTo(Person.class);
    assertThat(output.getUseBuilderTypes()).isFalse();
    support = create("subscriberSubscriberBuilderOfMessage");
    output = support.validate(Shape.SUBSCRIBER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.STREAM_OF_MESSAGE);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.NONE);
    assertThat(output.getIngestedPayloadType()).isEqualTo(Person.class);
    assertThat(output.getUseBuilderTypes()).isTrue();
    support = create("subscriberSubscriberBuilderOfPayload");
    output = support.validate(Shape.SUBSCRIBER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.STREAM_OF_PAYLOAD);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.NONE);
    assertThat(output.getIngestedPayloadType()).isEqualTo(Person.class);
    assertThat(output.getUseBuilderTypes()).isTrue();
    assertThatThrownBy(() -> create("subscriberSinkOfMessage").validate(Shape.SUBSCRIBER, null)).isInstanceOf(DefinitionException.class);
    support = create("subscriberSinkOfPayload");
    output = support.validate(Shape.SUBSCRIBER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.PAYLOAD);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.NONE);
    assertThat(output.getIngestedPayloadType()).isEqualTo(Person.class);
    assertThat(output.getUseBuilderTypes()).isFalse();
    support = create("subscriberSinkOfMessageCompletionStage");
    output = support.validate(Shape.SUBSCRIBER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.MESSAGE);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.NONE);
    assertThat(output.getIngestedPayloadType()).isEqualTo(Person.class);
    assertThat(output.getUseBuilderTypes()).isFalse();
    support = create("subscriberSinkOfPayloadCompletionStage");
    output = support.validate(Shape.SUBSCRIBER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.PAYLOAD);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.NONE);
    assertThat(output.getIngestedPayloadType()).isEqualTo(Person.class);
    assertThat(output.getUseBuilderTypes()).isFalse();
    support = create("subscriberSinkOfMessageUni");
    output = support.validate(Shape.SUBSCRIBER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.MESSAGE);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.NONE);
    assertThat(output.getIngestedPayloadType()).isEqualTo(Person.class);
    assertThat(output.getUseBuilderTypes()).isFalse();
    support = create("subscriberSinkOfPayloadUni");
    output = support.validate(Shape.SUBSCRIBER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.PAYLOAD);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.NONE);
    assertThat(output.getIngestedPayloadType()).isEqualTo(Person.class);
    assertThat(output.getUseBuilderTypes()).isFalse();
    support = create("subscriberSinkOfRawMessageCompletionStage");
    output = support.validate(Shape.SUBSCRIBER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.MESSAGE);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.NONE);
    assertThat(output.getIngestedPayloadType()).isEqualTo(null);
    assertThat(output.getUseBuilderTypes()).isFalse();
    support = create("subscriberSinkOfWildcardMessageCompletionStage");
    output = support.validate(Shape.SUBSCRIBER, null);
    assertThat(output.getConsumption()).isEqualTo(MediatorConfiguration.Consumption.MESSAGE);
    assertThat(output.getProduction()).isEqualTo(MediatorConfiguration.Production.NONE);
    assertThat(output.getIngestedPayloadType()).isEqualTo(null);
    assertThat(output.getUseBuilderTypes()).isFalse();
}
Also used : MediatorConfigurationSupport(io.smallrye.reactive.messaging.providers.MediatorConfigurationSupport) Test(org.junit.jupiter.api.Test)

Aggregations

MediatorConfigurationSupport (io.smallrye.reactive.messaging.providers.MediatorConfigurationSupport)15 Test (org.junit.jupiter.api.Test)14 QuarkusMediatorConfiguration (io.quarkus.smallrye.reactivemessaging.runtime.QuarkusMediatorConfiguration)1 Multi (io.smallrye.mutiny.Multi)1 Shape (io.smallrye.reactive.messaging.Shape)1 Merge (io.smallrye.reactive.messaging.annotations.Merge)1 ArrayList (java.util.ArrayList)1 Supplier (java.util.function.Supplier)1 Acknowledgment (org.eclipse.microprofile.reactive.messaging.Acknowledgment)1 PublisherBuilder (org.eclipse.microprofile.reactive.streams.operators.PublisherBuilder)1 AnnotationInstance (org.jboss.jandex.AnnotationInstance)1 AnnotationValue (org.jboss.jandex.AnnotationValue)1 Publisher (org.reactivestreams.Publisher)1