use of org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl in project che-server by eclipse-che.
the class ResourceAggregatorTest method shouldNotReturnResourceAsExcessiveWhenResourcesHaveTheSameAmount.
@Test
public void shouldNotReturnResourceAsExcessiveWhenResourcesHaveTheSameAmount() throws Exception {
// given
final ResourceImpl sourceAResource = new ResourceImpl(A_RESOURCE_TYPE, 5, "unit");
final ResourceImpl toCompareAResource = new ResourceImpl(A_RESOURCE_TYPE, 5, "unit");
// when
List<? extends Resource> excess = resourceAggregator.excess(singletonList(sourceAResource), singletonList(toCompareAResource));
// then
assertTrue(excess.isEmpty());
verify(aResourceType, never()).deduct(any(), any());
}
use of org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl in project che-server by eclipse-che.
the class ResourceAggregatorTest method shouldThrowIllegalArgumentExceptionWhenSecondListContainsResourceWithUnsupportedTypeExcessCalculation.
@Test(expectedExceptions = IllegalArgumentException.class)
public void shouldThrowIllegalArgumentExceptionWhenSecondListContainsResourceWithUnsupportedTypeExcessCalculation() throws Exception {
final ResourceImpl dResource = mock(ResourceImpl.class);
when(dResource.getType()).thenReturn("resourceD");
// when
resourceAggregator.excess(emptyList(), singletonList(dResource));
}
use of org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl in project che-server by eclipse-che.
the class ResourceAggregatorTest method shouldThrowIllegalArgumentExceptionWhenTryingToAggregateNotSupportedResource.
@Test(expectedExceptions = IllegalArgumentException.class)
public void shouldThrowIllegalArgumentExceptionWhenTryingToAggregateNotSupportedResource() throws Exception {
// given
final ResourceImpl dResource = mock(ResourceImpl.class);
when(dResource.getType()).thenReturn("resourceD");
// when
resourceAggregator.aggregateByType(singletonList(dResource));
}
use of org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl in project che-server by eclipse-che.
the class ResourceAggregatorTest method shouldNotReturnResourceAsExcessiveWhenToCompareResourceIsGreaterThanSource.
@Test
public void shouldNotReturnResourceAsExcessiveWhenToCompareResourceIsGreaterThanSource() throws Exception {
// given
final ResourceImpl sourceAResource = new ResourceImpl(A_RESOURCE_TYPE, 5, "unit");
final ResourceImpl toCompareAResource = new ResourceImpl(A_RESOURCE_TYPE, 10, "unit");
doThrow(new NoEnoughResourcesException(emptyList(), emptyList(), emptyList())).when(aResourceType).deduct(any(), any());
// when
List<? extends Resource> excess = resourceAggregator.excess(singletonList(sourceAResource), singletonList(toCompareAResource));
// then
assertTrue(excess.isEmpty());
verify(aResourceType).deduct(sourceAResource, toCompareAResource);
}
use of org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl in project che-server by eclipse-che.
the class ResourceAggregatorTest method shouldReturnResourceAsExcessiveWhenDeductedAmountGreaterThan0.
@Test
public void shouldReturnResourceAsExcessiveWhenDeductedAmountGreaterThan0() throws Exception {
// given
final ResourceImpl sourceAResource = new ResourceImpl(A_RESOURCE_TYPE, 5, "unit");
final ResourceImpl toCompareAResource = new ResourceImpl(A_RESOURCE_TYPE, 3, "unit");
final ResourceImpl excessiveAResource = new ResourceImpl(A_RESOURCE_TYPE, 2, "unit");
when(aResourceType.deduct(any(), any())).thenReturn(excessiveAResource);
// when
List<? extends Resource> excess = resourceAggregator.excess(singletonList(sourceAResource), singletonList(toCompareAResource));
// then
assertEquals(excess.size(), 1);
assertTrue(excess.contains(excessiveAResource));
verify(aResourceType).deduct(sourceAResource, toCompareAResource);
}
Aggregations