Ejemplo n.º 1
0
 @Test
 public void testBunchEdit() throws SQLException {
   Recipe r = RecipeUnitTest.createGenericRecipe("My Recipe", "Kyle Woo", 0, 0, 5, false);
   Recipe r2 = RecipeUnitTest.createGenericRecipe("My Recipe 2", "Kyle Woo", 0, 0, 5, false);
   ArrayList<Recipe> recipes = new ArrayList<>();
   recipes.add(r);
   mAccessor.storeRecipe(r);
   mAccessor.checkInvariants();
   mAccessor.storeRecipe(r2);
   mAccessor.checkInvariants();
   Bunch b = new Bunch("My Bunch", recipes);
   mAccessor.storeBunch(b);
   mAccessor.checkInvariants();
   Bunch result = mAccessor.loadBunch("My Bunch");
   mAccessor.checkInvariants();
   assertEquals(b, result);
   recipes.clear();
   recipes.add(r2);
   b.setRecipes(recipes);
   mAccessor.editBunch(b);
   mAccessor.checkInvariants();
   result = mAccessor.loadBunch("My Bunch");
   mAccessor.checkInvariants();
   assertEquals(b, result);
 }
Ejemplo n.º 2
0
  /**
   * Tests creating a bunch containing a recipe, deleting the recipe, and querying for the bunch
   * again
   *
   * @throws SQLException
   */
  @Test
  public void testDeleteRecipeInBunch() throws SQLException {
    final String mealName = "The 42905204th meal";
    final Recipe recipe = new Recipe("A Recipe", "Alan Smithee", Collections.<Step>emptyList());

    mAccessor.storeRecipe(recipe);

    final Bunch meal = new Bunch(mealName, Collections.singletonList(recipe));

    mAccessor.storeBunch(meal);
    mAccessor.checkInvariants();

    mAccessor.deleteRecipe(recipe);
    mAccessor.checkInvariants();

    // Remove recipe from bunch, retrieve and check equality
    meal.setRecipes(Collections.<Recipe>emptyList());

    final Bunch retrievedMeal = mAccessor.loadBunch(mealName);
    assertEquals(meal, retrievedMeal);
  }