use of com.redhat.service.bridge.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class KafkaTopicActionTest method createProcessorWithActionForTopic.
private ProcessorDTO createProcessorWithActionForTopic(String topicName) {
BaseAction b = new BaseAction();
b.setType(KafkaTopicAction.TYPE);
Map<String, String> params = new HashMap<>();
params.put(KafkaTopicAction.TOPIC_PARAM, topicName);
b.setParameters(params);
ProcessorDTO p = new ProcessorDTO();
p.setId("myProcessor");
p.setDefinition(new ProcessorDefinition(null, null, b));
p.setBridgeId("myBridge");
return p;
}
use of com.redhat.service.bridge.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class KafkaTopicActionValidatorTest method isValid.
@Test
public void isValid() {
ProcessorDTO processor = createProcessorWithActionForTopic("myTopic");
assertThat(validator.isValid(processor.getDefinition().getResolvedAction()).isValid()).isTrue();
}
use of com.redhat.service.bridge.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class KafkaTopicActionValidatorTest method isValid_noTopicIsNotValid.
@Test
public void isValid_noTopicIsNotValid() {
ProcessorDTO processor = createProcessorWithActionForTopic("myTopic");
processor.getDefinition().getResolvedAction().getParameters().remove(KafkaTopicAction.TOPIC_PARAM);
ValidationResult validationResult = validator.isValid(processor.getDefinition().getResolvedAction());
assertThat(validationResult.isValid()).isFalse();
assertThat(validationResult.getMessage()).isEqualTo(KafkaTopicActionValidator.INVALID_TOPIC_PARAM_MESSAGE);
}
use of com.redhat.service.bridge.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class KafkaTopicInvokerTest method onEvent.
@Test
public 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();
KafkaTopicInvoker invoker = new KafkaTopicInvoker(emitter, processor, topic);
invoker.onEvent(event);
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.bridge.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class WebhookActionTest method testInvokerOk.
@Test
void testInvokerOk() {
ProcessorDTO processor = createProcessorWithActionForEndpoint("http://www.example.com/webhook");
ActionInvoker actionInvoker = webhookAction.getActionInvoker(processor, processor.getDefinition().getResolvedAction());
assertThat(actionInvoker).isNotNull().isInstanceOf(WebhookInvoker.class);
}
Aggregations