Beispiel #1
0
  public void testChangeAllergies() {
    Ingredient testIng = new Ingredient();

    allergy = new Allergy("peanuts");
    testIng.addAllergy(allergy);
    assertEquals("peanuts", testIng.getAllergies().get(0).getName());
    testIng.deleteAllergy(allergy);
    assertEquals(0, testIng.getAllergies().size());
  }
Beispiel #2
0
  public void open(String dbName) {
    Recipe thisRecipe;
    ArrayList<Constituent> constituents;
    ArrayList<Constituent> tempCons;
    Constituent thisConstituent = null;
    Ingredient thisIngredient = null;
    LifeStyle thisLifeStyle = null;
    Allergy thisAllergy = null;

    constituents = new ArrayList<Constituent>();
    ingredients = new ArrayList<Ingredient>();
    allergies = new ArrayList<Allergy>();
    lifeStyles = new ArrayList<LifeStyle>();

    thisAllergy = new Allergy("Peanuts");
    allergies.add(thisAllergy);
    thisAllergy = new Allergy("Milk");
    allergies.add(thisAllergy);
    thisAllergy = new Allergy("Gluten");
    allergies.add(thisAllergy);
    thisAllergy = new Allergy("Lactose");
    allergies.add(thisAllergy);

    thisLifeStyle = new LifeStyle("Vegan");
    lifeStyles.add(thisLifeStyle);
    thisLifeStyle = new LifeStyle("Vegatarian");
    lifeStyles.add(thisLifeStyle);
    thisLifeStyle = new LifeStyle("Gluten Free");
    lifeStyles.add(thisLifeStyle);
    thisLifeStyle = new LifeStyle("Super Ham Sandwhich's only");
    lifeStyles.add(thisLifeStyle);

    thisIngredient = new Ingredient("Another thing");
    ingredients.add(thisIngredient);
    thisConstituent = new Constituent(thisIngredient, 5.0, "kg");
    constituents.add(thisConstituent);

    thisIngredient = new Ingredient("Ham");
    ingredients.add(thisIngredient);
    thisIngredient.addAllergy(allergies.get(0));
    thisIngredient.addLifeStyle(lifeStyles.get(0));
    thisConstituent = new Constituent(thisIngredient, 1.0, "tsp");
    constituents.add(thisConstituent);

    thisIngredient = new Ingredient("Mayo");
    thisIngredient.addAllergy(allergies.get(0));
    thisIngredient.addAllergy(allergies.get(1));
    thisIngredient.addAllergy(allergies.get(2));
    ingredients.add(thisIngredient);
    thisConstituent = new Constituent(thisIngredient, 2.5, "kg");
    constituents.add(thisConstituent);

    thisIngredient = new Ingredient("Someother thing");
    thisIngredient.addLifeStyle(lifeStyles.get(0));
    thisIngredient.addLifeStyle(lifeStyles.get(1));
    thisIngredient.addLifeStyle(lifeStyles.get(2));
    ingredients.add(thisIngredient);
    thisConstituent = new Constituent(thisIngredient, 1.0, "tbsp");
    constituents.add(thisConstituent);

    recipes = new ArrayList<Recipe>();
    tempCons = new ArrayList<Constituent>();
    tempCons.add(constituents.get(0));
    tempCons.add(constituents.get(1));
    thisRecipe = new Recipe(0, "Another recipe!", "Do stuff", "Tastes yummy", tempCons);
    recipes.add(thisRecipe);
    tempCons.clear();
    thisRecipe = new Recipe(1, "More recipes!", "Do stuff", "Tastes yummy", null);
    recipes.add(thisRecipe);
    thisRecipe = new Recipe(2, "Super Ham Sandwhich", null, null, constituents);
    recipes.add(thisRecipe);
    tempCons.clear();
    tempCons.add(constituents.get(3));
    thisRecipe = new Recipe(3, "Super Ham Sandwhich #2", "Do stuff", "Tastes good", tempCons);
    recipes.add(thisRecipe);

    System.out.println("Opened " + dbType + " database " + dbName);
  }