use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project devspaces-images by redhat-developer.
the class OrganizationServiceTest method shouldCreateOrganization.
@Test
public void shouldCreateOrganization() throws Exception {
when(orgManager.create(any())).thenAnswer(invocationOnMock -> new OrganizationImpl((Organization) invocationOnMock.getArguments()[0]));
final OrganizationDto toCreate = createOrganization();
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").body(toCreate).when().post(SECURE_PATH + "/organization");
assertEquals(response.statusCode(), 201);
final OrganizationDto createdOrganization = unwrapDto(response, OrganizationDto.class);
assertEquals(createdOrganization, toCreate);
verify(linksInjector).injectLinks(any(), any());
verify(orgManager).create(eq(toCreate));
}
use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project devspaces-images by redhat-developer.
the class OrganizationPermissionsFilterTest method shouldCheckPermissionsOnParentOrgLevelOnChildOrganizationUpdating.
@Test
public void shouldCheckPermissionsOnParentOrgLevelOnChildOrganizationUpdating() throws Exception {
when(manager.getById(anyString())).thenReturn(new OrganizationImpl("organization123", "test", "parent123"));
when(subject.hasPermission(DOMAIN_ID, "parent123", MANAGE_SUBORGANIZATIONS)).thenReturn(true);
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").when().post(SECURE_PATH + "/organization/organization123");
assertEquals(response.getStatusCode(), 204);
verify(service).update(eq("organization123"), any());
verify(subject).hasPermission(DOMAIN_ID, "parent123", MANAGE_SUBORGANIZATIONS);
verify(superPrivilegesChecker, never()).hasSuperPrivileges();
verifyNoMoreInteractions(subject);
}
use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project devspaces-images by redhat-developer.
the class OrganizationPermissionsFilterTest method shouldCheckPermissionsOnParentOrgLevelOnChildOrganizationRemoving.
@Test
public void shouldCheckPermissionsOnParentOrgLevelOnChildOrganizationRemoving() throws Exception {
when(manager.getById(anyString())).thenReturn(new OrganizationImpl("organization123", "test", "parent123"));
when(subject.hasPermission(DOMAIN_ID, "parent123", MANAGE_SUBORGANIZATIONS)).thenReturn(true);
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").when().delete(SECURE_PATH + "/organization/organization123");
assertEquals(response.getStatusCode(), 204);
verify(service).remove(eq("organization123"));
verify(subject).hasPermission(DOMAIN_ID, "parent123", MANAGE_SUBORGANIZATIONS);
verify(superPrivilegesChecker, never()).hasSuperPrivileges();
verifyNoMoreInteractions(subject);
}
use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project devspaces-images by redhat-developer.
the class OrganizationResourcesDistributorTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
lenient().doNothing().when(manager).checkResourcesAvailability(anyString(), any());
lenient().when(resourcesLocks.lock(anyString())).thenReturn(lock);
lenient().when(organizationManager.getById(ORG_ID)).thenReturn(new OrganizationImpl(ORG_ID, ORG_ID + "name", PARENT_ORG_ID));
lenient().when(organizationManager.getById(PARENT_ORG_ID)).thenReturn(new OrganizationImpl(PARENT_ORG_ID, PARENT_ORG_ID + "name", null));
}
use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project devspaces-images by redhat-developer.
the class JpaOrganizationImplTckRepository method removeAll.
@Override
public void removeAll() throws TckRepositoryException {
uow.begin();
final EntityManager manager = managerProvider.get();
try {
manager.getTransaction().begin();
for (int i = createdOrganizations.size() - 1; i > -1; i--) {
// and may also ignore some configuration options, while EntityManager#remove won't
try {
final OrganizationImpl organizationToRemove = manager.createQuery("SELECT o FROM Organization o " + "WHERE o.id = :id", OrganizationImpl.class).setParameter("id", createdOrganizations.get(i).getId()).getSingleResult();
manager.remove(organizationToRemove);
} catch (NoResultException ignored) {
// it is already removed
}
}
createdOrganizations.clear();
manager.getTransaction().commit();
} catch (RuntimeException x) {
if (manager.getTransaction().isActive()) {
manager.getTransaction().rollback();
}
throw new TckRepositoryException(x.getLocalizedMessage(), x);
} finally {
uow.end();
}
// remove all objects that was created in tests
super.removeAll();
}
Aggregations