Search in sources :

Example 1 with TopicDiscovery

use of org.kie.kogito.event.TopicDiscovery in project kogito-runtimes by kiegroup.

the class QuarkusTopicDiscoveryTest method verifyTopicsWithPropertiesAndChannels.

@Test
@ClearSystemProperty(key = "mp.messaging.outgoing.processedtravellers.connector")
@ClearSystemProperty(key = "mp.messaging.outgoing.processedtravellers.url")
@ClearSystemProperty(key = "mp.messaging.outgoing.processedtravellers.topic")
@ClearSystemProperty(key = "mp.messaging.incoming.kogito_incoming_stream.connector")
@ClearSystemProperty(key = "mp.messaging.incoming.kogito_incoming_stream.topic")
void verifyTopicsWithPropertiesAndChannels() {
    final TopicDiscovery discovery = new QuarkusTopicDiscovery();
    final List<Topic> topics = discovery.getTopics(Collections.emptyList());
    assertThat(topics).isEmpty();
}
Also used : TopicDiscovery(org.kie.kogito.event.TopicDiscovery) AbstractTopicDiscovery(org.kie.kogito.addon.cloudevents.AbstractTopicDiscovery) Topic(org.kie.kogito.event.Topic) Test(org.junit.jupiter.api.Test) ClearSystemProperty(org.junitpioneer.jupiter.ClearSystemProperty)

Example 2 with TopicDiscovery

use of org.kie.kogito.event.TopicDiscovery in project kogito-runtimes by kiegroup.

the class QuarkusTopicDiscoveryTest method verifyTopicsWithPropertiesSet.

@Test
@SetSystemProperty(key = "mp.messaging.outgoing.processedtravellers.connector", value = "quarkus-http")
@SetSystemProperty(key = "mp.messaging.outgoing.processedtravellers.url", value = "http://localhost:8080/")
@SetSystemProperty(key = "mp.messaging.incoming.kogito_incoming_stream.connector", value = "smallrye-kafka")
@SetSystemProperty(key = "mp.messaging.incoming.kogito_incoming_stream.topic", value = "mycooltopic")
void verifyTopicsWithPropertiesSet() {
    final List<Topic> expectedTopics = new ArrayList<>();
    expectedTopics.add(new Topic("processedtravellers", ChannelType.OUTGOING));
    expectedTopics.add(new Topic("mycooltopic", ChannelType.INCOMING));
    final TopicDiscovery discovery = new QuarkusTopicDiscovery();
    final List<Topic> topics = discovery.getTopics(Collections.emptyList());
    assertThat(topics).hasSize(2);
    expectedTopics.forEach(e -> assertThat(topics.stream().anyMatch(t -> t.getName().equals(e.getName()) && t.getType() == e.getType())).isTrue());
}
Also used : Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) TopicDiscovery(org.kie.kogito.event.TopicDiscovery) SetSystemProperty(org.junitpioneer.jupiter.SetSystemProperty) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test) List(java.util.List) EventKind(org.kie.kogito.event.EventKind) CloudEventMeta(org.kie.kogito.event.cloudevents.CloudEventMeta) ChannelType(org.kie.kogito.event.ChannelType) Topic(org.kie.kogito.event.Topic) AbstractTopicDiscovery(org.kie.kogito.addon.cloudevents.AbstractTopicDiscovery) ClearSystemProperty(org.junitpioneer.jupiter.ClearSystemProperty) Collections(java.util.Collections) ArrayList(java.util.ArrayList) TopicDiscovery(org.kie.kogito.event.TopicDiscovery) AbstractTopicDiscovery(org.kie.kogito.addon.cloudevents.AbstractTopicDiscovery) Topic(org.kie.kogito.event.Topic) SetSystemProperty(org.junitpioneer.jupiter.SetSystemProperty) Test(org.junit.jupiter.api.Test)

Example 3 with TopicDiscovery

use of org.kie.kogito.event.TopicDiscovery in project kogito-runtimes by kiegroup.

the class QuarkusTopicDiscoveryTest method verifyTopicsWithNoPropertiesSet.

