Search in sources :

Example 11 with BridgeContext

use of com.redhat.service.smartevents.integration.tests.context.BridgeContext in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorSteps method addProcessorToBridgeWithBody.

@When("^add a Processor to the Bridge \"([^\"]*)\" with body:$")
public void addProcessorToBridgeWithBody(String testBridgeName, String processorRequestJson) {
    BridgeContext bridgeContext = context.getBridge(testBridgeName);
    processorRequestJson = ContextResolver.resolveWithScenarioContext(context, processorRequestJson);
    JsonObject json = new JsonObject(processorRequestJson);
    String processorName = json.getString("name");
    ProcessorResponse response;
    try (InputStream resourceStream = new ByteArrayInputStream(processorRequestJson.getBytes(StandardCharsets.UTF_8))) {
        response = ProcessorResource.createProcessor(context.getManagerToken(), bridgeContext.getId(), resourceStream);
    } catch (IOException e) {
        throw new RuntimeException("Error with inputstream", e);
    }
    bridgeContext.newProcessor(processorName, response.getId());
    assertThat(response.getName()).isEqualTo(processorName);
    assertThat(response.getKind()).isEqualTo("Processor");
    assertThat(response.getHref()).isNotNull();
    assertThat(response.getStatus()).isEqualTo(ManagedResourceStatus.ACCEPTED);
}
Also used : ProcessorResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) BridgeContext(com.redhat.service.smartevents.integration.tests.context.BridgeContext) JsonObject(io.vertx.core.json.JsonObject) IOException(java.io.IOException) When(io.cucumber.java.en.When)

Example 12 with BridgeContext

use of com.redhat.service.smartevents.integration.tests.context.BridgeContext in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorSteps method addFakeProcessorToBridge.

@When("^add a fake Processor \"([^\"]*)\" to the Bridge \"([^\"]*)\"$")
public void addFakeProcessorToBridge(String processorName, String testBridgeName) {
    BridgeContext bridgeContext = context.getBridge(testBridgeName);
    ProcessorContext processorContext = bridgeContext.newProcessor(processorName, UUID.randomUUID().toString());
    processorContext.setDeleted(true);
}
Also used : BridgeContext(com.redhat.service.smartevents.integration.tests.context.BridgeContext) ProcessorContext(com.redhat.service.smartevents.integration.tests.context.ProcessorContext) When(io.cucumber.java.en.When)

Example 13 with BridgeContext

use of com.redhat.service.smartevents.integration.tests.context.BridgeContext in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorSteps method deleteProcessorOfBridgeIsFailingWithHTTPResponseCode.

@When("^delete the Processor \"([^\"]*)\" of the Bridge \"([^\"]*)\" is failing with HTTP response code (\\d+)$")
public void deleteProcessorOfBridgeIsFailingWithHTTPResponseCode(String processorName, String testBridgeName, int responseCode) {
    BridgeContext bridgeContext = context.getBridge(testBridgeName);
    String processorId = bridgeContext.getProcessor(processorName).getId();
    ProcessorResource.deleteProcessorResponse(context.getManagerToken(), bridgeContext.getId(), processorId).then().statusCode(responseCode);
}
Also used : BridgeContext(com.redhat.service.smartevents.integration.tests.context.BridgeContext) When(io.cucumber.java.en.When)

Example 14 with BridgeContext

use of com.redhat.service.smartevents.integration.tests.context.BridgeContext in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgeSteps method bridgeIsNotExistingWithinMinutes.

@Then("^the Bridge \"([^\"]*)\" is not existing within (\\d+) (?:minute|minutes)$")
public void bridgeIsNotExistingWithinMinutes(String testBridgeName, int timeoutMinutes) {
    BridgeContext bridgeContext = context.getBridge(testBridgeName);
    Awaitility.await().conditionEvaluationListener(new AwaitilityOnTimeOutHandler(() -> BridgeResource.getBridgeDetailsResponse(context.getManagerToken(), bridgeContext.getId()).then().log().all())).atMost(Duration.ofMinutes(timeoutMinutes)).pollInterval(Duration.ofSeconds(5)).untilAsserted(() -> BridgeResource.getBridgeDetailsResponse(context.getManagerToken(), bridgeContext.getId()).then().statusCode(404));
}
Also used : AwaitilityOnTimeOutHandler(com.redhat.service.smartevents.integration.tests.common.AwaitilityOnTimeOutHandler) BridgeContext(com.redhat.service.smartevents.integration.tests.context.BridgeContext) Then(io.cucumber.java.en.Then)

Example 15 with BridgeContext

use of com.redhat.service.smartevents.integration.tests.context.BridgeContext 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());
}
Also used : BridgeContext(com.redhat.service.smartevents.integration.tests.context.BridgeContext) BridgeListResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeListResponse) BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse) And(io.cucumber.java.en.And)

Aggregations

BridgeContext (com.redhat.service.smartevents.integration.tests.context.BridgeContext)18 And (io.cucumber.java.en.And)6 When (io.cucumber.java.en.When)6 AwaitilityOnTimeOutHandler (com.redhat.service.smartevents.integration.tests.common.AwaitilityOnTimeOutHandler)4 ProcessorContext (com.redhat.service.smartevents.integration.tests.context.ProcessorContext)3 Then (io.cucumber.java.en.Then)3 ProcessorResponse (com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse)2 JsonObject (io.vertx.core.json.JsonObject)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 BridgeListResponse (com.redhat.service.smartevents.manager.api.models.responses.BridgeListResponse)1 BridgeResponse (com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse)1 ProcessorListResponse (com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse)1