### Question:
TemplateClient { @SuppressWarnings("unchecked") public List<Template> get(TemplateGetParam param) { JSONObject params = JSONObject.fromObject(param, defaultConfig); Object result = accessor.execute("template.get", params); if (result instanceof JSONArray) { JsonConfig config = defaultConfig.copy(); config.setCollectionType(List.class); config.setRootClass(Template.class); return (List<Template>) JSONArray.toCollection((JSONArray) result, config); } else { List<Template> templates = new ArrayList<Template>(); Collection<?> values = ((JSONObject) result).values(); JsonConfig config = defaultConfig.copy(); config.setRootClass(Template.class); for (Object value : values) { JSONObject jsonValue = (JSONObject) value; templates.add((Template) JSONObject.toBean(jsonValue, config)); } return templates; } } TemplateClient(ZabbixAccessor accessor, JsonConfig defaultConfig); @SuppressWarnings("unchecked") List<Template> get(TemplateGetParam param);  }### Answer:
@Test public void testGetAll() { TemplateGetParam param = new TemplateGetParam(); param.setOutput("extend"); List<Template> templates = client.template().get(param); for (Template template : templates) { log.trace(ReflectionToStringBuilder.toString(template, ToStringStyle.SHORT_PREFIX_STYLE)); } assertTrue(templates.size() > 0); }
@Test public void testGet() { TemplateGetParam param = new TemplateGetParam(); param.setTemplateids(Arrays.asList("10001")); param.setOutput("extend"); List<Template> templates = client.template().get(param); assertEquals(1, templates.size()); assertEquals("10001", templates.get(0).getTemplateid()); }
@Test public void testGetNotExist() { TemplateGetParam param = new TemplateGetParam(); param.setTemplateids(Arrays.asList("999999")); param.setOutput("extend"); List<Template> templates = client.template().get(param); assertEquals(0, templates.size()); }
@Test public void testGetByFilter() { String templateName; if (client.checkVersion("2.0") < 0) { templateName = "Template_Linux"; } else { templateName = "Template OS Linux"; } TemplateGetParam param = new TemplateGetParam(); param.setOutput("extend"); Map<String, List<Object>> filter = new HashMap<String, List<Object>>(); filter.put("host", Arrays.asList((Object) templateName)); param.setFilter(filter); List<Template> templates = client.template().get(param); assertEquals(1, templates.size()); assertEquals(templateName, templates.get(0).getHost()); }
@Test public void testGetByFilter2() { TemplateGetParam param = new TemplateGetParam(); param.setOutput("extend"); Map<String, List<Object>> filter = new HashMap<String, List<Object>>(); filter.put("host", Arrays.asList((Object) "dummy")); param.setFilter(filter); List<Template> templates = client.template().get(param); assertEquals(0, templates.size()); }