### Question:
HostClient { @SuppressWarnings("unchecked") public List<String> create(HostCreateParam param) { if (param.getHost() == null || param.getHost().length() == 0) { throw new IllegalArgumentException("host is required."); } if (param.getGroups() == null || param.getGroups().size() == 0) { throw new IllegalArgumentException("groups is required."); } if (accessor.checkVersion("2.0") >= 0) { if (param.getInterfaces() == null || param.getInterfaces().size() == 0) { Hostinterface hostinterface = new Hostinterface(); hostinterface.setDns(param.getDns()); hostinterface.setIp((param.getIp() == null || param.getIp().length() == 0) ? "0.0.0.0" : param.getIp()); hostinterface.setPort((param.getPort() == null) ? 10050 : param.getPort()); hostinterface.setUseip((param.getUseip() == null) ? 0 : param.getUseip()); hostinterface.setType(1); hostinterface.setMain(1); param.setInterfaces(Arrays.asList(hostinterface)); param.setDns(null); param.setIp(null); param.setPort(null); param.setUseip(null); } } else { if (param.getInterfaces() != null && param.getInterfaces().size() > 0) { Hostinterface hostinterface = param.getInterfaces().get(0); param.setDns(hostinterface.getDns()); param.setIp(hostinterface.getIp()); param.setPort(hostinterface.getPort()); param.setUseip(hostinterface.getUseip()); param.setInterfaces(null); } } JSONObject params = JSONObject.fromObject(param, defaultConfig); JSONObject result = (JSONObject) accessor.execute("host.create", params); JSONArray hostids = result.getJSONArray("hostids"); JsonConfig config = defaultConfig.copy(); config.setCollectionType(List.class); config.setRootClass(String.class); return (List<String>) JSONArray.toCollection(hostids, config); } HostClient(ZabbixAccessor accessor, JsonConfig defaultConfig); @SuppressWarnings("unchecked") List<Host> get(HostGetParam param); @SuppressWarnings("unchecked") List<String> create(HostCreateParam param); @SuppressWarnings("unchecked") List<String> update(HostUpdateParam param); @SuppressWarnings("unchecked") List<String> delete(List<String> hostids);  }### Answer:
@Test public void testCreateIllegalArgument() { HostCreateParam param = new HostCreateParam(); param.setDns("dns1"); Hostgroup hostgroup = new Hostgroup(); hostgroup.setGroupid("2"); param.setGroups(Arrays.asList(hostgroup)); try { client.host().create(param); fail(); } catch (IllegalArgumentException ignore) { log.trace(ignore.getMessage()); } }
@Test public void testCreateIllegalArgument2() { HostCreateParam param = new HostCreateParam(); param.setHost("host1"); param.setDns("dns1"); try { client.host().create(param); fail(); } catch (IllegalArgumentException ignore) { log.trace(ignore.getMessage()); } }