Search in sources :

Example 61 with OrganizationImpl

use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project che-server by eclipse-che.

the class OrganizationDaoTest method shouldThrowNotFoundExceptionOnUpdatingNonExistingOrganization.

@Test(expectedExceptions = NotFoundException.class)
public void shouldThrowNotFoundExceptionOnUpdatingNonExistingOrganization() throws Exception {
    final OrganizationImpl toUpdate = new OrganizationImpl("non-existing-id", "new-name", "new-parent");
    organizationDao.update(toUpdate);
}
Also used : OrganizationImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl) Test(org.testng.annotations.Test)

Example 62 with OrganizationImpl

use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project che-server by eclipse-che.

the class OrganizationManagerTest method shouldGetOrganizationsByParent.

@Test
public void shouldGetOrganizationsByParent() throws Exception {
    final OrganizationImpl toFetch = new OrganizationImpl("org321", "toFetchOrg", "org123");
    when(organizationDao.getByParent(eq("org123"), anyInt(), anyLong())).thenReturn(new Page<>(singletonList(toFetch), 0, 1, 1));
    final Page<? extends Organization> organizations = manager.getByParent("org123", 30, 0);
    assertEquals(organizations.getItemsCount(), 1);
    assertEquals(organizations.getItems().get(0), toFetch);
    verify(organizationDao).getByParent("org123", 30, 0);
}
Also used : OrganizationImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl) Test(org.testng.annotations.Test)

Example 63 with OrganizationImpl

use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project che-server by eclipse-che.

the class OrganizationManagerTest method shouldRemoveSuborganizationsByParentOrganizationId.

@Test
public void shouldRemoveSuborganizationsByParentOrganizationId() throws Exception {
    doNothing().when(manager).remove(any());
    OrganizationImpl subOrg1 = new OrganizationImpl("subOrg1", "subOrg1", "org1");
    OrganizationImpl subOrg2 = new OrganizationImpl("subOrg2", "subOrg2", "org1");
    doReturn(new Page<>(singletonList(subOrg1), 0, 1, 2)).doReturn(new Page<>(singletonList(subOrg2), 1, 1, 2)).when(organizationDao).getByParent(anyString(), anyInt(), anyLong());
    manager.removeSuborganizations("org1");
    verify(organizationDao, times(2)).getByParent("org1", 100, 0);
    verify(manager).remove("subOrg1");
    verify(manager).remove("subOrg2");
}
Also used : Page(org.eclipse.che.api.core.Page) OrganizationImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl) Test(org.testng.annotations.Test)

Example 64 with OrganizationImpl

use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project che-server by eclipse-che.

the class OrganizationManagerTest method shouldGetSuborganizations.

@Test
public void shouldGetSuborganizations() throws Exception {
    final OrganizationImpl toFetch = new OrganizationImpl("org321", "parent/toFetchOrg", "org123");
    when(organizationDao.getSuborganizations(eq("parent"), anyInt(), anyLong())).thenReturn(new Page<>(singletonList(toFetch), 0, 1, 1));
    final Page<? extends Organization> organizations = manager.getSuborganizations("parent", 30, 0);
    assertEquals(organizations.getItemsCount(), 1);
    assertEquals(organizations.getItems().get(0), toFetch);
    verify(organizationDao).getSuborganizations("parent", 30, 0);
}
Also used : OrganizationImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl) Test(org.testng.annotations.Test)

Example 65 with OrganizationImpl

use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project che-server by eclipse-che.

the class JpaOrganizationDao method doUpdate.

@Transactional
protected void doUpdate(OrganizationImpl update) throws NotFoundException {
    final EntityManager manager = managerProvider.get();
    if (manager.find(OrganizationImpl.class, update.getId()) == null) {
        throw new NotFoundException(format("Couldn't update organization with id '%s' because it doesn't exist", update.getId()));
    }
    manager.merge(update);
    manager.flush();
}
Also used : EntityManager(javax.persistence.EntityManager) NotFoundException(org.eclipse.che.api.core.NotFoundException) OrganizationImpl(org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl) Transactional(com.google.inject.persist.Transactional)

Aggregations

OrganizationImpl (org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl)100 Test (org.testng.annotations.Test)56 Transactional (com.google.inject.persist.Transactional)18 BeforeMethod (org.testng.annotations.BeforeMethod)16 EntityManager (javax.persistence.EntityManager)14 MemberImpl (org.eclipse.che.multiuser.organization.spi.impl.MemberImpl)14 Organization (org.eclipse.che.multiuser.organization.shared.model.Organization)13 Response (io.restassured.response.Response)12 Page (org.eclipse.che.api.core.Page)10 ServerException (org.eclipse.che.api.core.ServerException)8 UserImpl (org.eclipse.che.api.user.server.model.impl.UserImpl)8 OrganizationDao (org.eclipse.che.multiuser.organization.spi.OrganizationDao)8 OrganizationDistributedResourcesImpl (org.eclipse.che.multiuser.organization.spi.impl.OrganizationDistributedResourcesImpl)7 TypeLiteral (com.google.inject.TypeLiteral)6 JpaPersistModule (com.google.inject.persist.jpa.JpaPersistModule)6 NotFoundException (org.eclipse.che.api.core.NotFoundException)6 OrganizationDto (org.eclipse.che.multiuser.organization.shared.dto.OrganizationDto)6 UserDevfilePermissionImpl (org.eclipse.che.multiuser.permission.devfile.server.model.impl.UserDevfilePermissionImpl)6 TckResourcesCleaner (org.eclipse.che.commons.test.tck.TckResourcesCleaner)5 DBInitializer (org.eclipse.che.core.db.DBInitializer)5