Search in sources :

Example 1 with DEFAULT_BRIDGE_NAME

use of com.redhat.service.smartevents.manager.TestConstants.DEFAULT_BRIDGE_NAME 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)

Example 2 with DEFAULT_BRIDGE_NAME

use of com.redhat.service.smartevents.manager.TestConstants.DEFAULT_BRIDGE_NAME in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ShardBridgesSyncAPITest method testNotifyDeployment.

@Test
@TestSecurity(user = DEFAULT_CUSTOMER_ID)
public void testNotifyDeployment() {
    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);
    bridge.setStatus(PROVISIONING);
    TestUtils.updateBridge(bridge).then().statusCode(200);
    await().atMost(5, SECONDS).untilAsserted(() -> {
        bridgesToDeployOrDelete.clear();
        bridgesToDeployOrDelete.addAll(TestUtils.getBridgesToDeployOrDelete().as(new TypeRef<List<BridgeDTO>>() {
        }));
        assertThat(bridgesToDeployOrDelete).isEmpty();
    });
}
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)

Example 3 with DEFAULT_BRIDGE_NAME

use of com.redhat.service.smartevents.manager.TestConstants.DEFAULT_BRIDGE_NAME in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ShardBridgesSyncAPITest method testGetBridgesToDelete.

@Test
@TestSecurity(user = DEFAULT_CUSTOMER_ID)
public void testGetBridgesToDelete() {
    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);
    await().atMost(5, SECONDS).untilAsserted(() -> {
        bridgesToDeployOrDelete.clear();
        bridgesToDeployOrDelete.addAll(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(DEPROVISION)).count()).isEqualTo(1);
    });
}
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

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 USER_NAME_ATTRIBUTE_CLAIM (com.redhat.service.smartevents.infra.api.APIConstants.USER_NAME_ATTRIBUTE_CLAIM)3 BridgeDTO (com.redhat.service.smartevents.infra.models.dto.BridgeDTO)3 KafkaConnectionDTO (com.redhat.service.smartevents.infra.models.dto.KafkaConnectionDTO)3 ManagedResourceStatus (com.redhat.service.smartevents.infra.models.dto.ManagedResourceStatus)3 DELETED (com.redhat.service.smartevents.infra.models.dto.ManagedResourceStatus.DELETED)3 DEPROVISION (com.redhat.service.smartevents.infra.models.dto.ManagedResourceStatus.DEPROVISION)3 PREPARING (com.redhat.service.smartevents.infra.models.dto.ManagedResourceStatus.PREPARING)3 PROVISIONING (com.redhat.service.smartevents.infra.models.dto.ManagedResourceStatus.PROVISIONING)3 READY (com.redhat.service.smartevents.infra.models.dto.ManagedResourceStatus.READY)3 ProcessorDTO (com.redhat.service.smartevents.infra.models.dto.ProcessorDTO)3 BaseFilter (com.redhat.service.smartevents.infra.models.filters.BaseFilter)3 StringEquals (com.redhat.service.smartevents.infra.models.filters.StringEquals)3 Action (com.redhat.service.smartevents.infra.models.gateways.Action)3 RhoasService (com.redhat.service.smartevents.manager.RhoasService)3 TestConstants (com.redhat.service.smartevents.manager.TestConstants)3 DEFAULT_BRIDGE_NAME (com.redhat.service.smartevents.manager.TestConstants.DEFAULT_BRIDGE_NAME)3 DEFAULT_CUSTOMER_ID (com.redhat.service.smartevents.manager.TestConstants.DEFAULT_CUSTOMER_ID)3 DEFAULT_ORGANISATION_ID (com.redhat.service.smartevents.manager.TestConstants.DEFAULT_ORGANISATION_ID)3