use of com.redhat.service.smartevents.manager.models.Bridge 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.models.Bridge 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.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorAPITest method updateProcessorWithName.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void updateProcessorWithName() {
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() + "-updated", filters, processor.getTransformationTemplate(), processor.getAction()));
assertThat(response.getStatusCode()).isEqualTo(400);
}
use of com.redhat.service.smartevents.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ConnectorsServiceTest method processorWith.
private static Processor processorWith(Gateway gateway) {
Processor processor = new Processor();
processor.setBridge(new Bridge());
ProcessorDefinition processorDefinition = new ProcessorDefinition();
if (gateway instanceof Action) {
processorDefinition.setRequestedAction((Action) gateway);
processor.setType(ProcessorType.SINK);
} else {
processorDefinition.setRequestedSource((Source) gateway);
processor.setType(ProcessorType.SOURCE);
}
processor.setId(TEST_PROCESSOR_ID);
processor.setName(TEST_PROCESSOR_NAME);
processor.setDefinition(processorDefinition);
return processor;
}
use of com.redhat.service.smartevents.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeDAOTest method testListByCustomerIdPaginationFilterByStatus.
@Test
public void testListByCustomerIdPaginationFilterByStatus() {
for (int i = 0; i < 10; i++) {
String id = String.valueOf(i);
Bridge bridge = buildBridge(id, id);
bridge.setStatus(i % 2 == 0 ? READY : ACCEPTED);
bridgeDAO.persist(bridge);
}
ListResult<Bridge> retrievedBridges = bridgeDAO.findByCustomerId(DEFAULT_CUSTOMER_ID, new QueryResourceInfo(0, 2, filter().by(READY).build()));
assertThat(retrievedBridges).isNotNull();
assertThat(retrievedBridges.getSize()).isEqualTo(2);
assertThat(retrievedBridges.getTotal()).isEqualTo(5);
assertThat(retrievedBridges.getPage()).isZero();
assertThat(retrievedBridges.getItems().get(0).getId()).isEqualTo("8");
assertThat(retrievedBridges.getItems().get(1).getId()).isEqualTo("6");
retrievedBridges = bridgeDAO.findByCustomerId(DEFAULT_CUSTOMER_ID, new QueryResourceInfo(1, 2, filter().by(READY).build()));
assertThat(retrievedBridges).isNotNull();
assertThat(retrievedBridges.getSize()).isEqualTo(2);
assertThat(retrievedBridges.getTotal()).isEqualTo(5);
assertThat(retrievedBridges.getPage()).isEqualTo(1);
assertThat(retrievedBridges.getItems().get(0).getId()).isEqualTo("4");
assertThat(retrievedBridges.getItems().get(1).getId()).isEqualTo("2");
retrievedBridges = bridgeDAO.findByCustomerId(DEFAULT_CUSTOMER_ID, new QueryResourceInfo(2, 2, filter().by(READY).build()));
assertThat(retrievedBridges).isNotNull();
assertThat(retrievedBridges.getSize()).isEqualTo(1);
assertThat(retrievedBridges.getTotal()).isEqualTo(5);
assertThat(retrievedBridges.getPage()).isEqualTo(2);
assertThat(retrievedBridges.getItems().get(0).getId()).isEqualTo("0");
}
Aggregations