Search in sources :

Example 1 with StringEquals

use of com.redhat.service.bridge.infra.models.filters.StringEquals 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 2 with StringEquals

use of com.redhat.service.bridge.infra.models.filters.StringEquals 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 3 with StringEquals

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

Example 4 with StringEquals

use of com.redhat.service.bridge.infra.models.filters.StringEquals in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ExecutorTest method testOnEventWithNullTemplate.

@Test
public void testOnEventWithNullTemplate() throws JsonProcessingException {
    Set<BaseFilter> filters = new HashSet<>();
    filters.add(new StringEquals("data.key", "value"));
    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(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)

Example 5 with StringEquals

use of com.redhat.service.bridge.infra.models.filters.StringEquals in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorServiceTest method testMGDOBR_80.

@Test
public void testMGDOBR_80() {
    Bridge b = createPersistBridge(ManagedResourceStatus.READY);
    Set<BaseFilter> filters = new HashSet<>();
    filters.add(new StringEquals("name", "myName"));
    filters.add(new StringEquals("surename", "mySurename"));
    ProcessorRequest r = new ProcessorRequest("My Processor", filters, null, createKafkaAction());
    Processor processor = processorService.createProcessor(b.getId(), b.getCustomerId(), r);
    await().atMost(5, SECONDS).untilAsserted(() -> {
        Processor p = processorDAO.findById(processor.getId());
        assertThat(p).isNotNull();
        assertThat(p.getDependencyStatus()).isEqualTo(ManagedResourceStatus.READY);
    });
    assertThat(processorService.getProcessors(b.getId(), TestConstants.DEFAULT_CUSTOMER_ID, new QueryInfo(0, 100)).getSize()).isEqualTo(1);
}
Also used : StringEquals(com.redhat.service.bridge.infra.models.filters.StringEquals) Processor(com.redhat.service.bridge.manager.models.Processor) ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) QueryInfo(com.redhat.service.bridge.infra.models.QueryInfo) Bridge(com.redhat.service.bridge.manager.models.Bridge) BaseFilter(com.redhat.service.bridge.infra.models.filters.BaseFilter) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Aggregations

StringEquals (com.redhat.service.bridge.infra.models.filters.StringEquals)15 BaseFilter (com.redhat.service.bridge.infra.models.filters.BaseFilter)14 Test (org.junit.jupiter.api.Test)14 BaseAction (com.redhat.service.bridge.infra.models.actions.BaseAction)9 ProcessorDTO (com.redhat.service.bridge.infra.models.dto.ProcessorDTO)8 ProcessorRequest (com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest)8 QuarkusTest (io.quarkus.test.junit.QuarkusTest)8 BridgeResponse (com.redhat.service.bridge.manager.api.models.responses.BridgeResponse)7 TestSecurity (io.quarkus.test.security.TestSecurity)7 HashSet (java.util.HashSet)7 ProcessorDefinition (com.redhat.service.bridge.infra.models.processors.ProcessorDefinition)6 ProcessorListResponse (com.redhat.service.bridge.manager.api.models.responses.ProcessorListResponse)5 ProcessorResponse (com.redhat.service.bridge.manager.api.models.responses.ProcessorResponse)5 CloudEvent (io.cloudevents.CloudEvent)5 Response (io.restassured.response.Response)5 BridgeDTO (com.redhat.service.bridge.infra.models.dto.BridgeDTO)2 KafkaConnectionDTO (com.redhat.service.bridge.infra.models.dto.KafkaConnectionDTO)2 BridgeRequest (com.redhat.service.bridge.manager.api.models.requests.BridgeRequest)2 List (java.util.List)2 QueryInfo (com.redhat.service.bridge.infra.models.QueryInfo)1