Search in sources :

Example 1 with CloudEventMeta

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

the class TopicInformationResourceIT method verifyTopicsInformation.

@Test
void verifyTopicsInformation() {
    final List<Topic> topics = Arrays.asList(given().get("/messaging/topics").as(Topic[].class));
    LOGGER.info("Topics registered in the service are {}", topics);
    assertThat(topics).isNotEmpty();
    assertThat(topics.stream().anyMatch(t -> t.getType() == ChannelType.INCOMING && t.getName().equals("kogito_it_test") && t.getEventsMeta().contains(new CloudEventMeta("pong_end", "", EventKind.CONSUMED)))).isTrue();
}
Also used : CloudEventMeta(org.kie.kogito.event.cloudevents.CloudEventMeta) Topic(org.kie.kogito.event.Topic) Test(org.junit.jupiter.api.Test) QuarkusIntegrationTest(io.quarkus.test.junit.QuarkusIntegrationTest)

Example 2 with CloudEventMeta

use of org.kie.kogito.event.cloudevents.CloudEventMeta 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 3 with CloudEventMeta

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

the class KogitoAddOnKnativeEventingProcessorTest method checkKogitoFileIsGeneratedWithDefaultConfig.

@Test
void checkKogitoFileIsGeneratedWithDefaultConfig() {
    final OutputTargetBuildItem outputTargetBuildItem = new OutputTargetBuildItem(Paths.get("/"), "", false, null, Optional.empty());
    final Set<CloudEventMeta> ces = new HashSet<>();
    ces.add(new CloudEventMeta("myProducedEvent", "/local/test", EventKind.PRODUCED));
    ces.add(new CloudEventMeta("myConsumedEvent", "/local/test", EventKind.CONSUMED));
    final KogitoServiceDeploymentTarget deploymentTarget = new KogitoServiceDeploymentTarget("apps", "v1", "Deployment", "kogito-service");
    final KogitoKnativeResourcesMetadataBuildItem resourcesMetadataBuildItem = new KogitoKnativeResourcesMetadataBuildItem(ces, deploymentTarget);
    final KogitoAddOnKnativeEventingProcessor eventingProcessor = buildTestProcessorWithDefaultConfig();
    final MockGeneratedFSProducer producer = new MockGeneratedFSProducer();
    eventingProcessor.generate(outputTargetBuildItem, Optional.of(resourcesMetadataBuildItem), producer);
    assertNotNull(producer.getItem().getData());
    assertTrue(producer.getItem().getData().length > 0);
    assertTrue(new String(producer.getItem().getData()).contains("SinkBinding"));
    assertFalse(new String(producer.getItem().getData()).contains("KogitoSource"));
    assertTrue(new String(producer.getItem().getData()).contains("Trigger"));
    assertTrue(new String(producer.getItem().getData()).contains("Broker"));
}
Also used : CloudEventMeta(org.kie.kogito.event.cloudevents.CloudEventMeta) OutputTargetBuildItem(io.quarkus.deployment.pkg.builditem.OutputTargetBuildItem) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 4 with CloudEventMeta

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

the class KogitoAddOnKnativeEventingProcessorTest method checkKogitoFileIsGeneratedWithKogitoSource.

