Search in sources :

Example 1 with PoolInfo

use of bio.terra.buffer.generated.model.PoolInfo in project terra-resource-buffer by DataBiosphere.

the class PoolService method getPoolInfo.

/**
 * Gets pool information by given {@link PoolId}.
 */
public PoolInfo getPoolInfo(PoolId poolId) {
    Optional<PoolAndResourceStates> poolAndResourceStates = bufferDao.retrievePoolAndResourceStatesById(poolId);
    if (poolAndResourceStates.isEmpty()) {
        throw new NotFoundException(String.format("Pool %s not found", poolId));
    }
    Pool pool = poolAndResourceStates.get().pool();
    Multiset<ResourceState> resourceStates = poolAndResourceStates.get().resourceStates();
    return new PoolInfo().poolConfig(new PoolConfig().poolId(poolId.toString()).size(pool.size()).resourceConfigName(pool.resourceConfig().getConfigName())).status(bio.terra.buffer.generated.model.PoolStatus.valueOf(pool.status().toString())).putResourceStateCountItem(ResourceState.CREATING.name(), resourceStates.count(ResourceState.CREATING)).putResourceStateCountItem(ResourceState.READY.name(), resourceStates.count(ResourceState.READY)).putResourceStateCountItem(ResourceState.DELETED.name(), resourceStates.count(ResourceState.DELETED)).putResourceStateCountItem(ResourceState.HANDED_OUT.name(), resourceStates.count(ResourceState.HANDED_OUT));
}
Also used : PoolAndResourceStates(bio.terra.buffer.common.PoolAndResourceStates) NotFoundException(bio.terra.buffer.common.exception.NotFoundException) PoolConfig(bio.terra.buffer.generated.model.PoolConfig) PoolConfigLoader.loadPoolConfig(bio.terra.buffer.service.pool.PoolConfigLoader.loadPoolConfig) Pool(bio.terra.buffer.common.Pool) ResourceState(bio.terra.buffer.common.ResourceState) PoolInfo(bio.terra.buffer.generated.model.PoolInfo)

Example 2 with PoolInfo

use of bio.terra.buffer.generated.model.PoolInfo in project terra-resource-buffer by DataBiosphere.

the class PoolServiceTest method getPoolInfo_success.

@Test
public void getPoolInfo_success() throws Exception {
    PoolId poolId = PoolId.create("poolId");
    newReadyPool(poolId, 2);
    assertEquals(new PoolInfo().poolConfig(new PoolConfig().size(2).poolId(poolId.toString()).resourceConfigName("resourceName")).status(bio.terra.buffer.generated.model.PoolStatus.ACTIVE).putResourceStateCountItem(ResourceState.READY.name(), 2).putResourceStateCountItem(ResourceState.CREATING.name(), 0).putResourceStateCountItem(ResourceState.DELETED.name(), 0).putResourceStateCountItem(ResourceState.HANDED_OUT.name(), 0), poolService.getPoolInfo(poolId));
}
Also used : PoolId(bio.terra.buffer.common.PoolId) PoolConfig(bio.terra.buffer.generated.model.PoolConfig) PoolInfo(bio.terra.buffer.generated.model.PoolInfo) BaseUnitTest(bio.terra.buffer.common.BaseUnitTest) Test(org.junit.jupiter.api.Test)

Aggregations

PoolConfig (bio.terra.buffer.generated.model.PoolConfig)2 PoolInfo (bio.terra.buffer.generated.model.PoolInfo)2 BaseUnitTest (bio.terra.buffer.common.BaseUnitTest)1 Pool (bio.terra.buffer.common.Pool)1 PoolAndResourceStates (bio.terra.buffer.common.PoolAndResourceStates)1 PoolId (bio.terra.buffer.common.PoolId)1 ResourceState (bio.terra.buffer.common.ResourceState)1 NotFoundException (bio.terra.buffer.common.exception.NotFoundException)1 PoolConfigLoader.loadPoolConfig (bio.terra.buffer.service.pool.PoolConfigLoader.loadPoolConfig)1 Test (org.junit.jupiter.api.Test)1