use of com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ProcessorAPITest method getProcessorWithSendToBridgeAction.
@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void getProcessorWithSendToBridgeAction() {
BridgeResponse bridgeResponse = createAndDeployBridge();
String bridgeId = bridgeResponse.getId();
Response response = TestUtils.addProcessorToBridge(bridgeId, new ProcessorRequest("myProcessor", TestUtils.createSendToBridgeAction(bridgeId)));
assertThat(response.getStatusCode()).isEqualTo(202);
ProcessorResponse pr = response.as(ProcessorResponse.class);
assertThat(pr.getAction().getType()).isEqualTo(SendToBridgeAction.TYPE);
assertThat(pr.getAction().getParameter(SendToBridgeAction.BRIDGE_ID_PARAM)).isEqualTo(bridgeId);
ProcessorResponse found = TestUtils.getProcessor(bridgeId, pr.getId()).as(ProcessorResponse.class);
assertThat(found.getId()).isEqualTo(pr.getId());
assertThat(found.getAction().getType()).isEqualTo(SendToBridgeAction.TYPE);
assertThat(found.getAction().getParameter(SendToBridgeAction.BRIDGE_ID_PARAM)).isEqualTo(bridgeId);
}
use of com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgesServiceImpl method toResponse.
@Override
public BridgeResponse toResponse(Bridge bridge) {
BridgeResponse response = new BridgeResponse();
response.setId(bridge.getId());
response.setName(bridge.getName());
response.setEndpoint(bridge.getEndpoint());
response.setSubmittedAt(bridge.getSubmittedAt());
response.setPublishedAt(bridge.getPublishedAt());
response.setStatus(bridge.getStatus());
response.setHref(APIConstants.USER_API_BASE_PATH + bridge.getId());
response.setOwner(bridge.getOwner());
response.setErrorHandler(bridge.getDefinition().getErrorHandler());
return response;
}
use of com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeSteps method createNewBridgeWithSupplier.
private void createNewBridgeWithSupplier(String testBridgeName, BiFunction<TestContext, String, BridgeResponse> bridgeCreator) {
String systemBridgeName = Utils.generateId("test-" + testBridgeName);
int creationRetry = 1;
while (creationRetry <= BRIDGE_NAME_CREATE_RETRY && isBridgeExisting(systemBridgeName)) {
creationRetry++;
systemBridgeName = Utils.generateId("test-" + testBridgeName);
}
if (isBridgeExisting(systemBridgeName)) {
throw new RuntimeException("Cannot create and initiate a random bridge name correctly. Please cleanup the environment...");
}
BridgeResponse response = bridgeCreator.apply(context, systemBridgeName);
assertThat(response.getName()).isEqualTo(systemBridgeName);
assertThat(response.getStatus()).isEqualTo(ManagedResourceStatus.ACCEPTED);
assertThat(response.getEndpoint()).isNull();
assertThat(response.getPublishedAt()).isNull();
assertThat(response.getHref()).isNotNull();
assertThat(response.getSubmittedAt()).isNotNull();
context.newBridge(testBridgeName, response.getId(), systemBridgeName);
}
use of com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse 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.BridgeResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeSteps method listOfBridgeInstancesIsContainingBridge.
@And("^the list of Bridge instances is containing the Bridge \"([^\"]*)\"$")
public void listOfBridgeInstancesIsContainingBridge(String testBridgeName) {
BridgeContext bridgeContext = context.getBridge(testBridgeName);
BridgeListResponse response = BridgeResource.getBridgeList(context.getManagerToken());
assertThat(response.getItems()).anyMatch(b -> b.getId().equals(bridgeContext.getId()));
BridgeResponse bridge = response.getItems().stream().filter(b -> b.getId().equals(bridgeContext.getId())).findFirst().orElseThrow();
assertThat(bridge.getName()).isEqualTo(bridgeContext.getName());
}
Aggregations