use of com.redhat.service.bridge.infra.models.processors.ProcessorDefinition in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class TestSupport method newRequestedProcessorDTO.
public static ProcessorDTO newRequestedProcessorDTO() {
Set<BaseFilter> filters = new HashSet<>();
filters.add(new StringEquals("key", "value"));
String transformationTemplate = "{\"test\": {key}}";
BaseAction a = new BaseAction();
a.setType(KafkaTopicAction.TYPE);
Map<String, String> params = new HashMap<>();
params.put(KafkaTopicAction.TOPIC_PARAM, "myTopic");
a.setParameters(params);
ProcessorDefinition definition = new ProcessorDefinition(filters, transformationTemplate, a);
return new ProcessorDTO(PROCESSOR_ID, PROCESSOR_NAME, definition, BRIDGE_ID, CUSTOMER_ID, ManagedResourceStatus.ACCEPTED, KAFKA_CONNECTION_DTO);
}
use of com.redhat.service.bridge.infra.models.processors.ProcessorDefinition in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ConnectorsDAOTest 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());
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;
}
use of com.redhat.service.bridge.infra.models.processors.ProcessorDefinition in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class KafkaTopicActionValidatorTest 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;
}
use of com.redhat.service.bridge.infra.models.processors.ProcessorDefinition in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ExecutorTest method testMetricsAreProduced.
@Test
public void testMetricsAreProduced() throws JsonProcessingException {
Set<BaseFilter> filters = new HashSet<>();
filters.add(new StringEquals("data.key", "value"));
BaseAction action = new BaseAction();
action.setType(KafkaTopicAction.TYPE);
String transformationTemplate = "{\"test\": \"{data.key}\"}";
ProcessorDTO processorDTO = createProcessor(new ProcessorDefinition(filters, transformationTemplate, action));
Executor executor = new Executor(processorDTO, filterEvaluatorFactory, transformationEvaluatorFactory, actionProviderFactoryMock, meterRegistry);
CloudEvent cloudEvent = createCloudEvent();
executor.onEvent(cloudEvent);
assertThat(meterRegistry.getMeters().stream().anyMatch(x -> x.getId().getName().equals(MetricsConstants.PROCESSOR_PROCESSING_TIME_METRIC_NAME))).isTrue();
assertThat(meterRegistry.getMeters().stream().anyMatch(x -> x.getId().getName().equals(MetricsConstants.FILTER_PROCESSING_TIME_METRIC_NAME))).isTrue();
assertThat(meterRegistry.getMeters().stream().anyMatch(x -> x.getId().getName().equals(MetricsConstants.TRANSFORMATION_PROCESSING_TIME_METRIC_NAME))).isTrue();
assertThat(meterRegistry.getMeters().stream().anyMatch(x -> x.getId().getName().equals(MetricsConstants.ACTION_PROCESSING_TIME_METRIC_NAME))).isTrue();
}
use of com.redhat.service.bridge.infra.models.processors.ProcessorDefinition in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceImpl method toResponse.
@Override
public ProcessorResponse toResponse(Processor processor) {
ProcessorResponse processorResponse = new ProcessorResponse();
processorResponse.setId(processor.getId());
processorResponse.setName(processor.getName());
processorResponse.setStatus(processor.getStatus());
processorResponse.setPublishedAt(processor.getPublishedAt());
processorResponse.setSubmittedAt(processor.getSubmittedAt());
if (processor.getDefinition() != null) {
ProcessorDefinition definition = jsonNodeToDefinition(processor.getDefinition());
processorResponse.setFilters(definition.getFilters());
processorResponse.setTransformationTemplate(definition.getTransformationTemplate());
processorResponse.setAction(definition.getRequestedAction());
}
if (processor.getBridge() != null) {
processorResponse.setHref(APIConstants.USER_API_BASE_PATH + processor.getBridge().getId() + "/processors/" + processor.getId());
}
return processorResponse;
}
Aggregations