@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++; } }
@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")); }