Search in sources :

Example 1 with ProcessorDefinition

use of com.redhat.service.bridge.infra.models.processors.ProcessorDefinition 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;
}
Also used : HashMap(java.util.HashMap) ProcessorDTO(com.redhat.service.bridge.infra.models.dto.ProcessorDTO) ProcessorDefinition(com.redhat.service.bridge.infra.models.processors.ProcessorDefinition) BaseAction(com.redhat.service.bridge.infra.models.actions.BaseAction)

Example 2 with ProcessorDefinition

use of com.redhat.service.bridge.infra.models.processors.ProcessorDefinition in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class WebhookActionTest method createProcessorWithParameterlessAction.

private ProcessorDTO createProcessorWithParameterlessAction() {
    BaseAction action = new BaseAction();
    action.setType(WebhookAction.TYPE);
    Map<String, String> params = new HashMap<>();
    action.setParameters(params);
    ProcessorDTO processor = new ProcessorDTO();
    processor.setId("myProcessor");
    processor.setDefinition(new ProcessorDefinition(null, null, action));
    processor.setBridgeId("myBridge");
    return processor;
}
Also used : HashMap(java.util.HashMap) ProcessorDTO(com.redhat.service.bridge.infra.models.dto.ProcessorDTO) ProcessorDefinition(com.redhat.service.bridge.infra.models.processors.ProcessorDefinition) BaseAction(com.redhat.service.bridge.infra.models.actions.BaseAction)

Example 3 with ProcessorDefinition

use of com.redhat.service.bridge.infra.models.processors.ProcessorDefinition in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ExecutorTest method testOnEventWithNoMatchingFilters.

@Test
public void testOnEventWithNoMatchingFilters() throws JsonProcessingException {
    Set<BaseFilter> filters = new HashSet<>();
    filters.add(new StringEquals("data.key", "notTheValue"));
    BaseAction action = new BaseAction();
    action.setType(KafkaTopicAction.TYPE);
    ProcessorDTO processorDTO = createProcessor(new ProcessorDefinition(filters, null, action));
    Executor executor = new Executor(processorDTO, filterEvaluatorFactory, transformationEvaluatorFactory, actionProviderFactoryMock, meterRegistry);
    CloudEvent cloudEvent = createCloudEvent();
    executor.onEvent(cloudEvent);
    verify(actionInvokerMock, never()).onEvent(any());
}
Also used : StringEquals(com.redhat.service.bridge.infra.models.filters.StringEquals) ProcessorDTO(com.redhat.service.bridge.infra.models.dto.ProcessorDTO) ProcessorDefinition(com.redhat.service.bridge.infra.models.processors.ProcessorDefinition) BaseAction(com.redhat.service.bridge.infra.models.actions.BaseAction) BaseFilter(com.redhat.service.bridge.infra.models.filters.BaseFilter) CloudEvent(io.cloudevents.CloudEvent) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 4 with ProcessorDefinition

use of com.redhat.service.bridge.infra.models.processors.ProcessorDefinition in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ExecutorTest method testOnEventWithFiltersTransformationAndDifferentRequestedResolvedActions.

