Search in sources :

Example 1 with ProcessorContext

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

Example 2 with ProcessorContext

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

the class ProcessorSteps method updateProcessorOfTheBridgeWithBody.

@When("^update the Processor \"([^\"]*)\" of the Bridge \"([^\"]*)\" with body:$")
public void updateProcessorOfTheBridgeWithBody(String processorName, String testBridgeName, String processorRequestJson) {
    BridgeContext bridgeContext = context.getBridge(testBridgeName);
    processorRequestJson = ContextResolver.resolveWithScenarioContext(context, processorRequestJson);
    ProcessorContext processorContext = bridgeContext.getProcessor(processorName);
    JsonObject json = new JsonObject(processorRequestJson);
    String newProcessorName = json.getString("name");
    ProcessorResponse response;
    try (InputStream resourceStream = new ByteArrayInputStream(processorRequestJson.getBytes(StandardCharsets.UTF_8))) {
        response = ProcessorResource.updateProcessor(context.getManagerToken(), bridgeContext.getId(), processorContext.getId(), resourceStream);
    } catch (IOException e) {
        throw new RuntimeException("Error opening inputstream", e);
    }
    bridgeContext.removeProcessor(processorName);
    bridgeContext.newProcessor(newProcessorName, 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) ProcessorContext(com.redhat.service.smartevents.integration.tests.context.ProcessorContext) When(io.cucumber.java.en.When)

Example 3 with ProcessorContext

use of com.redhat.service.smartevents.integration.tests.context.ProcessorContext 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)

Aggregations

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