mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 20:59:54 +01:00
fixed unread buttons for threaded lists and akwizgran's comments
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package org.briarproject.briar.client;
|
||||
|
||||
import org.briarproject.bramble.api.client.ClientHelper;
|
||||
import org.briarproject.bramble.api.data.BdfDictionary;
|
||||
import org.briarproject.bramble.api.data.BdfEntry;
|
||||
import org.briarproject.bramble.api.db.DatabaseComponent;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.briarproject.briar.api.client.MessageTracker;
|
||||
import org.briarproject.briar.test.BriarTestCase;
|
||||
import org.jmock.Expectations;
|
||||
import org.jmock.Mockery;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.briarproject.briar.client.MessageTrackerConstants.GROUP_KEY_STORED_MESSAGE_ID;
|
||||
|
||||
public class MessageTrackerTest extends BriarTestCase {
|
||||
|
||||
protected final Mockery context = new Mockery();
|
||||
protected final GroupId groupId = new GroupId(TestUtils.getRandomId());
|
||||
protected final ClientHelper clientHelper =
|
||||
context.mock(ClientHelper.class);
|
||||
private final DatabaseComponent db = context.mock(DatabaseComponent.class);
|
||||
private final MessageId messageId = new MessageId(TestUtils.getRandomId());
|
||||
private final MessageTracker messageTracker =
|
||||
new MessageTrackerImpl(db, clientHelper);
|
||||
private final BdfDictionary dictionary = BdfDictionary.of(
|
||||
new BdfEntry(GROUP_KEY_STORED_MESSAGE_ID, messageId)
|
||||
);
|
||||
|
||||
@Test
|
||||
public void testMessageStore() throws Exception {
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(clientHelper).mergeGroupMetadata(groupId, dictionary);
|
||||
}});
|
||||
messageTracker.storeMessageId(groupId, messageId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMessageLoad() throws Exception {
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(clientHelper).getGroupMetadataAsDictionary(groupId);
|
||||
will(returnValue(dictionary));
|
||||
}});
|
||||
MessageId loadedId = messageTracker.loadStoredMessageId(groupId);
|
||||
Assert.assertNotNull(loadedId);
|
||||
Assert.assertTrue(messageId.equals(loadedId));
|
||||
}
|
||||
|
||||
@After
|
||||
public void checkExpectations() {
|
||||
context.assertIsSatisfied();
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,7 @@
|
||||
package org.briarproject.briar.forum;
|
||||
|
||||
import org.briarproject.bramble.api.db.DbException;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.bramble.test.TestDatabaseModule;
|
||||
import org.briarproject.bramble.test.TestUtils;
|
||||
import org.briarproject.briar.api.forum.Forum;
|
||||
import org.briarproject.briar.api.forum.ForumManager;
|
||||
import org.briarproject.briar.api.forum.ForumPost;
|
||||
@@ -13,7 +10,6 @@ import org.briarproject.briar.api.forum.ForumSharingManager;
|
||||
import org.briarproject.briar.test.BriarIntegrationTest;
|
||||
import org.briarproject.briar.test.BriarIntegrationTestComponent;
|
||||
import org.briarproject.briar.test.DaggerBriarIntegrationTestComponent;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -227,18 +223,4 @@ public class ForumManagerTest
|
||||
assertEquals(1, forumManager1.getPostHeaders(g1).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMessageStoreAndLoad() {
|
||||
MessageId msgId = new MessageId(TestUtils.getRandomId());
|
||||
MessageId loadedId = null;
|
||||
try {
|
||||
messageTracker0.storeMessageId(groupId0, msgId);
|
||||
loadedId = messageTracker0.loadStoredMessageId(groupId0);
|
||||
} catch (DbException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Assert.assertNotNull(loadedId);
|
||||
Assert.assertTrue(msgId.equals(loadedId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user