Contact manager hooks. #209

This commit is contained in:
akwizgran
2016-01-19 19:16:35 +00:00
parent 33ef09a6bf
commit 82cf12040f
29 changed files with 333 additions and 195 deletions

View File

@@ -16,8 +16,6 @@ import org.briarproject.api.db.NoSuchLocalAuthorException;
import org.briarproject.api.db.NoSuchMessageException;
import org.briarproject.api.db.NoSuchSubscriptionException;
import org.briarproject.api.db.NoSuchTransportException;
import org.briarproject.api.event.ContactAddedEvent;
import org.briarproject.api.event.ContactRemovedEvent;
import org.briarproject.api.event.EventBus;
import org.briarproject.api.event.LocalAuthorAddedEvent;
import org.briarproject.api.event.LocalAuthorRemovedEvent;
@@ -59,6 +57,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import static org.briarproject.api.contact.Contact.Status.ACTIVE;
import static org.briarproject.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
import static org.briarproject.api.sync.SyncConstants.MAX_GROUP_DESCRIPTOR_LENGTH;
import static org.briarproject.db.DatabaseConstants.MAX_OFFERED_MESSAGES;
@@ -113,7 +112,7 @@ public class DatabaseComponentImplTest extends BriarTestCase {
"bar", "baz"));
maxLatency = Integer.MAX_VALUE;
contactId = new ContactId(234);
contact = new Contact(contactId, author, localAuthorId);
contact = new Contact(contactId, author, localAuthorId, ACTIVE);
}
private <T> DatabaseComponent createDatabaseComponent(Database<T> database,
@@ -150,7 +149,6 @@ public class DatabaseComponentImplTest extends BriarTestCase {
will(returnValue(true));
oneOf(database).addContact(txn, author, localAuthorId);
will(returnValue(contactId));
oneOf(eventBus).broadcast(with(any(ContactAddedEvent.class)));
// getContacts()
oneOf(database).getContacts(txn);
will(returnValue(Collections.singletonList(contact)));
@@ -183,7 +181,6 @@ public class DatabaseComponentImplTest extends BriarTestCase {
oneOf(database).containsContact(txn, contactId);
will(returnValue(true));
oneOf(database).removeContact(txn, contactId);
oneOf(eventBus).broadcast(with(any(ContactRemovedEvent.class)));
// removeLocalAuthor()
oneOf(database).containsLocalAuthor(txn, localAuthorId);
will(returnValue(true));
@@ -671,7 +668,6 @@ public class DatabaseComponentImplTest extends BriarTestCase {
oneOf(database).addContact(txn, author, localAuthorId);
will(returnValue(contactId));
oneOf(database).commitTransaction(txn);
oneOf(eventBus).broadcast(with(any(ContactAddedEvent.class)));
// Check whether the transport is in the DB (which it's not)
exactly(6).of(database).startTransaction();
will(returnValue(txn));

View File

@@ -35,6 +35,7 @@ import org.briarproject.api.sync.PacketWriterFactory;
import org.briarproject.api.sync.Request;
import org.briarproject.api.sync.SubscriptionUpdate;
import org.briarproject.api.sync.TransportUpdate;
import org.briarproject.contact.ContactModule;
import org.briarproject.crypto.CryptoModule;
import org.briarproject.data.DataModule;
import org.briarproject.db.DatabaseModule;
@@ -73,9 +74,9 @@ public class ConstantsTest extends BriarTestCase {
public ConstantsTest() throws Exception {
Injector i = Guice.createInjector(new TestDatabaseModule(),
new TestLifecycleModule(), new TestSystemModule(),
new CryptoModule(), new DatabaseModule(), new DataModule(),
new EventModule(), new ForumModule(), new MessagingModule(),
new SyncModule());
new ContactModule(), new CryptoModule(), new DatabaseModule(),
new DataModule(), new EventModule(), new ForumModule(),
new MessagingModule(), new SyncModule());
crypto = i.getInstance(CryptoComponent.class);
groupFactory = i.getInstance(GroupFactory.class);
authorFactory = i.getInstance(AuthorFactory.class);

View File

@@ -129,8 +129,6 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
Author bobAuthor = new Author(bobId, "Bob",
new byte[MAX_PUBLIC_KEY_LENGTH]);
ContactId contactId = contactManager.addContact(bobAuthor, aliceId);
// Create a private conversation
messagingManager.addContact(contactId);
// Derive and store the transport keys
keyManager.addContact(contactId, Collections.singletonList(transportId),
master, timestamp, true);
@@ -174,14 +172,14 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
IdentityManager identityManager =
bob.getInstance(IdentityManager.class);
ContactManager contactManager = bob.getInstance(ContactManager.class);
MessagingManager messagingManager =
bob.getInstance(MessagingManager.class);
KeyManager keyManager = bob.getInstance(KeyManager.class);
StreamReaderFactory streamReaderFactory =
bob.getInstance(StreamReaderFactory.class);
PacketReaderFactory packetReaderFactory =
bob.getInstance(PacketReaderFactory.class);
EventBus eventBus = bob.getInstance(EventBus.class);
// Bob needs a MessagingManager even though we're not using it directly
bob.getInstance(MessagingManager.class);
// Start the lifecyle manager
lifecycleManager.startServices();
@@ -196,8 +194,6 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
Author aliceAuthor = new Author(aliceId, "Alice",
new byte[MAX_PUBLIC_KEY_LENGTH]);
ContactId contactId = contactManager.addContact(aliceAuthor, bobId);
// Create a private conversation
messagingManager.addContact(contactId);
// Derive and store the transport keys
keyManager.addContact(contactId, Collections.singletonList(transportId),
master, timestamp, false);