use of org.eclipse.che.api.machine.shared.dto.recipe.RecipeDescriptor in project che by eclipse.
the class RecipePartPresenter method onCloneButtonClicked.
/** {@inheritDoc} */
@Override
public void onCloneButtonClicked() {
RecipeDescriptor selectedRecipeDescriptor = recipes.get(selectedRecipe);
String recipeName = NameGenerator.generateCopy(selectedRecipeDescriptor.getName(), recipes.keySet());
NewRecipe newRecipe = dtoFactory.createDto(NewRecipe.class).withType(selectedRecipeDescriptor.getType()).withScript(selectedRecipeDescriptor.getScript()).withName(recipeName).withTags(selectedRecipeDescriptor.getTags());
createRecipe(newRecipe);
}
use of org.eclipse.che.api.machine.shared.dto.recipe.RecipeDescriptor in project che by eclipse.
the class RecipesContainerPresenter method addRecipePanel.
/**
* Adds new recipe panel to container.
*
* @param recipe
* current recipe widget
*/
public void addRecipePanel(@NotNull RecipeWidget recipe) {
if (recipePanels.get(recipe) != null) {
return;
}
RecipeEditorPanel editorPanel = entityFactory.createRecipeEditorPanel(recipe.getDescriptor());
recipePanels.put(recipe, editorPanel);
RecipeEditorView editorView = ((RecipeEditorView) editorPanel.getView());
RecipeDescriptor recipeDescriptor = recipe.getDescriptor();
editorView.setScriptUrl(recipeDescriptor.getLink("get recipe script").getHref());
editorView.setTags(recipeDescriptor.getTags());
editorView.setName(recipeDescriptor.getName());
}
use of org.eclipse.che.api.machine.shared.dto.recipe.RecipeDescriptor in project che by eclipse.
the class NameGeneratorTest method generateCustomRecipeName3.
@Test
public void generateCustomRecipeName3() throws Exception {
String newName = "RECIPE-11";
RecipeWidget environment3 = mock(RecipeWidget.class);
RecipeWidget environment4 = mock(RecipeWidget.class);
RecipeWidget environment5 = mock(RecipeWidget.class);
RecipeWidget environment6 = mock(RecipeWidget.class);
RecipeWidget environment7 = mock(RecipeWidget.class);
RecipeWidget environment8 = mock(RecipeWidget.class);
RecipeWidget environment9 = mock(RecipeWidget.class);
RecipeWidget environment10 = mock(RecipeWidget.class);
RecipeDescriptor recipeDescriptor3 = mock(RecipeDescriptor.class);
RecipeDescriptor recipeDescriptor4 = mock(RecipeDescriptor.class);
RecipeDescriptor recipeDescriptor5 = mock(RecipeDescriptor.class);
RecipeDescriptor recipeDescriptor6 = mock(RecipeDescriptor.class);
RecipeDescriptor recipeDescriptor7 = mock(RecipeDescriptor.class);
RecipeDescriptor recipeDescriptor8 = mock(RecipeDescriptor.class);
RecipeDescriptor recipeDescriptor9 = mock(RecipeDescriptor.class);
RecipeDescriptor recipeDescriptor10 = mock(RecipeDescriptor.class);
when(recipe1.getDescriptor()).thenReturn(recipeDescriptor1);
when(recipe2.getDescriptor()).thenReturn(recipeDescriptor2);
when(environment3.getDescriptor()).thenReturn(recipeDescriptor3);
when(environment4.getDescriptor()).thenReturn(recipeDescriptor4);
when(environment5.getDescriptor()).thenReturn(recipeDescriptor5);
when(environment6.getDescriptor()).thenReturn(recipeDescriptor6);
when(environment7.getDescriptor()).thenReturn(recipeDescriptor7);
when(environment8.getDescriptor()).thenReturn(recipeDescriptor8);
when(environment9.getDescriptor()).thenReturn(recipeDescriptor9);
when(environment10.getDescriptor()).thenReturn(recipeDescriptor10);
when(recipeDescriptor1.getName()).thenReturn("RECIPE-1");
when(recipeDescriptor2.getName()).thenReturn("RECIPE-2");
when(recipeDescriptor3.getName()).thenReturn("RECIPE-3");
when(recipeDescriptor4.getName()).thenReturn("RECIPE-4");
when(recipeDescriptor5.getName()).thenReturn("RECIPE-5");
when(recipeDescriptor6.getName()).thenReturn("RECIPE-6");
when(recipeDescriptor7.getName()).thenReturn("RECIPE-7");
when(recipeDescriptor8.getName()).thenReturn("RECIPE-8");
when(recipeDescriptor9.getName()).thenReturn("RECIPE-9");
when(recipeDescriptor10.getName()).thenReturn("RECIPE-10");
HashSet<RecipeWidget> recipes = new HashSet<>(Arrays.asList(recipe1, recipe2, environment3, environment4, environment5, environment6, environment7, environment8, environment9, environment10));
String generated = NameGenerator.generateCustomRecipeName(recipes);
assertEquals(newName, generated);
}
use of org.eclipse.che.api.machine.shared.dto.recipe.RecipeDescriptor in project che by eclipse.
the class RecipeService method asRecipeDescriptor.
/**
* Transforms {@link ManagedRecipe} to {@link RecipeDescriptor}.
*/
private RecipeDescriptor asRecipeDescriptor(ManagedRecipe recipe) {
final RecipeDescriptor descriptor = DtoFactory.getInstance().createDto(RecipeDescriptor.class).withId(recipe.getId()).withName(recipe.getName()).withType(recipe.getType()).withScript(recipe.getScript()).withCreator(recipe.getCreator()).withTags(recipe.getTags());
final UriBuilder builder = getServiceContext().getServiceUriBuilder();
final Link removeLink = LinksHelper.createLink("DELETE", builder.clone().path(getClass(), "removeRecipe").build(recipe.getId()).toString(), LINK_REL_REMOVE_RECIPE);
final Link scriptLink = LinksHelper.createLink("GET", builder.clone().path(getClass(), "getRecipeScript").build(recipe.getId()).toString(), TEXT_PLAIN, LINK_REL_GET_RECIPE_SCRIPT);
descriptor.setLinks(asList(scriptLink, removeLink));
return descriptor;
}
use of org.eclipse.che.api.machine.shared.dto.recipe.RecipeDescriptor 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());
}
Aggregations