Search in sources :

Example 6 with QueryResourceInfo

use of com.redhat.service.smartevents.infra.models.QueryResourceInfo in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgeDAOTest method testListByCustomerId.

@Test
public void testListByCustomerId() {
    Bridge firstBridge = buildBridge(DEFAULT_BRIDGE_ID, DEFAULT_BRIDGE_NAME);
    bridgeDAO.persist(firstBridge);
    Bridge secondBridge = buildBridge("mySecondBridgeId", "mySecondBridgeName");
    bridgeDAO.persist(secondBridge);
    ListResult<Bridge> retrievedBridges = bridgeDAO.findByCustomerId(DEFAULT_CUSTOMER_ID, new QueryResourceInfo(DEFAULT_PAGE, DEFAULT_PAGE_SIZE));
    assertThat(retrievedBridges).isNotNull();
    assertThat(retrievedBridges.getSize()).isEqualTo(2);
    assertThat(retrievedBridges.getTotal()).isEqualTo(2);
    assertThat(retrievedBridges.getPage()).isZero();
    // Newest instances come first
    assertThat(retrievedBridges.getItems().get(1).getId()).isEqualTo(firstBridge.getId());
    assertThat(retrievedBridges.getItems().get(0).getId()).isEqualTo(secondBridge.getId());
}
Also used : 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 7 with QueryResourceInfo

use of com.redhat.service.smartevents.infra.models.QueryResourceInfo in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgeDAOTest method testListByCustomerIdFilterByNameAndStatus.

@Test
public void testListByCustomerIdFilterByNameAndStatus() {
    Bridge bridge1 = buildBridge(DEFAULT_BRIDGE_ID, DEFAULT_BRIDGE_NAME);
    bridge1.setStatus(ACCEPTED);
    bridgeDAO.persist(bridge1);
    Bridge bridge2 = buildBridge("mySecondBridgeId", "mySecondBridgeName");
    bridge2.setStatus(READY);
    bridgeDAO.persist(bridge2);
    ListResult<Bridge> retrievedBridges = bridgeDAO.findByCustomerId(DEFAULT_CUSTOMER_ID, new QueryResourceInfo(DEFAULT_PAGE, DEFAULT_PAGE_SIZE, filter().by(DEFAULT_BRIDGE_NAME).by(ACCEPTED).build()));
    assertThat(retrievedBridges).isNotNull();
    assertThat(retrievedBridges.getSize()).isEqualTo(1);
    assertThat(retrievedBridges.getTotal()).isEqualTo(1);
    assertThat(retrievedBridges.getPage()).isZero();
    assertThat(retrievedBridges.getItems().get(0).getId()).isEqualTo(bridge1.getId());
}
Also used : 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 8 with QueryResourceInfo

use of com.redhat.service.smartevents.infra.models.QueryResourceInfo in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgeDAOTest method testListByCustomerIdFilterByMoreStatuses.

@Test
public void testListByCustomerIdFilterByMoreStatuses() {
    Bridge bridge1 = buildBridge(DEFAULT_BRIDGE_ID, DEFAULT_BRIDGE_NAME);
    bridge1.setStatus(ACCEPTED);
    bridgeDAO.persist(bridge1);
    Bridge bridge2 = buildBridge("mySecondBridgeId", "mySecondBridgeName");
    bridge2.setStatus(READY);
    bridgeDAO.persist(bridge2);
    ListResult<Bridge> retrievedBridges = bridgeDAO.findByCustomerId(DEFAULT_CUSTOMER_ID, new QueryResourceInfo(DEFAULT_PAGE, DEFAULT_PAGE_SIZE, filter().by(ACCEPTED).by(READY).build()));
    assertThat(retrievedBridges).isNotNull();
    assertThat(retrievedBridges.getSize()).isEqualTo(2);
    assertThat(retrievedBridges.getTotal()).isEqualTo(2);
    assertThat(retrievedBridges.getPage()).isZero();
    assertThat(retrievedBridges.getItems().get(0).getId()).isEqualTo(bridge2.getId());
    assertThat(retrievedBridges.getItems().get(1).getId()).isEqualTo(bridge1.getId());
}
Also used : 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 9 with QueryResourceInfo

use of com.redhat.service.smartevents.infra.models.QueryResourceInfo 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(DEFAULT_CUSTOMER_ID, new QueryResourceInfo(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(DEFAULT_CUSTOMER_ID, new QueryResourceInfo(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(DEFAULT_CUSTOMER_ID, new QueryResourceInfo(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(DEFAULT_CUSTOMER_ID, new QueryResourceInfo(5, 2));
    assertThat(retrievedBridges).isNotNull();
    assertThat(retrievedBridges.getSize()).isZero();
    assertThat(retrievedBridges.getTotal()).isEqualTo(10);
    assertThat(retrievedBridges.getPage()).isEqualTo(5);
}
Also used : 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 10 with QueryResourceInfo

use of com.redhat.service.smartevents.infra.models.QueryResourceInfo in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgesServiceTest method testGetEmptyBridges.

@Test
public void testGetEmptyBridges() {
    ListResult<Bridge> bridges = bridgesService.getBridges(DEFAULT_CUSTOMER_ID, new QueryResourceInfo(DEFAULT_PAGE, DEFAULT_PAGE_SIZE));
    assertThat(bridges.getPage()).isZero();
    assertThat(bridges.getTotal()).isZero();
    assertThat(bridges.getSize()).isZero();
}
Also used : 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)

Aggregations

QueryResourceInfo (com.redhat.service.smartevents.infra.models.QueryResourceInfo)11 Bridge (com.redhat.service.smartevents.manager.models.Bridge)11 QuarkusTest (io.quarkus.test.junit.QuarkusTest)11 Test (org.junit.jupiter.api.Test)11 BridgeRequest (com.redhat.service.smartevents.manager.api.models.requests.BridgeRequest)2