DataStore implements DataCacheProvider, RolesProvider { int processLocalDomains(List<String> localDomainList) { if (localDomainList.isEmpty()) { return -1; } Set<String> zmsDomainList = changeLogStore.getServerDomainList(); int badDomains = 0; for (String domainName : localDomainList) { if (zmsDomainList != null && !zmsDomainList.contains(domainName)) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Removing local domain: {}. Domain not in ZMS anymore.", domainName); } deleteDomain(domainName); continue; } if (!processLocalDomain(domainName)) { if (changeLogStore.supportsFullRefresh()) { return -1; } else { badDomains += 1; } } } if (badDomains > localDomainList.size() / 4) { LOGGER.error("Too many invalid domains: {} out of {}", badDomains, localDomainList.size()); return -1; } return badDomains; } 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 testProcessLocalDomains() { ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0"); DataStore setupStore = new DataStore(clogStore, null); setupStore.loadAthenzPublicKeys(); SignedDomain signedDomain = createSignedDomain("coretech", "weather"); setupStore.processDomain(signedDomain, true); signedDomain = createSignedDomain("sports", "weather"); setupStore.processDomain(signedDomain, true); DataStore store = new DataStore(clogStore, null); List<String> list = new ArrayList<>(); list.add("coretech"); list.add("sports"); ((MockZMSFileChangeLogStore) store.changeLogStore).setDomainList(list); int badDomains = store.processLocalDomains(list); assertEquals(badDomains, 0); assertNotNull(store.getDomainData("coretech")); assertNotNull(store.getDomainData("sports")); }