Search in sources :

Example 6 with QueryInfo

use of com.redhat.service.bridge.infra.models.QueryInfo 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 7 with QueryInfo

use of com.redhat.service.bridge.infra.models.QueryInfo in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorDAOTest method findByBridgeIdAndCustomerId.

@Test
public void findByBridgeIdAndCustomerId() {
    Bridge b = createBridge();
    Processor p = createProcessor(b, "foo");
    Processor p1 = createProcessor(b, "bar");
    ListResult<Processor> listResult = processorDAO.findByBridgeIdAndCustomerId(b.getId(), TestConstants.DEFAULT_CUSTOMER_ID, new QueryInfo(0, 100));
    assertThat(listResult.getPage()).isZero();
    assertThat(listResult.getSize()).isEqualTo(2L);
    assertThat(listResult.getTotal()).isEqualTo(2L);
    listResult.getItems().forEach((px) -> assertThat(px.getId()).isIn(p.getId(), p1.getId()));
}
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 8 with QueryInfo

use of com.redhat.service.bridge.infra.models.QueryInfo in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorDAOTest method findByBridgeIdAndCustomerId_pageOffset.

@Test
public void findByBridgeIdAndCustomerId_pageOffset() {
    Bridge b = createBridge();
    Processor p = createProcessor(b, "foo");
    Processor p1 = createProcessor(b, "bar");
    ListResult<Processor> listResult = processorDAO.findByBridgeIdAndCustomerId(b.getId(), TestConstants.DEFAULT_CUSTOMER_ID, new QueryInfo(1, 1));
    assertThat(listResult.getPage()).isEqualTo(1L);
    assertThat(listResult.getSize()).isEqualTo(1L);
    assertThat(listResult.getTotal()).isEqualTo(2L);
    assertThat(listResult.getItems().get(0).getId()).isEqualTo(p1.getId());
}
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 9 with QueryInfo

use of com.redhat.service.bridge.infra.models.QueryInfo in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class BridgesServiceTest method testGetEmptyBridges.

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

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

Aggregations

QueryInfo (com.redhat.service.bridge.infra.models.QueryInfo)11 Bridge (com.redhat.service.bridge.manager.models.Bridge)11 QuarkusTest (io.quarkus.test.junit.QuarkusTest)11 Test (org.junit.jupiter.api.Test)11 Processor (com.redhat.service.bridge.manager.models.Processor)6 BridgeRequest (com.redhat.service.bridge.manager.api.models.requests.BridgeRequest)2 ProcessorRequest (com.redhat.service.bridge.manager.api.models.requests.ProcessorRequest)2 BaseFilter (com.redhat.service.bridge.infra.models.filters.BaseFilter)1 StringEquals (com.redhat.service.bridge.infra.models.filters.StringEquals)1 HashSet (java.util.HashSet)1