use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project devspaces-images by redhat-developer.
the class OrganizationDaoTest method shouldGetByParent.
@Test
public void shouldGetByParent() throws Exception {
final OrganizationImpl parent = organizations[0];
final OrganizationImpl child1 = new OrganizationImpl("child1", "childTest1", parent.getId());
final OrganizationImpl child2 = new OrganizationImpl("child2", "childTest2", parent.getId());
final OrganizationImpl child3 = new OrganizationImpl("child3", "childTest3", parent.getId());
tckRepository.createAll(asList(child1, child2, child3));
final Page<OrganizationImpl> children = organizationDao.getByParent(parent.getId(), 1, 1);
assertEquals(children.getTotalItemsCount(), 3);
assertEquals(children.getItemsCount(), 1);
assertTrue(children.getItems().contains(child1) ^ children.getItems().contains(child2) ^ children.getItems().contains(child3));
}
use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project devspaces-images by redhat-developer.
the class OrganizationDaoTest method shouldThrowConflictExceptionOnUpdatingOrganizationNameToExistingOne.
@Test(expectedExceptions = ConflictException.class)
public void shouldThrowConflictExceptionOnUpdatingOrganizationNameToExistingOne() throws Exception {
final OrganizationImpl toUpdate = new OrganizationImpl(organizations[0].getId(), organizations[1].getName(), "new-parent");
organizationDao.update(toUpdate);
}
use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project devspaces-images by redhat-developer.
the class OrganizationDaoTest method shouldThrowConflictExceptionOnCreatingOrganizationWithExistingId.
@Test(expectedExceptions = ConflictException.class)
public void shouldThrowConflictExceptionOnCreatingOrganizationWithExistingId() throws Exception {
final OrganizationImpl organization = new OrganizationImpl(organizations[0].getId(), "Test", null);
organizationDao.create(organization);
assertEquals(organizationDao.getById(organization.getId()), organization);
}
use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project devspaces-images by redhat-developer.
the class JpaMemberDao method getOrganizations.
@Override
@Transactional
public Page<OrganizationImpl> getOrganizations(String userId, int maxItems, long skipCount) throws ServerException {
requireNonNull(userId, "Required non-null user id");
checkArgument(skipCount <= Integer.MAX_VALUE, "The number of items to skip can't be greater than " + Integer.MAX_VALUE);
try {
final EntityManager manager = managerProvider.get();
final List<OrganizationImpl> result = manager.createNamedQuery("Member.getOrganizations", OrganizationImpl.class).setParameter("userId", userId).setMaxResults(maxItems).setFirstResult((int) skipCount).getResultList();
final Long organizationsCount = manager.createNamedQuery("Member.getOrganizationsCount", Long.class).setParameter("userId", userId).getSingleResult();
return new Page<>(result, skipCount, maxItems, organizationsCount);
} catch (RuntimeException e) {
throw new ServerException(e.getLocalizedMessage(), e);
}
}
use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project devspaces-images by redhat-developer.
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