Search in sources :

Example 11 with ProcessorDTO

use of com.redhat.service.bridge.infra.models.dto.ProcessorDTO 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 12 with ProcessorDTO

use of com.redhat.service.bridge.infra.models.dto.ProcessorDTO 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 13 with ProcessorDTO

use of com.redhat.service.bridge.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorServiceTest method updateProcessorStatus.

@Test
public void updateProcessorStatus() {
    Bridge b = createPersistBridge(ManagedResourceStatus.READY);
    ProcessorRequest r = new ProcessorRequest("My Processor", 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);
    });
    ProcessorDTO dto = processorService.toDTO(processor);
    dto.setStatus(ManagedResourceStatus.FAILED);
    Processor updated = processorService.updateProcessorStatus(dto);
    assertThat(updated.getStatus()).isEqualTo(ManagedResourceStatus.FAILED);
}
Also used : Processor(com.redhat.service.bridge.manager.models.Processor) ProcessorDTO(com.redhat.service.bridge.infra.models.dto.ProcessorDTO) ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) Bridge(com.redhat.service.bridge.manager.models.Bridge) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Example 14 with ProcessorDTO

use of com.redhat.service.bridge.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorServiceTest method updateProcessorStatus_bridgeDoesNotExist.

@Test
public void updateProcessorStatus_bridgeDoesNotExist() {
    ProcessorDTO processor = new ProcessorDTO();
    processor.setBridgeId("foo");
    assertThatExceptionOfType(ItemNotFoundException.class).isThrownBy(() -> processorService.updateProcessorStatus(processor));
}
Also used : ProcessorDTO(com.redhat.service.bridge.infra.models.dto.ProcessorDTO) ItemNotFoundException(com.redhat.service.bridge.infra.exceptions.definitions.user.ItemNotFoundException) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Example 15 with ProcessorDTO

use of com.redhat.service.bridge.infra.models.dto.ProcessorDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorServiceTest method updateProcessorStatus_processorDoesNotExist.

@Test
public void updateProcessorStatus_processorDoesNotExist() {
    Processor p = new Processor();
    p.setBridge(createPersistBridge(ManagedResourceStatus.READY));
    p.setId("foo");
    ProcessorDTO processor = processorService.toDTO(p);
    assertThatExceptionOfType(ItemNotFoundException.class).isThrownBy(() -> processorService.updateProcessorStatus(processor));
}
Also used : Processor(com.redhat.service.bridge.manager.models.Processor) ProcessorDTO(com.redhat.service.bridge.infra.models.dto.ProcessorDTO) ItemNotFoundException(com.redhat.service.bridge.infra.exceptions.definitions.user.ItemNotFoundException) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Aggregations

ProcessorDTO (com.redhat.service.bridge.infra.models.dto.ProcessorDTO)39 Test (org.junit.jupiter.api.Test)28 QuarkusTest (io.quarkus.test.junit.QuarkusTest)21 ProcessorDefinition (com.redhat.service.bridge.infra.models.processors.ProcessorDefinition)11 BaseAction (com.redhat.service.bridge.infra.models.actions.BaseAction)10 BaseFilter (com.redhat.service.bridge.infra.models.filters.BaseFilter)8 StringEquals (com.redhat.service.bridge.infra.models.filters.StringEquals)8 BridgeDTO (com.redhat.service.bridge.infra.models.dto.BridgeDTO)6 HashSet (java.util.HashSet)6 KafkaConnectionDTO (com.redhat.service.bridge.infra.models.dto.KafkaConnectionDTO)5 ProcessorRequest (com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest)5 CloudEvent (io.cloudevents.CloudEvent)5 TestSecurity (io.quarkus.test.security.TestSecurity)5 BridgeRequest (com.redhat.service.bridge.manager.api.models.requests.BridgeRequest)4 BridgeResponse (com.redhat.service.bridge.manager.api.models.responses.BridgeResponse)4 HashMap (java.util.HashMap)4 List (java.util.List)4 ActionInvoker (com.redhat.service.bridge.actions.ActionInvoker)2 ValidationResult (com.redhat.service.bridge.actions.ValidationResult)2 ActionProviderException (com.redhat.service.bridge.infra.exceptions.definitions.user.ActionProviderException)2