use of org.eclipse.che.multiuser.resource.model.Resource 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.model.Resource 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.model.Resource 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.model.Resource in project devspaces-images by redhat-developer.
the class ResourceManagerTest method testGetsAccountTotalResources.
@Test
public void testGetsAccountTotalResources() throws Exception {
final List<Resource> res = ImmutableList.of(new ResourceImpl("RAM", 2048, "mb"), new ResourceImpl("timeout", 15, "minutes"));
doReturn(res).when(providedResources).getResources();
List<? extends Resource> actual = resourceManager.getTotalResources(ACCOUNT_ID);
assertEquals(actual.size(), res.size());
assertTrue(actual.containsAll(res));
}
use of org.eclipse.che.multiuser.resource.model.Resource in project devspaces-images by redhat-developer.
the class RamResourceUsageTrackerTest method shouldReturnUsedRamOfRunningWorkspaceForGivenAccount.
@Test
public void shouldReturnUsedRamOfRunningWorkspaceForGivenAccount() throws Exception {
mockWorkspaces(createWorkspace(WorkspaceStatus.RUNNING, 1000, 500, 500));
when(envRamCalculator.calculate(any(Runtime.class))).thenReturn(2000L);
final Optional<Resource> usedRamOpt = ramUsageTracker.getUsedResource(ACCOUNT_ID);
assertTrue(usedRamOpt.isPresent());
final Resource usedRam = usedRamOpt.get();
assertEquals(usedRam.getType(), RamResourceType.ID);
assertEquals(usedRam.getAmount(), 2000L);
assertEquals(usedRam.getUnit(), RamResourceType.UNIT);
verify(accountManager).getById(ACCOUNT_ID);
verify(workspaceManager).getByNamespace(anyString(), anyBoolean(), anyInt(), anyLong());
}
Aggregations