Search in sources :

Example 1 with BridgeDTO

use of com.redhat.service.bridge.infra.models.dto.BridgeDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ShardBridgesSyncAPITest method testGetBridgesToDeploy.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void testGetBridgesToDeploy() {
    TestUtils.createBridge(new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME));
    List<BridgeDTO> response = TestUtils.getBridgesToDeployOrDelete().as(new TypeRef<List<BridgeDTO>>() {
    });
    assertThat(response.stream().filter(x -> x.getStatus().equals(ManagedResourceStatus.ACCEPTED)).count()).isEqualTo(1);
    BridgeDTO bridge = response.get(0);
    assertThat(bridge.getName()).isEqualTo(TestConstants.DEFAULT_BRIDGE_NAME);
    assertThat(bridge.getCustomerId()).isEqualTo(TestConstants.DEFAULT_CUSTOMER_ID);
    assertThat(bridge.getStatus()).isEqualTo(ManagedResourceStatus.ACCEPTED);
    assertThat(bridge.getEndpoint()).isNull();
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) StringEquals(com.redhat.service.bridge.infra.models.filters.StringEquals) BaseFilter(com.redhat.service.bridge.infra.models.filters.BaseFilter) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) BridgeRequest(com.redhat.service.bridge.manager.api.models.requests.BridgeRequest) RhoasService(com.redhat.service.bridge.manager.RhoasService) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Inject(javax.inject.Inject) DatabaseManagerUtils(com.redhat.service.bridge.manager.utils.DatabaseManagerUtils) BaseAction(com.redhat.service.bridge.infra.models.actions.BaseAction) KafkaTopicAction(com.redhat.service.bridge.actions.kafkatopic.KafkaTopicAction) WebhookAction(com.redhat.service.bridge.actions.webhook.WebhookAction) TypeRef(io.restassured.common.mapper.TypeRef) TestConstants(com.redhat.service.bridge.manager.TestConstants) InjectMock(io.quarkus.test.junit.mockito.InjectMock) ResponseLoggingFilter(io.restassured.filter.log.ResponseLoggingFilter) ContentType(io.restassured.http.ContentType) Set(java.util.Set) Mockito.when(org.mockito.Mockito.when) BridgeResponse(com.redhat.service.bridge.manager.api.models.responses.BridgeResponse) BridgeDTO(com.redhat.service.bridge.infra.models.dto.BridgeDTO) Test(org.junit.jupiter.api.Test) List(java.util.List) ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) ManagedResourceStatus(com.redhat.service.bridge.infra.models.dto.ManagedResourceStatus) JsonWebToken(org.eclipse.microprofile.jwt.JsonWebToken) ProcessorDTO(com.redhat.service.bridge.infra.models.dto.ProcessorDTO) SendToBridgeAction(com.redhat.service.bridge.manager.actions.sendtobridge.SendToBridgeAction) TestUtils(com.redhat.service.bridge.manager.utils.TestUtils) RestAssured.given(io.restassured.RestAssured.given) KafkaConnectionDTO(com.redhat.service.bridge.infra.models.dto.KafkaConnectionDTO) TestSecurity(io.quarkus.test.security.TestSecurity) Collections(java.util.Collections) Mockito.reset(org.mockito.Mockito.reset) APIConstants(com.redhat.service.bridge.infra.api.APIConstants) BridgeRequest(com.redhat.service.bridge.manager.api.models.requests.BridgeRequest) BridgeDTO(com.redhat.service.bridge.infra.models.dto.BridgeDTO) List(java.util.List) TestSecurity(io.quarkus.test.security.TestSecurity) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 2 with BridgeDTO

