use of com.redhat.service.smartevents.infra.models.filters.StringEquals 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.StringEquals 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.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, 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.StringEquals 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);
}
use of com.redhat.service.smartevents.infra.models.filters.StringEquals in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ShardBridgesSyncAPITest method getProcessorsWithKafkaAction.
@Test
@TestSecurity(user = DEFAULT_CUSTOMER_ID)
public void getProcessorsWithKafkaAction() {
BridgeResponse bridgeResponse = TestUtils.createBridge(new BridgeRequest(DEFAULT_BRIDGE_NAME)).as(BridgeResponse.class);
// Emulate the Shard having deployed the Bridge
BridgeDTO bridge = new BridgeDTO(bridgeResponse.getId(), 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"));
TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest(DEFAULT_PROCESSOR_NAME, filters, null, TestUtils.createKafkaAction()));
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(KafkaTopicAction.TYPE);
assertThat(processor.getDefinition().getRequestedAction().getParameter(KafkaTopicAction.TOPIC_PARAM)).isEqualTo(TestConstants.DEFAULT_KAFKA_TOPIC);
assertThat(processor.getDefinition().getResolvedAction()).isNotNull();
assertThat(processor.getDefinition().getResolvedAction().getType()).isEqualTo(KafkaTopicAction.TYPE);
assertThat(processor.getDefinition().getResolvedAction().getParameter(KafkaTopicAction.TOPIC_PARAM)).isEqualTo(TestConstants.DEFAULT_KAFKA_TOPIC);
}
Aggregations