OrientKeyStoreStorage extends ComponentSupport implements KeyStoreStorage { @Subscribe public void onKeyStoreDataUpdated(final KeyStoreDataEvent event) { if (keyStoreName.equals(event.getKeyStoreName())) { latestVersion = event.getVersion(); log.debug("Observed version {} of key store {} updated by node {}", latestVersion, keyStoreName, event.getRemoteNodeId()); } } OrientKeyStoreStorage(final OrientKeyStoreStorageManager storageManager, final String keyStoreName); @VisibleForTesting String getKeyStoreName(); @Override boolean exists(); @Override boolean modified(); @Subscribe void onKeyStoreDataUpdated(final KeyStoreDataEvent event); @Override void load(final KeyStore keyStore, final char[] password); @Override void save(final KeyStore keyStore, final char[] password); @Override String toString();  }
@Test public void testOnKeyStoreDataUpdated() throws Exception { OrientKeyStoreData entity = new OrientKeyStoreData(); entity.setName(KEY_STORE_NAME); entity.setBytes(serialize(newKeyStore())); entity.setEntityMetadata(newEntityMetadata("1")); when(storageManager.load(KEY_STORE_NAME)).thenReturn(entity); KeyStore keyStore = newKeyStore(); storage.load(keyStore, STORE_PASSWORD); assertThat(storage.modified(), is(false)); storage.onKeyStoreDataUpdated(new OrientKeyStoreDataUpdatedEvent(newEntityMetadata("2"), "another" + KEY_STORE_NAME)); assertThat(storage.modified(), is(false)); storage.onKeyStoreDataUpdated(new OrientKeyStoreDataUpdatedEvent(newEntityMetadata("1"), KEY_STORE_NAME)); assertThat(storage.modified(), is(false)); storage.onKeyStoreDataUpdated(new OrientKeyStoreDataUpdatedEvent(newEntityMetadata("2"), KEY_STORE_NAME)); assertThat(storage.modified(), is(true)); }