DataStore implements DataCacheProvider, RolesProvider { public boolean processDomainDeletes() { ArrayList<String> localDomainList = new ArrayList<>(getCacheStore().asMap().keySet()); if (localDomainList.isEmpty()) { return true; } Set<String> zmsDomainList = changeLogStore.getServerDomainList(); if (zmsDomainList == null) { return false; } if (!validDomainListResponse(zmsDomainList)) { return false; } for (String domainName : localDomainList) { if (!zmsDomainList.contains(domainName)) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Removing local domain: " + domainName + ". Domain not in ZMS anymore."); } deleteDomain(domainName); } } return true; } 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 testProcessDomainDeletesNoLocalDomains() { ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0"); DataStore store = new DataStore(clogStore, null); assertTrue(store.processDomainDeletes()); }
@Test public void testProcessDomainDeletesZMSFailure() { ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0"); DataStore store = new DataStore(clogStore, null); ((MockZMSFileChangeLogStore) store.changeLogStore).setDomainList(null); addDomainToDataStore(store, "coretech"); assertFalse(store.processDomainDeletes()); }
@Test public void testProcessDomainDeletesZMSInvalidResponse() { ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0"); DataStore store = new DataStore(clogStore, null); List<String> list = new ArrayList<>(); list.add("sports"); list.add("coretech"); ((MockZMSFileChangeLogStore) store.changeLogStore).setDomainList(list); addDomainToDataStore(store, "coretech"); assertFalse(store.processDomainDeletes()); }