use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project devspaces-images by redhat-developer.
the class OrganizationManagerTest method shouldThrowConflictExceptionOnUpdatingIfOrganizationNameIsReserved.
@Test(expectedExceptions = ConflictException.class)
public void shouldThrowConflictExceptionOnUpdatingIfOrganizationNameIsReserved() throws Exception {
when(organizationDao.getById("id")).thenReturn(new OrganizationImpl("id", "oldName", null));
manager.update("id", new OrganizationImpl("id", "reserved", null));
}
use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project devspaces-images by redhat-developer.
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 devspaces-images by redhat-developer.
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 devspaces-images by redhat-developer.
the class OrganizationManagerTest method shouldGetOrganizationByName.
@Test
public void shouldGetOrganizationByName() throws Exception {
final OrganizationImpl toFetch = new OrganizationImpl("org123", "toFetchOrg", "org321");
when(organizationDao.getByName(eq("org123"))).thenReturn(toFetch);
final Organization fetched = manager.getByName("org123");
assertEquals(fetched, toFetch);
verify(organizationDao).getByName("org123");
}
use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project devspaces-images by redhat-developer.
the class OrganizationPermissionsFilterTest method shouldCheckPermissionsOnChildOrganizationRemovingWhenUserDoesNotHavePermissionsOnParentOrgLevel.
@Test
public void shouldCheckPermissionsOnChildOrganizationRemovingWhenUserDoesNotHavePermissionsOnParentOrgLevel() throws Exception {
when(manager.getById(anyString())).thenReturn(new OrganizationImpl("organization123", "test", "parent123"));
doReturn(false).when(subject).hasPermission(DOMAIN_ID, "parent123", MANAGE_SUBORGANIZATIONS);
doReturn(true).when(subject).hasPermission(DOMAIN_ID, "organization123", DELETE);
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(subject).hasPermission(DOMAIN_ID, "organization123", DELETE);
verify(superPrivilegesChecker, never()).hasSuperPrivileges();
verifyNoMoreInteractions(subject);
}
Aggregations