Search in sources :

Example 11 with BridgeRequest

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

the class ShardBridgesSyncAPITest method updateProcessorStatus.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void updateProcessorStatus() {
    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);
    processors = TestUtils.getProcessorsToDeployOrDelete().as(new TypeRef<List<ProcessorDTO>>() {
    });
    assertThat(processors.size()).isZero();
}
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) TypeRef(io.restassured.common.mapper.TypeRef) ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) List(java.util.List) 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 12 with BridgeRequest

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

the class ShardBridgesSyncAPITest method testGetBridgesToDelete.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void testGetBridgesToDelete() {
    TestUtils.createBridge(new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME));
    List<BridgeDTO> bridgesToDeployOrDelete = TestUtils.getBridgesToDeployOrDelete().as(new TypeRef<List<BridgeDTO>>() {
    });
    BridgeDTO bridge = bridgesToDeployOrDelete.get(0);
    TestUtils.deleteBridge(bridge.getId()).then().statusCode(202);
    bridgesToDeployOrDelete = TestUtils.getBridgesToDeployOrDelete().as(new TypeRef<List<BridgeDTO>>() {
    });
    assertThat(bridgesToDeployOrDelete.stream().filter(x -> x.getStatus().equals(ManagedResourceStatus.ACCEPTED)).count()).isZero();
    assertThat(bridgesToDeployOrDelete.stream().filter(x -> x.getStatus().equals(ManagedResourceStatus.DEPROVISION)).count()).isEqualTo(1);
}
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 13 with BridgeRequest

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

the class ShardBridgesSyncSegmentationAPITest method testShardSegmentation.

/**
 * This test needs to be in a separated class since for the current implementation the ShardService fetches
 * the authorized shards at startup. We inject a mock for this scenario.
 */
@Test
@TestSecurity(user = "knative")
public void testShardSegmentation() {
    // the bridge gets assigned to the default shard
    TestUtils.createBridge(new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME));
    // The default shard retrieves the bridge to deploy
    List<BridgeDTO> bridgesToDeployForDefaultShard = TestUtils.getBridgesToDeployOrDelete().as(new TypeRef<List<BridgeDTO>>() {
    });
    assertThat(bridgesToDeployForDefaultShard.size()).isEqualTo(1);
    reset(jwt);
    when(jwt.getClaim(APIConstants.SUBJECT_ATTRIBUTE_CLAIM)).thenReturn("knative");
    // No bridges are assigned to the 'knative' shard
    List<BridgeDTO> bridgesToDeployForOtherShard = TestUtils.getBridgesToDeployOrDelete().as(new TypeRef<List<BridgeDTO>>() {
    });
    assertThat(bridgesToDeployForOtherShard.size()).isEqualTo(0);
}
Also used : 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 14 with BridgeRequest

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

the class BridgesAPITest method getBridge.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void getBridge() {
    Response bridgeCreateResponse = TestUtils.createBridge(new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME));
    bridgeCreateResponse.then().statusCode(201);
    BridgeResponse bridge = bridgeCreateResponse.as(BridgeResponse.class);
    BridgeResponse retrievedBridge = TestUtils.getBridge(bridge.getId()).as(BridgeResponse.class);
    assertThat(retrievedBridge).isNotNull();
    assertThat(retrievedBridge.getId()).isEqualTo(bridge.getId());
    assertThat(retrievedBridge.getName()).isEqualTo(bridge.getName());
    assertThat(retrievedBridge.getEndpoint()).isEqualTo(bridge.getEndpoint());
}
Also used : ErrorResponse(com.redhat.service.bridge.infra.api.models.responses.ErrorResponse) BridgeResponse(com.redhat.service.bridge.manager.api.models.responses.BridgeResponse) Response(io.restassured.response.Response) BridgeListResponse(com.redhat.service.bridge.manager.api.models.responses.BridgeListResponse) BridgeRequest(com.redhat.service.bridge.manager.api.models.requests.BridgeRequest) 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 15 with BridgeRequest

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

the class BridgesAPITest method testCreateAndGetBridge.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void testCreateAndGetBridge() {
    TestUtils.createBridge(new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME)).then().statusCode(201);
    BridgeListResponse bridgeListResponse = TestUtils.getBridges().as(BridgeListResponse.class);
    assertThat(bridgeListResponse.getItems().size()).isEqualTo(1);
    BridgeResponse bridgeResponse = bridgeListResponse.getItems().get(0);
    assertThat(bridgeResponse.getName()).isEqualTo(TestConstants.DEFAULT_BRIDGE_NAME);
    assertThat(bridgeResponse.getStatus()).isEqualTo(ManagedResourceStatus.ACCEPTED);
    assertThat(bridgeResponse.getHref()).isEqualTo(APIConstants.USER_API_BASE_PATH + bridgeResponse.getId());
    assertThat(bridgeResponse.getSubmittedAt()).isNotNull();
    assertThat(bridgeResponse.getEndpoint()).isNull();
}
Also used : BridgeRequest(com.redhat.service.bridge.manager.api.models.requests.BridgeRequest) BridgeListResponse(com.redhat.service.bridge.manager.api.models.responses.BridgeListResponse) 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

BridgeRequest (com.redhat.service.bridge.manager.api.models.requests.BridgeRequest)22 QuarkusTest (io.quarkus.test.junit.QuarkusTest)21 Test (org.junit.jupiter.api.Test)21 TestSecurity (io.quarkus.test.security.TestSecurity)14 BridgeResponse (com.redhat.service.bridge.manager.api.models.responses.BridgeResponse)13 BridgeDTO (com.redhat.service.bridge.infra.models.dto.BridgeDTO)10 List (java.util.List)9 KafkaConnectionDTO (com.redhat.service.bridge.infra.models.dto.KafkaConnectionDTO)8 ProcessorRequest (com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest)8 ProcessorDTO (com.redhat.service.bridge.infra.models.dto.ProcessorDTO)7 Bridge (com.redhat.service.bridge.manager.models.Bridge)7 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 TypeRef (io.restassured.common.mapper.TypeRef)4 ResponseLoggingFilter (io.restassured.filter.log.ResponseLoggingFilter)4 KafkaTopicAction (com.redhat.service.bridge.actions.kafkatopic.KafkaTopicAction)3 WebhookAction (com.redhat.service.bridge.actions.webhook.WebhookAction)3 APIConstants (com.redhat.service.bridge.infra.api.APIConstants)3 ManagedResourceStatus (com.redhat.service.bridge.infra.models.dto.ManagedResourceStatus)3