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);
}
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;
}
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);
}
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();
}
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;
}
Aggregations