Search in sources :

Example 11 with BridgeRequest

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

the class BridgesServiceTest method getBridge.

@Test
public void getBridge() {
    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);
    Bridge found = bridgesService.getBridge(bridge.getId());
    assertThat(found).isNotNull();
    assertThat(found.getId()).isEqualTo(bridge.getId());
}
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 12 with BridgeRequest

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

the class BridgesServiceTest method testGetBridges.

@Test
public void testGetBridges() {
    BridgeRequest request = new BridgeRequest(DEFAULT_BRIDGE_NAME);
    bridgesService.createBridge(DEFAULT_CUSTOMER_ID, DEFAULT_ORGANISATION_ID, DEFAULT_USER_NAME, request);
    ListResult<Bridge> bridges = bridgesService.getBridges(DEFAULT_CUSTOMER_ID, new QueryResourceInfo(DEFAULT_PAGE, DEFAULT_PAGE_SIZE));
    assertThat(bridges.getSize()).isEqualTo(1);
    assertThat(bridges.getTotal()).isEqualTo(1);
    assertThat(bridges.getPage()).isZero();
    // filter by customer id not implemented yet
    bridges = bridgesService.getBridges("not-the-id", new QueryResourceInfo(DEFAULT_PAGE, DEFAULT_PAGE_SIZE));
    assertThat(bridges.getSize()).isZero();
    assertThat(bridges.getTotal()).isZero();
    assertThat(bridges.getPage()).isZero();
}
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 13 with BridgeRequest

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

the class BridgesServiceTest method testGetBridgeWithWrongCustomerId.

@Test
public void testGetBridgeWithWrongCustomerId() {
    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);
    assertThatExceptionOfType(ItemNotFoundException.class).isThrownBy(() -> bridgesService.getBridge(bridge.getId(), "not-the-customerId"));
}
Also used : BridgeRequest(com.redhat.service.smartevents.manager.api.models.requests.BridgeRequest) Bridge(com.redhat.service.smartevents.manager.models.Bridge) ItemNotFoundException(com.redhat.service.smartevents.infra.exceptions.definitions.user.ItemNotFoundException) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 14 with BridgeRequest

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

the class BridgesServiceTest method testGetBridge.

@Test
public void testGetBridge() {
    BridgeRequest request = new BridgeRequest(DEFAULT_BRIDGE_NAME);
    Bridge bridge = bridgesService.createBridge(DEFAULT_CUSTOMER_ID, DEFAULT_ORGANISATION_ID, DEFAULT_USER_NAME, request);
    // Wait for Workers to complete
    TestUtils.waitForBridgeToBeReady(bridgesService);
    Bridge retrievedBridge = bridgesService.getBridge(bridge.getId(), DEFAULT_CUSTOMER_ID);
    assertThat(retrievedBridge).isNotNull();
    assertThat(retrievedBridge.getName()).isEqualTo(bridge.getName());
    assertThat(retrievedBridge.getCustomerId()).isEqualTo(bridge.getCustomerId());
    // Bridges are moved to the PREPARING status by Workers
    assertThat(retrievedBridge.getStatus()).isEqualTo(ManagedResourceStatus.PREPARING);
    assertThat(retrievedBridge.getShardId()).isEqualTo(SHARD_ID);
}
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 15 with BridgeRequest

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

the class ShardBridgesSyncAPITest method testGetBridgesToDeploy.

