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