Search in sources :

Example 1 with BaseAction

use of com.redhat.service.bridge.infra.models.actions.BaseAction 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 BaseAction

use of com.redhat.service.bridge.infra.models.actions.BaseAction 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 BaseAction

use of com.redhat.service.bridge.infra.models.actions.BaseAction in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class WebhookActionValidatorTest method assertIsValid.

private void assertIsValid(String endpoint) {
    BaseAction action = createActionWithEndpoint(endpoint);
    ValidationResult validationResult = validator.isValid(action);
    assertThat(validationResult.isValid()).isTrue();
}
Also used : BaseAction(com.redhat.service.bridge.infra.models.actions.BaseAction) ValidationResult(com.redhat.service.bridge.actions.ValidationResult)

Example 4 with BaseAction

use of com.redhat.service.bridge.infra.models.actions.BaseAction in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class WebhookActionValidatorTest method assertIsInvalid.

private void assertIsInvalid(String endpoint, String errorMessage, Map<String, String> params) {
    BaseAction action = createActionWithEndpoint(endpoint);
    params.forEach((k, v) -> action.getParameters().put(k, v));
    ValidationResult validationResult = validator.isValid(action);
    assertThat(validationResult.isValid()).isFalse();
    assertThat(validationResult.getMessage()).startsWith(errorMessage);
}
Also used : BaseAction(com.redhat.service.bridge.infra.models.actions.BaseAction) ValidationResult(com.redhat.service.bridge.actions.ValidationResult)

Example 5 with BaseAction

use of com.redhat.service.bridge.infra.models.actions.BaseAction 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)

Aggregations

BaseAction (com.redhat.service.bridge.infra.models.actions.BaseAction)48 Test (org.junit.jupiter.api.Test)20 QuarkusTest (io.quarkus.test.junit.QuarkusTest)15 ProcessorDefinition (com.redhat.service.bridge.infra.models.processors.ProcessorDefinition)13 HashMap (java.util.HashMap)13 ProcessorDTO (com.redhat.service.bridge.infra.models.dto.ProcessorDTO)10 BaseFilter (com.redhat.service.bridge.infra.models.filters.BaseFilter)10 StringEquals (com.redhat.service.bridge.infra.models.filters.StringEquals)9 ProcessorRequest (com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest)9 Processor (com.redhat.service.bridge.manager.models.Processor)7 Bridge (com.redhat.service.bridge.manager.models.Bridge)6 HashSet (java.util.HashSet)6 CloudEvent (io.cloudevents.CloudEvent)5 ProcessorResponse (com.redhat.service.bridge.manager.api.models.responses.ProcessorResponse)4 ValidationResult (com.redhat.service.bridge.actions.ValidationResult)3 BridgeResponse (com.redhat.service.bridge.manager.api.models.responses.BridgeResponse)3 TestSecurity (io.quarkus.test.security.TestSecurity)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 Connector (com.openshift.cloud.api.connector.models.Connector)2 ConnectorRequest (com.openshift.cloud.api.connector.models.ConnectorRequest)2