@Test
@TestSecurity(user = DEFAULT_CUSTOMER_ID)
public void testGetBridgesToDeploy() {
    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.stream().filter(x -> x.getStatus().equals(PREPARING)).count()).isEqualTo(1);
    });
    BridgeDTO bridge = bridgesToDeployOrDelete.get(0);
    assertThat(bridge.getName()).isEqualTo(DEFAULT_BRIDGE_NAME);
    assertThat(bridge.getCustomerId()).isEqualTo(DEFAULT_CUSTOMER_ID);
    assertThat(bridge.getStatus()).isEqualTo(PREPARING);
    assertThat(bridge.getEndpoint()).isNull();
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) PREPARING(com.redhat.service.smartevents.infra.models.dto.ManagedResourceStatus.PREPARING) Action(com.redhat.service.smartevents.infra.models.gateways.Action) PROVISIONING(com.redhat.service.smartevents.infra.models.dto.ManagedResourceStatus.PROVISIONING) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) DatabaseManagerUtils(com.redhat.service.smartevents.manager.utils.DatabaseManagerUtils) TestUtils(com.redhat.service.smartevents.manager.utils.TestUtils) ACCOUNT_ID_SERVICE_ACCOUNT_ATTRIBUTE_CLAIM(com.redhat.service.smartevents.infra.api.APIConstants.ACCOUNT_ID_SERVICE_ACCOUNT_ATTRIBUTE_CLAIM) DEFAULT_USER_NAME(com.redhat.service.smartevents.manager.TestConstants.DEFAULT_USER_NAME) DEPROVISION(com.redhat.service.smartevents.infra.models.dto.ManagedResourceStatus.DEPROVISION) DEFAULT_ORGANISATION_ID(com.redhat.service.smartevents.manager.TestConstants.DEFAULT_ORGANISATION_ID) DEFAULT_CUSTOMER_ID(com.redhat.service.smartevents.manager.TestConstants.DEFAULT_CUSTOMER_ID) TypeRef(io.restassured.common.mapper.TypeRef) WebhookAction(com.redhat.service.smartevents.processor.actions.webhook.WebhookAction) Awaitility.await(org.awaitility.Awaitility.await) ProcessorDTO(com.redhat.service.smartevents.infra.models.dto.ProcessorDTO) TestProfile(io.quarkus.test.junit.TestProfile) ContentType(io.restassured.http.ContentType) DEFAULT_PROCESSOR_NAME(com.redhat.service.smartevents.manager.TestConstants.DEFAULT_PROCESSOR_NAME) Set(java.util.Set) Test(org.junit.jupiter.api.Test) List(java.util.List) BridgeDTO(com.redhat.service.smartevents.infra.models.dto.BridgeDTO) KafkaConnectionDTO(com.redhat.service.smartevents.infra.models.dto.KafkaConnectionDTO) RestAssured.given(io.restassured.RestAssured.given) TestSecurity(io.quarkus.test.security.TestSecurity) MetricsService(com.redhat.service.smartevents.manager.metrics.MetricsService) READY(com.redhat.service.smartevents.infra.models.dto.ManagedResourceStatus.READY) TestConstants(com.redhat.service.smartevents.manager.TestConstants) KafkaTopicAction(com.redhat.service.smartevents.processor.actions.kafkatopic.KafkaTopicAction) ArrayList(java.util.ArrayList) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Inject(javax.inject.Inject) BridgeResponse(com.redhat.service.smartevents.manager.api.models.responses.BridgeResponse) DELETED(com.redhat.service.smartevents.infra.models.dto.ManagedResourceStatus.DELETED) USER_NAME_ATTRIBUTE_CLAIM(com.redhat.service.smartevents.infra.api.APIConstants.USER_NAME_ATTRIBUTE_CLAIM) ProcessorRequest(com.redhat.service.smartevents.manager.api.models.requests.ProcessorRequest) ORG_ID_SERVICE_ACCOUNT_ATTRIBUTE_CLAIM(com.redhat.service.smartevents.infra.api.APIConstants.ORG_ID_SERVICE_ACCOUNT_ATTRIBUTE_CLAIM) StringEquals(com.redhat.service.smartevents.infra.models.filters.StringEquals) InjectMock(io.quarkus.test.junit.mockito.InjectMock) DEFAULT_BRIDGE_NAME(com.redhat.service.smartevents.manager.TestConstants.DEFAULT_BRIDGE_NAME) ResponseLoggingFilter(io.restassured.filter.log.ResponseLoggingFilter) SHARD_ID(com.redhat.service.smartevents.manager.TestConstants.SHARD_ID) Mockito.when(org.mockito.Mockito.when) WorkerSchedulerProfile(com.redhat.service.smartevents.manager.WorkerSchedulerProfile) JsonWebToken(org.eclipse.microprofile.jwt.JsonWebToken) RhoasService(com.redhat.service.smartevents.manager.RhoasService) ManagedResourceStatus(com.redhat.service.smartevents.infra.models.dto.ManagedResourceStatus) BridgeRequest(com.redhat.service.smartevents.manager.api.models.requests.BridgeRequest) SendToBridgeAction(com.redhat.service.smartevents.processor.actions.sendtobridge.SendToBridgeAction) Collections(java.util.Collections) Mockito.reset(org.mockito.Mockito.reset) SECONDS(java.util.concurrent.TimeUnit.SECONDS) BaseFilter(com.redhat.service.smartevents.infra.models.filters.BaseFilter) 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) 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