use of org.opennms.netmgt.model.OnmsGroupList in project opennms by OpenNMS.
the class GroupRestServiceIT method testGroup.
@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);
}
use of org.opennms.netmgt.model.OnmsGroupList in project opennms by OpenNMS.
the class GroupRestServiceIT method testAddGroup.
@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();
// add group
createGroup("My little Test 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<"));
}
use of org.opennms.netmgt.model.OnmsGroupList in project opennms by OpenNMS.
the class GroupRestService method getGroups.
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML })
public OnmsGroupList getGroups() {
readLock();
try {
final OnmsGroupList list = m_groupService.getOnmsGroupList();
final List<OnmsGroup> groups = new ArrayList<OnmsGroup>(list.getGroups());
Collections.sort(groups, new Comparator<OnmsGroup>() {
@Override
public int compare(final OnmsGroup a, final OnmsGroup b) {
return a.getName().compareTo(b.getName());
}
});
list.setGroups(groups);
return list;
} finally {
readUnlock();
}
}