Examples of Ingredient


Examples of demo.hw.server.data.Ingredient

   
    private List<Beverage> beverages;
   
    public JavascriptExampleImpl() {
        beverages = new ArrayList<Beverage>();
        Ingredient calcium = new Ingredient();
        calcium.setName("calcium");
        calcium.setCategory(Category.Mineral);
        Ingredient zinc = new Ingredient();
        zinc.setName("zinc");
        zinc.setCategory(Category.Mineral);
        Ingredient broccoli = new Ingredient();
        broccoli.setName("broccoli");
        broccoli.setCategory(Category.Vegetable);
        Ingredient apple = new Ingredient();
        apple.setName("apple");
        apple.setCategory(Category.Fruit);
       
        Beverage b = new Beverage();
        b.setName("zinc-fortified broccoli shake");
        b.setProof(20);
        Ingredient[] ingredients;
View Full Code Here

Examples of fr.valtech.many2many.domain.Ingredient

    private Ingredient jambon;

    @Before
    public void setUp() throws Exception {

        jambon = new Ingredient();
        jambon.setLabel("jambon");

    }
View Full Code Here

Examples of fr.valtech.many2many.domain.Ingredient

    public void testFindByLabel() throws Exception {
        ingredientDAO.save(jambon);
        flushSession();
        entityManager.clear();

        Ingredient i = ingredientDAO.findByLabel(jambon.getLabel());
        assertNotNull(i);
        assertEquals(jambon.getId(), i.getId());
        assertEquals(jambon.getLabel(), i.getLabel());

    }
View Full Code Here

Examples of fr.valtech.many2many.domain.Ingredient

    }

    @Test
    public void testFindByLabelWithNoResult() throws Exception {
        Ingredient i = ingredientDAO.findByLabel("nonExistingLabel");
        assertNull(i);
    }
View Full Code Here

Examples of fr.valtech.many2many.domain.Ingredient

    }

    @Before
    public void setUp() throws Exception {

        jambon = new Ingredient();
        jambon.setLabel("jambon");

        _400gJambon = new RecipeIngredient();
        _400gJambon.setAmount("400g grammes");
        _400gJambon.setIngredient(jambon);
View Full Code Here

Examples of fr.valtech.many2many.domain.Ingredient

    @Test
    public void testCreate2recipesWithSameIngredients() throws Exception {

        // recette1
        Ingredient pain = new Ingredient();
        pain.setLabel("pain");

        RecipeIngredient _100gPain = new RecipeIngredient(pain, "100g");
        recipe.addRecipeIngredient(_100gPain);
        Assert.assertNull(recipe.getId());
        recipeDAO.save(recipe);
        flushSession();

        // recette2
        Recipe recipe2 = new Recipe();
        recipe2.setTitle("title2");
        Iterator<RecipeIngredient> it = recipe.getRecipeIngredients()
                .iterator();

        // les ingredients détachés
        Ingredient i1 = new Ingredient();
        i1.setId(it.next().getIngredient().getId());
        RecipeIngredient ri1 = new RecipeIngredient(i1, "200g");
        recipe2.addRecipeIngredient(ri1);

        Ingredient i2 = new Ingredient();
        i2.setId(it.next().getIngredient().getId());
        RecipeIngredient ri2 = new RecipeIngredient(i2, "300g");
        recipe2.addRecipeIngredient(ri2);

        assertFalse(i1.getId().equals(i2.getId()));
        assertFalse(i1.equals(i2));

        recipeDAO.save(recipe2);
        assertEquals(2, recipe2.getRecipeIngredients().size());
        flushSession();
View Full Code Here

Examples of fr.valtech.many2many.domain.Ingredient

        flushSession();

        Recipe searchedRecipe;
        // clean la session pour detacher les objets
        entityManager.clear();
        Ingredient pates = new Ingredient();
        pates.setLabel("pates");

        RecipeIngredient _100gPates = new RecipeIngredient(pates, "200g");

        searchedRecipe = detachRecipe(recipe);
        searchedRecipe.addRecipeIngredient(_100gPates);
View Full Code Here

Examples of fr.valtech.many2many.domain.Ingredient

        // clean de la session pour detacher les objets
        entityManager.clear();
        Recipe searchedRecipe = detachRecipe(recipe);
        // ajoute un nouvel ingredient (sans id)
        Ingredient pates = new Ingredient();
        pates.setLabel("pates");
        RecipeIngredient _100gPates = new RecipeIngredient(pates, "100g");

        searchedRecipe.addRecipeIngredient(_100gPates);
        recipeDAO.merge(searchedRecipe);
        flushSession();
View Full Code Here

Examples of fr.valtech.many2many.domain.Ingredient

        // enregistre la recette
        Assert.assertNull(recipe.getId());
        recipeDAO.save(recipe);
        Assert.assertTrue(recipe.getId() > 0);
        // cree un nouvel ingredient en base
        Ingredient salade = new Ingredient();
        salade.setLabel("salade");
        entityManager.persist(salade);
        flushSession();

        // clean de la session et de la recette
        entityManager.clear();
        Ingredient saladeDetached = new Ingredient();
        saladeDetached.setId(salade.getId());

        Recipe searchedRecipe = detachRecipe(recipe);
        // ajoute un nouvel ingredient (avec id)
        RecipeIngredient _1feuilleSalade = new RecipeIngredient(saladeDetached,
                "1 feuille");
View Full Code Here

Examples of fr.valtech.many2many.domain.Ingredient

        // enregistre la recette
        Assert.assertNull(recipe.getId());
        recipeDAO.save(recipe);
        Assert.assertTrue(recipe.getId() > 0);
        // cree un nouvel ingredient en base
        Ingredient salade = new Ingredient();
        salade.setLabel("salade");
        entityManager.persist(salade);
        flushSession();

        // clean de la session et de la recette
        entityManager.clear();
        Ingredient saladeDetached = new Ingredient();
        saladeDetached.setId(salade.getId());

        Recipe searchedRecipe = detachRecipe(recipe);
        // ajoute un nouvel ingredient (avec id)
        RecipeIngredient ri = searchedRecipe.getRecipeIngredients().iterator()
                .next();
        ri.setIngredient(saladeDetached);

        recipeDAO.merge(searchedRecipe);
        flushSession();
        entityManager.clear();

        recipe = recipeDAO.getEntity(Recipe.class, searchedRecipe.getId());
        Assert.assertEquals(1, recipe.getRecipeIngredients().size());
        Assert.assertEquals(saladeDetached.getId(), recipe
                .getRecipeIngredients().iterator().next().getIngredient()
                .getId());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.