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);
}
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);
}
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");
}
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);
}
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();
}
Aggregations