Search in sources :

Example 26 with OrganizationDistributedResourcesImpl

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

Example 27 with OrganizationDistributedResourcesImpl

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

Example 28 with OrganizationDistributedResourcesImpl

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

Example 29 with OrganizationDistributedResourcesImpl

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

Example 30 with OrganizationDistributedResourcesImpl

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

Aggregations

OrganizationDistributedResourcesImpl (org.eclipse.che.multiuser.organization.spi.impl.OrganizationDistributedResourcesImpl)32 Test (org.testng.annotations.Test)16 OrganizationImpl (org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl)8 ResourceImpl (org.eclipse.che.multiuser.resource.spi.impl.ResourceImpl)8 TypeLiteral (com.google.inject.TypeLiteral)6 Transactional (com.google.inject.persist.Transactional)6 JpaPersistModule (com.google.inject.persist.jpa.JpaPersistModule)6 UserImpl (org.eclipse.che.api.user.server.model.impl.UserImpl)6 TckResourcesCleaner (org.eclipse.che.commons.test.tck.TckResourcesCleaner)6 DBInitializer (org.eclipse.che.core.db.DBInitializer)6 SchemaInitializer (org.eclipse.che.core.db.schema.SchemaInitializer)6 FlywaySchemaInitializer (org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer)6 MemberDao (org.eclipse.che.multiuser.organization.spi.MemberDao)6 OrganizationDao (org.eclipse.che.multiuser.organization.spi.OrganizationDao)6 OrganizationDistributedResourcesDao (org.eclipse.che.multiuser.organization.spi.OrganizationDistributedResourcesDao)6 MemberImpl (org.eclipse.che.multiuser.organization.spi.impl.MemberImpl)6 JpaMemberDao (org.eclipse.che.multiuser.organization.spi.jpa.JpaMemberDao)6 JpaOrganizationDao (org.eclipse.che.multiuser.organization.spi.jpa.JpaOrganizationDao)6 JpaOrganizationDistributedResourcesDao (org.eclipse.che.multiuser.organization.spi.jpa.JpaOrganizationDistributedResourcesDao)6 HashMap (java.util.HashMap)4