Broadcast status event when active contact is added.

This commit is contained in:
akwizgran
2016-02-19 12:10:44 +00:00
parent 0f1dc554bd
commit 8a20f330be
2 changed files with 6 additions and 0 deletions

View File

@@ -145,6 +145,7 @@ class DatabaseComponentImpl<T> implements DatabaseComponent {
throw new ContactExistsException();
ContactId c = db.addContact(txn, remote, local, active);
transaction.attach(new ContactAddedEvent(c));
if (active) transaction.attach(new ContactStatusChangedEvent(c, true));
return c;
}

View File

@@ -16,6 +16,7 @@ import org.briarproject.api.db.NoSuchTransportException;
import org.briarproject.api.db.Transaction;
import org.briarproject.api.event.ContactAddedEvent;
import org.briarproject.api.event.ContactRemovedEvent;
import org.briarproject.api.event.ContactStatusChangedEvent;
import org.briarproject.api.event.EventBus;
import org.briarproject.api.event.GroupAddedEvent;
import org.briarproject.api.event.GroupRemovedEvent;
@@ -146,6 +147,8 @@ public class DatabaseComponentImplTest extends BriarTestCase {
oneOf(database).addContact(txn, author, localAuthorId, true);
will(returnValue(contactId));
oneOf(eventBus).broadcast(with(any(ContactAddedEvent.class)));
oneOf(eventBus).broadcast(with(any(
ContactStatusChangedEvent.class)));
// getContacts()
oneOf(database).getContacts(txn);
will(returnValue(Collections.singletonList(contact)));
@@ -768,6 +771,8 @@ public class DatabaseComponentImplTest extends BriarTestCase {
oneOf(database).addContact(txn, author, localAuthorId, true);
will(returnValue(contactId));
oneOf(eventBus).broadcast(with(any(ContactAddedEvent.class)));
oneOf(eventBus).broadcast(with(any(
ContactStatusChangedEvent.class)));
// endTransaction()
oneOf(database).commitTransaction(txn);
// Check whether the transport is in the DB (which it's not)