use of org.eclipse.che.api.machine.shared.dto.recipe.NewRecipe in project che by eclipse.
the class RecipeServiceTest method shouldThrowBadRequestExceptionOnCreateRecipeWithNewRecipeWhichDoesNotHaveType.
@Test
public void shouldThrowBadRequestExceptionOnCreateRecipeWithNewRecipeWhichDoesNotHaveType() {
final NewRecipe newRecipe = newDto(NewRecipe.class).withScript("FROM ubuntu\n");
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 type required");
}
use of org.eclipse.che.api.machine.shared.dto.recipe.NewRecipe in project che by eclipse.
the class RecipePartPresenterTest method recipeShouldBeSaved.
@Test
public void recipeShouldBeSaved() throws Exception {
NewRecipe newRecipe = mock(NewRecipe.class);
List<String> tags = Collections.singletonList("tag");
when(dtoFactory.createDto(NewRecipe.class)).thenReturn(newRecipe);
when(newRecipe.withType(anyString())).thenReturn(newRecipe);
when(newRecipe.withScript(anyString())).thenReturn(newRecipe);
when(newRecipe.withName(anyString())).thenReturn(newRecipe);
when(newRecipe.withTags(Matchers.<List<String>>any())).thenReturn(newRecipe);
when(service.createRecipe(newRecipe)).thenReturn(recipeDescriptorPromise);
when(recipesContainerPresenter.getEditorPanel(Matchers.<RecipeWidget>any())).thenReturn(recipeEditorPanel);
RecipeUpdate recipeUpdate = mock(RecipeUpdate.class);
when(dtoFactory.createDto(RecipeUpdate.class)).thenReturn(recipeUpdate);
when(recipeUpdate.withType(anyString())).thenReturn(recipeUpdate);
when(recipeUpdate.withId(anyString())).thenReturn(recipeUpdate);
when(recipeUpdate.withScript(anyString())).thenReturn(recipeUpdate);
when(recipeUpdate.withName(anyString())).thenReturn(recipeUpdate);
when(recipeUpdate.withTags(Matchers.<List<String>>any())).thenReturn(recipeUpdate);
when(recipeDescriptor1.getId()).thenReturn("id");
when(recipeDescriptor1.getName()).thenReturn("name");
when(recipeDescriptor1.getScript()).thenReturn("script");
when(recipeDescriptor1.getTags()).thenReturn(tags);
when(service.updateRecipe(recipeUpdate)).thenReturn(savedRecipeDescriptorPromise);
when(recipeDescriptor1.getType()).thenReturn(RECIPE_TYPE);
when(recipeEditorPanel.getScript()).thenReturn("script");
when(recipeEditorPanel.getTags()).thenReturn(tags);
when(recipeEditorPanel.getName()).thenReturn("name");
recipePartPresenter.onNewButtonClicked();
verify(recipeDescriptorPromise).then(operationDescriptorCaptor.capture());
operationDescriptorCaptor.getValue().apply(recipeDescriptor1);
recipePartPresenter.onSaveButtonClicked();
verify(service).updateRecipe(recipeUpdate);
verify(savedRecipeDescriptorPromise).then(savedDescriptorCaptor.capture());
savedDescriptorCaptor.getValue().apply(recipeDescriptor1);
verify(recipeDescriptor1).setScript("script");
verify(recipeDescriptor1).setTags(recipeDescriptor1.getTags());
verify(notificationManager).notify(eq("Recipe \"name\" was saved."));
}
Aggregations