use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project devspaces-images by redhat-developer.
the class OrganizationManagerTest method shouldRemoveOrganization.
@Test
public void shouldRemoveOrganization() throws Exception {
doNothing().when(manager).removeSuborganizations(anyString());
final List<Member> members = Collections.singletonList(mock(Member.class));
doReturn(members).when(manager).removeMembers(anyString());
OrganizationImpl toRemove = new OrganizationImpl("org123", "toRemove", null);
when(organizationDao.getById(anyString())).thenReturn(toRemove);
BeforeAccountRemovedEvent beforeAccountRemovedEvent = mock(BeforeAccountRemovedEvent.class);
BeforeOrganizationRemovedEvent beforeOrganizationRemovedEvent = mock(BeforeOrganizationRemovedEvent.class);
doReturn(beforeAccountRemovedEvent).doReturn(beforeOrganizationRemovedEvent).when(eventService).publish(any());
manager.remove(toRemove.getId());
verify(organizationDao).remove(toRemove.getId());
verify(manager).removeMembers(eq(toRemove.getId()));
verify(manager).removeSuborganizations(eq(toRemove.getId()));
verify(eventService, times(3)).publish(anyObject());
verify(beforeAccountRemovedEvent).propagateException();
verify(beforeOrganizationRemovedEvent).propagateException();
}
use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project devspaces-images by redhat-developer.
the class OrganizationManagerTest method shouldCreateOrganization.
@Test
public void shouldCreateOrganization() throws Exception {
final Organization toCreate = DtoFactory.newDto(OrganizationDto.class).withName("newOrg");
manager.create(toCreate);
verify(organizationDao).create(organizationCaptor.capture());
final OrganizationImpl createdOrganization = organizationCaptor.getValue();
assertEquals(createdOrganization.getName(), toCreate.getName());
assertEquals(createdOrganization.getQualifiedName(), toCreate.getName());
assertEquals(createdOrganization.getParent(), toCreate.getParent());
verify(eventService).publish(persistEventCaptor.capture());
assertEquals(persistEventCaptor.getValue().getOrganization(), createdOrganization);
verify(memberDao).store(new MemberImpl(USER_ID, createdOrganization.getId(), OrganizationDomain.getActions()));
}
use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project devspaces-images by redhat-developer.
the class OrganizationManagerTest method shouldGetOrganizationById.
@Test
public void shouldGetOrganizationById() throws Exception {
final OrganizationImpl toFetch = new OrganizationImpl("org123", "toFetchOrg", "org321");
when(organizationDao.getById(eq("org123"))).thenReturn(toFetch);
final Organization fetched = manager.getById("org123");
assertEquals(fetched, toFetch);
verify(organizationDao).getById("org123");
}
use of org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl in project devspaces-images by redhat-developer.
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 devspaces-images by redhat-developer.
the class OrganizationServiceTest method shouldUpdateOrganization.
@Test
public void shouldUpdateOrganization() throws Exception {
when(orgManager.update(anyString(), any())).thenAnswer(invocationOnMock -> new OrganizationImpl((Organization) invocationOnMock.getArguments()[1]));
final OrganizationDto toUpdate = createOrganization();
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").body(toUpdate).when().post(SECURE_PATH + "/organization/organization123");
assertEquals(response.statusCode(), 200);
final OrganizationDto createdOrganization = unwrapDto(response, OrganizationDto.class);
assertEquals(createdOrganization, toUpdate);
verify(linksInjector).injectLinks(any(), any());
verify(orgManager).update(eq("organization123"), eq(toUpdate));
}
Aggregations