use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationDistributedResourcesImpl in project devspaces-images by redhat-developer.
the class OrganizationResourcesDistributorTest method shouldCapResources.
@Test
public void shouldCapResources() throws Exception {
List<ResourceImpl> toCap = singletonList(createTestResource(1000));
// when
manager.capResources(ORG_ID, toCap);
// then
verify(manager).checkResourcesAvailability(ORG_ID, toCap);
verify(distributedResourcesDao).store(new OrganizationDistributedResourcesImpl(ORG_ID, toCap));
verify(resourcesLocks).lock(ORG_ID);
verify(lock).close();
}
use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationDistributedResourcesImpl in project devspaces-images by redhat-developer.
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 devspaces-images by redhat-developer.
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 devspaces-images by redhat-developer.
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));
}
use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationDistributedResourcesImpl in project devspaces-images by redhat-developer.
the class OrganizationDistributedResourcesDaoTest method shouldUpdateDistributedResourcesWhenStoringExistentOne.
@Test
public void shouldUpdateDistributedResourcesWhenStoringExistentOne() throws Exception {
// given
OrganizationDistributedResourcesImpl toStore = new OrganizationDistributedResourcesImpl(distributedResources[0].getOrganizationId(), singletonList(new ResourceImpl(TEST_RESOURCE_TYPE, 1000, "unit")));
// when
distributedResourcesDao.store(toStore);
// then
assertEquals(distributedResourcesDao.get(toStore.getOrganizationId()), copy(toStore));
}
Aggregations