use of org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl in project devspaces-images by redhat-developer.
the class ResourceAggregatorTest method shouldThrowIllegalArgumentExceptionWhenTotalResourcesListContainsNotSupportedResourceOnResourcesDeduction.
@Test(expectedExceptions = IllegalArgumentException.class)
public void shouldThrowIllegalArgumentExceptionWhenTotalResourcesListContainsNotSupportedResourceOnResourcesDeduction() throws Exception {
// given
final ResourceImpl dResource = mock(ResourceImpl.class);
when(dResource.getType()).thenReturn("resourceD");
// when
resourceAggregator.deduct(emptyList(), singletonList(dResource));
}
use of org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl in project devspaces-images by redhat-developer.
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 devspaces-images by redhat-developer.
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 devspaces-images by redhat-developer.
the class FreeResourceManagerTest method shouldStoreFreeResourcesLimit.
@Test
public void shouldStoreFreeResourcesLimit() throws Exception {
// given
ResourceImpl resource = new ResourceImpl(TEST_RESOURCE_TYPE, 1, "unit");
FreeResourcesLimitImpl resourcesLimitImpl = new FreeResourcesLimitImpl("account123", singletonList(resource));
ResourceDto resourceDto = DtoFactory.newDto(ResourceDto.class).withAmount(1).withType(TEST_RESOURCE_TYPE).withUnit("unit");
FreeResourcesLimitDto freeResourcesLimitDto = DtoFactory.newDto(FreeResourcesLimitDto.class).withAccountId("account123").withResources(singletonList(resourceDto));
// when
FreeResourcesLimit storedLimit = manager.store(freeResourcesLimitDto);
// then
assertEquals(storedLimit, resourcesLimitImpl);
verify(freeResourcesLimitDao).store(resourcesLimitImpl);
}
use of org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl in project devspaces-images by redhat-developer.
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);
}
Aggregations