mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-20 14:49:53 +01:00
Added unit test for setting contact active.
This commit is contained in:
@@ -4,6 +4,7 @@ import org.briarproject.BriarTestCase;
|
|||||||
import org.briarproject.TestDatabaseConfig;
|
import org.briarproject.TestDatabaseConfig;
|
||||||
import org.briarproject.TestUtils;
|
import org.briarproject.TestUtils;
|
||||||
import org.briarproject.api.TransportId;
|
import org.briarproject.api.TransportId;
|
||||||
|
import org.briarproject.api.contact.Contact;
|
||||||
import org.briarproject.api.contact.ContactId;
|
import org.briarproject.api.contact.ContactId;
|
||||||
import org.briarproject.api.crypto.SecretKey;
|
import org.briarproject.api.crypto.SecretKey;
|
||||||
import org.briarproject.api.db.DbException;
|
import org.briarproject.api.db.DbException;
|
||||||
@@ -1108,6 +1109,38 @@ public class H2DatabaseTest extends BriarTestCase {
|
|||||||
db.close();
|
db.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetContactActive() throws Exception {
|
||||||
|
Database<Connection> db = open(false);
|
||||||
|
Connection txn = db.startTransaction();
|
||||||
|
|
||||||
|
// Add a contact
|
||||||
|
db.addLocalAuthor(txn, localAuthor);
|
||||||
|
assertEquals(contactId, db.addContact(txn, author, localAuthorId,
|
||||||
|
true));
|
||||||
|
|
||||||
|
// The contact should be active
|
||||||
|
Contact contact = db.getContact(txn, contactId);
|
||||||
|
assertTrue(contact.isActive());
|
||||||
|
|
||||||
|
// Set the contact inactive
|
||||||
|
db.setContactActive(txn, contactId, false);
|
||||||
|
|
||||||
|
// The contact should be inactive
|
||||||
|
contact = db.getContact(txn, contactId);
|
||||||
|
assertFalse(contact.isActive());
|
||||||
|
|
||||||
|
// Set the contact active
|
||||||
|
db.setContactActive(txn, contactId, true);
|
||||||
|
|
||||||
|
// The contact should be active
|
||||||
|
contact = db.getContact(txn, contactId);
|
||||||
|
assertTrue(contact.isActive());
|
||||||
|
|
||||||
|
db.commitTransaction(txn);
|
||||||
|
db.close();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExceptionHandling() throws Exception {
|
public void testExceptionHandling() throws Exception {
|
||||||
Database<Connection> db = open(false);
|
Database<Connection> db = open(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user