use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project che-server by eclipse-che.
the class MemberDaoTest method setUp.
@BeforeMethod
private void setUp() throws TckRepositoryException {
users = new UserImpl[3];
users[0] = new UserImpl("user1-id", "user1@test.com", "user1-name");
users[1] = new UserImpl("user2-id", "user2@test.com", "user2-name");
users[2] = new UserImpl("user3-id", "user3@test.com", "user3-name");
userRepo.createAll(asList(users));
orgs = new OrganizationImpl[3];
orgs[0] = new OrganizationImpl("org1-id", "org1-name", null);
orgs[1] = new OrganizationImpl("org2-id", "org2-name", null);
orgs[2] = new OrganizationImpl("org3-id", "org3-name", null);
organizationRepo.createAll(asList(orgs));
members = new MemberImpl[5];
members[0] = new MemberImpl(users[0].getId(), orgs[0].getId(), asList("read", "update"));
members[1] = new MemberImpl(users[1].getId(), orgs[0].getId(), asList("read", "update"));
members[2] = new MemberImpl(users[2].getId(), orgs[0].getId(), asList("read", "update"));
members[3] = new MemberImpl(users[1].getId(), orgs[1].getId(), asList("read", "update"));
members[4] = new MemberImpl(users[1].getId(), orgs[2].getId(), asList("read", "update"));
memberRepo.createAll(Stream.of(members).map(MemberImpl::new).collect(Collectors.toList()));
}
use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project che-server by eclipse-che.
the class OrganizationDaoTest method shouldGetOrganizationByName.
@Test
public void shouldGetOrganizationByName() throws Exception {
final OrganizationImpl organization = organizations[0];
final OrganizationImpl found = organizationDao.getByName(organization.getName());
assertEquals(organization, found);
}
use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project devspaces-images by redhat-developer.
the class OrganizationManager method remove.
/**
* Removes organization with given id
*
* @param organizationId organization id
* @throws NullPointerException when {@code organizationId} is null
* @throws ServerException when any other error occurs during organization removing
*/
@Transactional(rollbackOn = { RuntimeException.class, ApiException.class })
public void remove(String organizationId) throws ServerException {
requireNonNull(organizationId, "Required non-null organization id");
try {
OrganizationImpl organization = organizationDao.getById(organizationId);
eventService.publish(new BeforeAccountRemovedEvent(organization.getAccount())).propagateException();
eventService.publish(new BeforeOrganizationRemovedEvent(organization)).propagateException();
removeSuborganizations(organizationId);
final List<String> members = removeMembers(organizationId);
organizationDao.remove(organizationId);
final String initiator = EnvironmentContext.getCurrent().getSubject().getUserName();
eventService.publish(asDto(new OrganizationRemovedEvent(initiator, organization, members)));
} catch (NotFoundException e) {
// organization is already removed
}
}
use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project devspaces-images by redhat-developer.
the class OrganizationManagerTest method shouldGetOrganizationsByMember.
@Test
public void shouldGetOrganizationsByMember() throws Exception {
final OrganizationImpl toFetch = new OrganizationImpl("org123", "toFetchOrg", "org321");
when(memberDao.getOrganizations(eq("org123"), anyInt(), anyLong())).thenReturn(new Page<>(singletonList(toFetch), 0, 1, 1));
final Page<? extends Organization> organizations = manager.getByMember("org123", 30, 0);
assertEquals(organizations.getItemsCount(), 1);
assertEquals(organizations.getItems().get(0), toFetch);
verify(memberDao).getOrganizations("org123", 30, 0);
}
use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project devspaces-images by redhat-developer.
the class OrganizationManagerTest method shouldUpdateOrganizationAndIgnoreNewIdAndParentFields.
@Test
public void shouldUpdateOrganizationAndIgnoreNewIdAndParentFields() throws Exception {
final OrganizationImpl existing = new OrganizationImpl("org123", "oldName", "parent123");
final OrganizationImpl expectedExistingToUpdate = new OrganizationImpl(existing);
expectedExistingToUpdate.setQualifiedName("newName");
final OrganizationImpl suborganization = new OrganizationImpl("org321", "oldName/suborgName", "org123");
final OrganizationImpl expectedSuborganizationToUpdate = new OrganizationImpl(suborganization);
expectedSuborganizationToUpdate.setQualifiedName(expectedExistingToUpdate.getQualifiedName() + "/" + suborganization.getName());
when(organizationDao.getById(any())).thenReturn(existing);
doReturn(new Page<>(singletonList(suborganization), 0, 1, 1)).when(organizationDao).getSuborganizations(anyString(), anyInt(), anyLong());
final OrganizationImpl update = new OrganizationImpl("newId", "newName", "newParentId");
final Organization updated = manager.update("organizationId", update);
verify(organizationDao).getById("organizationId");
verify(organizationDao, times(2)).update(organizationCaptor.capture());
List<OrganizationImpl> updatedOrganizations = organizationCaptor.getAllValues();
assertEquals(updatedOrganizations.get(0), expectedExistingToUpdate);
assertEquals(updatedOrganizations.get(1), expectedSuborganizationToUpdate);
verify(organizationDao).getSuborganizations(eq("oldName"), anyInt(), anyLong());
assertEquals(updated, expectedExistingToUpdate);
}
Aggregations