use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationDistributedResourcesImpl in project che-server by eclipse-che.
the class OrganizationResourcesDistributorTest method shouldGetDistributedResources.
@Test
public void shouldGetDistributedResources() throws Exception {
// given
final OrganizationDistributedResourcesImpl distributedResources = createDistributedResources(1000);
doReturn(new Page<>(singletonList(distributedResources), 0, 10, 1)).when(distributedResourcesDao).getByParent(anyString(), anyInt(), anyLong());
// when
final Page<? extends OrganizationDistributedResources> fetchedDistributedResources = manager.getByParent(ORG_ID, 10, 0);
// then
assertEquals(fetchedDistributedResources.getTotalItemsCount(), 1);
assertEquals(fetchedDistributedResources.getItems().get(0), distributedResources);
verify(distributedResourcesDao).getByParent(ORG_ID, 10, 0);
}
use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationDistributedResourcesImpl in project che-server by eclipse-che.
the class OrganizationResourcesDistributorTest method shouldGetResourcesCap.
@Test
public void shouldGetResourcesCap() throws Exception {
// given
final OrganizationDistributedResourcesImpl distributedResources = createDistributedResources(1000);
when(distributedResourcesDao.get(anyString())).thenReturn(distributedResources);
// when
final List<? extends Resource> fetchedDistributedResources = manager.getResourcesCaps(ORG_ID);
// then
assertEquals(fetchedDistributedResources, distributedResources.getResourcesCap());
verify(distributedResourcesDao).get(ORG_ID);
}
use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationDistributedResourcesImpl in project che-server by eclipse-che.
the class OrganizationResourcesDistributorTest method shouldRemoveResourceFromListWhenItsAmountEqualsToMinusOne.
@Test
public void shouldRemoveResourceFromListWhenItsAmountEqualsToMinusOne() throws Exception {
ResourceImpl toCap = new ResourceImpl("test1", 1000, "init");
ResourceImpl toReset = new ResourceImpl("test2", -1, "init");
List<ResourceImpl> resourcesToCap = asList(toCap, toReset);
// when
manager.capResources(ORG_ID, resourcesToCap);
// then
verify(manager).checkResourcesAvailability(ORG_ID, singletonList(toCap));
verify(distributedResourcesDao).store(new OrganizationDistributedResourcesImpl(ORG_ID, singletonList(toCap)));
verify(resourcesLocks).lock(ORG_ID);
verify(lock).close();
}
use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationDistributedResourcesImpl in project che-server by eclipse-che.
the class OrganizationDistributedResourcesDaoTest method shouldCreateDistributedResourcesWhenStoringNotExistentOne.
@Test
public void shouldCreateDistributedResourcesWhenStoringNotExistentOne() throws Exception {
// given
OrganizationDistributedResourcesImpl toStore = distributedResources[0];
distributedResourcesDao.remove(toStore.getOrganizationId());
// when
distributedResourcesDao.store(toStore);
// then
assertEquals(distributedResourcesDao.get(toStore.getOrganizationId()), copy(toStore));
}
use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationDistributedResourcesImpl in project che-server by eclipse-che.
the class OrganizationDistributedResourcesDaoTest method setUp.
@BeforeMethod
private void setUp() throws Exception {
parentOrganization = new OrganizationImpl("parentOrg", "parentOrgName", null);
suborganizations = new OrganizationImpl[ORGANIZATION_RESOURCES_COUNT];
distributedResources = new OrganizationDistributedResourcesImpl[ORGANIZATION_RESOURCES_COUNT];
for (int i = 0; i < ORGANIZATION_RESOURCES_COUNT; i++) {
suborganizations[i] = new OrganizationImpl("suborgId-" + i, "suborgName" + i, parentOrganization.getId());
distributedResources[i] = new OrganizationDistributedResourcesImpl(suborganizations[i].getId(), singletonList(new ResourceImpl(TEST_RESOURCE_TYPE, i, "test")));
}
organizationsRepository.createAll(Collections.singletonList(parentOrganization));
organizationsRepository.createAll(Arrays.asList(suborganizations));
distributedResourcesRepository.createAll(Arrays.asList(distributedResources));
}
Aggregations