use of bio.terra.buffer.generated.model.ResourceInfo in project terra-resource-buffer by DataBiosphere.
the class PoolServiceTest method handoutResource_success.
@Test
public void handoutResource_success() throws Exception {
PoolId poolId = PoolId.create("poolId");
RequestHandoutId requestHandoutId = RequestHandoutId.create("handoutId");
newReadyPool(poolId, 2);
List<CloudResourceUid> resourceUids = bufferDao.retrieveResourcesRandomly(poolId, ResourceState.READY, 2).stream().map(Resource::cloudResourceUid).collect(Collectors.toList());
ResourceInfo resourceInfo = poolService.handoutResource(poolId, requestHandoutId);
assertEquals(poolId.id(), resourceInfo.getPoolId());
assertEquals(requestHandoutId.id(), resourceInfo.getRequestHandoutId());
// CloudResource may be either of the two resources.
assertTrue(resourceInfo.getCloudResourceUid().equals(resourceUids.get(0)) || resourceInfo.getCloudResourceUid().equals(resourceUids.get(1)));
// Use the same requestHandoutId, expect to get the same resource back.
ResourceInfo secondResourceInfo = poolService.handoutResource(poolId, requestHandoutId);
assertEquals(resourceInfo, secondResourceInfo);
}
Aggregations