public OnmsGroupList getOnmsGroupList()
      throws MarshalException, ValidationException, IOException {
    final OnmsGroupList list = new OnmsGroupList();

    for (final String name : getGroupNames()) {
      list.add(getOnmsGroup(name));
    }
    list.setTotalCount(list.getCount());

    return list;
  }
  @Test
  public void testGroup() throws Exception {
    // Testing GET Collection
    String xml = sendRequest(GET, "/groups", 200);
    assertTrue(xml.contains("Admin"));
    LOG.debug("testGroup: XML = " + xml);
    OnmsGroupList list = JaxbUtils.unmarshal(OnmsGroupList.class, xml);
    assertEquals(1, list.getGroups().size());
    assertEquals(xml, "Admin", list.getGroups().get(0).getName());

    xml = sendRequest(GET, "/groups/Admin", 200);
    assertTrue(xml.contains(">Admin<"));
    sendRequest(GET, "/groups/idontexist", 404);
  }
  @Test
  public void testAddGroup() throws Exception {
    OnmsGroupList groups =
        JaxbUtils.unmarshal(OnmsGroupList.class, sendRequest(GET, "/groups", 200));
    assertNotNull(groups);
    assertTrue(groups.size() > 0);
    int initialGroupSize = groups.size();

    createGroup("My little Test group"); // add group
    String xml = sendRequest(GET, "/groups", 200);
    groups = JaxbUtils.unmarshal(OnmsGroupList.class, xml);
    assertEquals(initialGroupSize + 1, groups.size());
    assertTrue(xml.contains(">My little Test group<"));
  }
示例#4
0
 public OnmsGroupList map(Collection<OnmsGroup> groups) {
   final OnmsGroupList list = new OnmsGroupList();
   list.addAll(groups);
   list.setTotalCount(list.getCount());
   return list;
 }