use of com.redhat.service.smartevents.infra.models.filters.BaseFilter 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);
}
use of com.redhat.service.smartevents.infra.models.filters.BaseFilter in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorAPITest method updateProcessorWithFilter.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void updateProcessorWithFilter() {
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());
Set<BaseFilter> updatedFilters = Set.of(new StringEquals("key1", "value1"), new StringEquals("key2", "value2"));
Response response = TestUtils.updateProcessor(bridge.getId(), processor.getId(), new ProcessorRequest(processor.getName(), updatedFilters, processor.getTransformationTemplate(), processor.getAction()));
assertThat(response.getStatusCode()).isEqualTo(202);
ProcessorResponse updated = TestUtils.getProcessor(bridge.getId(), createResponse.as(ProcessorResponse.class).getId()).as(ProcessorResponse.class);
assertThat(updated.getName()).isEqualTo("myProcessor");
assertThat(updated.getFilters().size()).isEqualTo(2);
assertThat(updated.getFilters().stream().filter(f -> f.getKey().equals("key1") && f.getValue().equals("value1")).count()).isEqualTo(1);
assertThat(updated.getFilters().stream().filter(f -> f.getKey().equals("key2") && f.getValue().equals("value2")).count()).isEqualTo(1);
assertThat(updated.getTransformationTemplate()).isNull();
assertRequestedAction(updated);
}
use of com.redhat.service.smartevents.infra.models.filters.BaseFilter in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorAPITest method addProcessorToBridge_noActionSpecified.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void addProcessorToBridge_noActionSpecified() {
BridgeResponse bridgeResponse = createAndDeployBridge();
Set<BaseFilter> filters = Collections.singleton(new StringEquals("json.key", "value"));
Response response = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor", filters, null, null));
assertThat(response.getStatusCode()).isEqualTo(400);
}
use of com.redhat.service.smartevents.infra.models.filters.BaseFilter 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, TestUtils.createKafkaAction()));
assertThat(response.getStatusCode()).isEqualTo(202);
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.smartevents.infra.models.filters.BaseFilter in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorServiceTest method testUpdateProcessorWithNoChange.
@ParameterizedTest
@MethodSource("updateProcessorParams")
void testUpdateProcessorWithNoChange(ProcessorRequest request) {
Set<BaseFilter> filters = Set.of(new StringBeginsWith("source", List.of("Storage")), new StringContains("source", List.of("StorageService")), new StringEquals("source", "StorageService"), new StringIn("source", List.of("StorageService")));
request.setFilters(filters);
Processor existingProcessor = createReadyProcessorFromRequest(request);
when(processorDAO.findByIdBridgeIdAndCustomerId(DEFAULT_BRIDGE_ID, DEFAULT_PROCESSOR_ID, DEFAULT_CUSTOMER_ID)).thenReturn(existingProcessor);
Processor updatedProcessor = processorService.updateProcessor(DEFAULT_BRIDGE_ID, DEFAULT_PROCESSOR_ID, DEFAULT_CUSTOMER_ID, request);
assertThat(updatedProcessor.getStatus()).isEqualTo(READY);
assertThat(updatedProcessor).isEqualTo(existingProcessor);
}
Aggregations