use of com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorAPITest method listProcessors.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void listProcessors() {
BridgeResponse bridgeResponse = createAndDeployBridge();
ProcessorResponse p = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor", TestUtils.createKafkaAction())).as(ProcessorResponse.class);
ProcessorResponse p2 = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor2", TestUtils.createKafkaAction())).as(ProcessorResponse.class);
ProcessorListResponse listResponse = TestUtils.listProcessors(bridgeResponse.getId(), 0, 100).as(ProcessorListResponse.class);
assertThat(listResponse.getPage()).isZero();
assertThat(listResponse.getSize()).isEqualTo(2L);
assertThat(listResponse.getTotal()).isEqualTo(2L);
listResponse.getItems().forEach((i) -> assertThat(i.getId()).isIn(p.getId(), p2.getId()));
}
use of com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorAPITest method updateProcessorWithMalformedTemplate.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void updateProcessorWithMalformedTemplate() {
Bridge bridge = Fixtures.createBridge();
bridgeDAO.persist(bridge);
Response createResponse = TestUtils.addProcessorToBridge(bridge.getId(), new ProcessorRequest("myProcessor", null, 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(), null, "template {this.is.broken", processor.getAction()));
assertThat(response.getStatusCode()).isEqualTo(400);
}
use of com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorAPITest method updateProcessorWithTemplate.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void updateProcessorWithTemplate() {
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, "template", 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, "template-updated", 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(1);
BaseFilter updatedFilter = updated.getFilters().iterator().next();
assertThat(updatedFilter.getKey()).isEqualTo("key");
assertThat(updatedFilter.getValue()).isEqualTo("value");
assertThat(updated.getTransformationTemplate()).isEqualTo("template-updated");
assertRequestedAction(updated);
}
use of com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorAPITest method getProcessor.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void getProcessor() {
BridgeResponse bridgeResponse = createAndDeployBridge();
Response response = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor", TestUtils.createKafkaAction()));
assertThat(response.getStatusCode()).isEqualTo(202);
ProcessorResponse pr = response.as(ProcessorResponse.class);
assertThat(pr.getAction().getType()).isEqualTo(KafkaTopicAction.TYPE);
assertThat(pr.getAction().getParameter(KafkaTopicAction.TOPIC_PARAM)).isEqualTo(TestConstants.DEFAULT_KAFKA_TOPIC);
ProcessorResponse found = TestUtils.getProcessor(bridgeResponse.getId(), pr.getId()).as(ProcessorResponse.class);
assertThat(found.getId()).isEqualTo(pr.getId());
assertThat(found.getAction().getType()).isEqualTo(KafkaTopicAction.TYPE);
assertThat(found.getAction().getParameter(KafkaTopicAction.TOPIC_PARAM)).isEqualTo(TestConstants.DEFAULT_KAFKA_TOPIC);
}
use of com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorAPITest method listProcessorsFilterByType.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void listProcessorsFilterByType() {
BridgeResponse bridgeResponse = createAndDeployBridge();
TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor", TestUtils.createKafkaAction())).as(ProcessorResponse.class);
ProcessorResponse p2 = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor2", TestUtils.createSlackSource())).as(ProcessorResponse.class);
ProcessorListResponse listResponse = TestUtils.listProcessorsFilterByType(bridgeResponse.getId(), SOURCE).as(ProcessorListResponse.class);
assertThat(listResponse.getPage()).isZero();
assertThat(listResponse.getSize()).isEqualTo(1L);
assertThat(listResponse.getTotal()).isEqualTo(1L);
assertThat(listResponse.getItems().get(0).getId()).isEqualTo(p2.getId());
}
Aggregations