Search in sources :

Example 1 with ResourceInfo

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);
}
Also used : CloudResourceUid(bio.terra.buffer.generated.model.CloudResourceUid) ResourceInfo(bio.terra.buffer.generated.model.ResourceInfo) PoolId(bio.terra.buffer.common.PoolId) RequestHandoutId(bio.terra.buffer.common.RequestHandoutId) BaseUnitTest(bio.terra.buffer.common.BaseUnitTest) Test(org.junit.jupiter.api.Test)

Aggregations

BaseUnitTest (bio.terra.buffer.common.BaseUnitTest)1 PoolId (bio.terra.buffer.common.PoolId)1 RequestHandoutId (bio.terra.buffer.common.RequestHandoutId)1 CloudResourceUid (bio.terra.buffer.generated.model.CloudResourceUid)1 ResourceInfo (bio.terra.buffer.generated.model.ResourceInfo)1 Test (org.junit.jupiter.api.Test)1