Search in sources :

Example 6 with ProcessorDTO

use of com.redhat.service.smartevents.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class KafkaTopicActionInvokerTest method onEvent.

@Test
void onEvent() {
    ArgumentCaptor<Message<String>> captor = ArgumentCaptor.forClass(Message.class);
    Emitter<String> emitter = mock(Emitter.class);
    String event = "{\"key\": \"value\"}";
    String topic = "myTestTopic";
    ProcessorDTO processor = createProcessor();
    KafkaTopicActionInvoker invoker = new KafkaTopicActionInvoker(emitter, processor, topic);
    invoker.onEvent(event, Collections.emptyMap());
    verify(emitter).send(captor.capture());
    Message<String> sent = captor.getValue();
    assertThat(sent.getPayload()).isEqualTo(event);
    Metadata metadata = sent.getMetadata();
    OutgoingKafkaRecordMetadata recordMetadata = metadata.get(OutgoingKafkaRecordMetadata.class).get();
    assertThat(recordMetadata.getTopic()).isEqualTo(topic);
}
Also used : Message(org.eclipse.microprofile.reactive.messaging.Message) ProcessorDTO(com.redhat.service.smartevents.infra.models.dto.ProcessorDTO) OutgoingKafkaRecordMetadata(io.smallrye.reactive.messaging.kafka.api.OutgoingKafkaRecordMetadata) Metadata(org.eclipse.microprofile.reactive.messaging.Metadata) OutgoingKafkaRecordMetadata(io.smallrye.reactive.messaging.kafka.api.OutgoingKafkaRecordMetadata) Test(org.junit.jupiter.api.Test)

Example 7 with ProcessorDTO

use of com.redhat.service.smartevents.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class KafkaTopicActionInvokerTest method createProcessor.

private ProcessorDTO createProcessor() {
    ProcessorDTO p = new ProcessorDTO();
    p.setType(ProcessorType.SINK);
    p.setId("myProcessor");
    p.setBridgeId("myBridge");
    return p;
}
Also used : ProcessorDTO(com.redhat.service.smartevents.infra.models.dto.ProcessorDTO)

Example 8 with ProcessorDTO

use of com.redhat.service.smartevents.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class WebhookActionInvokerBuilderTest method testInvokerWithBasicAuth.

@Test
void testInvokerWithBasicAuth() {
    ProcessorDTO processor = createProcessor();
    processor.getDefinition().getResolvedAction().getParameters().put(BASIC_AUTH_USERNAME_PARAM, TEST_USERNAME);
    processor.getDefinition().getResolvedAction().getParameters().put(BASIC_AUTH_PASSWORD_PARAM, TEST_PASSWORD);
    ActionInvoker actionInvoker = builder.build(processor, processor.getDefinition().getResolvedAction());
    assertThat(actionInvoker).isNotNull().isInstanceOf(WebhookActionInvoker.class);
    WebhookActionInvoker webhookActionInvoker = (WebhookActionInvoker) actionInvoker;
    assertThat(webhookActionInvoker.getEndpoint()).isEqualTo(TEST_ENDPOINT);
    assertThat(webhookActionInvoker.getWebClient()).isNotNull();
    assertThat(webhookActionInvoker.getOidcClient()).isNull();
    assertThat(webhookActionInvoker.getBasicAuthUsername()).isEqualTo(TEST_USERNAME);
    assertThat(webhookActionInvoker.getBasicAuthPassword()).isEqualTo(TEST_PASSWORD);
}
Also used : ActionInvoker(com.redhat.service.smartevents.processor.actions.ActionInvoker) ProcessorDTO(com.redhat.service.smartevents.infra.models.dto.ProcessorDTO) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 9 with ProcessorDTO

use of com.redhat.service.smartevents.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class WebhookActionInvokerBuilderTest method testInvokerWithSslVerificationDisabled.

@Test
void testInvokerWithSslVerificationDisabled() {
    ProcessorDTO processor = createProcessor();
    processor.getDefinition().getResolvedAction().getParameters().put(SSL_VERIFICATION_DISABLED, "true");
    ActionInvoker actionInvoker = builder.build(processor, processor.getDefinition().getResolvedAction());
    assertThat(actionInvoker).isNotNull().isInstanceOf(WebhookActionInvoker.class);
    WebhookActionInvoker webhookActionInvoker = (WebhookActionInvoker) actionInvoker;
    assertThat(webhookActionInvoker.getEndpoint()).isEqualTo(TEST_ENDPOINT);
    assertThat(webhookActionInvoker.getWebClient()).isNotNull();
    assertThat(webhookActionInvoker.getOidcClient()).isNull();
    assertThat(webhookActionInvoker.getBasicAuthUsername()).isNull();
    assertThat(webhookActionInvoker.getBasicAuthPassword()).isNull();
}
Also used : ActionInvoker(com.redhat.service.smartevents.processor.actions.ActionInvoker) ProcessorDTO(com.redhat.service.smartevents.infra.models.dto.ProcessorDTO) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 10 with ProcessorDTO

use of com.redhat.service.smartevents.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class WebhookActionInvokerBuilderTest method createProcessor.

private ProcessorDTO createProcessor() {
    Action action = new Action();
    action.setType(WebhookAction.TYPE);
    Map<String, String> params = new HashMap<>();
    params.put(ENDPOINT_PARAM, TEST_ENDPOINT);
    action.setMapParameters(params);
    ProcessorDTO processor = new ProcessorDTO();
    processor.setType(ProcessorType.SINK);
    processor.setId("myProcessor");
    processor.setDefinition(new ProcessorDefinition(null, null, action));
    processor.setBridgeId("myBridge");
    return processor;
}
Also used : Action(com.redhat.service.smartevents.infra.models.gateways.Action) HashMap(java.util.HashMap) ProcessorDTO(com.redhat.service.smartevents.infra.models.dto.ProcessorDTO) ProcessorDefinition(com.redhat.service.smartevents.infra.models.processors.ProcessorDefinition)

Aggregations

ProcessorDTO (com.redhat.service.smartevents.infra.models.dto.ProcessorDTO)33 Test (org.junit.jupiter.api.Test)24 QuarkusTest (io.quarkus.test.junit.QuarkusTest)22 BridgeDTO (com.redhat.service.smartevents.infra.models.dto.BridgeDTO)5 TestSecurity (io.quarkus.test.security.TestSecurity)5 KafkaConnectionDTO (com.redhat.service.smartevents.infra.models.dto.KafkaConnectionDTO)4 Action (com.redhat.service.smartevents.infra.models.gateways.Action)4 ProcessorDefinition (com.redhat.service.smartevents.infra.models.processors.ProcessorDefinition)4 BridgeRequest (com.redhat.service.smartevents.manager.api.models.requests.BridgeRequest)4 ProcessorRequest (com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest)4 BridgeResponse (com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse)4 ActionInvoker (com.redhat.service.smartevents.processor.actions.ActionInvoker)4 TypeRef (io.restassured.common.mapper.TypeRef)4 ArrayList (java.util.ArrayList)4 CountDownLatch (java.util.concurrent.CountDownLatch)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 BaseFilter (com.redhat.service.smartevents.infra.models.filters.BaseFilter)3 StringEquals (com.redhat.service.smartevents.infra.models.filters.StringEquals)3 HashMap (java.util.HashMap)3 ItemNotFoundException (com.redhat.service.smartevents.infra.exceptions.definitions.user.ItemNotFoundException)2