Search in sources :

Example 16 with BridgeRequest

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

the class BridgesAPITest method testDeleteBridge.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void testDeleteBridge() {
    BridgeResponse response = TestUtils.createBridge(new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME)).as(BridgeResponse.class);
    TestUtils.deleteBridge(response.getId()).then().statusCode(202);
    response = TestUtils.getBridge(response.getId()).as(BridgeResponse.class);
    assertThat(response.getStatus()).isEqualTo(ManagedResourceStatus.DEPROVISION);
}
Also used : 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 17 with BridgeRequest

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

the class BridgesAPITest method testAlreadyExistingBridge.

@Test
@TestSecurity(user = TestConstants.DEFAULT_CUSTOMER_ID)
public void testAlreadyExistingBridge() {
    TestUtils.createBridge(new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME)).then().statusCode(201);
    TestUtils.createBridge(new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME)).then().statusCode(400);
}
Also used : BridgeRequest(com.redhat.service.bridge.manager.api.models.requests.BridgeRequest) TestSecurity(io.quarkus.test.security.TestSecurity) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 18 with BridgeRequest

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

the class BridgesServiceTest method testUpdateBridgeStatus.

@Test
public void testUpdateBridgeStatus() {
    BridgeRequest request = new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME);
    Bridge bridge = bridgesService.createBridge(TestConstants.DEFAULT_CUSTOMER_ID, request);
    List<Bridge> bridges = bridgesService.getBridgesByStatusesAndShardId(Collections.singletonList(ManagedResourceStatus.ACCEPTED), TestConstants.SHARD_ID);
    assertThat(bridges.size()).isEqualTo(1);
    assertThat(bridges.get(0).getStatus()).isEqualTo(ManagedResourceStatus.ACCEPTED);
    bridge.setStatus(ManagedResourceStatus.PROVISIONING);
    bridgesService.updateBridge(bridgesService.toDTO(bridge));
    bridges = bridgesService.getBridgesByStatusesAndShardId(Collections.singletonList(ManagedResourceStatus.ACCEPTED), TestConstants.SHARD_ID);
    assertThat(bridges.size()).isZero();
    Bridge retrievedBridge = bridgesService.getBridge(bridge.getId(), TestConstants.DEFAULT_CUSTOMER_ID);
    assertThat(retrievedBridge.getStatus()).isEqualTo(ManagedResourceStatus.PROVISIONING);
}
Also used : BridgeRequest(com.redhat.service.bridge.manager.api.models.requests.BridgeRequest) Bridge(com.redhat.service.bridge.manager.models.Bridge) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 19 with BridgeRequest

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

the class BridgesServiceTest method testGetBridgeWithWrongCustomerId.

@Test
public void testGetBridgeWithWrongCustomerId() {
    BridgeRequest request = new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME);
    Bridge bridge = bridgesService.createBridge(TestConstants.DEFAULT_CUSTOMER_ID, request);
    assertThatExceptionOfType(ItemNotFoundException.class).isThrownBy(() -> bridgesService.getBridge(bridge.getId(), "not-the-customerId"));
}
Also used : BridgeRequest(com.redhat.service.bridge.manager.api.models.requests.BridgeRequest) Bridge(com.redhat.service.bridge.manager.models.Bridge) ItemNotFoundException(com.redhat.service.bridge.infra.exceptions.definitions.user.ItemNotFoundException) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 20 with BridgeRequest

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

the class BridgesServiceTest method testUpdateBridgeStatusReadyPublishedAt.

@Test
public void testUpdateBridgeStatusReadyPublishedAt() {
    BridgeRequest request = new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME);
    Bridge bridge = bridgesService.createBridge(TestConstants.DEFAULT_CUSTOMER_ID, request);
    bridge.setStatus(ManagedResourceStatus.PROVISIONING);
    bridgesService.updateBridge(bridgesService.toDTO(bridge));
    Bridge retrievedBridge = bridgesService.getBridge(bridge.getId(), TestConstants.DEFAULT_CUSTOMER_ID);
    assertThat(retrievedBridge.getStatus()).isEqualTo(ManagedResourceStatus.PROVISIONING);
    assertThat(retrievedBridge.getPublishedAt()).isNull();
    // Once ready it should have its published date set
    bridge.setStatus(ManagedResourceStatus.READY);
    bridgesService.updateBridge(bridgesService.toDTO(bridge));
    Bridge publishedBridge = bridgesService.getBridge(bridge.getId(), TestConstants.DEFAULT_CUSTOMER_ID);
    assertThat(publishedBridge.getStatus()).isEqualTo(ManagedResourceStatus.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(), TestConstants.DEFAULT_CUSTOMER_ID);
    assertThat(publishedBridge2.getStatus()).isEqualTo(ManagedResourceStatus.READY);
    assertThat(publishedBridge2.getPublishedAt()).isEqualTo(publishedAt);
}
Also used : BridgeRequest(com.redhat.service.bridge.manager.api.models.requests.BridgeRequest) ZonedDateTime(java.time.ZonedDateTime) Bridge(com.redhat.service.bridge.manager.models.Bridge) 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