use of com.redhat.service.smartevents.infra.models.QueryResourceInfo in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeDAOTest method testListByCustomerIdPaginationFilterByStatus.
@Test
public void testListByCustomerIdPaginationFilterByStatus() {
for (int i = 0; i < 10; i++) {
String id = String.valueOf(i);
Bridge bridge = buildBridge(id, id);
bridge.setStatus(i % 2 == 0 ? READY : ACCEPTED);
bridgeDAO.persist(bridge);
}
ListResult<Bridge> retrievedBridges = bridgeDAO.findByCustomerId(DEFAULT_CUSTOMER_ID, new QueryResourceInfo(0, 2, filter().by(READY).build()));
assertThat(retrievedBridges).isNotNull();
assertThat(retrievedBridges.getSize()).isEqualTo(2);
assertThat(retrievedBridges.getTotal()).isEqualTo(5);
assertThat(retrievedBridges.getPage()).isZero();
assertThat(retrievedBridges.getItems().get(0).getId()).isEqualTo("8");
assertThat(retrievedBridges.getItems().get(1).getId()).isEqualTo("6");
retrievedBridges = bridgeDAO.findByCustomerId(DEFAULT_CUSTOMER_ID, new QueryResourceInfo(1, 2, filter().by(READY).build()));
assertThat(retrievedBridges).isNotNull();
assertThat(retrievedBridges.getSize()).isEqualTo(2);
assertThat(retrievedBridges.getTotal()).isEqualTo(5);
assertThat(retrievedBridges.getPage()).isEqualTo(1);
assertThat(retrievedBridges.getItems().get(0).getId()).isEqualTo("4");
assertThat(retrievedBridges.getItems().get(1).getId()).isEqualTo("2");
retrievedBridges = bridgeDAO.findByCustomerId(DEFAULT_CUSTOMER_ID, new QueryResourceInfo(2, 2, filter().by(READY).build()));
assertThat(retrievedBridges).isNotNull();
assertThat(retrievedBridges.getSize()).isEqualTo(1);
assertThat(retrievedBridges.getTotal()).isEqualTo(5);
assertThat(retrievedBridges.getPage()).isEqualTo(2);
assertThat(retrievedBridges.getItems().get(0).getId()).isEqualTo("0");
}
use of com.redhat.service.smartevents.infra.models.QueryResourceInfo in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeDAOTest method testListByCustomerIdFilterByStatus.
@Test
public void testListByCustomerIdFilterByStatus() {
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(READY).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(bridge2.getId());
}
use of com.redhat.service.smartevents.infra.models.QueryResourceInfo in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeDAOTest method testListByCustomerIdFilterByName.
@Test
public void testListByCustomerIdFilterByName() {
Bridge bridge1 = buildBridge(DEFAULT_BRIDGE_ID, DEFAULT_BRIDGE_NAME);
bridgeDAO.persist(bridge1);
Bridge bridge2 = buildBridge("mySecondBridgeId", "mySecondBridgeName");
bridgeDAO.persist(bridge2);
ListResult<Bridge> retrievedBridges = bridgeDAO.findByCustomerId(DEFAULT_CUSTOMER_ID, new QueryResourceInfo(DEFAULT_PAGE, DEFAULT_PAGE_SIZE, filter().by(DEFAULT_BRIDGE_NAME).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());
}
use of com.redhat.service.smartevents.infra.models.QueryResourceInfo in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgesServiceTest method testCreateBridge.
@Test
public void testCreateBridge() {
BridgeRequest request = new BridgeRequest(DEFAULT_BRIDGE_NAME);
bridgesService.createBridge(DEFAULT_CUSTOMER_ID, DEFAULT_ORGANISATION_ID, DEFAULT_USER_NAME, request);
// Wait for Workers to complete
Bridge bridge = TestUtils.waitForBridgeToBeReady(bridgesService);
assertThat(bridge.getStatus()).isEqualTo(ManagedResourceStatus.PREPARING);
assertThat(bridge.getEndpoint()).isNull();
ListResult<Bridge> bridges = bridgesService.getBridges(DEFAULT_CUSTOMER_ID, new QueryResourceInfo(DEFAULT_PAGE, DEFAULT_PAGE_SIZE));
assertThat(bridges.getSize()).isEqualTo(1);
assertThat(bridges.getItems().get(0).getOrganisationId()).isEqualTo(DEFAULT_ORGANISATION_ID);
}
use of com.redhat.service.smartevents.infra.models.QueryResourceInfo in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class BridgeDAOTest method testListByCustomerIdFilterByNameWildcard.
@Test
public void testListByCustomerIdFilterByNameWildcard() {
Bridge bridge1 = buildBridge(DEFAULT_BRIDGE_ID, DEFAULT_BRIDGE_NAME);
bridgeDAO.persist(bridge1);
Bridge bridge2 = buildBridge("mySecondBridgeId", "mySecondBridgeName");
bridgeDAO.persist(bridge2);
ListResult<Bridge> retrievedBridges = bridgeDAO.findByCustomerId(DEFAULT_CUSTOMER_ID, new QueryResourceInfo(DEFAULT_PAGE, DEFAULT_PAGE_SIZE, filter().by(DEFAULT_BRIDGE_NAME.substring(0, 5)).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());
}
Aggregations