HostFromPropertiesFileAdapter extends AbstractHostAdapter { @Override public boolean initializeAdapter(Map<String, Object> config) { if(_known_hosts.size() > 0) return true; else return false; } HostFromPropertiesFileAdapter(Map<String, JSONObject> known_hosts); @Override boolean initializeAdapter(Map<String, Object> config); @Override void updateAdapter(Map<String, Object> config); @Override String getOutputPrefix(CacheKey value); @Override void logAccess(CacheKey value); @SuppressWarnings("unchecked") @Override JSONObject enrich(CacheKey metadata);  }
@Test public void testInitializeAdapter() { Map<String, JSONObject> mapKnownHosts = new HashMap<>(); HostFromPropertiesFileAdapter hfa = new HostFromPropertiesFileAdapter(mapKnownHosts); assertFalse(hfa.initializeAdapter(null)); JSONArray jsonArray = (JSONArray) JSONValue.parse(expectedKnownHostsString); Iterator jsonArrayIterator = jsonArray.iterator(); while(jsonArrayIterator.hasNext()) { JSONObject jsonObject = (JSONObject) jsonArrayIterator.next(); String host = (String) jsonObject.remove("ip"); mapKnownHosts.put(host, jsonObject); } hfa = new HostFromPropertiesFileAdapter(mapKnownHosts); assertTrue(hfa.initializeAdapter(null)); }