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());
}
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());
}
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);
}
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));
}
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));
}
Aggregations