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");
}
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());
}
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);
}
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());
}
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());
}
Aggregations