@Test
@ClearSystemProperty(key = "mp.messaging.outgoing.processedtravellers.connector")
@ClearSystemProperty(key = "mp.messaging.outgoing.processedtravellers.url")
@ClearSystemProperty(key = "mp.messaging.outgoing.processedtravellers.topic")
@ClearSystemProperty(key = "mp.messaging.incoming.kogito_incoming_stream.connector")
@ClearSystemProperty(key = "mp.messaging.incoming.kogito_incoming_stream.topic")
void verifyTopicsWithNoPropertiesSet() {
    final List<Topic> expectedTopics = new ArrayList<>();
    expectedTopics.add(AbstractTopicDiscovery.DEFAULT_OUTGOING_CHANNEL);
    expectedTopics.add(AbstractTopicDiscovery.DEFAULT_INCOMING_CHANNEL);
    final List<CloudEventMeta> eventsMeta = new ArrayList<>();
    eventsMeta.add(new CloudEventMeta("event1", "", EventKind.CONSUMED));
    eventsMeta.add(new CloudEventMeta("event2", "", EventKind.PRODUCED));
    final TopicDiscovery discovery = new QuarkusTopicDiscovery();
    final List<Topic> topics = discovery.getTopics(eventsMeta);
    assertThat(topics).hasSize(2);
    expectedTopics.forEach(e -> assertThat(topics.stream().anyMatch(t -> t.getName().equals(e.getName()) && t.getType() == e.getType())).isTrue());
}
Also used : Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) TopicDiscovery(org.kie.kogito.event.TopicDiscovery) SetSystemProperty(org.junitpioneer.jupiter.SetSystemProperty) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test) List(java.util.List) EventKind(org.kie.kogito.event.EventKind) CloudEventMeta(org.kie.kogito.event.cloudevents.CloudEventMeta) ChannelType(org.kie.kogito.event.ChannelType) Topic(org.kie.kogito.event.Topic) AbstractTopicDiscovery(org.kie.kogito.addon.cloudevents.AbstractTopicDiscovery) ClearSystemProperty(org.junitpioneer.jupiter.ClearSystemProperty) Collections(java.util.Collections) CloudEventMeta(org.kie.kogito.event.cloudevents.CloudEventMeta) ArrayList(java.util.ArrayList) TopicDiscovery(org.kie.kogito.event.TopicDiscovery) AbstractTopicDiscovery(org.kie.kogito.addon.cloudevents.AbstractTopicDiscovery) Topic(org.kie.kogito.event.Topic) Test(org.junit.jupiter.api.Test) ClearSystemProperty(org.junitpioneer.jupiter.ClearSystemProperty)

Example 4 with TopicDiscovery

use of org.kie.kogito.event.TopicDiscovery in project kogito-runtimes by kiegroup.

the class QuarkusTopicDiscoveryTest method verifyTopicsWithPropertiesSameTopic.

@Test
@SetSystemProperty(key = "mp.messaging.outgoing.processedtravellers.connector", value = "quarkus-http")
@SetSystemProperty(key = "mp.messaging.outgoing.processedtravellers.url", value = "http://localhost:8080/")
@SetSystemProperty(key = "mp.messaging.outgoing.processedtravellers.topic", value = "mycooltopic")
@SetSystemProperty(key = "mp.messaging.incoming.kogito_incoming_stream.connector", value = "smallrye-kafka")
@SetSystemProperty(key = "mp.messaging.incoming.kogito_incoming_stream.topic", value = "mycooltopic")
void verifyTopicsWithPropertiesSameTopic() {
    final List<Topic> expectedTopics = new ArrayList<>();
    expectedTopics.add(new Topic("mycooltopic", ChannelType.OUTGOING));
    expectedTopics.add(new Topic("mycooltopic", ChannelType.INCOMING));
    final TopicDiscovery discovery = new QuarkusTopicDiscovery();
    final List<Topic> topics = discovery.getTopics(Collections.emptyList());
    assertThat(topics).hasSize(2);
    expectedTopics.forEach(e -> assertThat(topics.stream().anyMatch(t -> t.getName().equals(e.getName()) && t.getType() == e.getType())).isTrue());
}
Also used : Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) TopicDiscovery(org.kie.kogito.event.TopicDiscovery) SetSystemProperty(org.junitpioneer.jupiter.SetSystemProperty) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test) List(java.util.List) EventKind(org.kie.kogito.event.EventKind) CloudEventMeta(org.kie.kogito.event.cloudevents.CloudEventMeta) ChannelType(org.kie.kogito.event.ChannelType) Topic(org.kie.kogito.event.Topic) AbstractTopicDiscovery(org.kie.kogito.addon.cloudevents.AbstractTopicDiscovery) ClearSystemProperty(org.junitpioneer.jupiter.ClearSystemProperty) Collections(java.util.Collections) ArrayList(java.util.ArrayList) TopicDiscovery(org.kie.kogito.event.TopicDiscovery) AbstractTopicDiscovery(org.kie.kogito.addon.cloudevents.AbstractTopicDiscovery) Topic(org.kie.kogito.event.Topic) SetSystemProperty(org.junitpioneer.jupiter.SetSystemProperty) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)4 ClearSystemProperty (org.junitpioneer.jupiter.ClearSystemProperty)4 AbstractTopicDiscovery (org.kie.kogito.addon.cloudevents.AbstractTopicDiscovery)4 Topic (org.kie.kogito.event.Topic)4 TopicDiscovery (org.kie.kogito.event.TopicDiscovery)4 ArrayList (java.util.ArrayList)3 Collections (java.util.Collections)3 List (java.util.List)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 SetSystemProperty (org.junitpioneer.jupiter.SetSystemProperty)3 ChannelType (org.kie.kogito.event.ChannelType)3 EventKind (org.kie.kogito.event.EventKind)3 CloudEventMeta (org.kie.kogito.event.cloudevents.CloudEventMeta)3