Search in sources :

Example 1 with BridgeResponse

use of com.redhat.service.bridge.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.bridge.integration.tests.context.BridgeContext) BridgeListResponse(com.redhat.service.bridge.manager.api.models.responses.BridgeListResponse) BridgeResponse(com.redhat.service.bridge.manager.api.models.responses.BridgeResponse) And(io.cucumber.java.en.And)

Example 2 with BridgeResponse

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

use of com.redhat.service.bridge.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());
    return response;
}
Also used : BridgeResponse(com.redhat.service.bridge.manager.api.models.responses.BridgeResponse)

Example 4 with BridgeResponse

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

the class ShardBridgesSyncAPITest method getProcessorsWithKafkaAction.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void getProcessorsWithKafkaAction() {
    BridgeResponse bridgeResponse = TestUtils.createBridge(new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME)).as(BridgeResponse.class);
    BridgeDTO bridge = new BridgeDTO(bridgeResponse.getId(), bridgeResponse.getName(), TEST_BRIDGE_ENDPOINT, TestConstants.DEFAULT_CUSTOMER_ID, ManagedResourceStatus.READY, new KafkaConnectionDTO());
    Set<BaseFilter> filters = Collections.singleton(new StringEquals("json.key", "value"));
    TestUtils.updateBridge(bridge);
    TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest(TestConstants.DEFAULT_PROCESSOR_NAME, filters, null, TestUtils.createKafkaAction()));
    List<ProcessorDTO> processors = TestUtils.getProcessorsToDeployOrDelete().as(new TypeRef<List<ProcessorDTO>>() {
    });
    assertThat(processors.size()).isEqualTo(1);
    ProcessorDTO processor = processors.get(0);
    assertThat(processor.getName()).isEqualTo(TestConstants.DEFAULT_PROCESSOR_NAME);
    assertThat(processor.getStatus()).isEqualTo(ManagedResourceStatus.ACCEPTED);
    assertThat(processor.getDefinition().getFilters().size()).isEqualTo(1);
    assertThat(processor.getDefinition().getRequestedAction()).isNotNull();
    assertThat(processor.getDefinition().getRequestedAction().getType()).isEqualTo(KafkaTopicAction.TYPE);
    assertThat(processor.getDefinition().getRequestedAction().getParameters()).containsEntry(KafkaTopicAction.TOPIC_PARAM, TestConstants.DEFAULT_KAFKA_TOPIC);
    assertThat(processor.getDefinition().getResolvedAction()).isNotNull();
    assertThat(processor.getDefinition().getResolvedAction().getType()).isEqualTo(KafkaTopicAction.TYPE);
    assertThat(processor.getDefinition().getResolvedAction().getParameters()).containsEntry(KafkaTopicAction.TOPIC_PARAM, TestConstants.DEFAULT_KAFKA_TOPIC);
}
Also used : StringEquals(com.redhat.service.bridge.infra.models.filters.StringEquals) BridgeRequest(com.redhat.service.bridge.manager.api.models.requests.BridgeRequest) BridgeDTO(com.redhat.service.bridge.infra.models.dto.BridgeDTO) KafkaConnectionDTO(com.redhat.service.bridge.infra.models.dto.KafkaConnectionDTO) ProcessorDTO(com.redhat.service.bridge.infra.models.dto.ProcessorDTO) ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) List(java.util.List) BridgeResponse(com.redhat.service.bridge.manager.api.models.responses.BridgeResponse) BaseFilter(com.redhat.service.bridge.infra.models.filters.BaseFilter) TestSecurity(io.quarkus.test.security.TestSecurity) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 5 with BridgeResponse

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

the class ShardBridgesSyncAPITest method metricsAreProduced.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void metricsAreProduced() {
    BridgeResponse bridgeResponse = TestUtils.createBridge(new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME)).as(BridgeResponse.class);
    BridgeDTO bridge = new BridgeDTO(bridgeResponse.getId(), bridgeResponse.getName(), TEST_BRIDGE_ENDPOINT, TestConstants.DEFAULT_CUSTOMER_ID, ManagedResourceStatus.READY, new KafkaConnectionDTO());
    TestUtils.updateBridge(bridge);
    TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest(TestConstants.DEFAULT_PROCESSOR_NAME, TestUtils.createKafkaAction()));
    List<ProcessorDTO> processors = TestUtils.getProcessorsToDeployOrDelete().as(new TypeRef<List<ProcessorDTO>>() {
    });
    ProcessorDTO processor = processors.get(0);
    processor.setStatus(ManagedResourceStatus.READY);
    TestUtils.updateProcessor(processor);
    String metrics = given().filter(new ResponseLoggingFilter()).contentType(ContentType.JSON).when().get("/q/metrics").then().extract().body().asString();
    assertThat(metrics).contains("manager_processor_status_change_total");
    assertThat(metrics).contains("manager_bridge_status_change_total");
}
Also used : BridgeRequest(com.redhat.service.bridge.manager.api.models.requests.BridgeRequest) BridgeDTO(com.redhat.service.bridge.infra.models.dto.BridgeDTO) KafkaConnectionDTO(com.redhat.service.bridge.infra.models.dto.KafkaConnectionDTO) ProcessorDTO(com.redhat.service.bridge.infra.models.dto.ProcessorDTO) ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) List(java.util.List) ResponseLoggingFilter(io.restassured.filter.log.ResponseLoggingFilter) 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)

Aggregations

BridgeResponse (com.redhat.service.bridge.manager.api.models.responses.BridgeResponse)30 QuarkusTest (io.quarkus.test.junit.QuarkusTest)24 TestSecurity (io.quarkus.test.security.TestSecurity)24 Test (org.junit.jupiter.api.Test)24 ProcessorRequest (com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest)20 ProcessorListResponse (com.redhat.service.bridge.manager.api.models.responses.ProcessorListResponse)16 ProcessorResponse (com.redhat.service.bridge.manager.api.models.responses.ProcessorResponse)16 Response (io.restassured.response.Response)14 BridgeRequest (com.redhat.service.bridge.manager.api.models.requests.BridgeRequest)10 BridgeDTO (com.redhat.service.bridge.infra.models.dto.BridgeDTO)7 BaseFilter (com.redhat.service.bridge.infra.models.filters.BaseFilter)7 StringEquals (com.redhat.service.bridge.infra.models.filters.StringEquals)7 KafkaConnectionDTO (com.redhat.service.bridge.infra.models.dto.KafkaConnectionDTO)5 List (java.util.List)5 ProcessorDTO (com.redhat.service.bridge.infra.models.dto.ProcessorDTO)4 BaseAction (com.redhat.service.bridge.infra.models.actions.BaseAction)3 BridgeListResponse (com.redhat.service.bridge.manager.api.models.responses.BridgeListResponse)3 ErrorResponse (com.redhat.service.bridge.infra.api.models.responses.ErrorResponse)1 ManagedResourceStatus (com.redhat.service.bridge.infra.models.dto.ManagedResourceStatus)1 ValuesIn (com.redhat.service.bridge.infra.models.filters.ValuesIn)1