DataStore implements DataCacheProvider, RolesProvider { public HostServices getHostServices(String host) { HostServices result = new HostServices().setHost(host); try { hostRLock.lock(); List<String> services = hostCache.get(host); if (services != null) { result.setNames(new ArrayList<>(services)); } } finally { hostRLock.unlock(); } return result; } DataStore(ChangeLogStore clogStore, CloudStore cloudStore); JWKList getZtsJWKList(Boolean rfc); void init(); boolean processDomain(SignedDomain signedDomain, boolean saveInStore); boolean processDomainDeletes(); void processDomainChecks(); boolean processDomainUpdates(); DomainData getDomainData(String name); void addDomainToCache(String name, DataCache dataCache); @Override DataCache getDataCache(String domainName); List<GroupMember> getGroupMembers(final String groupName); void getAccessibleRoles(DataCache data, String domainName, String identity,
            String[] requestedRoleList, Set<String> accessibleRoles, boolean keepFullName); String getPublicKey(String domain, String service, String keyId); HostServices getHostServices(String host); CloudStore getCloudStore(); void setCloudStore(CloudStore cloudStore); Cache<String, DataCache> getCacheStore(); Map<String, String> getPublicKeyCache(); @Override List<Role> getRolesByDomain(String domain);  }
@Test public void testGetHostServices() { ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0"); DataStore store = new DataStore(clogStore, null); List<String> services = new ArrayList<>(); services.add("coretech.storage"); services.add("sports.storage"); store.hostCache.put("host1", services); services = new ArrayList<>(); services.add("coretech.storage"); services.add("sports.storage"); store.hostCache.put("host2", services); HostServices hostServices = store.getHostServices("host1"); List<String> hosts = hostServices.getNames(); assertEquals(hosts.size(), 2); assertTrue(hosts.contains("coretech.storage")); assertTrue(hosts.contains("sports.storage")); hostServices = store.getHostServices("host2"); hosts = hostServices.getNames(); assertEquals(hosts.size(), 2); assertTrue(hosts.contains("coretech.storage")); assertTrue(hosts.contains("sports.storage")); }
@Test public void testGetHostServicesInvalid() { ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0"); DataStore store = new DataStore(clogStore, null); List<String> services = new ArrayList<>(); services.add("coretech.storage"); services.add("sports.storage"); store.hostCache.put("host1", services); services = new ArrayList<>(); services.add("coretech.storage"); services.add("sports.storage"); store.hostCache.put("host2", services); HostServices hostServices = store.getHostServices("host3"); List<String> hosts = hostServices.getNames(); assertNull(hosts); }