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();
// asserts
Recipe searchedRecipe2 = recipeDAO.getEntity(Recipe.class,
recipe2.getId());
Iterator<RecipeIngredient> itRecipe1 = recipe.getRecipeIngredients()
.iterator();
i1 = itRecipe1.next().getIngredient();
i2 = itRecipe1.next().getIngredient();
it = searchedRecipe2.getRecipeIngredients().iterator();
boolean foundi1 = false;
boolean foundi2 = false;
while (it.hasNext()) {
RecipeIngredient ri = it.next();
if (ri.getIngredient().equals(i1)) {