use of bio.terra.buffer.generated.model.PoolConfig in project terra-resource-buffer by DataBiosphere.
the class PoolConfigLoaderTest method combineParsedResult_resourceConfigNotFound.
@Test
public void combineParsedResult_resourceConfigNotFound() {
String resourceConfigName = "configName";
PoolConfig poolConfig = new PoolConfig().poolId("id").resourceConfigName("badName");
PoolConfigs pools = new PoolConfigs().poolConfigs(ImmutableList.of(poolConfig, poolConfig));
ResourceConfig resourceConfig = new ResourceConfig().configName(resourceConfigName);
assertThrows(BadPoolConfigException.class, () -> combineParsedConfig(pools, ImmutableMap.of(resourceConfigName, resourceConfig)));
}
use of bio.terra.buffer.generated.model.PoolConfig 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.generated.model.PoolConfig 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()));
}
use of bio.terra.buffer.generated.model.PoolConfig in project terra-resource-buffer by DataBiosphere.
the class PoolServiceTest method updateFromConfig_updateResourceConfigOnExistingPool_throwsException.
@Test
public void updateFromConfig_updateResourceConfigOnExistingPool_throwsException() throws Exception {
PoolId poolId = PoolId.create("poolId");
PoolConfig poolConfig = new PoolConfig().poolId(poolId.toString()).size(1).resourceConfigName(RESOURCE_CONFIG_NAME);
PoolWithResourceConfig parsedPoolConfig = PoolWithResourceConfig.create(poolConfig, newResourceConfig());
poolService.updateFromConfig(ImmutableList.of(parsedPoolConfig));
// Sets ResourceConfig's GCP project id prefix to newer value.
PoolWithResourceConfig updatedPoolConfig = PoolWithResourceConfig.create(poolConfig, newResourceConfig(new GcpProjectConfig().projectIdSchema(new ProjectIdSchema().prefix("aou-rw-test2").scheme(ProjectIdSchema.SchemeEnum.RANDOM_CHAR))));
assertThrows(RuntimeException.class, () -> poolService.updateFromConfig(ImmutableList.of(updatedPoolConfig)));
assertThat(bufferDao.retrievePools().stream().map(Pool::resourceConfig).collect(Collectors.toList()), Matchers.containsInAnyOrder(parsedPoolConfig.resourceConfig()));
}
use of bio.terra.buffer.generated.model.PoolConfig in project terra-resource-buffer by DataBiosphere.
the class PoolServiceTest method updateFromConfig_deactivatePool_updatePoolStatusSuccess.
@Test
public void updateFromConfig_deactivatePool_updatePoolStatusSuccess() 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();
Pool createdPool = pools.get(0);
assertEquals(poolId, createdPool.id());
assertEquals(PoolStatus.ACTIVE, createdPool.status());
poolService.updateFromConfig(ImmutableList.of());
Pool resizedPool = bufferDao.retrievePools().get(0);
assertEquals(poolId, resizedPool.id());
assertEquals(PoolStatus.DEACTIVATED, resizedPool.status());
}
Aggregations