ZMSFileChangeLogStore implements ChangeLogStore { @Override public List<String> getLocalDomainList() { return changeLogStoreCommon.getLocalDomainList(); } 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 testGetLocalDomainListEmpty() { ZMSFileChangeLogStore fstore = new ZMSFileChangeLogStore(FSTORE_PATH, null, null); List<String> ls = fstore.getLocalDomainList(); assertEquals(ls.size(), 0); }
@Test public void testGetLocalDomainListError() { ZMSFileChangeLogStore fstore = new ZMSFileChangeLogStore(FSTORE_PATH, null, null); ZMSFileChangeLogStoreCommon cstore = new ZMSFileChangeLogStoreCommon(FSTORE_PATH); File dir = Mockito.spy(cstore.rootDir); Mockito.when(dir.list()).thenReturn(null); cstore.rootDir = dir; List<String> ls = fstore.getLocalDomainList(); assertEquals(ls.size(), 0); }
@Test public void testGetLocalDomainListSingle() throws IOException { File rootDir = new File(FSTORE_PATH); rootDir.mkdirs(); Struct lastModStruct = new Struct(); lastModStruct.put("lastModTime", 1001); File file = new File(FSTORE_PATH, ".lastModTime"); Path path = Paths.get(file.toURI()); Files.write(path, JSON.bytes(lastModStruct)); ZMSFileChangeLogStore fstore = new ZMSFileChangeLogStore(FSTORE_PATH, null, null); ZMSFileChangeLogStoreCommon cstore = new ZMSFileChangeLogStoreCommon(FSTORE_PATH); Struct data = new Struct(); data.put("key", "val1"); cstore.put("test1", JSON.bytes(data)); List<String> ls = fstore.getLocalDomainList(); assertEquals(ls.size(), 1); assertTrue(ls.contains("test1")); }
@Test public void testGetLocalDomainListMultiple() { ZMSFileChangeLogStore fstore = new ZMSFileChangeLogStore(FSTORE_PATH, null, null); ZMSFileChangeLogStoreCommon cstore = new ZMSFileChangeLogStoreCommon(FSTORE_PATH); Struct data = new Struct(); data.put("key", "val1"); cstore.put("test1", JSON.bytes(data)); data = new Struct(); data.put("key", "val1"); cstore.put("test2", JSON.bytes(data)); data = new Struct(); data.put("key", "val1"); cstore.put("test3", JSON.bytes(data)); List<String> ls = fstore.getLocalDomainList(); assertEquals(ls.size(), 3); assertTrue(ls.contains("test1")); assertTrue(ls.contains("test2")); assertTrue(ls.contains("test3")); }
@Test public void testGetLocalDomainListHidden() { ZMSFileChangeLogStore fstore = new ZMSFileChangeLogStore(FSTORE_PATH, null, null); ZMSFileChangeLogStoreCommon cstore = new ZMSFileChangeLogStoreCommon(FSTORE_PATH); Struct data = new Struct(); data.put("key", "val1"); cstore.put("test1", JSON.bytes(data)); data = new Struct(); data.put("key", "val1"); cstore.put(".test2", JSON.bytes(data)); data = new Struct(); data.put("key", "val1"); cstore.put(".test3", JSON.bytes(data)); List<String> ls = fstore.getLocalDomainList(); assertEquals(ls.size(), 1); assertTrue(ls.contains("test1")); }
@Test public void testGetLocalDomainListDelete() { ZMSFileChangeLogStore fstore = new ZMSFileChangeLogStore(FSTORE_PATH, null, null); ZMSFileChangeLogStoreCommon cstore = new ZMSFileChangeLogStoreCommon(FSTORE_PATH); Struct data = new Struct(); data.put("key", "val1"); cstore.put("test1", JSON.bytes(data)); data = new Struct(); data.put("key", "val1"); cstore.put("test2", JSON.bytes(data)); data = new Struct(); data.put("key", "val1"); cstore.put("test3", JSON.bytes(data)); cstore.delete("test2"); List<String> ls = fstore.getLocalDomainList(); assertEquals(ls.size(), 2); assertTrue(ls.contains("test1")); assertTrue(ls.contains("test3")); }