Search in sources :

Example 1 with ProcessorListResponse

use of com.redhat.service.bridge.manager.api.models.responses.ProcessorListResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class Hooks method cleanUp.

@After
public void cleanUp() {
    String token = Optional.ofNullable(context.getManagerToken()).orElse(BridgeUtils.retrieveBridgeToken());
    // Remove all bridges/processors created
    context.getAllBridges().values().stream().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().stream().forEach(p -> ProcessorResource.deleteProcessor(token, bridgeId, p.getId()));
                Awaitility.await().atMost(Duration.ofMinutes(2)).pollInterval(Duration.ofSeconds(5)).until(() -> ProcessorResource.getProcessorList(token, bridgeId).getSize() == 0);
            }
        }
        switch(bridge.getStatus()) {
            case ACCEPTED:
            case PROVISIONING:
            case READY:
            case FAILED:
                try {
                    BridgeResource.deleteBridge(token, bridgeId);
                } catch (Exception e) {
                    LOGGER.warn(e, () -> "Unable to delete bridge with id " + bridgeId);
                }
            default:
                break;
        }
    });
}
Also used : Logger(io.cucumber.core.logging.Logger) BridgeResource(com.redhat.service.bridge.integration.tests.resources.BridgeResource) Scenario(io.cucumber.java.Scenario) BridgeResponse(com.redhat.service.bridge.manager.api.models.responses.BridgeResponse) BridgeUtils(com.redhat.service.bridge.integration.tests.common.BridgeUtils) LoggerFactory(io.cucumber.core.logging.LoggerFactory) TestContext(com.redhat.service.bridge.integration.tests.context.TestContext) ProcessorResource(com.redhat.service.bridge.integration.tests.resources.ProcessorResource) ManagedResourceStatus(com.redhat.service.bridge.infra.models.dto.ManagedResourceStatus) After(io.cucumber.java.After) Duration(java.time.Duration) ProcessorListResponse(com.redhat.service.bridge.manager.api.models.responses.ProcessorListResponse) Optional(java.util.Optional) Before(io.cucumber.java.Before) Awaitility(org.awaitility.Awaitility) ProcessorListResponse(com.redhat.service.bridge.manager.api.models.responses.ProcessorListResponse) BridgeResponse(com.redhat.service.bridge.manager.api.models.responses.BridgeResponse) After(io.cucumber.java.After)

Example 2 with ProcessorListResponse

use of com.redhat.service.bridge.manager.api.models.responses.ProcessorListResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorAPITest method listProcessors.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void listProcessors() {
    BridgeResponse bridgeResponse = createAndDeployBridge();
    ProcessorResponse p = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor", createKafkaAction())).as(ProcessorResponse.class);
    ProcessorResponse p2 = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor2", createKafkaAction())).as(ProcessorResponse.class);
    ProcessorListResponse listResponse = TestUtils.listProcessors(bridgeResponse.getId(), 0, 100).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(p.getId(), p2.getId()));
}
Also used : ProcessorResponse(com.redhat.service.bridge.manager.api.models.responses.ProcessorResponse) ProcessorListResponse(com.redhat.service.bridge.manager.api.models.responses.ProcessorListResponse) ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) BridgeResponse(com.redhat.service.bridge.manager.api.models.responses.BridgeResponse) TestSecurity(io.quarkus.test.security.TestSecurity) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 3 with ProcessorListResponse

use of com.redhat.service.bridge.manager.api.models.responses.ProcessorListResponse in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorAPITest method listProcessors_pageOffset.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void listProcessors_pageOffset() {
    BridgeResponse bridgeResponse = createAndDeployBridge();
    TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor", createKafkaAction())).as(ProcessorResponse.class);
    ProcessorResponse p2 = TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest("myProcessor2", createKafkaAction())).as(ProcessorResponse.class);
    ProcessorListResponse listResponse = TestUtils.listProcessors(bridgeResponse.getId(), 1, 1).as(ProcessorListResponse.class);
    assertThat(listResponse.getPage()).isEqualTo(1L);
    assertThat(listResponse.getSize()).isEqualTo(1L);
    assertThat(listResponse.getTotal()).isEqualTo(2L);
    assertThat(listResponse.getItems().get(0).getId()).isEqualTo(p2.getId());
    assertRequestedAction(listResponse.getItems().get(0));
}
Also used : ProcessorResponse(com.redhat.service.bridge.manager.api.models.responses.ProcessorResponse) ProcessorListResponse(com.redhat.service.bridge.manager.api.models.responses.ProcessorListResponse) ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) BridgeResponse(com.redhat.service.bridge.manager.api.models.responses.BridgeResponse) TestSecurity(io.quarkus.test.security.TestSecurity) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 4 with ProcessorListResponse

use of com.redhat.service.bridge.manager.api.models.responses.ProcessorListResponse 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)

Aggregations

ProcessorListResponse (com.redhat.service.bridge.manager.api.models.responses.ProcessorListResponse)4 BridgeResponse (com.redhat.service.bridge.manager.api.models.responses.BridgeResponse)3 ProcessorRequest (com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest)2 ProcessorResponse (com.redhat.service.bridge.manager.api.models.responses.ProcessorResponse)2 QuarkusTest (io.quarkus.test.junit.QuarkusTest)2 TestSecurity (io.quarkus.test.security.TestSecurity)2 Test (org.junit.jupiter.api.Test)2 ManagedResourceStatus (com.redhat.service.bridge.infra.models.dto.ManagedResourceStatus)1 BridgeUtils (com.redhat.service.bridge.integration.tests.common.BridgeUtils)1 BridgeContext (com.redhat.service.bridge.integration.tests.context.BridgeContext)1 ProcessorContext (com.redhat.service.bridge.integration.tests.context.ProcessorContext)1 TestContext (com.redhat.service.bridge.integration.tests.context.TestContext)1 BridgeResource (com.redhat.service.bridge.integration.tests.resources.BridgeResource)1 ProcessorResource (com.redhat.service.bridge.integration.tests.resources.ProcessorResource)1 Logger (io.cucumber.core.logging.Logger)1 LoggerFactory (io.cucumber.core.logging.LoggerFactory)1 After (io.cucumber.java.After)1 Before (io.cucumber.java.Before)1 Scenario (io.cucumber.java.Scenario)1 And (io.cucumber.java.en.And)1