Search in sources :

Example 1 with BridgeRequest

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

the class ProcessorAPITest method createBridge.

private BridgeResponse createBridge() {
    BridgeRequest r = new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME);
    BridgeResponse bridgeResponse = TestUtils.createBridge(r).as(BridgeResponse.class);
    return bridgeResponse;
}
Also used : BridgeRequest(com.redhat.service.smartevents.manager.api.models.requests.BridgeRequest) BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse)

Example 2 with BridgeRequest

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

the class BridgesServiceTest method testCreateBridge.

@Test
public void testCreateBridge() {
    BridgeRequest request = new BridgeRequest(DEFAULT_BRIDGE_NAME);
    bridgesService.createBridge(DEFAULT_CUSTOMER_ID, DEFAULT_ORGANISATION_ID, DEFAULT_USER_NAME, request);
    // Wait for Workers to complete
    Bridge bridge = TestUtils.waitForBridgeToBeReady(bridgesService);
    assertThat(bridge.getStatus()).isEqualTo(ManagedResourceStatus.PREPARING);
    assertThat(bridge.getEndpoint()).isNull();
    ListResult<Bridge> bridges = bridgesService.getBridges(DEFAULT_CUSTOMER_ID, new QueryResourceInfo(DEFAULT_PAGE, DEFAULT_PAGE_SIZE));
    assertThat(bridges.getSize()).isEqualTo(1);
    assertThat(bridges.getItems().get(0).getOrganisationId()).isEqualTo(DEFAULT_ORGANISATION_ID);
}
Also used : BridgeRequest(com.redhat.service.smartevents.manager.api.models.requests.BridgeRequest) QueryResourceInfo(com.redhat.service.smartevents.infra.models.QueryResourceInfo) Bridge(com.redhat.service.smartevents.manager.models.Bridge) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 3 with BridgeRequest

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

the class BridgesServiceTest method testUpdateBridgeStatusReadyPublishedAt.

@Test
public void testUpdateBridgeStatusReadyPublishedAt() {
    BridgeRequest request = new BridgeRequest(DEFAULT_BRIDGE_NAME);
    bridgesService.createBridge(DEFAULT_CUSTOMER_ID, DEFAULT_ORGANISATION_ID, DEFAULT_USER_NAME, request);
    // Wait for Workers to complete
    Bridge bridge = TestUtils.waitForBridgeToBeReady(bridgesService);
    // Emulate Shard setting Bridge status to PROVISIONING
    bridge.setStatus(PROVISIONING);
    bridgesService.updateBridge(bridgesService.toDTO(bridge));
    Bridge retrievedBridge = bridgesService.getBridge(bridge.getId(), DEFAULT_CUSTOMER_ID);
    assertThat(retrievedBridge.getStatus()).isEqualTo(PROVISIONING);
    assertThat(retrievedBridge.getPublishedAt()).isNull();
    // Once ready it should have its published date set
    bridge.setStatus(READY);
    bridgesService.updateBridge(bridgesService.toDTO(bridge));
    Bridge publishedBridge = bridgesService.getBridge(bridge.getId(), DEFAULT_CUSTOMER_ID);
    assertThat(publishedBridge.getStatus()).isEqualTo(READY);
    ZonedDateTime publishedAt = publishedBridge.getPublishedAt();
    assertThat(publishedAt).isNotNull();
    // Check calls to set PublishedAt at idempotent
    bridgesService.updateBridge(bridgesService.toDTO(bridge));
    Bridge publishedBridge2 = bridgesService.getBridge(bridge.getId(), DEFAULT_CUSTOMER_ID);
    assertThat(publishedBridge2.getStatus()).isEqualTo(READY);
    assertThat(publishedBridge2.getPublishedAt()).isEqualTo(publishedAt);
}
Also used : BridgeRequest(com.redhat.service.smartevents.manager.api.models.requests.BridgeRequest) ZonedDateTime(java.time.ZonedDateTime) Bridge(com.redhat.service.smartevents.manager.models.Bridge) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 4 with BridgeRequest

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

the class BridgesServiceTest method testUpdateBridgeStatus.

