use of com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class Hooks method cleanUp.
@After
public void cleanUp() {
if (!Boolean.parseBoolean(DISABLE_CLEANUP)) {
String token = Optional.ofNullable(context.getManagerToken()).orElse(BridgeUtils.retrieveBridgeToken());
// Remove all bridges/processors created
context.getAllBridges().values().parallelStream().filter(bridgeContext -> !bridgeContext.isDeleted()).forEach(bridgeContext -> {
final String bridgeId = bridgeContext.getId();
BridgeResponse bridge = BridgeResource.getBridgeDetails(token, bridgeId);
if (bridge.getStatus() == ManagedResourceStatus.READY) {
ProcessorListResponse processorList = ProcessorResource.getProcessorList(token, bridgeId);
if (processorList.getSize() > 0) {
processorList.getItems().parallelStream().forEach(p -> {
String processorId = p.getId();
ProcessorResource.deleteProcessor(token, bridgeId, processorId);
Awaitility.await().atMost(Duration.ofMinutes(4)).pollInterval(Duration.ofSeconds(5)).untilAsserted(() -> assertThat(ProcessorResource.getProcessorList(token, bridgeId).getItems()).as("waiting until Processor `%s` of the Bridge `%s` is deleted", processorId, bridgeId).noneMatch(processor -> Objects.equals(processor.getId(), processorId)));
});
}
}
switch(bridge.getStatus()) {
case ACCEPTED:
case PROVISIONING:
case READY:
case FAILED:
try {
BridgeResource.deleteBridge(token, bridgeId);
Awaitility.await().atMost(Duration.ofMinutes(4)).pollInterval(Duration.ofSeconds(5)).untilAsserted(() -> assertThat(BridgeResource.getBridgeList(token).getItems()).as("waiting until Bridge `%s` is deleted", bridgeId).noneMatch(b -> Objects.equals(b.getId(), bridgeId)));
} catch (Exception e) {
throw new RuntimeException("Unable to delete bridge with id " + bridgeId, e);
}
default:
break;
}
});
}
}
use of com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorSteps method listOfProcessorInstancesOfBridgeIsContainingProcessor.
@And("^the list of Processor instances of the Bridge \"([^\"]*)\" is containing the Processor \"([^\"]*)\"$")
public void listOfProcessorInstancesOfBridgeIsContainingProcessor(String testBridgeName, String processorName) {
BridgeContext bridgeContext = context.getBridge(testBridgeName);
ProcessorContext processorContext = bridgeContext.getProcessor(processorName);
ProcessorListResponse response = ProcessorResource.getProcessorList(context.getManagerToken(), bridgeContext.getId());
assertThat(response.getItems()).anyMatch(p -> p.getId().equals(processorContext.getId()));
}
use of com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorAPITest method listProcessorsFilterByMultipleStatuses.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void listProcessorsFilterByMultipleStatuses() {
BridgeResponse bridgeResponse = createAndDeployBridge();
ProcessorResponse p1 = 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);
setProcessorStatus(p1.getId(), ACCEPTED);
setProcessorStatus(p2.getId(), READY);
ProcessorListResponse listResponse = TestUtils.listProcessorsFilterByStatus(bridgeResponse.getId(), ACCEPTED, READY).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(p1.getId(), p2.getId()));
}
use of com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorAPITest method listProcessorsFilterByName.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void listProcessorsFilterByName() {
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.createKafkaAction())).as(ProcessorResponse.class);
ProcessorListResponse listResponse = TestUtils.listProcessorsFilterByName(bridgeResponse.getId(), "myProcessor2").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());
}
use of com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorAPITest method listProcessorsFilterByNameAndType.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void listProcessorsFilterByNameAndType() {
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.listProcessorsFilterByNameAndType(bridgeResponse.getId(), "myProcessor", 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