Search in sources :

Example 26 with BridgeResponse

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

the class ProcessorAPITest method getProcessorWithSendToBridgeAction.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void getProcessorWithSendToBridgeAction() {
    BridgeResponse bridgeResponse = createAndDeployBridge();
    String bridgeId = bridgeResponse.getId();
    Response response = TestUtils.addProcessorToBridge(bridgeId, new ProcessorRequest("myProcessor", TestUtils.createSendToBridgeAction(bridgeId)));
    assertThat(response.getStatusCode()).isEqualTo(202);
    ProcessorResponse pr = response.as(ProcessorResponse.class);
    assertThat(pr.getAction().getType()).isEqualTo(SendToBridgeAction.TYPE);
    assertThat(pr.getAction().getParameter(SendToBridgeAction.BRIDGE_ID_PARAM)).isEqualTo(bridgeId);
    ProcessorResponse found = TestUtils.getProcessor(bridgeId, pr.getId()).as(ProcessorResponse.class);
    assertThat(found.getId()).isEqualTo(pr.getId());
    assertThat(found.getAction().getType()).isEqualTo(SendToBridgeAction.TYPE);
    assertThat(found.getAction().getParameter(SendToBridgeAction.BRIDGE_ID_PARAM)).isEqualTo(bridgeId);
}
Also used : ProcessorResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse) ProcessorListResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse) BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse) Response(io.restassured.response.Response) ProcessorResponse(com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse) 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 27 with BridgeResponse

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

the class BridgesServiceImpl method toResponse.

@Override
public BridgeResponse toResponse(Bridge bridge) {
    BridgeResponse response = new BridgeResponse();
    response.setId(bridge.getId());
    response.setName(bridge.getName());
    response.setEndpoint(bridge.getEndpoint());
    response.setSubmittedAt(bridge.getSubmittedAt());
    response.setPublishedAt(bridge.getPublishedAt());
    response.setStatus(bridge.getStatus());
    response.setHref(APIConstants.USER_API_BASE_PATH + bridge.getId());
    response.setOwner(bridge.getOwner());
    response.setErrorHandler(bridge.getDefinition().getErrorHandler());
    return response;
}
Also used : BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse)

Example 28 with BridgeResponse

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

the class BridgeSteps method createNewBridgeWithSupplier.

private void createNewBridgeWithSupplier(String testBridgeName, BiFunction<TestContext, String, BridgeResponse> bridgeCreator) {
    String systemBridgeName = Utils.generateId("test-" + testBridgeName);
    int creationRetry = 1;
    while (creationRetry <= BRIDGE_NAME_CREATE_RETRY && isBridgeExisting(systemBridgeName)) {
        creationRetry++;
        systemBridgeName = Utils.generateId("test-" + testBridgeName);
    }
    if (isBridgeExisting(systemBridgeName)) {
        throw new RuntimeException("Cannot create and initiate a random bridge name correctly. Please cleanup the environment...");
    }
    BridgeResponse response = bridgeCreator.apply(context, systemBridgeName);
    assertThat(response.getName()).isEqualTo(systemBridgeName);
    assertThat(response.getStatus()).isEqualTo(ManagedResourceStatus.ACCEPTED);
    assertThat(response.getEndpoint()).isNull();
    assertThat(response.getPublishedAt()).isNull();
    assertThat(response.getHref()).isNotNull();
    assertThat(response.getSubmittedAt()).isNotNull();
    context.newBridge(testBridgeName, response.getId(), systemBridgeName);
}
Also used : BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse)

Example 29 with BridgeResponse

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

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

BridgeResponse (com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse)48 QuarkusTest (io.quarkus.test.junit.QuarkusTest)42 TestSecurity (io.quarkus.test.security.TestSecurity)42 Test (org.junit.jupiter.api.Test)42 ProcessorRequest (com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest)29 ProcessorListResponse (com.redhat.service.smartevents.manager.api.models.responses.ProcessorListResponse)27 ProcessorResponse (com.redhat.service.smartevents.manager.api.models.responses.ProcessorResponse)26 Response (io.restassured.response.Response)19 BridgeRequest (com.redhat.service.smartevents.manager.api.models.requests.BridgeRequest)10 BridgeListResponse (com.redhat.service.smartevents.manager.api.models.responses.BridgeListResponse)8 BridgeDTO (com.redhat.service.smartevents.infra.models.dto.BridgeDTO)7 BaseFilter (com.redhat.service.smartevents.infra.models.filters.BaseFilter)7 StringEquals (com.redhat.service.smartevents.infra.models.filters.StringEquals)7 Action (com.redhat.service.smartevents.infra.models.gateways.Action)6 TypeRef (io.restassured.common.mapper.TypeRef)6 ArrayList (java.util.ArrayList)6 KafkaConnectionDTO (com.redhat.service.smartevents.infra.models.dto.KafkaConnectionDTO)5 Bridge (com.redhat.service.smartevents.manager.models.Bridge)5 KafkaTopicAction (com.redhat.service.smartevents.processor.actions.kafkatopic.KafkaTopicAction)5 SendToBridgeAction (com.redhat.service.smartevents.processor.actions.sendtobridge.SendToBridgeAction)5