use of com.redhat.service.bridge.infra.models.processors.ProcessorDefinition 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.processors.ProcessorDefinition in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceTest method toResponse.
@Test
public void toResponse() {
Bridge b = Fixtures.createBridge();
Processor p = Fixtures.createProcessor(b, "foo", ManagedResourceStatus.READY);
BaseAction action = Fixtures.createKafkaAction();
ProcessorDefinition definition = new ProcessorDefinition(Collections.emptySet(), "", action);
p.setDefinition(definitionToJsonNode(definition));
ProcessorResponse r = processorService.toResponse(p);
assertThat(r).isNotNull();
assertThat(r.getHref()).isEqualTo(APIConstants.USER_API_BASE_PATH + b.getId() + "/processors/" + p.getId());
assertThat(r.getName()).isEqualTo(p.getName());
assertThat(r.getStatus()).isEqualTo(p.getStatus());
assertThat(r.getId()).isEqualTo(p.getId());
assertThat(r.getSubmittedAt()).isEqualTo(p.getSubmittedAt());
assertThat(r.getPublishedAt()).isEqualTo(p.getPublishedAt());
assertThat(r.getKind()).isEqualTo("Processor");
assertThat(r.getTransformationTemplate()).isEmpty();
assertThat(r.getAction().getType()).isEqualTo(KafkaTopicAction.TYPE);
}
use of com.redhat.service.bridge.infra.models.processors.ProcessorDefinition in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceTest method createProcessor.
@Test
public void createProcessor() {
Bridge b = createPersistBridge(ManagedResourceStatus.READY);
ProcessorRequest r = new ProcessorRequest("My Processor", 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(processor.getBridge().getId()).isEqualTo(b.getId());
assertThat(processor.getName()).isEqualTo(r.getName());
assertThat(processor.getStatus()).isEqualTo(ManagedResourceStatus.ACCEPTED);
assertThat(processor.getSubmittedAt()).isNotNull();
assertThat(processor.getDefinition()).isNotNull();
ProcessorDefinition definition = jsonNodeToDefinition(processor.getDefinition());
assertThat(definition.getTransformationTemplate()).isEqualTo("{}");
}
use of com.redhat.service.bridge.infra.models.processors.ProcessorDefinition in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceImpl method toDTO.
@Override
public ProcessorDTO toDTO(Processor processor) {
ProcessorDefinition definition = processor.getDefinition() != null ? jsonNodeToDefinition(processor.getDefinition()) : null;
KafkaConnectionDTO kafkaConnectionDTO = new KafkaConnectionDTO(internalKafkaConfigurationProvider.getBootstrapServers(), internalKafkaConfigurationProvider.getClientId(), internalKafkaConfigurationProvider.getClientSecret(), internalKafkaConfigurationProvider.getSecurityProtocol(), bridgesService.getBridgeTopicName(processor.getBridge()));
return new ProcessorDTO(processor.getId(), processor.getName(), definition, processor.getBridge().getId(), processor.getBridge().getCustomerId(), processor.getStatus(), kafkaConnectionDTO);
}
use of com.redhat.service.bridge.infra.models.processors.ProcessorDefinition in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorDAOTest method createProcessor.
private Processor createProcessor(Bridge bridge, String name) {
Processor p = new Processor();
p.setBridge(bridge);
p.setName(name);
p.setStatus(ManagedResourceStatus.ACCEPTED);
p.setSubmittedAt(ZonedDateTime.now());
p.setPublishedAt(ZonedDateTime.now());
p.setShardId(TestConstants.SHARD_ID);
BaseAction a = new BaseAction();
a.setType(KafkaTopicAction.TYPE);
Map<String, String> params = new HashMap<>();
params.put(KafkaTopicAction.TOPIC_PARAM, TestConstants.DEFAULT_KAFKA_TOPIC);
a.setParameters(params);
ProcessorDefinition definition = new ProcessorDefinition(Collections.emptySet(), null, a);
p.setDefinition(mapper.valueToTree(definition));
processorDAO.persist(p);
return p;
}
Aggregations