use of org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl in project che-server by eclipse-che.
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.spi.impl.ResourceImpl in project che-server by eclipse-che.
the class ResourceAggregatorTest method shouldReturnResourceAsExcessiveWhenToSourceListContainsResourceButToCompareListDoesNotContainItAtAll.
@Test
public void shouldReturnResourceAsExcessiveWhenToSourceListContainsResourceButToCompareListDoesNotContainItAtAll() throws Exception {
// given
final ResourceImpl sourceAResource = new ResourceImpl(A_RESOURCE_TYPE, 5, "unit");
// when
List<? extends Resource> excess = resourceAggregator.excess(singletonList(sourceAResource), emptyList());
// then
assertEquals(excess.size(), 1);
assertTrue(excess.contains(sourceAResource));
}
use of org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl in project che-server by eclipse-che.
the class ResourceAggregatorTest method shouldThrowIllegalArgumentExceptionWhenListContainsResourceWithUnsupportedTypeOnMinFinding.
@Test(expectedExceptions = IllegalArgumentException.class)
public void shouldThrowIllegalArgumentExceptionWhenListContainsResourceWithUnsupportedTypeOnMinFinding() throws Exception {
final ResourceImpl dResource = mock(ResourceImpl.class);
when(dResource.getType()).thenReturn("resourceD");
// when
resourceAggregator.min(singletonList(dResource));
}
use of org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl in project che-server by eclipse-che.
the class ResourceAggregatorTest method shouldThrowIllegalArgumentExceptionWhenTryingToAggregateNotSupportedResources.
@Test(expectedExceptions = IllegalArgumentException.class)
public void shouldThrowIllegalArgumentExceptionWhenTryingToAggregateNotSupportedResources() throws Exception {
// given
final ResourceImpl dResource = mock(ResourceImpl.class);
final ResourceImpl anotherDResource = mock(ResourceImpl.class);
when(dResource.getType()).thenReturn("resourceD");
when(anotherDResource.getType()).thenReturn("resourceD");
// when
resourceAggregator.aggregateByType(asList(dResource, anotherDResource));
}
use of org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl in project che-server by eclipse-che.
the class ResourceAggregatorTest method shouldReturnMinResourcesWhenTheyContainsMinusOneValue.
@Test
public void shouldReturnMinResourcesWhenTheyContainsMinusOneValue() throws Exception {
// given
final ResourceImpl aResource = new ResourceImpl(A_RESOURCE_TYPE, -1, "unit");
final ResourceImpl bResource = new ResourceImpl(B_RESOURCE_TYPE, -1, "unit");
final ResourceImpl minAResource = new ResourceImpl(A_RESOURCE_TYPE, 250, "unit");
final ResourceImpl minBResource = new ResourceImpl(B_RESOURCE_TYPE, 500, "unit");
// when
List<? extends Resource> min = resourceAggregator.min(asList(aResource, minAResource, minBResource, bResource));
// then
assertEquals(min.size(), 2);
assertTrue(min.contains(minAResource));
assertTrue(min.contains(minBResource));
}
Aggregations