use of bio.terra.buffer.common.PoolId 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.PoolId in project terra-resource-buffer by DataBiosphere.
the class PoolServiceTest method handoutResource_deactivatedPool.
@Test
public void handoutResource_deactivatedPool() throws Exception {
PoolId poolId = PoolId.create("poolId");
RequestHandoutId requestHandoutId = RequestHandoutId.create("handoutId");
newReadyPool(poolId, 1);
bufferDao.deactivatePools(ImmutableList.of(poolId));
assertThrows(BadRequestException.class, () -> poolService.handoutResource(poolId, requestHandoutId));
}
use of bio.terra.buffer.common.PoolId in project terra-resource-buffer by DataBiosphere.
the class PoolServiceTest method updateFromConfig_createPool.
@Test
public void updateFromConfig_createPool() throws Exception {
PoolId poolId = PoolId.create("poolId");
PoolWithResourceConfig parsedPoolConfig = PoolWithResourceConfig.create(new PoolConfig().poolId(poolId.toString()).size(10).resourceConfigName(RESOURCE_CONFIG_NAME), newResourceConfig());
poolService.updateFromConfig(ImmutableList.of(parsedPoolConfig));
List<Pool> pools = bufferDao.retrievePools();
assertEquals(1, pools.size());
Pool createdPool = pools.get(0);
assertEquals(poolId, createdPool.id());
assertEquals(ResourceType.GOOGLE_PROJECT, createdPool.resourceType());
assertEquals(PoolStatus.ACTIVE, createdPool.status());
assertEquals(parsedPoolConfig.resourceConfig(), createdPool.resourceConfig());
}
use of bio.terra.buffer.common.PoolId in project terra-resource-buffer by DataBiosphere.
the class PoolServiceTest method handoutResource_noReadyResource.
@Test
public void handoutResource_noReadyResource() throws Exception {
PoolId poolId = PoolId.create("poolId");
RequestHandoutId requestHandoutId = RequestHandoutId.create("handoutId");
newReadyPool(poolId, 0);
assertThrows(NotFoundException.class, () -> poolService.handoutResource(poolId, requestHandoutId));
}
use of bio.terra.buffer.common.PoolId in project terra-resource-buffer by DataBiosphere.
the class PoolServiceTest method updateFromConfig_alreadyExists.
@Test
public void updateFromConfig_alreadyExists() throws Exception {
PoolId poolId = PoolId.create("poolId");
PoolWithResourceConfig parsedPoolConfig = PoolWithResourceConfig.create(new PoolConfig().poolId(poolId.toString()).size(10).resourceConfigName(RESOURCE_CONFIG_NAME), newResourceConfig());
poolService.updateFromConfig(ImmutableList.of(parsedPoolConfig));
List<Pool> pools = bufferDao.retrievePools();
assertEquals(1, pools.size());
Pool createdPool = pools.get(0);
assertEquals(poolId, createdPool.id());
assertEquals(ResourceType.GOOGLE_PROJECT, createdPool.resourceType());
assertEquals(PoolStatus.ACTIVE, createdPool.status());
assertEquals(parsedPoolConfig.resourceConfig(), createdPool.resourceConfig());
poolService.updateFromConfig(ImmutableList.of(parsedPoolConfig));
assertThat(bufferDao.retrievePools(), Matchers.containsInAnyOrder(pools.toArray()));
}
Aggregations