@Test public void testAddContact() throws Exception { SecretKey secretKey = getSecretKey(); long timestamp = System.currentTimeMillis(); boolean alice = random.nextBoolean(); boolean active = random.nextBoolean(); context.checking(new Expectations() {{ oneOf(transportKeyManager).addContact(txn, contactId, secretKey, timestamp, alice, active); will(returnValue(keySetId)); }}); Map<TransportId, KeySetId> ids = keyManager.addContact(txn, contactId, secretKey, timestamp, alice, active); assertEquals(singletonMap(transportId, keySetId), ids); }
@Override public Map<TransportId, KeySetId> addContact(Transaction txn, ContactId c, SecretKey master, long timestamp, boolean alice, boolean active) throws DbException { Map<TransportId, KeySetId> ids = new HashMap<>(); for (Entry<TransportId, TransportKeyManager> e : managers.entrySet()) { TransportId t = e.getKey(); TransportKeyManager m = e.getValue(); ids.put(t, m.addContact(txn, c, master, timestamp, alice, active)); } return ids; }
KeyManagerImpl implements KeyManager, Service, EventListener { @Override public Map<TransportId, KeySetId> addContact(Transaction txn, ContactId c, SecretKey master, long timestamp, boolean alice, boolean active) throws DbException { Map<TransportId, KeySetId> ids = new HashMap<>(); for (Entry<TransportId, TransportKeyManager> e : managers.entrySet()) { TransportId t = e.getKey(); TransportKeyManager m = e.getValue(); ids.put(t, m.addContact(txn, c, master, timestamp, alice, active)); } return ids; } }
KeyManagerImpl implements KeyManager, Service, EventListener { @Override public Map<TransportId, KeySetId> addContact(Transaction txn, ContactId c, SecretKey master, long timestamp, boolean alice, boolean active) throws DbException { Map<TransportId, KeySetId> ids = new HashMap<>(); for (Entry<TransportId, TransportKeyManager> e : managers.entrySet()) { TransportId t = e.getKey(); TransportKeyManager m = e.getValue(); ids.put(t, m.addContact(txn, c, master, timestamp, alice, active)); } return ids; } @Inject  KeyManagerImpl(DatabaseComponent db, @DatabaseExecutor Executor dbExecutor,
			PluginConfig pluginConfig,
			TransportKeyManagerFactory transportKeyManagerFactory); }
KeyManagerImpl implements KeyManager, Service, EventListener { @Override public Map<TransportId, KeySetId> addContact(Transaction txn, ContactId c, SecretKey master, long timestamp, boolean alice, boolean active) throws DbException { Map<TransportId, KeySetId> ids = new HashMap<>(); for (Entry<TransportId, TransportKeyManager> e : managers.entrySet()) { TransportId t = e.getKey(); TransportKeyManager m = e.getValue(); ids.put(t, m.addContact(txn, c, master, timestamp, alice, active)); } return ids; } @Inject  KeyManagerImpl(DatabaseComponent db, @DatabaseExecutor Executor dbExecutor,
			PluginConfig pluginConfig,
			TransportKeyManagerFactory transportKeyManagerFactory); @Override void startService(); @Override void stopService(); @Override Map<TransportId, KeySetId> addContact(Transaction txn, ContactId c,
			SecretKey master, long timestamp, boolean alice, boolean active); @Override void activateKeys(Transaction txn, Map<TransportId, KeySetId> keys); @Override boolean canSendOutgoingStreams(ContactId c, TransportId t); @Override StreamContext getStreamContext(ContactId c, TransportId t); @Override StreamContext getStreamContext(TransportId t, byte[] tag); @Override void eventOccurred(Event e); }
KeyManagerImpl implements KeyManager, Service, EventListener { @Override public Map<TransportId, KeySetId> addContact(Transaction txn, ContactId c, SecretKey master, long timestamp, boolean alice, boolean active) throws DbException { Map<TransportId, KeySetId> ids = new HashMap<>(); for (Entry<TransportId, TransportKeyManager> e : managers.entrySet()) { TransportId t = e.getKey(); TransportKeyManager m = e.getValue(); ids.put(t, m.addContact(txn, c, master, timestamp, alice, active)); } return ids; } @Inject  KeyManagerImpl(DatabaseComponent db, @DatabaseExecutor Executor dbExecutor,
			PluginConfig pluginConfig,
			TransportKeyManagerFactory transportKeyManagerFactory); @Override void startService(); @Override void stopService(); @Override Map<TransportId, KeySetId> addContact(Transaction txn, ContactId c,
			SecretKey master, long timestamp, boolean alice, boolean active); @Override void activateKeys(Transaction txn, Map<TransportId, KeySetId> keys); @Override boolean canSendOutgoingStreams(ContactId c, TransportId t); @Override StreamContext getStreamContext(ContactId c, TransportId t); @Override StreamContext getStreamContext(TransportId t, byte[] tag); @Override void eventOccurred(Event e);  }