From 60adf73616aad41adaabfe663ab69f43a60bb638 Mon Sep 17 00:00:00 2001 From: Christian Basler Date: Sun, 7 Feb 2016 23:36:35 +0100 Subject: [PATCH] Improved tests for repositories --- .../repository/JdbcMessageRepositoryTest.java | 39 +++++++-- .../JdbcProofOfWorkRepositoryTest.java | 84 +++++++++++++++++++ 2 files changed, 116 insertions(+), 7 deletions(-) create mode 100644 repositories/src/test/java/ch/dissem/bitmessage/repository/JdbcProofOfWorkRepositoryTest.java diff --git a/repositories/src/test/java/ch/dissem/bitmessage/repository/JdbcMessageRepositoryTest.java b/repositories/src/test/java/ch/dissem/bitmessage/repository/JdbcMessageRepositoryTest.java index c7c3614..4c93271 100644 --- a/repositories/src/test/java/ch/dissem/bitmessage/repository/JdbcMessageRepositoryTest.java +++ b/repositories/src/test/java/ch/dissem/bitmessage/repository/JdbcMessageRepositoryTest.java @@ -30,11 +30,12 @@ import org.junit.Test; import java.util.Arrays; import java.util.List; +import java.util.Random; import static ch.dissem.bitmessage.entity.Plaintext.Type.MSG; import static ch.dissem.bitmessage.utils.Singleton.security; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.*; public class JdbcMessageRepositoryTest extends TestBase { private BitmessageAddress contactA; @@ -47,6 +48,7 @@ public class JdbcMessageRepositoryTest extends TestBase { private Label inbox; private Label drafts; + private Label unread; @Before public void setUp() throws Exception { @@ -72,27 +74,28 @@ public class JdbcMessageRepositoryTest extends TestBase { inbox = repo.getLabels(Label.Type.INBOX).get(0); drafts = repo.getLabels(Label.Type.DRAFT).get(0); + unread = repo.getLabels(Label.Type.UNREAD).get(0); - addMessage(contactA, identity, Plaintext.Status.RECEIVED, inbox); + addMessage(contactA, identity, Plaintext.Status.RECEIVED, inbox, unread); addMessage(identity, contactA, Plaintext.Status.DRAFT, drafts); - addMessage(identity, contactB, Plaintext.Status.DRAFT); + addMessage(identity, contactB, Plaintext.Status.DRAFT, unread); } @Test - public void testGetLabels() throws Exception { + public void ensureLabelsAreRetrieved() throws Exception { List