PrivateKeyStorage { public void delete(String keyName) { this.keyStorage.delete(keyName); } PrivateKeyStorage(VirgilPrivateKeyExporter keyExporter, KeyStorage keyStorage); void delete(String keyName); boolean exists(String keyName); Tuple<VirgilPrivateKey, Map<String, String>> load(String keyName); Set<String> names(); void store(VirgilPrivateKey privateKey, String name, Map<String, String> meta);  }
@Test public void delete() { storage.delete(this.keyName); ArgumentCaptor<String> keyNameCaptor = ArgumentCaptor.forClass(String.class); verify(this.keyStorage, times(1)).delete(keyNameCaptor.capture()); assertEquals(this.keyName, keyNameCaptor.getValue()); }
@Test public void delete_nonExisting() { doThrow(KeyEntryNotFoundException.class).when(this.keyStorage).delete(this.keyName); assertThrows(KeyEntryNotFoundException.class, () -> { storage.delete(this.keyName); }); }
@Test public void delete_nullName() { doThrow(KeyEntryNotFoundException.class).when(this.keyStorage).delete(null); assertThrows(KeyEntryNotFoundException.class, () -> { storage.delete(null); }); }