Search in sources :

Example 26 with Bridge

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

the class ProcessorDAOTest method findByBridgeIdAndCustomerId_noProcessors.

@Test
public void findByBridgeIdAndCustomerId_noProcessors() {
    Bridge b = createBridge();
    ListResult<Processor> listResult = processorDAO.findByBridgeIdAndCustomerId(b.getId(), TestConstants.DEFAULT_CUSTOMER_ID, new QueryInfo(0, 100));
    assertThat(listResult.getPage()).isZero();
    assertThat(listResult.getSize()).isZero();
    assertThat(listResult.getTotal()).isZero();
}
Also used : Processor(com.redhat.service.bridge.manager.models.Processor) 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 27 with Bridge

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

the class Fixtures method createBridge.

public static Bridge createBridge() {
    Bridge b = new Bridge();
    b.setPublishedAt(ZonedDateTime.now());
    b.setCustomerId(TestConstants.DEFAULT_CUSTOMER_ID);
    b.setStatus(ManagedResourceStatus.READY);
    b.setName(TestConstants.DEFAULT_BRIDGE_NAME);
    b.setSubmittedAt(ZonedDateTime.now());
    b.setEndpoint("https://bridge.redhat.com");
    return b;
}
Also used : Bridge(com.redhat.service.bridge.manager.models.Bridge)

Example 28 with Bridge

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

the class BridgeDAOTest method testFindByStatus.

@Test
public void testFindByStatus() {
    Bridge bridge = buildBridge(TestConstants.DEFAULT_BRIDGE_ID, TestConstants.DEFAULT_BRIDGE_NAME);
    bridgeDAO.persist(bridge);
    List<Bridge> retrievedBridges = bridgeDAO.findByStatusesAndShardId(Collections.singletonList(ManagedResourceStatus.PROVISIONING), TestConstants.SHARD_ID);
    assertThat(retrievedBridges.size()).isZero();
    retrievedBridges = bridgeDAO.findByStatusesAndShardId(Collections.singletonList(ManagedResourceStatus.READY), TestConstants.SHARD_ID);
    assertThat(retrievedBridges.size()).isZero();
    retrievedBridges = bridgeDAO.findByStatusesAndShardId(Collections.singletonList(ManagedResourceStatus.ACCEPTED), TestConstants.SHARD_ID);
    assertThat(retrievedBridges.size()).isEqualTo(1);
}
Also used : Bridge(com.redhat.service.bridge.manager.models.Bridge) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 29 with Bridge

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

the class BridgeDAOTest method testListByCustomerIdPagination.

@Test
public void testListByCustomerIdPagination() {
    for (int i = 0; i < 10; i++) {
        String id = String.valueOf(i);
        Bridge bridge = buildBridge(id, id);
        bridgeDAO.persist(bridge);
    }
    ListResult<Bridge> retrievedBridges = bridgeDAO.findByCustomerId(TestConstants.DEFAULT_CUSTOMER_ID, new QueryInfo(0, 2));
    assertThat(retrievedBridges).isNotNull();
    assertThat(retrievedBridges.getSize()).isEqualTo(2);
    assertThat(retrievedBridges.getTotal()).isEqualTo(10);
    assertThat(retrievedBridges.getPage()).isZero();
    assertThat(retrievedBridges.getItems().get(0).getId()).isEqualTo("9");
    assertThat(retrievedBridges.getItems().get(1).getId()).isEqualTo("8");
    retrievedBridges = bridgeDAO.findByCustomerId(TestConstants.DEFAULT_CUSTOMER_ID, new QueryInfo(1, 2));
    assertThat(retrievedBridges).isNotNull();
    assertThat(retrievedBridges.getSize()).isEqualTo(2);
    assertThat(retrievedBridges.getTotal()).isEqualTo(10);
    assertThat(retrievedBridges.getPage()).isEqualTo(1);
    assertThat(retrievedBridges.getItems().get(0).getId()).isEqualTo("7");
    assertThat(retrievedBridges.getItems().get(1).getId()).isEqualTo("6");
    retrievedBridges = bridgeDAO.findByCustomerId(TestConstants.DEFAULT_CUSTOMER_ID, new QueryInfo(4, 2));
    assertThat(retrievedBridges).isNotNull();
    assertThat(retrievedBridges.getSize()).isEqualTo(2);
    assertThat(retrievedBridges.getTotal()).isEqualTo(10);
    assertThat(retrievedBridges.getPage()).isEqualTo(4);
    assertThat(retrievedBridges.getItems().get(0).getId()).isEqualTo("1");
    assertThat(retrievedBridges.getItems().get(1).getId()).isEqualTo("0");
    retrievedBridges = bridgeDAO.findByCustomerId(TestConstants.DEFAULT_CUSTOMER_ID, new QueryInfo(5, 2));
    assertThat(retrievedBridges).isNotNull();
    assertThat(retrievedBridges.getSize()).isZero();
    assertThat(retrievedBridges.getTotal()).isEqualTo(10);
    assertThat(retrievedBridges.getPage()).isEqualTo(5);
}
Also used : 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 30 with Bridge

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

the class BridgeDAOTest method buildBridge.

private Bridge buildBridge(String id, String name) {
    Bridge bridge = new Bridge();
    bridge.setId(id);
    bridge.setCustomerId(TestConstants.DEFAULT_CUSTOMER_ID);
    bridge.setName(name);
    bridge.setStatus(ManagedResourceStatus.ACCEPTED);
    bridge.setSubmittedAt(ZonedDateTime.now());
    bridge.setShardId(TestConstants.SHARD_ID);
    return bridge;
}
Also used : Bridge(com.redhat.service.bridge.manager.models.Bridge)

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