@Test
public void testUpdateBridgeStatus() {
    BridgeRequest request = new BridgeRequest(DEFAULT_BRIDGE_NAME);
    bridgesService.createBridge(DEFAULT_CUSTOMER_ID, DEFAULT_ORGANISATION_ID, DEFAULT_USER_NAME, request);
    // Wait for Workers to complete
    Bridge bridge = TestUtils.waitForBridgeToBeReady(bridgesService);
    assertThat(bridge.getStatus()).isEqualTo(ManagedResourceStatus.PREPARING);
    // Emulate Shard setting Bridge status to PROVISIONING
    bridge.setStatus(PROVISIONING);
    bridgesService.updateBridge(bridgesService.toDTO(bridge));
    assertThat(bridgesService.findByShardIdWithReadyDependencies(SHARD_ID)).isEmpty();
    Bridge retrievedBridge = bridgesService.getBridge(bridge.getId(), DEFAULT_CUSTOMER_ID);
    assertThat(retrievedBridge.getStatus()).isEqualTo(PROVISIONING);
}
Also used : BridgeRequest(com.redhat.service.smartevents.manager.api.models.requests.BridgeRequest) Bridge(com.redhat.service.smartevents.manager.models.Bridge) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 5 with BridgeRequest

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

the class ShardBridgesSyncAPITest method testNotifyDeletion.

@Test
@TestSecurity(user = DEFAULT_CUSTOMER_ID)
public void testNotifyDeletion() {
    TestUtils.createBridge(new BridgeRequest(DEFAULT_BRIDGE_NAME));
    final List<BridgeDTO> bridgesToDeployOrDelete = new ArrayList<>();
    await().atMost(5, SECONDS).untilAsserted(() -> {
        bridgesToDeployOrDelete.clear();
        bridgesToDeployOrDelete.addAll(TestUtils.getBridgesToDeployOrDelete().as(new TypeRef<List<BridgeDTO>>() {
        }));
        assertThat(bridgesToDeployOrDelete.size()).isEqualTo(1);
    });
    BridgeDTO bridge = bridgesToDeployOrDelete.get(0);
    bridge.setStatus(READY);
    TestUtils.updateBridge(bridge).then().statusCode(200);
    TestUtils.deleteBridge(bridge.getId()).then().statusCode(202);
    BridgeResponse bridgeResponse = TestUtils.getBridge(bridge.getId()).as(BridgeResponse.class);
    assertThat(bridgeResponse.getStatus()).isEqualTo(DEPROVISION);
    bridge.setStatus(DELETED);
    TestUtils.updateBridge(bridge).then().statusCode(200);
    TestUtils.getBridge(bridge.getId()).then().statusCode(404);
}
Also used : BridgeRequest(com.redhat.service.smartevents.manager.api.models.requests.BridgeRequest) BridgeDTO(com.redhat.service.smartevents.infra.models.dto.BridgeDTO) TypeRef(io.restassured.common.mapper.TypeRef) ArrayList(java.util.ArrayList) 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

BridgeRequest (com.redhat.service.smartevents.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.smartevents.manager.api.models.responses.BridgeResponse)13 BridgeDTO (com.redhat.service.smartevents.infra.models.dto.BridgeDTO)10 TypeRef (io.restassured.common.mapper.TypeRef)9 ArrayList (java.util.ArrayList)9 KafkaConnectionDTO (com.redhat.service.smartevents.infra.models.dto.KafkaConnectionDTO)8 ProcessorRequest (com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest)8 ProcessorDTO (com.redhat.service.smartevents.infra.models.dto.ProcessorDTO)7 Bridge (com.redhat.service.smartevents.manager.models.Bridge)7 BaseFilter (com.redhat.service.smartevents.infra.models.filters.BaseFilter)5 StringEquals (com.redhat.service.smartevents.infra.models.filters.StringEquals)5 Action (com.redhat.service.smartevents.infra.models.gateways.Action)5 KafkaTopicAction (com.redhat.service.smartevents.processor.actions.kafkatopic.KafkaTopicAction)4 SendToBridgeAction (com.redhat.service.smartevents.processor.actions.sendtobridge.SendToBridgeAction)4 WebhookAction (com.redhat.service.smartevents.processor.actions.webhook.WebhookAction)4 ACCOUNT_ID_SERVICE_ACCOUNT_ATTRIBUTE_CLAIM (com.redhat.service.smartevents.infra.api.APIConstants.ACCOUNT_ID_SERVICE_ACCOUNT_ATTRIBUTE_CLAIM)3 ORG_ID_SERVICE_ACCOUNT_ATTRIBUTE_CLAIM (com.redhat.service.smartevents.infra.api.APIConstants.ORG_ID_SERVICE_ACCOUNT_ATTRIBUTE_CLAIM)3