Search in sources :

Example 61 with ResourceImpl

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));
}
Also used : ResourceImpl(org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl) Test(org.testng.annotations.Test)

Example 62 with ResourceImpl

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));
}
Also used : ResourceImpl(org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl) Test(org.testng.annotations.Test)

Example 63 with ResourceImpl

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));
}
Also used : ResourceImpl(org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl) Test(org.testng.annotations.Test)

Example 64 with ResourceImpl

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);
}
Also used : FreeResourcesLimitImpl(org.eclipse.che.multiuser.resource.spi.impl.FreeResourcesLimitImpl) ResourceImpl(org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl) FreeResourcesLimit(org.eclipse.che.multiuser.resource.model.FreeResourcesLimit) FreeResourcesLimitDto(org.eclipse.che.multiuser.resource.shared.dto.FreeResourcesLimitDto) ResourceDto(org.eclipse.che.multiuser.resource.shared.dto.ResourceDto) Test(org.testng.annotations.Test)

Example 65 with ResourceImpl

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);
}
Also used : FreeResourcesLimitImpl(org.eclipse.che.multiuser.resource.spi.impl.FreeResourcesLimitImpl) ResourceImpl(org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl) Test(org.testng.annotations.Test)

Aggregations

ResourceImpl (org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl)138 Test (org.testng.annotations.Test)116 Resource (org.eclipse.che.multiuser.resource.model.Resource)24 NoEnoughResourcesException (org.eclipse.che.multiuser.resource.api.exception.NoEnoughResourcesException)20 FreeResourcesLimitImpl (org.eclipse.che.multiuser.resource.spi.impl.FreeResourcesLimitImpl)20 ProvidedResourcesImpl (org.eclipse.che.multiuser.resource.spi.impl.ProvidedResourcesImpl)14 FreeResourcesLimit (org.eclipse.che.multiuser.resource.model.FreeResourcesLimit)12 NotFoundException (org.eclipse.che.api.core.NotFoundException)10 AccountManager (org.eclipse.che.account.api.AccountManager)8 Account (org.eclipse.che.account.shared.model.Account)8 Environment (org.eclipse.che.api.core.model.workspace.config.Environment)8 OrganizationDistributedResourcesImpl (org.eclipse.che.multiuser.organization.spi.impl.OrganizationDistributedResourcesImpl)8 ProvidedResources (org.eclipse.che.multiuser.resource.model.ProvidedResources)8 FreeResourcesLimitDto (org.eclipse.che.multiuser.resource.shared.dto.FreeResourcesLimitDto)8 Response (io.restassured.response.Response)6 Optional (java.util.Optional)6 Inject (javax.inject.Inject)6 Provider (javax.inject.Provider)6 Singleton (javax.inject.Singleton)6 Pages (org.eclipse.che.api.core.Pages)6