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());
}
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 CreateWorkspacePresenter method show.
/**
* Shows special dialog window which allows set up workspace which will be created.
*
* @param workspaces
* list of existing workspaces
*/
public void show(List<WorkspaceDto> workspaces, final Callback<Component, Exception> callback) {
this.callback = callback;
workspacesNames.clear();
for (WorkspaceDto workspace : workspaces) {
workspacesNames.add(workspace.getConfig().getName());
}
Promise<List<RecipeDescriptor>> recipes = recipeService.getAllRecipes();
recipes.then(new Operation<List<RecipeDescriptor>>() {
@Override
public void apply(List<RecipeDescriptor> recipeDescriptors) throws OperationException {
CreateWorkspacePresenter.this.recipes = recipeDescriptors;
}
});
String workspaceName = browserAddress.getWorkspaceName();
view.setWorkspaceName(workspaceName);
validateCreateWorkspaceForm();
view.show();
}
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 SshCategoryPresenter method updateTargetRecipe.
/**
* Updates as existent target recipe and save it.
*/
private void updateTargetRecipe() {
RecipeUpdate recipeUpdate = dtoFactory.createDto(RecipeUpdate.class).withId(selectedTarget.getRecipe().getId()).withName(sshView.getTargetName()).withType(selectedTarget.getRecipe().getType()).withTags(selectedTarget.getRecipe().getTags()).withDescription(selectedTarget.getRecipe().getDescription()).withScript("{" + "\"host\": \"" + selectedTarget.getHost() + "\", " + "\"port\": \"" + selectedTarget.getPort() + "\", " + "\"username\": \"" + selectedTarget.getUserName() + "\", " + "\"password\": \"" + selectedTarget.getPassword() + "\"" + "}");
Promise<RecipeDescriptor> updateRecipe = recipeServiceClient.updateRecipe(recipeUpdate);
updateRecipe.then(new Operation<RecipeDescriptor>() {
@Override
public void apply(RecipeDescriptor recipe) throws OperationException {
onTargetSaved(recipe);
}
});
updateRecipe.catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError arg) throws OperationException {
dialogFactory.createMessageDialog("Error", machineLocale.targetsViewSaveError(), null).show();
}
});
}
Aggregations