Search in sources :

Example 11 with BridgeContext

use of com.redhat.service.bridge.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);
    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.bridge.manager.api.models.responses.ProcessorResponse) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) BridgeContext(com.redhat.service.bridge.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.bridge.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, Utils.generateId(processorName));
    processorContext.setDeleted(true);
}
Also used : BridgeContext(com.redhat.service.bridge.integration.tests.context.BridgeContext) ProcessorContext(com.redhat.service.bridge.integration.tests.context.ProcessorContext) When(io.cucumber.java.en.When)

Example 13 with BridgeContext

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

the class ProcessorSteps method getProcessorOfBridgeIsFailingWithHTTPResponseCode.

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

Example 14 with BridgeContext

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

the class ProcessorSteps method listOfBridgeInstancesIsContainingBridge.

@And("^the list of Processor instances of the Bridge \"([^\"]*)\" is containing the Processor \"([^\"]*)\"$")
public void listOfBridgeInstancesIsContainingBridge(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()));
}
Also used : ProcessorListResponse(com.redhat.service.bridge.manager.api.models.responses.ProcessorListResponse) BridgeContext(com.redhat.service.bridge.integration.tests.context.BridgeContext) ProcessorContext(com.redhat.service.bridge.integration.tests.context.ProcessorContext) And(io.cucumber.java.en.And)

Example 15 with BridgeContext

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

the class ProcessorSteps method processorOfBridgeIsNotExistingWithinMinutes.

@Then("^the Processor \"([^\"]*)\" of the Bridge \"([^\"]*)\" is not existing within (\\d+) (?:minute|minutes)$")
public void processorOfBridgeIsNotExistingWithinMinutes(String processorName, String testBridgeName, int timeoutMinutes) {
    BridgeContext bridgeContext = context.getBridge(testBridgeName);
    String processorId = bridgeContext.getProcessor(processorName).getId();
    Awaitility.await().atMost(Duration.ofMinutes(timeoutMinutes)).pollInterval(Duration.ofSeconds(5)).untilAsserted(() -> ProcessorResource.getProcessorResponse(context.getManagerToken(), bridgeContext.getId(), processorId).then().statusCode(404));
}
Also used : BridgeContext(com.redhat.service.bridge.integration.tests.context.BridgeContext) Then(io.cucumber.java.en.Then)

Aggregations

BridgeContext (com.redhat.service.bridge.integration.tests.context.BridgeContext)16 And (io.cucumber.java.en.And)7 When (io.cucumber.java.en.When)5 Then (io.cucumber.java.en.Then)3 ProcessorContext (com.redhat.service.bridge.integration.tests.context.ProcessorContext)2 ProcessorResponse (com.redhat.service.bridge.manager.api.models.responses.ProcessorResponse)2 BaseAction (com.redhat.service.bridge.infra.models.actions.BaseAction)1 BridgeListResponse (com.redhat.service.bridge.manager.api.models.responses.BridgeListResponse)1 BridgeResponse (com.redhat.service.bridge.manager.api.models.responses.BridgeResponse)1 ProcessorListResponse (com.redhat.service.bridge.manager.api.models.responses.ProcessorListResponse)1 JsonObject (io.vertx.core.json.JsonObject)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1