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);
}
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()));
}
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());
}
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();
}
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();
}
Aggregations