DefaultKeyStorage implements KeyStorage { @Override public KeyEntry load(String keyName) { synchronized (this) { Entries entries = load(); if (!entries.containsKey(keyName)) { throw new KeyEntryNotFoundException(); } JsonKeyEntry entry = entries.get(keyName); entry.setName(keyName); return entry; } } 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 load() { storage.store(entry); KeyEntry loadedEntry = storage.load(alias); assertTrue(loadedEntry instanceof JsonKeyEntry); assertEquals(entry.getName(), loadedEntry.getName()); assertArrayEquals(entry.getValue(), loadedEntry.getValue()); assertEquals(entry.getMeta(), loadedEntry.getMeta()); }
@Test public void load_nonExisting() { assertThrows(KeyEntryNotFoundException.class, () -> { storage.load(alias); }); }
@Test public void load_nullName() { assertThrows(KeyEntryNotFoundException.class, () -> { storage.load(alias); }); }