JsonFileKeyStorage implements KeyStorage { @Override public boolean exists(String keyName) { if (keyName == null) { return false; } File file = new File(keysPath, keyName.toLowerCase()); return file.exists(); } 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 exists() throws IOException { if (!tmpDir.exists()) { tmpDir.mkdirs(); } File tmpFile = File.createTempFile(alias, "", tmpDir); String name = tmpFile.getName(); assertTrue(storage.exists(name)); }
@Test public void exists_nullAlias() { assertFalse(storage.exists(null)); }
@Test public void exists_randomName() { assertFalse(storage.exists(UUID.randomUUID().toString())); }