@Test public void testAddContact() throws Exception { SecretKey master = getSecretKey(); long timestamp = System.currentTimeMillis(); boolean alice = new Random().nextBoolean(); Transaction txn = new Transaction(null, false); context.checking(new Expectations() {{ oneOf(db).startTransaction(false); will(returnValue(txn)); oneOf(db).addContact(txn, remote, local, verified, active); will(returnValue(contactId)); oneOf(keyManager).addContact(txn, contactId, master, timestamp, alice, active); oneOf(db).getContact(txn, contactId); will(returnValue(contact)); oneOf(db).commitTransaction(txn); oneOf(db).endTransaction(txn); }}); assertEquals(contactId, contactManager.addContact(remote, local, master, timestamp, alice, verified, active)); }
@Override public ContactId addContact(Transaction txn, Author remote, AuthorId local, SecretKey master, long timestamp, boolean alice, boolean verified, boolean active) throws DbException { ContactId c = db.addContact(txn, remote, local, verified, active); keyManager.addContact(txn, c, master, timestamp, alice, active); Contact contact = db.getContact(txn, c); for (ContactHook hook : hooks) hook.addingContact(txn, contact); return c; }
ContactManagerImpl implements ContactManager { @Override public ContactId addContact(Transaction txn, Author remote, AuthorId local, SecretKey master, long timestamp, boolean alice, boolean verified, boolean active) throws DbException { ContactId c = db.addContact(txn, remote, local, verified, active); keyManager.addContact(txn, c, master, timestamp, alice, active); Contact contact = db.getContact(txn, c); for (ContactHook hook : hooks) hook.addingContact(txn, contact); return c; } }
ContactManagerImpl implements ContactManager { @Override public ContactId addContact(Transaction txn, Author remote, AuthorId local, SecretKey master, long timestamp, boolean alice, boolean verified, boolean active) throws DbException { ContactId c = db.addContact(txn, remote, local, verified, active); keyManager.addContact(txn, c, master, timestamp, alice, active); Contact contact = db.getContact(txn, c); for (ContactHook hook : hooks) hook.addingContact(txn, contact); return c; } @Inject  ContactManagerImpl(DatabaseComponent db, KeyManager keyManager); }
ContactManagerImpl implements ContactManager { @Override public ContactId addContact(Transaction txn, Author remote, AuthorId local, SecretKey master, long timestamp, boolean alice, boolean verified, boolean active) throws DbException { ContactId c = db.addContact(txn, remote, local, verified, active); keyManager.addContact(txn, c, master, timestamp, alice, active); Contact contact = db.getContact(txn, c); for (ContactHook hook : hooks) hook.addingContact(txn, contact); return c; } @Inject  ContactManagerImpl(DatabaseComponent db, KeyManager keyManager); @Override void registerContactHook(ContactHook hook); @Override ContactId addContact(Transaction txn, Author remote, AuthorId local,
			SecretKey master, long timestamp, boolean alice, boolean verified,
			boolean active); @Override ContactId addContact(Transaction txn, Author remote, AuthorId local,
			boolean verified, boolean active); @Override ContactId addContact(Author remote, AuthorId local, SecretKey master,
			long timestamp, boolean alice, boolean verified, boolean active); @Override Contact getContact(ContactId c); @Override Contact getContact(AuthorId remoteAuthorId, AuthorId localAuthorId); @Override Contact getContact(Transaction txn, AuthorId remoteAuthorId,
			AuthorId localAuthorId); @Override Collection<Contact> getActiveContacts(); @Override void removeContact(ContactId c); @Override void setContactActive(Transaction txn, ContactId c, boolean active); @Override boolean contactExists(Transaction txn, AuthorId remoteAuthorId,
			AuthorId localAuthorId); @Override boolean contactExists(AuthorId remoteAuthorId,
			AuthorId localAuthorId); @Override void removeContact(Transaction txn, ContactId c); }
ContactManagerImpl implements ContactManager { @Override public ContactId addContact(Transaction txn, Author remote, AuthorId local, SecretKey master, long timestamp, boolean alice, boolean verified, boolean active) throws DbException { ContactId c = db.addContact(txn, remote, local, verified, active); keyManager.addContact(txn, c, master, timestamp, alice, active); Contact contact = db.getContact(txn, c); for (ContactHook hook : hooks) hook.addingContact(txn, contact); return c; } @Inject  ContactManagerImpl(DatabaseComponent db, KeyManager keyManager); @Override void registerContactHook(ContactHook hook); @Override ContactId addContact(Transaction txn, Author remote, AuthorId local,
			SecretKey master, long timestamp, boolean alice, boolean verified,
			boolean active); @Override ContactId addContact(Transaction txn, Author remote, AuthorId local,
			boolean verified, boolean active); @Override ContactId addContact(Author remote, AuthorId local, SecretKey master,
			long timestamp, boolean alice, boolean verified, boolean active); @Override Contact getContact(ContactId c); @Override Contact getContact(AuthorId remoteAuthorId, AuthorId localAuthorId); @Override Contact getContact(Transaction txn, AuthorId remoteAuthorId,
			AuthorId localAuthorId); @Override Collection<Contact> getActiveContacts(); @Override void removeContact(ContactId c); @Override void setContactActive(Transaction txn, ContactId c, boolean active); @Override boolean contactExists(Transaction txn, AuthorId remoteAuthorId,
			AuthorId localAuthorId); @Override boolean contactExists(AuthorId remoteAuthorId,
			AuthorId localAuthorId); @Override void removeContact(Transaction txn, ContactId c);  }