Search in sources :

Example 16 with OrganizationDto

use of org.eclipse.che.multiuser.organization.shared.dto.OrganizationDto in project devspaces-images by redhat-developer.

the class OrganizationServiceTest method shouldGetOrganizationsBySpecifiedUser.

@Test
public void shouldGetOrganizationsBySpecifiedUser() throws Exception {
    final OrganizationDto toFetch = createOrganization();
    doReturn(new Page<>(singletonList(toFetch), 0, 1, 1)).when(orgManager).getByMember(anyString(), anyInt(), anyInt());
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").when().get(SECURE_PATH + "/organization?user=user789&skipCount=0&maxItems=1");
    assertEquals(response.statusCode(), 200);
    final List<OrganizationDto> organizationDtos = unwrapDtoList(response, OrganizationDto.class);
    assertEquals(organizationDtos.size(), 1);
    assertEquals(organizationDtos.get(0), toFetch);
    verify(orgManager).getByMember("user789", 1, 0);
    verify(linksInjector).injectLinks(any(), any());
}
Also used : Response(io.restassured.response.Response) OrganizationDto(org.eclipse.che.multiuser.organization.shared.dto.OrganizationDto) Test(org.testng.annotations.Test)

Example 17 with OrganizationDto

use of org.eclipse.che.multiuser.organization.shared.dto.OrganizationDto in project devspaces-images by redhat-developer.

the class OrganizationLinksInjectorTest method shouldInjectLinks.

@Test
public void shouldInjectLinks() {
    final OrganizationDto organization = DtoFactory.newDto(OrganizationDto.class).withId("org123");
    final OrganizationDto withLinks = organizationLinksInjector.injectLinks(organization, context);
    assertEquals(withLinks.getLinks().size(), 2);
    assertNotNull(withLinks.getLink(Constants.LINK_REL_SELF));
    assertNotNull(withLinks.getLink(Constants.LINK_REL_SUBORGANIZATIONS));
}
Also used : OrganizationDto(org.eclipse.che.multiuser.organization.shared.dto.OrganizationDto) Test(org.testng.annotations.Test)

Example 18 with OrganizationDto

use of org.eclipse.che.multiuser.organization.shared.dto.OrganizationDto in project che-server by eclipse-che.

the class OrganizationLinksInjectorTest method shouldInjectLinks.

@Test
public void shouldInjectLinks() {
    final OrganizationDto organization = DtoFactory.newDto(OrganizationDto.class).withId("org123");
    final OrganizationDto withLinks = organizationLinksInjector.injectLinks(organization, context);
    assertEquals(withLinks.getLinks().size(), 2);
    assertNotNull(withLinks.getLink(Constants.LINK_REL_SELF));
    assertNotNull(withLinks.getLink(Constants.LINK_REL_SUBORGANIZATIONS));
}
Also used : OrganizationDto(org.eclipse.che.multiuser.organization.shared.dto.OrganizationDto) Test(org.testng.annotations.Test)

Example 19 with OrganizationDto

use of org.eclipse.che.multiuser.organization.shared.dto.OrganizationDto in project che-server by eclipse-che.

the class OrganizationServiceTest method shouldGetOrganizationsByCurrentUserIfParameterIsNotSpecified.

@Test
public void shouldGetOrganizationsByCurrentUserIfParameterIsNotSpecified() throws Exception {
    final OrganizationDto toFetch = createOrganization();
    doReturn(new Page<>(singletonList(toFetch), 0, 1, 1)).when(orgManager).getByMember(anyString(), anyInt(), anyInt());
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").when().get(SECURE_PATH + "/organization?skipCount=0&maxItems=1");
    assertEquals(response.statusCode(), 200);
    final List<OrganizationDto> organizationDtos = unwrapDtoList(response, OrganizationDto.class);
    assertEquals(organizationDtos.size(), 1);
    assertEquals(organizationDtos.get(0), toFetch);
    verify(orgManager).getByMember(CURRENT_USER_ID, 1, 0);
    verify(linksInjector).injectLinks(any(), any());
}
Also used : Response(io.restassured.response.Response) OrganizationDto(org.eclipse.che.multiuser.organization.shared.dto.OrganizationDto) Test(org.testng.annotations.Test)

Example 20 with OrganizationDto

use of org.eclipse.che.multiuser.organization.shared.dto.OrganizationDto in project che-server by eclipse-che.

the class OrganizationServiceTest method shouldThrowBadRequestWhenCreatingNonValidOrganization.

@Test
public void shouldThrowBadRequestWhenCreatingNonValidOrganization() throws Exception {
    doThrow(new BadRequestException("non valid organization")).when(validator).checkOrganization(any());
    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(), 400);
    final ServiceError error = unwrapDto(response, ServiceError.class);
    assertEquals(error.getMessage(), "non valid organization");
    verify(validator).checkOrganization(toCreate);
}
Also used : Response(io.restassured.response.Response) ServiceError(org.eclipse.che.api.core.rest.shared.dto.ServiceError) BadRequestException(org.eclipse.che.api.core.BadRequestException) OrganizationDto(org.eclipse.che.multiuser.organization.shared.dto.OrganizationDto) Test(org.testng.annotations.Test)

Aggregations

OrganizationDto (org.eclipse.che.multiuser.organization.shared.dto.OrganizationDto)22 Test (org.testng.annotations.Test)20 Response (io.restassured.response.Response)18 Organization (org.eclipse.che.multiuser.organization.shared.model.Organization)6 BadRequestException (org.eclipse.che.api.core.BadRequestException)4 ServiceError (org.eclipse.che.api.core.rest.shared.dto.ServiceError)4 OrganizationImpl (org.eclipse.che.multiuser.organization.spi.impl.OrganizationImpl)4 ForbiddenException (org.eclipse.che.api.core.ForbiddenException)2 Subject (org.eclipse.che.commons.subject.Subject)2