use of com.jayway.restassured.response.Response in project che by eclipse.
the class RecipeServiceTest method shouldBeAbleToSearchRecipes.
@Test
public void shouldBeAbleToSearchRecipes() throws Exception {
final RecipeImpl recipe1 = new RecipeImpl().withId("id1").withCreator(USER_ID).withType("docker").withScript("script1 content").withTags(asList("java"));
final RecipeImpl recipe2 = new RecipeImpl().withId("id2").withCreator(USER_ID).withType("docker").withScript("script2 content").withTags(asList("java", "mongodb"));
when(recipeDao.search(eq("user123"), eq(asList("java", "mongodb")), eq("docker"), any(int.class), any(int.class))).thenReturn(asList(recipe1, recipe2));
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().queryParameter("tags", asList("java", "mongodb")).queryParameter("type", "docker").get(SECURE_PATH + "/recipe");
assertEquals(response.getStatusCode(), 200);
assertEquals(unwrapDtoList(response, RecipeDescriptor.class).size(), 2);
}
use of com.jayway.restassured.response.Response in project che by eclipse.
the class RecipeServiceTest method shouldThrowBadRequestExceptionWhenCreatingRecipeWithoutName.
@Test
public void shouldThrowBadRequestExceptionWhenCreatingRecipeWithoutName() {
final NewRecipe newRecipe = newDto(NewRecipe.class).withType("docker").withScript("script");
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").body(newRecipe).when().post(SECURE_PATH + "/recipe");
assertEquals(response.getStatusCode(), 400);
assertEquals(unwrapDto(response, ServiceError.class).getMessage(), "Recipe name required");
}
use of com.jayway.restassured.response.Response in project che by eclipse.
the class RecipeServiceTest method shouldBeAbleToGetRecipe.
@Test
public void shouldBeAbleToGetRecipe() throws Exception {
final RecipeImpl recipe = new RecipeImpl().withCreator("someone2").withId("recipe123").withName("name").withType("docker").withScript("FROM ubuntu\n").withTags(asList("java", "mognodb"));
when(recipeDao.getById(recipe.getId())).thenReturn(recipe);
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().get(SECURE_PATH + "/recipe/" + recipe.getId());
assertEquals(response.getStatusCode(), 200);
final RecipeDescriptor descriptor = unwrapDto(response, RecipeDescriptor.class);
assertEquals(descriptor.getId(), recipe.getId());
assertEquals(descriptor.getName(), recipe.getName());
assertEquals(descriptor.getType(), recipe.getType());
assertEquals(descriptor.getScript(), recipe.getScript());
assertEquals(descriptor.getTags(), recipe.getTags());
assertEquals(descriptor.getCreator(), recipe.getCreator());
}
use of com.jayway.restassured.response.Response in project che by eclipse.
the class RecipeServiceTest method shouldThrowBadRequestExceptionWhenUpdatingRecipeWithNullId.
@Test
public void shouldThrowBadRequestExceptionWhenUpdatingRecipeWithNullId() throws Exception {
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").body(newDto(RecipeUpdate.class)).when().put(SECURE_PATH + "/recipe");
assertEquals(response.getStatusCode(), 400);
}
use of com.jayway.restassured.response.Response in project che by eclipse.
the class RecipeServiceTest method shouldBeAbleToUpdateRecipe.
@Test
public void shouldBeAbleToUpdateRecipe() throws Exception {
final RecipeImpl recipe = new RecipeImpl().withId("id").withCreator(USER_ID).withType("docker").withScript("script1 content").withTags(asList("java"));
final RecipeImpl updatedRecipe = new RecipeImpl(recipe).withType("new-type").withScript("new script content").withTags(asList("java", "mongodb"));
when(recipeDao.update(any())).thenReturn(updatedRecipe);
RecipeUpdate update = newDto(RecipeUpdate.class).withId(recipe.getId()).withType("new-type").withScript("new script content").withTags(asList("java", "mongodb"));
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").body(update).when().put(SECURE_PATH + "/recipe");
assertEquals(response.getStatusCode(), 200);
verify(recipeDao).update(any(RecipeImpl.class));
}
Aggregations