use of org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl in project che-server by eclipse-che.
the class ResourceAggregatorTest method shouldThrowIllegalArgumentExceptionWhenSecondListContainsResourceWithUnsupportedTypeOnIntersection.
@Test(expectedExceptions = IllegalArgumentException.class)
public void shouldThrowIllegalArgumentExceptionWhenSecondListContainsResourceWithUnsupportedTypeOnIntersection() throws Exception {
final ResourceImpl dResource = mock(ResourceImpl.class);
when(dResource.getType()).thenReturn("resourceD");
// when
resourceAggregator.intersection(emptyList(), singletonList(dResource));
}
use of org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl in project che-server by eclipse-che.
the class FreeResourceManagerTest method shouldReturnFreeResourcesLimits.
@Test
public void shouldReturnFreeResourcesLimits() throws Exception {
// given
ResourceImpl resource = new ResourceImpl(TEST_RESOURCE_TYPE, 1, "unit");
FreeResourcesLimitImpl resourcesLimitImpl = new FreeResourcesLimitImpl("account123", singletonList(resource));
when(freeResourcesLimitDao.getAll(anyInt(), anyInt())).thenReturn(new Page<>(singletonList(resourcesLimitImpl), 5, 1, 9));
// when
Page<? extends FreeResourcesLimit> fetchedLimits = manager.getAll(1, 5);
// then
assertEquals(fetchedLimits.getTotalItemsCount(), 9);
assertEquals(fetchedLimits.getSize(), 1);
assertEquals(fetchedLimits.getItems().get(0), resourcesLimitImpl);
verify(freeResourcesLimitDao).getAll(1, 5);
}
use of org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl in project che-server by eclipse-che.
the class FreeResourceManagerTest method shouldReturnFreeResourcesLimitForSpecifiedAccount.
@Test
public void shouldReturnFreeResourcesLimitForSpecifiedAccount() throws Exception {
// given
ResourceImpl resource = new ResourceImpl(TEST_RESOURCE_TYPE, 1, "unit");
FreeResourcesLimitImpl resourcesLimitImpl = new FreeResourcesLimitImpl("account123", singletonList(resource));
when(freeResourcesLimitDao.get(any())).thenReturn(resourcesLimitImpl);
// when
FreeResourcesLimit fetchedLimit = manager.get("account123");
// then
assertEquals(fetchedLimit, resourcesLimitImpl);
verify(freeResourcesLimitDao).get("account123");
}
use of org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl in project che-server by eclipse-che.
the class LimitsCheckingWorkspaceManagerTest method shouldThrowLimitExceedExceptionIfAccountDoesNotHaveEnoughAvailableWorkspaceResource.
@Test(expectedExceptions = LimitExceededException.class, expectedExceptionsMessageRegExp = "You are not allowed to create more workspaces\\.")
public void shouldThrowLimitExceedExceptionIfAccountDoesNotHaveEnoughAvailableWorkspaceResource() throws Exception {
// given
doThrow(new NoEnoughResourcesException(emptyList(), emptyList(), emptyList())).when(resourceManager).checkResourcesAvailability(any(), any());
doReturn(singletonList(new ResourceImpl(WorkspaceResourceType.ID, 5, WorkspaceResourceType.UNIT))).when(resourceManager).getTotalResources(anyString());
LimitsCheckingWorkspaceManager manager = managerBuilder().setResourceManager(resourceManager).build();
// when
manager.checkWorkspaceResourceAvailability(ACCOUNT_ID);
}
use of org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl in project che-server by eclipse-che.
the class LimitsCheckingWorkspaceManagerTest method shouldUseRamOfSpecifiedEnvironmentOnCheckingAvailabilityOfRamResource.
@Test
public void shouldUseRamOfSpecifiedEnvironmentOnCheckingAvailabilityOfRamResource() throws Exception {
// given
LimitsCheckingWorkspaceManager manager = managerBuilder().setResourceManager(resourceManager).setEnvironmentRamCalculator(environmentRamCalculator).build();
when(environmentRamCalculator.calculate(any(Environment.class))).thenReturn(3000L);
WorkspaceConfig config = createConfig("3gb");
String envToStart = config.getDefaultEnv();
// when
manager.checkRamResourcesAvailability(ACCOUNT_ID, NAMESPACE, config, envToStart);
// then
verify(environmentRamCalculator).calculate(config.getEnvironments().get(envToStart));
verify(resourceManager).checkResourcesAvailability(ACCOUNT_ID, singletonList(new ResourceImpl(RamResourceType.ID, 3000, RamResourceType.UNIT)));
}
Aggregations