use of org.eclipse.che.api.machine.shared.dto.recipe.NewRecipe in project che by eclipse.
the class RecipeServiceTest method shouldThrowBadRequestExceptionOnCreateRecipeWithNewRecipeWhichDoesNotHaveScript.
@Test
public void shouldThrowBadRequestExceptionOnCreateRecipeWithNewRecipeWhichDoesNotHaveScript() {
final NewRecipe newRecipe = newDto(NewRecipe.class).withType("docker");
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 script required");
}
use of org.eclipse.che.api.machine.shared.dto.recipe.NewRecipe 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 org.eclipse.che.api.machine.shared.dto.recipe.NewRecipe in project che by eclipse.
the class RecipePartPresenterTest method secondRecipeShouldBeCreated.
@Test
public void secondRecipeShouldBeCreated() throws Exception {
NewRecipe newRecipe = mock(NewRecipe.class);
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);
when(recipesContainerPresenter.getEditorStubPanel()).thenReturn(stubPanel);
recipePartPresenter.onNewButtonClicked();
verify(recipeDescriptorPromise).then(operationDescriptorCaptor.capture());
operationDescriptorCaptor.getValue().apply(recipeDescriptor1);
when(recipeDescriptor1.getName()).thenReturn("name");
recipePartPresenter.onCloneButtonClicked();
verify(recipeDescriptor1).getType();
verify(recipeDescriptor1).getScript();
verify(recipeDescriptor1).getTags();
verify(newRecipe).withType(RECIPE_TYPE);
verify(newRecipe).withScript("script");
verify(newRecipe).withName("name");
assertTrue(newRecipe.getTags().isEmpty());
verify(service, times(2)).createRecipe(newRecipe);
verify(recipeDescriptorPromise, times(2)).then(operationDescriptorCaptor.capture());
operationDescriptorCaptor.getValue().apply(recipeDescriptor1);
verify(recipePartView, times(2)).addRecipe(Matchers.<RecipeWidget>any());
verify(recipesContainerPresenter, times(2)).addRecipePanel(Matchers.<RecipeWidget>any());
verify(recipesContainerPresenter, times(2)).showEditorPanel(Matchers.<RecipeWidget>any());
verify(recipesContainerPresenter, times(2)).getEditorPanel(Matchers.<RecipeWidget>any());
verify(recipeEditorPanel, times(2)).setDelegate(recipePartPresenter);
}
use of org.eclipse.che.api.machine.shared.dto.recipe.NewRecipe in project che by eclipse.
the class RecipePartPresenterTest method firstRecipeShouldBeCreated.
@Test
public void firstRecipeShouldBeCreated() throws Exception {
NewRecipe newRecipe = mock(NewRecipe.class);
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);
when(recipeEditorPanel.getName()).thenReturn("name");
recipePartPresenter.onNewButtonClicked();
verify(service).createRecipe(newRecipe);
verify(newRecipe).withType(RECIPE_TYPE);
verify(newRecipe).withScript("script");
verify(newRecipe).withName("name");
verify(stubPanel, times(2)).getName();
verify(stubPanel).getTags();
assertTrue(newRecipe.getTags().isEmpty());
verify(recipeDescriptorPromise).then(operationDescriptorCaptor.capture());
operationDescriptorCaptor.getValue().apply(recipeDescriptor1);
verify(recipePartView).addRecipe(Matchers.<RecipeWidget>any());
verify(recipesContainerPresenter).addRecipePanel(Matchers.<RecipeWidget>any());
verify(recipesContainerPresenter).showEditorPanel(Matchers.<RecipeWidget>any());
verify(recipesContainerPresenter).getEditorPanel(Matchers.<RecipeWidget>any());
verify(recipeEditorPanel).setDelegate(recipePartPresenter);
}
use of org.eclipse.che.api.machine.shared.dto.recipe.NewRecipe in project che by eclipse.
the class RecipePartPresenterTest method notificationShouldBeShowedWhenCreationIsFailed.
@Test
public void notificationShouldBeShowedWhenCreationIsFailed() throws Exception {
NewRecipe newRecipe = mock(NewRecipe.class);
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);
when(recipeEditorPanel.getName()).thenReturn("name");
recipePartPresenter.onNewButtonClicked();
verify(service).createRecipe(newRecipe);
verify(newRecipe).withType(RECIPE_TYPE);
verify(newRecipe).withScript("script");
verify(newRecipe).withName("name");
verify(stubPanel, times(2)).getName();
verify(stubPanel).getTags();
assertTrue(newRecipe.getTags().isEmpty());
verify(recipeDescriptorPromise).then(operationDescriptorCaptor.capture());
operationDescriptorCaptor.getValue().apply(recipeDescriptor1);
verify(recipePartView).addRecipe(Matchers.<RecipeWidget>any());
verify(recipesContainerPresenter).addRecipePanel(Matchers.<RecipeWidget>any());
verify(recipesContainerPresenter).showEditorPanel(Matchers.<RecipeWidget>any());
verify(recipesContainerPresenter).getEditorPanel(Matchers.<RecipeWidget>any());
verify(recipeEditorPanel).setDelegate(recipePartPresenter);
PromiseError promiseError = mock(PromiseError.class);
when(promiseError.getMessage()).thenReturn("text");
verify(recipeDescriptorPromise).catchError(operationErrorArgumentCaptor.capture());
operationErrorArgumentCaptor.getValue().apply(promiseError);
verify(notificationManager).notify(anyString(), anyString(), any(StatusNotification.Status.class), any(DisplayMode.class));
}
Aggregations