DefaultKeyStorage implements KeyStorage { @Override public boolean exists(String keyName) { if (keyName == null) { return false; } synchronized (this) { Entries entries = load(); return entries.containsKey(keyName); } } DefaultKeyStorage();  DefaultKeyStorage(String directoryName, String fileName); @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 exists() throws IOException { if (!tmpDir.exists()) { tmpDir.mkdirs(); } storage.store(entry); assertTrue(storage.exists(entry.getName())); }
@Test public void exists_nullAlias() { assertFalse(storage.exists(null)); }
@Test public void exists_randomName() { assertFalse(storage.exists(UUID.randomUUID().toString())); }