use of org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl in project devspaces-images by redhat-developer.
the class AbstractExhaustibleResourceTest method shouldReturnResourceWithMinusOneAmountWhenTotalResourceHasMinusOneOnResourcesDeduction.
@Test
public void shouldReturnResourceWithMinusOneAmountWhenTotalResourceHasMinusOneOnResourcesDeduction() throws Exception {
final Resource deducted = resourceType.deduct(new ResourceImpl(TestResourceType.ID, -1, TestResourceType.UNIT), new ResourceImpl(TestResourceType.ID, 500, TestResourceType.UNIT));
assertEquals(deducted.getType(), TestResourceType.ID);
assertEquals(deducted.getAmount(), -1);
assertEquals(deducted.getUnit(), TestResourceType.UNIT);
}
use of org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl in project devspaces-images by redhat-developer.
the class AbstractExhaustibleResourceTest method shouldFindSumResourcesAmountsOnResourcesAggregation.
@Test
public void shouldFindSumResourcesAmountsOnResourcesAggregation() throws Exception {
final Resource aggregate = resourceType.aggregate(new ResourceImpl(TestResourceType.ID, 1000, TestResourceType.UNIT), new ResourceImpl(TestResourceType.ID, 500, TestResourceType.UNIT));
assertEquals(aggregate.getType(), TestResourceType.ID);
assertEquals(aggregate.getAmount(), 1500);
assertEquals(aggregate.getUnit(), TestResourceType.UNIT);
}
use of org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl in project devspaces-images by redhat-developer.
the class AbstractExhaustibleResourceTest method shouldFindDifferenceResourcesAmountsOnResourcesDeduction.
@Test
public void shouldFindDifferenceResourcesAmountsOnResourcesDeduction() throws Exception {
final Resource deducted = resourceType.deduct(new ResourceImpl(TestResourceType.ID, 1000, TestResourceType.UNIT), new ResourceImpl(TestResourceType.ID, 500, TestResourceType.UNIT));
assertEquals(deducted.getType(), TestResourceType.ID);
assertEquals(deducted.getAmount(), 500);
assertEquals(deducted.getUnit(), TestResourceType.UNIT);
}
use of org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl in project devspaces-images by redhat-developer.
the class AbstractExhaustibleResourceTest method shouldReturnResourceWithMinusOneAmountWhenSecondResourceHasMinusOneAmountOnResourcesDeduction.
@Test
public void shouldReturnResourceWithMinusOneAmountWhenSecondResourceHasMinusOneAmountOnResourcesDeduction() throws Exception {
final Resource aggregate = resourceType.aggregate(new ResourceImpl(TestResourceType.ID, 2000, TestResourceType.UNIT), new ResourceImpl(TestResourceType.ID, -1, TestResourceType.UNIT));
assertEquals(aggregate.getType(), TestResourceType.ID);
assertEquals(aggregate.getAmount(), -1);
assertEquals(aggregate.getUnit(), TestResourceType.UNIT);
}
use of org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl in project devspaces-images by redhat-developer.
the class DefaultAvailableResourcesProviderTest method shouldReturnAvailableResourcesWhenNotAllTotalResourcesAreUsed.
@Test
public void shouldReturnAvailableResourcesWhenNotAllTotalResourcesAreUsed() throws Exception {
// given
List<ResourceImpl> totalResources = singletonList(new ResourceImpl("test", 5000, "unit"));
doReturn(totalResources).when(resourceManager).getTotalResources(anyString());
List<ResourceImpl> usedResources = singletonList(new ResourceImpl("test", 2000, "unit"));
doReturn(usedResources).when(resourceManager).getUsedResources(anyString());
ResourceImpl availableResource = new ResourceImpl("test", 3000, "unit");
doReturn(singletonList(availableResource)).when(resourceAggregator).deduct(anyList(), anyList());
// when
List<? extends Resource> availableResources = defaultAvailableResourcesProvider.getAvailableResources("account123");
// then
assertEquals(availableResources.size(), 1);
assertEquals(availableResources.get(0), availableResource);
verify(resourceManager).getTotalResources("account123");
verify(resourceManager).getUsedResources("account123");
verify(resourceAggregator).deduct(totalResources, usedResources);
verify(resourceAggregator, never()).excess(anyList(), anyList());
}
Aggregations