use of com.redhat.service.bridge.infra.models.filters.StringEquals in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ShardBridgesSyncAPITest method getProcessorsWithSendToBridgeAction.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void getProcessorsWithSendToBridgeAction() {
BridgeResponse bridgeResponse = TestUtils.createBridge(new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME)).as(BridgeResponse.class);
String bridgeId = bridgeResponse.getId();
BridgeDTO bridge = new BridgeDTO(bridgeId, bridgeResponse.getName(), TEST_BRIDGE_ENDPOINT, TestConstants.DEFAULT_CUSTOMER_ID, ManagedResourceStatus.READY, new KafkaConnectionDTO());
Set<BaseFilter> filters = Collections.singleton(new StringEquals("json.key", "value"));
BaseAction action = TestUtils.createSendToBridgeAction(bridgeId);
TestUtils.updateBridge(bridge);
TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest(TestConstants.DEFAULT_PROCESSOR_NAME, filters, null, action));
List<ProcessorDTO> processors = TestUtils.getProcessorsToDeployOrDelete().as(new TypeRef<List<ProcessorDTO>>() {
});
assertThat(processors.size()).isEqualTo(1);
ProcessorDTO processor = processors.get(0);
assertThat(processor.getName()).isEqualTo(TestConstants.DEFAULT_PROCESSOR_NAME);
assertThat(processor.getStatus()).isEqualTo(ManagedResourceStatus.ACCEPTED);
assertThat(processor.getDefinition().getFilters().size()).isEqualTo(1);
assertThat(processor.getDefinition().getRequestedAction()).isNotNull();
assertThat(processor.getDefinition().getRequestedAction().getType()).isEqualTo(SendToBridgeAction.TYPE);
assertThat(processor.getDefinition().getRequestedAction().getParameters()).containsEntry(SendToBridgeAction.BRIDGE_ID_PARAM, bridgeId);
assertThat(processor.getDefinition().getResolvedAction()).isNotNull();
assertThat(processor.getDefinition().getResolvedAction().getType()).isEqualTo(WebhookAction.TYPE);
assertThat(processor.getDefinition().getResolvedAction().getParameters()).containsEntry(WebhookAction.ENDPOINT_PARAM, TEST_BRIDGE_WEBHOOK);
}
use of com.redhat.service.bridge.infra.models.filters.StringEquals in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorAPITest method addProcessorToBridge_unrecognisedActionType.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void addProcessorToBridge_unrecognisedActionType() {
BridgeResponse bridgeResponse = createAndDeployBridge();
BaseAction action = createKafkaAction();
action.setType("thisDoesNotExist");
Set<BaseFilter> filters = Collections.singleton(new StringEquals("json.key", "value"));
Response response = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor", filters, null, action));
assertThat(response.getStatusCode()).isEqualTo(400);
}
use of com.redhat.service.bridge.infra.models.filters.StringEquals in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorAPITest method addProcessorToBridgeAndRetrieve.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void addProcessorToBridgeAndRetrieve() {
BridgeResponse bridgeResponse = createAndDeployBridge();
Set<BaseFilter> filters = Collections.singleton(new StringEquals("json.key", "value"));
Response response = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor", filters, null, createKafkaAction()));
assertThat(response.getStatusCode()).isEqualTo(201);
ProcessorResponse retrieved = TestUtils.getProcessor(bridgeResponse.getId(), response.as(ProcessorResponse.class).getId()).as(ProcessorResponse.class);
assertThat(retrieved.getName()).isEqualTo("myProcessor");
assertThat(retrieved.getFilters().size()).isEqualTo(1);
assertThat(retrieved.getTransformationTemplate()).isNull();
assertRequestedAction(retrieved);
}
use of com.redhat.service.bridge.infra.models.filters.StringEquals 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.filters.StringEquals in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class FilterEvaluatorFactoryFEELTest method testStringEqualsTemplate.
@Test
public void testStringEqualsTemplate() {
String expected = "if data.name = \"jrota\" then \"OK\" else \"NOT_OK\"";
String template = TEMPLATE_FACTORY_FEEL.getTemplateByFilterType(new StringEquals("data.name", "jrota"));
assertThat(template).isEqualTo(expected);
}
Aggregations