### Question:
HostgroupClient { @SuppressWarnings("unchecked") public List<Hostgroup> get(HostgroupGetParam param) { JSONObject params = JSONObject.fromObject(param, defaultConfig); JSONArray result = (JSONArray) accessor.execute("hostgroup.get", params); JsonConfig config = defaultConfig.copy(); config.setCollectionType(List.class); config.setRootClass(Hostgroup.class); return (List<Hostgroup>) JSONArray.toCollection(result, config); } HostgroupClient(ZabbixAccessor accessor, JsonConfig defaultConfig); @SuppressWarnings("unchecked") List<Hostgroup> get(HostgroupGetParam param); @SuppressWarnings("unchecked") List<String> create(HostgroupCreateParam param); @SuppressWarnings("unchecked") List<String> update(HostgroupUpdateParam param); @SuppressWarnings("unchecked") List<String> delete(List<String> groupids);  }### Answer:
@Test public void testGetAll() { HostgroupGetParam param = new HostgroupGetParam(); param.setOutput("extend"); List<Hostgroup> hostgroups = client.hostgroup().get(param); for (Hostgroup hostgroup : hostgroups) { log.trace(ReflectionToStringBuilder.toString(hostgroup, ToStringStyle.SHORT_PREFIX_STYLE)); } assertTrue(hostgroups.size() > 0); }
@Test public void testGet() { HostgroupGetParam param = new HostgroupGetParam(); param.setGroupids(Arrays.asList("2")); param.setOutput("extend"); List<Hostgroup> hostgroups = client.hostgroup().get(param); assertEquals(1, hostgroups.size()); assertEquals("2", hostgroups.get(0).getGroupid()); }
@Test public void testGetNotExist() { HostGetParam param = new HostGetParam(); param.setHostids(Arrays.asList("999999")); param.setOutput("extend"); List<Host> hosts = client.host().get(param); assertEquals(0, hosts.size()); }
@Test public void testGetByFilter() { HostgroupGetParam param = new HostgroupGetParam(); param.setOutput("extend"); Map<String, List<Object>> filter = new HashMap<String, List<Object>>(); filter.put("name", Arrays.asList((Object) "Linux servers")); param.setFilter(filter); List<Hostgroup> hostgroups = client.hostgroup().get(param); assertEquals(1, hostgroups.size()); assertEquals("2", hostgroups.get(0).getGroupid()); assertEquals("Linux servers", hostgroups.get(0).getName()); }
@Test public void testGetByFilter2() { HostgroupGetParam param = new HostgroupGetParam(); param.setOutput("extend"); Map<String, List<Object>> filter = new HashMap<String, List<Object>>(); filter.put("name", Arrays.asList((Object) "dummy")); param.setFilter(filter); List<Hostgroup> hostgroups = client.hostgroup().get(param); assertEquals(0, hostgroups.size()); }