Search in sources :

Example 6 with ProcessorListResponse

use of com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse 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;
            }
        });
    }
}
Also used : WebhookSiteQuerySorting(com.redhat.service.smartevents.integration.tests.resources.webhook.site.WebhookSiteQuerySorting) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Scenario(io.cucumber.java.Scenario) BridgeResource(com.redhat.service.smartevents.integration.tests.resources.BridgeResource) ProcessorListResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse) BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse) Duration(java.time.Duration) Utils(com.redhat.service.smartevents.integration.tests.common.Utils) ProcessorResource(com.redhat.service.smartevents.integration.tests.resources.ProcessorResource) Properties(java.util.Properties) WebhookSiteResource(com.redhat.service.smartevents.integration.tests.resources.webhook.site.WebhookSiteResource) BridgeUtils(com.redhat.service.smartevents.integration.tests.common.BridgeUtils) BeforeAll(io.cucumber.java.BeforeAll) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) File(java.io.File) ZoneId(java.time.ZoneId) Objects(java.util.Objects) After(io.cucumber.java.After) LocalDate(java.time.LocalDate) TestContext(com.redhat.service.smartevents.integration.tests.context.TestContext) Optional(java.util.Optional) ManagedResourceStatus(com.redhat.service.smartevents.infra.models.dto.ManagedResourceStatus) Before(io.cucumber.java.Before) Awaitility(org.awaitility.Awaitility) InputStream(java.io.InputStream) ProcessorListResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse) BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse) IOException(java.io.IOException) After(io.cucumber.java.After)

Example 7 with ProcessorListResponse

use of com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse 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 8 with ProcessorListResponse

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

the class ProcessorAPITest method listProcessorsFilterByMultipleStatuses.

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

Example 9 with ProcessorListResponse

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

the class ProcessorAPITest method listProcessorsFilterByName.

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

Example 10 with ProcessorListResponse

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

the class ProcessorAPITest method listProcessorsFilterByNameAndType.

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

Aggregations

ProcessorListResponse (com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse)11 BridgeResponse (com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse)10 ProcessorRequest (com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest)9 ProcessorResponse (com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse)9 QuarkusTest (io.quarkus.test.junit.QuarkusTest)9 TestSecurity (io.quarkus.test.security.TestSecurity)9 Test (org.junit.jupiter.api.Test)9 ManagedResourceStatus (com.redhat.service.smartevents.infra.models.dto.ManagedResourceStatus)1 BridgeUtils (com.redhat.service.smartevents.integration.tests.common.BridgeUtils)1 Utils (com.redhat.service.smartevents.integration.tests.common.Utils)1 BridgeContext (com.redhat.service.smartevents.integration.tests.context.BridgeContext)1 ProcessorContext (com.redhat.service.smartevents.integration.tests.context.ProcessorContext)1 TestContext (com.redhat.service.smartevents.integration.tests.context.TestContext)1 BridgeResource (com.redhat.service.smartevents.integration.tests.resources.BridgeResource)1 ProcessorResource (com.redhat.service.smartevents.integration.tests.resources.ProcessorResource)1 WebhookSiteQuerySorting (com.redhat.service.smartevents.integration.tests.resources.webhook.site.WebhookSiteQuerySorting)1 WebhookSiteResource (com.redhat.service.smartevents.integration.tests.resources.webhook.site.WebhookSiteResource)1 After (io.cucumber.java.After)1 Before (io.cucumber.java.Before)1 BeforeAll (io.cucumber.java.BeforeAll)1