use of com.redhat.service.smartevents.infra.models.filters.StringEquals in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceTest method testUpdateProcessorWithFilter.
@ParameterizedTest
@MethodSource("updateProcessorParams")
void testUpdateProcessorWithFilter(ProcessorRequest request) {
Processor existingProcessor = createReadyProcessorFromRequest(request);
when(processorDAO.findByIdBridgeIdAndCustomerId(DEFAULT_BRIDGE_ID, DEFAULT_PROCESSOR_ID, DEFAULT_CUSTOMER_ID)).thenReturn(existingProcessor);
Set<BaseFilter> updatedFilters = Collections.singleton(new StringEquals("key", "value"));
request.setFilters(updatedFilters);
Processor updatedProcessor = processorService.updateProcessor(DEFAULT_BRIDGE_ID, DEFAULT_PROCESSOR_ID, DEFAULT_CUSTOMER_ID, request);
ProcessorResponse updatedResponse = processorService.toResponse(updatedProcessor);
assertThat(updatedResponse.getStatus()).isEqualTo(ACCEPTED);
assertThat(updatedResponse.getFilters()).hasSize(1);
BaseFilter updatedFilter = updatedResponse.getFilters().iterator().next();
assertThat(updatedFilter.getKey()).isEqualTo("key");
assertThat(updatedFilter.getValue()).isEqualTo("value");
assertThat(updatedResponse.getTransformationTemplate()).isNull();
}
use of com.redhat.service.smartevents.infra.models.filters.StringEquals in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ShardBridgesSyncAPITest method getProcessorsWithSendToBridgeAction.
@Test
@TestSecurity(user = DEFAULT_CUSTOMER_ID)
public void getProcessorsWithSendToBridgeAction() {
BridgeResponse bridgeResponse = TestUtils.createBridge(new BridgeRequest(DEFAULT_BRIDGE_NAME)).as(BridgeResponse.class);
String bridgeId = bridgeResponse.getId();
// Emulate the Shard having deployed the Bridge
BridgeDTO bridge = new BridgeDTO(bridgeId, bridgeResponse.getName(), TEST_BRIDGE_ENDPOINT, DEFAULT_CUSTOMER_ID, DEFAULT_USER_NAME, READY, new KafkaConnectionDTO());
TestUtils.updateBridge(bridge);
// Create a Processor for the Bridge
Set<BaseFilter> filters = Collections.singleton(new StringEquals("json.key", "value"));
Action action = TestUtils.createSendToBridgeAction(bridgeId);
TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest(DEFAULT_PROCESSOR_NAME, filters, null, action));
final List<ProcessorDTO> processors = new ArrayList<>();
await().atMost(5, SECONDS).untilAsserted(() -> {
processors.clear();
processors.addAll(TestUtils.getProcessorsToDeployOrDelete().as(new TypeRef<List<ProcessorDTO>>() {
}));
assertThat(processors.size()).isEqualTo(1);
});
ProcessorDTO processor = processors.get(0);
assertThat(processor.getName()).isEqualTo(DEFAULT_PROCESSOR_NAME);
assertThat(processor.getStatus()).isEqualTo(PREPARING);
assertThat(processor.getDefinition().getFilters().size()).isEqualTo(1);
assertThat(processor.getDefinition().getRequestedAction()).isNotNull();
assertThat(processor.getDefinition().getRequestedAction().getType()).isEqualTo(SendToBridgeAction.TYPE);
assertThat(processor.getDefinition().getRequestedAction().getParameter(SendToBridgeAction.BRIDGE_ID_PARAM)).isEqualTo(bridgeId);
assertThat(processor.getDefinition().getResolvedAction()).isNotNull();
assertThat(processor.getDefinition().getResolvedAction().getType()).isEqualTo(WebhookAction.TYPE);
assertThat(processor.getDefinition().getResolvedAction().getParameter(WebhookAction.ENDPOINT_PARAM)).isEqualTo(TEST_BRIDGE_WEBHOOK);
}
use of com.redhat.service.smartevents.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);
}
use of com.redhat.service.smartevents.infra.models.filters.StringEquals 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}}";
Action a = new Action();
a.setType(KafkaTopicAction.TYPE);
Map<String, String> params = new HashMap<>();
params.put(KafkaTopicAction.TOPIC_PARAM, "myTopic");
a.setMapParameters(params);
ProcessorDefinition definition = new ProcessorDefinition(filters, transformationTemplate, a);
ProcessorDTO dto = new ProcessorDTO();
dto.setType(PROCESSOR_TYPE);
dto.setId(PROCESSOR_ID);
dto.setName(PROCESSOR_NAME);
dto.setDefinition(definition);
dto.setBridgeId(BRIDGE_ID);
dto.setCustomerId(CUSTOMER_ID);
dto.setOwner(USER_NAME);
dto.setStatus(PREPARING);
dto.setKafkaConnection(KAFKA_CONNECTION_DTO);
return dto;
}
use of com.redhat.service.smartevents.infra.models.filters.StringEquals in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorAPITest method updateProcessorWithAction.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void updateProcessorWithAction() {
Bridge bridge = Fixtures.createBridge();
bridgeDAO.persist(bridge);
Set<BaseFilter> filters = Collections.singleton(new StringEquals("key", "value"));
Response createResponse = TestUtils.addProcessorToBridge(bridge.getId(), new ProcessorRequest("myProcessor", filters, null, TestUtils.createKafkaAction()));
ProcessorResponse processor = TestUtils.getProcessor(bridge.getId(), createResponse.as(ProcessorResponse.class).getId()).as(ProcessorResponse.class);
setProcessorAsReady(processor.getId());
Response response = TestUtils.updateProcessor(bridge.getId(), processor.getId(), new ProcessorRequest(processor.getName(), filters, processor.getTransformationTemplate(), null));
assertThat(response.getStatusCode()).isEqualTo(400);
}
Aggregations