@Test
public void testOnEventWithFiltersTransformationAndDifferentRequestedResolvedActions() throws JsonProcessingException {
    Set<BaseFilter> filters = new HashSet<>();
    filters.add(new StringEquals("data.key", "value"));
    String transformationTemplate = "{\"test\": \"{data.key}\"}";
    BaseAction requestedAction = new BaseAction();
    requestedAction.setType("SendToBridge");
    BaseAction resolvedAction = new BaseAction();
    resolvedAction.setType(WebhookAction.TYPE);
    ProcessorDTO processorDTO = createProcessor(new ProcessorDefinition(filters, transformationTemplate, requestedAction, resolvedAction));
    Executor executor = new Executor(processorDTO, filterEvaluatorFactory, transformationEvaluatorFactory, actionProviderFactoryMock, meterRegistry);
    CloudEvent cloudEvent = createCloudEvent();
    executor.onEvent(cloudEvent);
    verify(actionProviderFactoryMock).getInvokableActionProvider(WebhookAction.TYPE);
    verify(actionInvokerMock, times(1)).onEvent(any());
}
Also used : StringEquals(com.redhat.service.bridge.infra.models.filters.StringEquals) ProcessorDTO(com.redhat.service.bridge.infra.models.dto.ProcessorDTO) ProcessorDefinition(com.redhat.service.bridge.infra.models.processors.ProcessorDefinition) BaseAction(com.redhat.service.bridge.infra.models.actions.BaseAction) BaseFilter(com.redhat.service.bridge.infra.models.filters.BaseFilter) CloudEvent(io.cloudevents.CloudEvent) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 5 with ProcessorDefinition

use of com.redhat.service.bridge.infra.models.processors.ProcessorDefinition in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ExecutorTest method testOnEventWithFiltersTransformationAndSameRequestedResolvedActions.

@Test
public void testOnEventWithFiltersTransformationAndSameRequestedResolvedActions() throws JsonProcessingException {
    Set<BaseFilter> filters = new HashSet<>();
    filters.add(new StringEquals("data.key", "value"));
    String transformationTemplate = "{\"test\": \"{data.key}\"}";
    BaseAction action = new BaseAction();
    action.setType(KafkaTopicAction.TYPE);
    ProcessorDTO processorDTO = createProcessor(new ProcessorDefinition(filters, transformationTemplate, action));
    Executor executor = new Executor(processorDTO, filterEvaluatorFactory, transformationEvaluatorFactory, actionProviderFactoryMock, meterRegistry);
    CloudEvent cloudEvent = createCloudEvent();
    executor.onEvent(cloudEvent);
    verify(actionProviderFactoryMock).getInvokableActionProvider(KafkaTopicAction.TYPE);
    verify(actionInvokerMock).onEvent(any());
}
Also used : StringEquals(com.redhat.service.bridge.infra.models.filters.StringEquals) ProcessorDTO(com.redhat.service.bridge.infra.models.dto.ProcessorDTO) ProcessorDefinition(com.redhat.service.bridge.infra.models.processors.ProcessorDefinition) BaseAction(com.redhat.service.bridge.infra.models.actions.BaseAction) BaseFilter(com.redhat.service.bridge.infra.models.filters.BaseFilter) CloudEvent(io.cloudevents.CloudEvent) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Aggregations

ProcessorDefinition (com.redhat.service.bridge.infra.models.processors.ProcessorDefinition)16 BaseAction (com.redhat.service.bridge.infra.models.actions.BaseAction)13 ProcessorDTO (com.redhat.service.bridge.infra.models.dto.ProcessorDTO)10 BaseFilter (com.redhat.service.bridge.infra.models.filters.BaseFilter)7 Test (org.junit.jupiter.api.Test)7 StringEquals (com.redhat.service.bridge.infra.models.filters.StringEquals)6 HashMap (java.util.HashMap)6 HashSet (java.util.HashSet)6 Processor (com.redhat.service.bridge.manager.models.Processor)5 CloudEvent (io.cloudevents.CloudEvent)5 Bridge (com.redhat.service.bridge.manager.models.Bridge)3 ProcessorResponse (com.redhat.service.bridge.manager.api.models.responses.ProcessorResponse)2 QuarkusTest (io.quarkus.test.junit.QuarkusTest)2 ActionProvider (com.redhat.service.bridge.actions.ActionProvider)1 AlreadyExistingItemException (com.redhat.service.bridge.infra.exceptions.definitions.user.AlreadyExistingItemException)1 KafkaConnectionDTO (com.redhat.service.bridge.infra.models.dto.KafkaConnectionDTO)1 ProcessorRequest (com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest)1