use of bio.terra.buffer.common.Pool in project terra-resource-buffer by DataBiosphere.
the class BufferDaoTest method updateOneReadyResourceToHandedOut_noResourceAvailable.
@Test
public void updateOneReadyResourceToHandedOut_noResourceAvailable() {
Pool pool = newPool(PoolId.create("poolId"));
RequestHandoutId requestHandoutId = RequestHandoutId.create("handoutId");
bufferDao.createPools(ImmutableList.of(pool));
assertFalse(bufferDao.updateOneReadyResourceToHandedOut(pool.id(), requestHandoutId).isPresent());
}
use of bio.terra.buffer.common.Pool in project terra-resource-buffer by DataBiosphere.
the class BufferDaoTest method createPoolAndRetrievePools.
@Test
public void createPoolAndRetrievePools() {
Pool pool1 = newPool(PoolId.create("pool1"));
Pool pool2 = newPool(PoolId.create("pool2"));
bufferDao.createPools(ImmutableList.of(pool1, pool2));
List<Pool> pools = bufferDao.retrievePools();
assertThat(pools, Matchers.containsInAnyOrder(pool1, pool2));
assertEquals(pool1, bufferDao.retrievePool(pool1.id()).get());
assertEquals(pool2, bufferDao.retrievePool(pool2.id()).get());
}
use of bio.terra.buffer.common.Pool in project terra-resource-buffer by DataBiosphere.
the class BufferDaoTest method updatePoolSize.
@Test
public void updatePoolSize() {
PoolId poolId = PoolId.create("poolId");
Pool pool = newPool(poolId);
bufferDao.createPools(ImmutableList.of(pool));
Pool retrievedPool = bufferDao.retrievePools().get(0);
Pool resizedPool = pool.toBuilder().size(retrievedPool.size() + 10).build();
bufferDao.updatePoolsSizes(ImmutableMap.of(poolId, resizedPool.size()));
assertThat(bufferDao.retrievePools(), Matchers.containsInAnyOrder(resizedPool));
}
use of bio.terra.buffer.common.Pool in project terra-resource-buffer by DataBiosphere.
the class BufferDaoTest method updateReadyResourceAsDeleting_currentStateIsNotReady.
@Test
public void updateReadyResourceAsDeleting_currentStateIsNotReady() {
Pool pool = newPool(PoolId.create("poolId"));
Resource resource = newResource(pool.id(), ResourceState.HANDED_OUT);
bufferDao.createPools(ImmutableList.of(pool));
bufferDao.createResource(resource);
assertFalse(bufferDao.updateReadyResourceToDeleting(resource.id()));
assertEquals(ResourceState.HANDED_OUT, bufferDao.retrieveResource(resource.id()).get().state());
}
use of bio.terra.buffer.common.Pool in project terra-resource-buffer by DataBiosphere.
the class BufferDaoTest method retrieveResourcesWithState.
@Test
public void retrieveResourcesWithState() {
Pool pool = newPool(PoolId.create("poolId1"));
// 1 CREATING, 3 READY resources; and ask for 2 READY resources.
Resource creating = newResource(pool.id(), ResourceState.CREATING);
Resource ready1 = newResource(pool.id(), ResourceState.READY);
Resource ready2 = newResource(pool.id(), ResourceState.READY);
Resource ready3 = newResource(pool.id(), ResourceState.READY);
bufferDao.createPools(ImmutableList.of(pool));
bufferDao.createResource(creating);
bufferDao.createResource(ready1);
bufferDao.createResource(ready2);
bufferDao.createResource(ready3);
List<Resource> resources = bufferDao.retrieveResourcesRandomly(pool.id(), ResourceState.READY, 2);
assertEquals(2, resources.size());
assertThat(ImmutableList.of(ready1, ready2, ready3), Matchers.hasItems(resources.toArray()));
}
Aggregations