DataStore implements DataCacheProvider, RolesProvider { @Override public List<Role> getRolesByDomain(String domain) { DomainData domainData = getDomainData(domain); if (domainData == null) { return new ArrayList<>(); } return domainData.getRoles(); } 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 testGetRolesByDomain() { ChangeLogStore clogStore = new MockZMSFileChangeLogStore("/tmp/zts_server_unit_tests/zts_root", pkey, "0"); DataStore store = new DataStore(clogStore, null); DataCache dataCache = new DataCache(); Role role = new Role(); role.setName("coretech:role.admin"); List<RoleMember> members = new ArrayList<>(); members.add(new RoleMember().setMemberName("user_domain.user")); role.setRoleMembers(members); List<Role> roles = new ArrayList<>(); roles.add(role); DomainData domainData = new DomainData(); domainData.setRoles(roles); dataCache.setDomainData(domainData); store.addDomainToCache("coretech", dataCache); List<Role> fetchedRoles = store.getRolesByDomain("coretech"); assertEquals(fetchedRoles.size(), 1); assertEquals(fetchedRoles.get(0).getName(), "coretech:role.admin"); fetchedRoles = store.getRolesByDomain("unknownDomain"); assertEquals(fetchedRoles.size(), 0); }