JsonFileKeyStorage implements KeyStorage { @Override public Set<String> names() { File dir = new File(keysPath); Set<String> names = new HashSet<>(); if (dir.exists() && dir.isDirectory()) { for (File file : dir.listFiles()) { names.add(file.getName()); } } return names; } JsonFileKeyStorage();  JsonFileKeyStorage(String keysPath); @Override void delete(String keyName); @Override boolean exists(String keyName); @Override KeyEntry load(String keyName); @Override Set<String> names(); @Override void store(KeyEntry keyEntry); @Override KeyEntry createEntry(String name, byte[] value); @Override void update(KeyEntry keyEntry);  }
@Test public void names() { storage.store(entry); Set<String> names = storage.names(); assertNotNull(names); assertEquals(1, names.size()); assertEquals(entry.getName(), names.iterator().next()); }
@Test public void names_empty() { Set<String> names = storage.names(); assertNotNull(names); assertTrue(names.isEmpty()); }