Ejemplo n.º 1
0
  @Test
  public void checkDeletingRelationship() {

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

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

    Ingredient ing = new Ingredient(ING_NAMES.get(1), ING_KINDS.get(1));
    iManager.addIngredient(ing);
    ing = iManager.getAll().get(0);

    rManager.addRelationship(cake, ing);

    int count = rManager.getAll().size();

    rManager.removeRelationship(cake, ing);

    assertEquals(count - 1, rManager.getAll().size());
  }
Ejemplo n.º 2
0
  @Test
  public void checkAddingRelationship() {

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

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

    Ingredient ing = new Ingredient(ING_NAMES.get(0), ING_KINDS.get(0));
    iManager.addIngredient(ing);
    ing = iManager.getAll().get(0);

    rManager.addRelationship(cake, ing);

    List<Relationship> relations = rManager.getAll();
    Relationship r = relations.get(0);

    assertEquals(CAKE_NAME, cManager.getOne(r.getCakeId()).getName());
    assertEquals(ING_NAMES.get(0), iManager.getOne(r.getIngredientId()).getName());
  }