Search in sources :

Example 66 with Response

use of com.jayway.restassured.response.Response in project che by eclipse.

the class UserServiceTest method shouldNotCreateUserIfTokenIsNotValid.

@Test
public void shouldNotCreateUserIfTokenIsNotValid() throws Exception {
    when(tokenValidator.validateToken("token_value")).thenThrow(new ConflictException("error"));
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().contentType("application/json").post(SECURE_PATH + "/user?token=token_value");
    assertEquals(response.statusCode(), 409);
    assertEquals(unwrapError(response), "error");
}
Also used : Response(com.jayway.restassured.response.Response) ConflictException(org.eclipse.che.api.core.ConflictException) Test(org.testng.annotations.Test)

Example 67 with Response

use of com.jayway.restassured.response.Response in project che by eclipse.

the class PreferencesServiceTest method shouldFindPreferences.

@Test
public void shouldFindPreferences() throws Exception {
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().get(SECURE_PATH + "/preferences");
    assertEquals(response.getStatusCode(), 200);
    verify(preferenceManager).find(SUBJECT.getUserId());
}
Also used : Response(com.jayway.restassured.response.Response) Test(org.testng.annotations.Test)

Example 68 with Response

use of com.jayway.restassured.response.Response in project che by eclipse.

the class PreferencesServiceTest method shouldNotUpdatePreferencesWhenNothingSent.

@Test
public void shouldNotUpdatePreferencesWhenNothingSent() throws Exception {
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").when().put(SECURE_PATH + "/preferences");
    assertEquals(response.getStatusCode(), 400);
}
Also used : Response(com.jayway.restassured.response.Response) Test(org.testng.annotations.Test)

Example 69 with Response

use of com.jayway.restassured.response.Response in project che by eclipse.

the class ProfileServiceTest method shouldRemoveAllAttributeIfNoSpecified.

@Test
public void shouldRemoveAllAttributeIfNoSpecified() throws Exception {
    when(profileManager.getById(SUBJECT.getUserId())).thenReturn(new ProfileImpl(SUBJECT.getUserId(), ImmutableMap.of("attr1", "value1", "attr2", "value2", "attr3", "value3")));
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().contentType("application/json").delete(SECURE_PATH + "/profile/attributes");
    assertEquals(response.getStatusCode(), 204);
    verify(profileManager).update(profileCaptor.capture());
    final Profile profile = profileCaptor.getValue();
    assertTrue(profile.getAttributes().isEmpty());
}
Also used : Response(com.jayway.restassured.response.Response) ProfileImpl(org.eclipse.che.api.user.server.model.impl.ProfileImpl) Profile(org.eclipse.che.api.core.model.user.Profile) Test(org.testng.annotations.Test)

Example 70 with Response

use of com.jayway.restassured.response.Response in project che by eclipse.

the class ProfileServiceTest method shouldGetProfileById.

@Test
public void shouldGetProfileById() throws Exception {
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().get(SECURE_PATH + "/profile/" + SUBJECT.getUserId());
    assertEquals(response.getStatusCode(), 200);
    final ProfileDto profileDto = unwrapDto(response, ProfileDto.class);
    assertEquals(profileDto.getUserId(), SUBJECT.getUserId());
}
Also used : Response(com.jayway.restassured.response.Response) ProfileDto(org.eclipse.che.api.user.shared.dto.ProfileDto) Test(org.testng.annotations.Test)

Aggregations

Response (com.jayway.restassured.response.Response)214 Test (org.testng.annotations.Test)129 Test (org.junit.Test)73 WorkspaceImpl (org.eclipse.che.api.workspace.server.model.impl.WorkspaceImpl)35 AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)31 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)27 Matchers.anyString (org.mockito.Matchers.anyString)21 ValidatableResponse (com.jayway.restassured.response.ValidatableResponse)19 CswTestCommons.getMetacardIdFromCswInsertResponse (org.codice.ddf.itests.common.csw.CswTestCommons.getMetacardIdFromCswInsertResponse)15 IOException (java.io.IOException)14 SkipUnstableTest (org.codice.ddf.itests.common.annotations.SkipUnstableTest)14 XPathExpressionException (javax.xml.xpath.XPathExpressionException)12 ImmutableMap (com.google.common.collect.ImmutableMap)11 Map (java.util.Map)11 Factory (org.eclipse.che.api.core.model.factory.Factory)11 FactoryDto (org.eclipse.che.api.factory.shared.dto.FactoryDto)11 UserImpl (org.eclipse.che.api.user.server.model.impl.UserImpl)11 DtoFactory (org.eclipse.che.dto.server.DtoFactory)11 Matchers.containsString (org.hamcrest.Matchers.containsString)10 WorkspaceDto (org.eclipse.che.api.workspace.shared.dto.WorkspaceDto)9