use of com.redhat.service.bridge.infra.models.dto.BridgeDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ShardBridgesSyncAPITest method testNotifyDeployment.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void testNotifyDeployment() {
    TestUtils.createBridge(new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME));
    List<BridgeDTO> bridgesToDeployOrDelete = TestUtils.getBridgesToDeployOrDelete().as(new TypeRef<List<BridgeDTO>>() {
    });
    assertThat(bridgesToDeployOrDelete.stream().filter(x -> x.getStatus().equals(ManagedResourceStatus.ACCEPTED)).count()).isEqualTo(1);
    BridgeDTO bridge = bridgesToDeployOrDelete.get(0);
    bridge.setStatus(ManagedResourceStatus.PROVISIONING);
    TestUtils.updateBridge(bridge).then().statusCode(200);
    bridgesToDeployOrDelete = TestUtils.getBridgesToDeployOrDelete().as(new TypeRef<List<BridgeDTO>>() {
    });
    assertThat(bridgesToDeployOrDelete.size()).isZero();
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) StringEquals(com.redhat.service.bridge.infra.models.filters.StringEquals) BaseFilter(com.redhat.service.bridge.infra.models.filters.BaseFilter) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) BridgeRequest(com.redhat.service.bridge.manager.api.models.requests.BridgeRequest) RhoasService(com.redhat.service.bridge.manager.RhoasService) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Inject(javax.inject.Inject) DatabaseManagerUtils(com.redhat.service.bridge.manager.utils.DatabaseManagerUtils) BaseAction(com.redhat.service.bridge.infra.models.actions.BaseAction) KafkaTopicAction(com.redhat.service.bridge.actions.kafkatopic.KafkaTopicAction) WebhookAction(com.redhat.service.bridge.actions.webhook.WebhookAction) TypeRef(io.restassured.common.mapper.TypeRef) TestConstants(com.redhat.service.bridge.manager.TestConstants) InjectMock(io.quarkus.test.junit.mockito.InjectMock) ResponseLoggingFilter(io.restassured.filter.log.ResponseLoggingFilter) ContentType(io.restassured.http.ContentType) Set(java.util.Set) Mockito.when(org.mockito.Mockito.when) BridgeResponse(com.redhat.service.bridge.manager.api.models.responses.BridgeResponse) BridgeDTO(com.redhat.service.bridge.infra.models.dto.BridgeDTO) Test(org.junit.jupiter.api.Test) List(java.util.List) ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) ManagedResourceStatus(com.redhat.service.bridge.infra.models.dto.ManagedResourceStatus) JsonWebToken(org.eclipse.microprofile.jwt.JsonWebToken) ProcessorDTO(com.redhat.service.bridge.infra.models.dto.ProcessorDTO) SendToBridgeAction(com.redhat.service.bridge.manager.actions.sendtobridge.SendToBridgeAction) TestUtils(com.redhat.service.bridge.manager.utils.TestUtils) RestAssured.given(io.restassured.RestAssured.given) KafkaConnectionDTO(com.redhat.service.bridge.infra.models.dto.KafkaConnectionDTO) TestSecurity(io.quarkus.test.security.TestSecurity) Collections(java.util.Collections) Mockito.reset(org.mockito.Mockito.reset) APIConstants(com.redhat.service.bridge.infra.api.APIConstants) BridgeRequest(com.redhat.service.bridge.manager.api.models.requests.BridgeRequest) BridgeDTO(com.redhat.service.bridge.infra.models.dto.BridgeDTO) TypeRef(io.restassured.common.mapper.TypeRef) List(java.util.List) TestSecurity(io.quarkus.test.security.TestSecurity) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 3 with BridgeDTO

use of com.redhat.service.bridge.infra.models.dto.BridgeDTO 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 4 with BridgeDTO

use of com.redhat.service.bridge.infra.models.dto.BridgeDTO 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)

Example 5 with BridgeDTO

use of com.redhat.service.bridge.infra.models.dto.BridgeDTO in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgesAPITest method testDeleteBridgeWithActiveProcessors.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void testDeleteBridgeWithActiveProcessors() {
    BridgeResponse bridgeResponse = TestUtils.createBridge(new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME)).as(BridgeResponse.class);
    TestUtils.updateBridge(new BridgeDTO(bridgeResponse.getId(), bridgeResponse.getName(), bridgeResponse.getEndpoint(), TestConstants.DEFAULT_CUSTOMER_ID, ManagedResourceStatus.READY, new KafkaConnectionDTO()));
    TestUtils.addProcessorToBridge(bridgeResponse.getId(), new ProcessorRequest(TestConstants.DEFAULT_PROCESSOR_NAME, TestUtils.createKafkaAction())).then().statusCode(201);
    TestUtils.deleteBridge(bridgeResponse.getId()).then().statusCode(400);
}
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) 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)

Aggregations

BridgeDTO (com.redhat.service.bridge.infra.models.dto.BridgeDTO)29 Test (org.junit.jupiter.api.Test)24 QuarkusTest (io.quarkus.test.junit.QuarkusTest)23 TestSecurity (io.quarkus.test.security.TestSecurity)11 BridgeRequest (com.redhat.service.bridge.manager.api.models.requests.BridgeRequest)10 BridgeResponse (com.redhat.service.bridge.manager.api.models.responses.BridgeResponse)10 KafkaConnectionDTO (com.redhat.service.bridge.infra.models.dto.KafkaConnectionDTO)9 ProcessorDTO (com.redhat.service.bridge.infra.models.dto.ProcessorDTO)9 List (java.util.List)9 ProcessorRequest (com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest)8 BridgeIngress (com.redhat.service.bridge.shard.operator.resources.BridgeIngress)6 BaseFilter (com.redhat.service.bridge.infra.models.filters.BaseFilter)5 StringEquals (com.redhat.service.bridge.infra.models.filters.StringEquals)5 BaseAction (com.redhat.service.bridge.infra.models.actions.BaseAction)4 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)4 TypeRef (io.restassured.common.mapper.TypeRef)4 ResponseLoggingFilter (io.restassured.filter.log.ResponseLoggingFilter)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 KafkaTopicAction (com.redhat.service.bridge.actions.kafkatopic.KafkaTopicAction)3 WebhookAction (com.redhat.service.bridge.actions.webhook.WebhookAction)3