ZMSFileChangeLogStore implements ChangeLogStore { @Override public SignedDomains getServerDomainModifiedList() { SignedDomains signedDomains = null; try (ZMSClient zmsClient = getZMSClient()) { signedDomains = changeLogStoreCommon.getServerDomainModifiedList(zmsClient); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Number of ZMS domains: {}", signedDomains == null ? 0 : signedDomains.getDomains().size()); } } catch (ZMSClientException ex) { LOGGER.error("Unable to retrieve signed domain list from ZMS", ex); } return signedDomains; } ZMSFileChangeLogStore(String rootDirectory, PrivateKey privateKey, String privateKeyId); @Override boolean supportsFullRefresh(); @Override SignedDomain getLocalSignedDomain(String domainName); @Override SignedDomain getServerSignedDomain(String domainName); @Override void removeLocalDomain(String domainName); @Override void saveLocalDomain(String domainName, SignedDomain signedDomain); @Override List<String> getLocalDomainList(); ZMSClient getZMSClient(); @Override Set<String> getServerDomainList(); @Override SignedDomains getServerDomainModifiedList(); @Override void setLastModificationTimestamp(String newLastModTime); @Override SignedDomains getUpdatedSignedDomains(StringBuilder lastModTimeBuffer); void setChangeLogStoreCommon(ZMSFileChangeLogStoreCommon changeLogStoreCommon);  }
@Test public void testGetServerDomainModifiedList() { MockZMSFileChangeLogStore fstore = new MockZMSFileChangeLogStore(FSTORE_PATH, null, null); ZMSClient zmsClient = Mockito.mock(ZMSClient.class); fstore.setZMSClient(zmsClient); List<SignedDomain> domains = new ArrayList<>(); DomainData domData = new DomainData().setName("athenz"); SignedDomain domain = new SignedDomain().setDomain(domData); domains.add(domain); SignedDomains domainList = new SignedDomains().setDomains(domains); Mockito.when(zmsClient.getSignedDomains(null, "true", null, null)).thenReturn(domainList); SignedDomains returnList = fstore.getServerDomainModifiedList(); assertEquals(returnList.getDomains().size(), 1); assertEquals(returnList.getDomains().get(0).getDomain().getName(), "athenz"); }
@Test public void testGetServerDomainModifiedListNull() { MockZMSFileChangeLogStore fstore = new MockZMSFileChangeLogStore(FSTORE_PATH, null, null); ZMSClient zmsClient = Mockito.mock(ZMSClient.class); fstore.setZMSClient(zmsClient); Mockito.when(zmsClient.getSignedDomains(null, "true", null, null)).thenReturn(null); assertNull(fstore.getServerDomainModifiedList()); }
@Test public void testGetServerDomainModifiedListException() { MockZMSFileChangeLogStore fstore = new MockZMSFileChangeLogStore(FSTORE_PATH, null, null); ZMSClient zmsClient = Mockito.mock(ZMSClient.class); fstore.setZMSClient(zmsClient); Mockito.when(zmsClient.getSignedDomains(null, "true", null, null)) .thenThrow(new ZMSClientException(500, "invalid server error:")); SignedDomains returnList = fstore.getServerDomainModifiedList(); assertNull(returnList); }