@Test
void checkKogitoFileIsGeneratedWithKogitoSource() {
    final OutputTargetBuildItem outputTargetBuildItem = new OutputTargetBuildItem(Paths.get("/"), "", false, null, Optional.empty());
    final Set<CloudEventMeta> ces = new HashSet<>();
    ces.add(new CloudEventMeta("myProducedEvent", "/local/test", EventKind.PRODUCED));
    final KogitoServiceDeploymentTarget deploymentTarget = new KogitoServiceDeploymentTarget("apps", "v1", "Deployment", "kogito-service");
    final KogitoKnativeResourcesMetadataBuildItem resourcesMetadataBuildItem = new KogitoKnativeResourcesMetadataBuildItem(ces, deploymentTarget);
    final KogitoAddOnKnativeEventingProcessor eventingProcessor = buildTestProcessorWithDefaultConfig();
    eventingProcessor.config.generateKogitoSource = true;
    final MockGeneratedFSProducer producer = new MockGeneratedFSProducer();
    eventingProcessor.generate(outputTargetBuildItem, Optional.of(resourcesMetadataBuildItem), producer);
    assertNotNull(producer.getItem().getData());
    assertTrue(producer.getItem().getData().length > 0);
    assertFalse(new String(producer.getItem().getData()).contains("SinkBinding"));
    assertTrue(new String(producer.getItem().getData()).contains("KogitoSource"));
    assertFalse(new String(producer.getItem().getData()).contains("Trigger"));
    assertTrue(new String(producer.getItem().getData()).contains("Broker"));
}
Also used : CloudEventMeta(org.kie.kogito.event.cloudevents.CloudEventMeta) OutputTargetBuildItem(io.quarkus.deployment.pkg.builditem.OutputTargetBuildItem) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 5 with CloudEventMeta

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

the class KogitoAddOnKnativeEventingProcessorTest method checkKogitoFileIsGeneratedOnlyProduced.

@Test
void checkKogitoFileIsGeneratedOnlyProduced() {
    final OutputTargetBuildItem outputTargetBuildItem = new OutputTargetBuildItem(Paths.get("/"), "", false, null, Optional.empty());
    final Set<CloudEventMeta> ces = new HashSet<>();
    ces.add(new CloudEventMeta("myProducedEvent", "/local/test", EventKind.PRODUCED));
    final KogitoServiceDeploymentTarget deploymentTarget = new KogitoServiceDeploymentTarget("apps", "v1", "Deployment", "kogito-service");
    final KogitoKnativeResourcesMetadataBuildItem resourcesMetadataBuildItem = new KogitoKnativeResourcesMetadataBuildItem(ces, deploymentTarget);
    final KogitoAddOnKnativeEventingProcessor eventingProcessor = buildTestProcessorWithDefaultConfig();
    final MockGeneratedFSProducer producer = new MockGeneratedFSProducer();
    eventingProcessor.generate(outputTargetBuildItem, Optional.of(resourcesMetadataBuildItem), producer);
    assertNotNull(producer.getItem().getData());
    assertTrue(producer.getItem().getData().length > 0);
    assertTrue(new String(producer.getItem().getData()).contains("SinkBinding"));
    assertFalse(new String(producer.getItem().getData()).contains("KogitoSource"));
    assertFalse(new String(producer.getItem().getData()).contains("Trigger"));
    assertTrue(new String(producer.getItem().getData()).contains("Broker"));
}
Also used : CloudEventMeta(org.kie.kogito.event.cloudevents.CloudEventMeta) OutputTargetBuildItem(io.quarkus.deployment.pkg.builditem.OutputTargetBuildItem) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)8 CloudEventMeta (org.kie.kogito.event.cloudevents.CloudEventMeta)8 OutputTargetBuildItem (io.quarkus.deployment.pkg.builditem.OutputTargetBuildItem)5 HashSet (java.util.HashSet)5 List (java.util.List)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 EventKind (org.kie.kogito.event.EventKind)2 Topic (org.kie.kogito.event.Topic)2 StaticJavaParser (com.github.javaparser.StaticJavaParser)1 CompilationUnit (com.github.javaparser.ast.CompilationUnit)1 ClassOrInterfaceDeclaration (com.github.javaparser.ast.body.ClassOrInterfaceDeclaration)1 MethodDeclaration (com.github.javaparser.ast.body.MethodDeclaration)1 Expression (com.github.javaparser.ast.expr.Expression)1 ObjectCreationExpr (com.github.javaparser.ast.expr.ObjectCreationExpr)1 BlockStmt (com.github.javaparser.ast.stmt.BlockStmt)1 ReturnStmt (com.github.javaparser.ast.stmt.ReturnStmt)1 Statement (com.github.javaparser.ast.stmt.Statement)1 QuarkusIntegrationTest (io.quarkus.test.junit.QuarkusIntegrationTest)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1