예제 #1
0
  @Test
  public void shouldNotUpdatePairingIfOneExists() {
    FlavorPair flavorPair = new FlavorPair();
    flavorPair.setIngredient1("Chicken");
    flavorPair.setIngredient2("Carrot");
    flavorPair.setCategory1("Meat");
    flavorPair.setCategory2("Vegetable");
    flavorPair.setAffinity(Affinity.EXCELLENT.name());
    flavorController.addPair(flavorPair);

    FlavorPair flavorPair2 = new FlavorPair();
    flavorPair2.setIngredient1("Chicken");
    flavorPair2.setIngredient2("Carrot");
    flavorPair2.setCategory1("Meat");
    flavorPair2.setCategory2("Vegetable");
    flavorPair2.setAffinity(Affinity.GOOD.name());
    flavorController.addPair(flavorPair2);

    Ingredient chicken = ingredientRepository.findByName("Chicken").iterator().next();
    assertEquals(1, chicken.getPairings().size());
    Pairing pairing = chicken.getPairings().iterator().next();
    assertEquals(Affinity.EXCELLENT, pairing.getAffinity());
    assertEquals("Chicken", pairing.getFirst().getName());
    assertEquals("Carrot", pairing.getSecond().getName());

    Ingredient carrot = ingredientRepository.findByName("Carrot").iterator().next();
    assertEquals(1, carrot.getPairings().size());
    assertEquals(Affinity.EXCELLENT, pairing.getAffinity());
    assertEquals("Chicken", pairing.getFirst().getName());
    assertEquals("Carrot", pairing.getSecond().getName());
  }
예제 #2
0
  @Test
  public void checkGettingIngsofCake() {

    cManager.removeAll();
    iManager.removeAll();
    rManager.removeAll();

    Cake cake = new Cake(CAKE_NAME, CAKE_PRICE, CAKE_WEIGHT);
    cManager.addCake(cake);
    cake = cManager.getAll().get(0);

    int i = 0;
    for (String n : ING_NAMES) {
      Ingredient ing = new Ingredient(n, ING_KINDS.get(i));
      iManager.addIngredient(ing);
      i++;
    }
    List<Ingredient> ings = iManager.getAll();

    for (Ingredient ing : ings) rManager.addRelationship(cake, ing);

    List<Ingredient> ingsOfCake = rManager.getIngdredientsOfCake(cake);

    i = 0;
    for (Ingredient ing : ingsOfCake) {
      assertEquals(ING_NAMES.get(i), ing.getName());
      assertEquals(ING_KINDS.get(i), ing.getKind());
      i++;
    }
  }
예제 #3
0
 @Test
 public void shouldFetchAllIngredients() {
   Iterable<Ingredient> ingredients = flavorController.getIngredients();
   assertNotNull(ingredients);
   Map<String, Ingredient> ing = new HashMap<>();
   for (Ingredient ingredient : ingredients) {
     ing.put(ingredient.getName(), ingredient);
   }
   assertEquals(5, ing.size());
   assertEquals(ingredientRepository.findByName("Chicken").iterator().next(), ing.get("Chicken"));
   assertEquals(ingredientRepository.findByName("Carrot").iterator().next(), ing.get("Carrot"));
   assertEquals(ingredientRepository.findByName("Butter").iterator().next(), ing.get("Butter"));
   assertEquals(
       ingredientRepository.findByName("Coriander").iterator().next(), ing.get("Coriander"));
   assertEquals(ingredientRepository.findByName("Yoghurt").iterator().next(), ing.get("Yoghurt"));
 }
예제 #4
0
  @Before
  public void setup() {
    // Create some ingredients and categories
    Category meat = new Category("Meat");
    Category dairy = new Category("Dairy");
    Category veg = new Category("Vegetable");
    categoryRepository.save(Arrays.asList(meat, dairy, veg));

    Ingredient chicken = new Ingredient("Chicken");
    chicken.setCategory(meat);
    Ingredient carrot = new Ingredient("Carrot");
    carrot.setCategory(veg);
    Ingredient butter = new Ingredient("Butter");
    butter.setCategory(dairy);
    Ingredient coriander = new Ingredient("Coriander");
    coriander.setCategory(veg);
    Ingredient yoghurt = new Ingredient("Yoghurt");
    yoghurt.setCategory(dairy);
    ingredientRepository.save(Arrays.asList(chicken, carrot, butter, yoghurt, coriander));
  }