Search in sources :

Example 46 with Bridge

use of com.redhat.service.bridge.manager.models.Bridge 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)

Example 47 with Bridge

use of com.redhat.service.bridge.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgesServiceTest method testGetBridges.

@Test
public void testGetBridges() {
    BridgeRequest request = new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME);
    bridgesService.createBridge(TestConstants.DEFAULT_CUSTOMER_ID, request);
    ListResult<Bridge> bridges = bridgesService.getBridges(TestConstants.DEFAULT_CUSTOMER_ID, new QueryInfo(TestConstants.DEFAULT_PAGE, TestConstants.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 QueryInfo(TestConstants.DEFAULT_PAGE, TestConstants.DEFAULT_PAGE_SIZE));
    assertThat(bridges.getSize()).isZero();
    assertThat(bridges.getTotal()).isZero();
    assertThat(bridges.getPage()).isZero();
}
Also used : BridgeRequest(com.redhat.service.bridge.manager.api.models.requests.BridgeRequest) QueryInfo(com.redhat.service.bridge.infra.models.QueryInfo) Bridge(com.redhat.service.bridge.manager.models.Bridge) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 48 with Bridge

use of com.redhat.service.bridge.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgesServiceTest method testCreateBridge.

@Test
public void testCreateBridge() {
    BridgeRequest request = new BridgeRequest(TestConstants.DEFAULT_BRIDGE_NAME);
    bridgesService.createBridge(TestConstants.DEFAULT_CUSTOMER_ID, request);
    List<Bridge> bridgesToDeploy = bridgesService.getBridgesByStatusesAndShardId(Collections.singletonList(ManagedResourceStatus.ACCEPTED), TestConstants.SHARD_ID);
    assertThat(bridgesToDeploy.size()).isEqualTo(1);
    assertThat(bridgesToDeploy.get(0).getStatus()).isEqualTo(ManagedResourceStatus.ACCEPTED);
    assertThat(bridgesToDeploy.get(0).getEndpoint()).isNull();
    ListResult<Bridge> bridges = bridgesService.getBridges(TestConstants.DEFAULT_CUSTOMER_ID, new QueryInfo(TestConstants.DEFAULT_PAGE, TestConstants.DEFAULT_PAGE_SIZE));
    assertThat(bridges.getSize()).isEqualTo(1);
}
Also used : BridgeRequest(com.redhat.service.bridge.manager.api.models.requests.BridgeRequest) QueryInfo(com.redhat.service.bridge.infra.models.QueryInfo) Bridge(com.redhat.service.bridge.manager.models.Bridge) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 49 with Bridge

use of com.redhat.service.bridge.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorServiceTest method testDeleteProcessor.

@Test
public void testDeleteProcessor() {
    Bridge b = createPersistBridge(ManagedResourceStatus.READY);
    ProcessorRequest r = new ProcessorRequest("My Processor", createKafkaAction());
    Processor processor = processorService.createProcessor(b.getId(), b.getCustomerId(), r);
    await().atMost(5, SECONDS).untilAsserted(() -> {
        Processor p = processorDAO.findById(processor.getId());
        assertThat(p).isNotNull();
        assertThat(p.getDependencyStatus()).isEqualTo(ManagedResourceStatus.READY);
    });
    processorService.deleteProcessor(b.getId(), processor.getId(), TestConstants.DEFAULT_CUSTOMER_ID);
    await().atMost(5, SECONDS).untilAsserted(() -> {
        Processor p = processorDAO.findById(processor.getId());
        assertThat(p).isNotNull();
        assertThat(p.getDependencyStatus()).isEqualTo(ManagedResourceStatus.DELETED);
        assertThat(p.getStatus()).isEqualTo(ManagedResourceStatus.DEPROVISION);
        assertShardAsksForProcessorToBeDeletedIncludes(processor);
    });
}
Also used : Processor(com.redhat.service.bridge.manager.models.Processor) ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) Bridge(com.redhat.service.bridge.manager.models.Bridge) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Example 50 with Bridge

use of com.redhat.service.bridge.manager.models.Bridge in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorServiceTest method createProcessor_bridgeNotActive.

@Test
public void createProcessor_bridgeNotActive() {
    Bridge b = createPersistBridge(ManagedResourceStatus.PROVISIONING);
    assertThatExceptionOfType(BridgeLifecycleException.class).isThrownBy(() -> processorService.createProcessor(b.getId(), b.getCustomerId(), new ProcessorRequest()));
}
Also used : ProcessorRequest(com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest) BridgeLifecycleException(com.redhat.service.bridge.infra.exceptions.definitions.user.BridgeLifecycleException) Bridge(com.redhat.service.bridge.manager.models.Bridge) Test(org.junit.jupiter.api.Test) QuarkusTest(io.quarkus.test.junit.QuarkusTest)

Aggregations

Bridge (com.redhat.service.bridge.manager.models.Bridge)60 QuarkusTest (io.quarkus.test.junit.QuarkusTest)46 Test (org.junit.jupiter.api.Test)46 Processor (com.redhat.service.bridge.manager.models.Processor)34 ProcessorRequest (com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest)15 QueryInfo (com.redhat.service.bridge.infra.models.QueryInfo)11 Transactional (javax.transaction.Transactional)8 BridgeRequest (com.redhat.service.bridge.manager.api.models.requests.BridgeRequest)7 ItemNotFoundException (com.redhat.service.bridge.infra.exceptions.definitions.user.ItemNotFoundException)6 BaseAction (com.redhat.service.bridge.infra.models.actions.BaseAction)6 ConnectorEntity (com.redhat.service.bridge.manager.models.ConnectorEntity)6 Connector (com.openshift.cloud.api.connector.models.Connector)5 ConnectorStatusStatus (com.openshift.cloud.api.connector.models.ConnectorStatusStatus)4 InternalPlatformException (com.redhat.service.bridge.infra.exceptions.definitions.platform.InternalPlatformException)4 AlreadyExistingItemException (com.redhat.service.bridge.infra.exceptions.definitions.user.AlreadyExistingItemException)3 ProcessorDefinition (com.redhat.service.bridge.infra.models.processors.ProcessorDefinition)3 ConnectorRequest (com.openshift.cloud.api.connector.models.ConnectorRequest)2 BridgeLifecycleException (com.redhat.service.bridge.infra.exceptions.definitions.user.BridgeLifecycleException)2 BaseFilter (com.redhat.service.bridge.infra.models.filters.BaseFilter)2 ZonedDateTime (java.time.ZonedDateTime)2