Ejemplo n.º 1
0
  /**
   * Convenience method to add the given <code>obs</code> to this grouping. Will implicitly make
   * this obs an ObsGroup
   *
   * @param member Obs to add to this group
   * @see #setGroupMembers(Set)
   * @see #getGroupMembers()
   */
  public void addGroupMember(Obs member) {
    if (member == null) return;

    if (getGroupMembers() == null) groupMembers = new HashSet<Obs>();

    // a quick sanity check to make sure someone isn't adding
    // itself to the group
    if (member.equals(this))
      throw new APIException(
          "An obsGroup cannot have itself as a mentor. obsGroup: "
              + this
              + " obsMember attempting to add: "
              + member);

    member.setObsGroup(this);
    groupMembers.add(member);
  }
Ejemplo n.º 2
0
  /** @see Encounter#getObs() */
  @Test
  @Verifies(value = "should only get child obs", method = "getObs()")
  public void getObs_shouldOnlyGetChildObs() throws Exception {
    Encounter encounter = new Encounter();

    // create and add an Obs
    Obs parentObs = new Obs();
    encounter.addObs(parentObs);

    // add a child to the obs and make sure that the Obs is an ObsGroup with one child:
    Obs childObs = new Obs();
    parentObs.addGroupMember(childObs);

    // obsGroup should recurse and ONLY the child obs should be picked up:
    assertEquals(1, encounter.getObs().size());
    // make sure that the obs is the oChild
    Obs obsInEncounter = (Obs) encounter.getObs().toArray()[0];
    assertTrue(childObs.equals(obsInEncounter));
    assertFalse(obsInEncounter.isObsGrouping());
  }