Exemple #1
0
  @Test
  @SuppressWarnings("unchecked")
  public void shouldIncludeParents() {

    deleteFromTable("computers");
    deleteFromTable("motherboards");
    deleteFromTable("keyboards");

    populateTable("motherboards");
    populateTable("keyboards");
    populateTable("computers");

    String json = Computer.findAll().include(Motherboard.class, Keyboard.class).toJson(true);
    List list = org.javalite.common.JsonHelper.toList(json);
    Map m = (Map) list.get(0);
    Map parents = (Map) m.get("parents");
    List motherboards = (List) parents.get("motherboards");
    List keyboards = (List) parents.get("keyboards");
    the(motherboards.size()).shouldBeEqual(1);
    the(keyboards.size()).shouldBeEqual(1);
  }