From eaf17c054fdfa71b3f3bf97cad03d35a32b9c535 Mon Sep 17 00:00:00 2001
From: akwizgran <akwizgran@users.sourceforge.net>
Date: Wed, 16 Nov 2016 16:39:30 +0000
Subject: [PATCH] Moved common fields to superclass.

---
 briar-tests/src/org/briarproject/ValidatorTestCase.java  | 9 +++++++++
 .../briarproject/clients/BdfMessageValidatorTest.java    | 8 --------
 .../org/briarproject/forum/ForumPostValidatorTest.java   | 7 -------
 .../messaging/PrivateMessageValidatorTest.java           | 8 --------
 .../briarproject/sharing/ForumSharingValidatorTest.java  | 8 --------
 5 files changed, 9 insertions(+), 31 deletions(-)

diff --git a/briar-tests/src/org/briarproject/ValidatorTestCase.java b/briar-tests/src/org/briarproject/ValidatorTestCase.java
index a340994ed9..4e5a3b5e62 100644
--- a/briar-tests/src/org/briarproject/ValidatorTestCase.java
+++ b/briar-tests/src/org/briarproject/ValidatorTestCase.java
@@ -1,13 +1,22 @@
 package org.briarproject;
 
+import org.briarproject.api.clients.ClientHelper;
+import org.briarproject.api.data.MetadataEncoder;
 import org.briarproject.api.sync.ClientId;
 import org.briarproject.api.sync.Group;
 import org.briarproject.api.sync.GroupId;
 import org.briarproject.api.sync.Message;
 import org.briarproject.api.sync.MessageId;
+import org.briarproject.api.system.Clock;
 
 public abstract class ValidatorTestCase extends BriarMockTestCase {
 
+	protected final ClientHelper clientHelper =
+			context.mock(ClientHelper.class);
+	protected final MetadataEncoder metadataEncoder =
+			context.mock(MetadataEncoder.class);
+	protected final Clock clock = context.mock(Clock.class);
+
 	protected final MessageId messageId =
 			new MessageId(TestUtils.getRandomId());
 	protected final GroupId groupId = new GroupId(TestUtils.getRandomId());
diff --git a/briar-tests/src/org/briarproject/clients/BdfMessageValidatorTest.java b/briar-tests/src/org/briarproject/clients/BdfMessageValidatorTest.java
index 8c567e295e..65d856dc00 100644
--- a/briar-tests/src/org/briarproject/clients/BdfMessageValidatorTest.java
+++ b/briar-tests/src/org/briarproject/clients/BdfMessageValidatorTest.java
@@ -3,16 +3,13 @@ package org.briarproject.clients;
 import org.briarproject.ValidatorTestCase;
 import org.briarproject.api.FormatException;
 import org.briarproject.api.clients.BdfMessageContext;
-import org.briarproject.api.clients.ClientHelper;
 import org.briarproject.api.data.BdfDictionary;
 import org.briarproject.api.data.BdfList;
-import org.briarproject.api.data.MetadataEncoder;
 import org.briarproject.api.db.Metadata;
 import org.briarproject.api.sync.Group;
 import org.briarproject.api.sync.InvalidMessageException;
 import org.briarproject.api.sync.Message;
 import org.briarproject.api.sync.MessageContext;
-import org.briarproject.api.system.Clock;
 import org.jmock.Expectations;
 import org.jmock.lib.legacy.ClassImposteriser;
 import org.junit.Test;
@@ -25,11 +22,6 @@ import static org.junit.Assert.fail;
 
 public class BdfMessageValidatorTest extends ValidatorTestCase {
 
-	private final ClientHelper clientHelper = context.mock(ClientHelper.class);
-	private final MetadataEncoder metadataEncoder =
-			context.mock(MetadataEncoder.class);
-	private final Clock clock = context.mock(Clock.class);
-
 	private final BdfList body = BdfList.of(123, 456);
 	private final BdfDictionary dictionary = new BdfDictionary();
 	private final Metadata meta = new Metadata();
diff --git a/briar-tests/src/org/briarproject/forum/ForumPostValidatorTest.java b/briar-tests/src/org/briarproject/forum/ForumPostValidatorTest.java
index 512b6f3d16..17e5c1266d 100644
--- a/briar-tests/src/org/briarproject/forum/ForumPostValidatorTest.java
+++ b/briar-tests/src/org/briarproject/forum/ForumPostValidatorTest.java
@@ -5,16 +5,13 @@ import org.briarproject.ValidatorTestCase;
 import org.briarproject.api.FormatException;
 import org.briarproject.api.UniqueId;
 import org.briarproject.api.clients.BdfMessageContext;
-import org.briarproject.api.clients.ClientHelper;
 import org.briarproject.api.data.BdfDictionary;
 import org.briarproject.api.data.BdfList;
-import org.briarproject.api.data.MetadataEncoder;
 import org.briarproject.api.identity.Author;
 import org.briarproject.api.identity.AuthorFactory;
 import org.briarproject.api.identity.AuthorId;
 import org.briarproject.api.sync.InvalidMessageException;
 import org.briarproject.api.sync.MessageId;
-import org.briarproject.api.system.Clock;
 import org.jmock.Expectations;
 import org.junit.Test;
 
@@ -33,10 +30,6 @@ public class ForumPostValidatorTest extends ValidatorTestCase {
 
 	private final AuthorFactory authorFactory =
 			context.mock(AuthorFactory.class);
-	private final ClientHelper clientHelper = context.mock(ClientHelper.class);
-	private final MetadataEncoder metadataEncoder =
-			context.mock(MetadataEncoder.class);
-	private final Clock clock = context.mock(Clock.class);
 
 	private final MessageId parentId = new MessageId(TestUtils.getRandomId());
 	private final String authorName =
diff --git a/briar-tests/src/org/briarproject/messaging/PrivateMessageValidatorTest.java b/briar-tests/src/org/briarproject/messaging/PrivateMessageValidatorTest.java
index fd99b31bb4..3d5fad97a6 100644
--- a/briar-tests/src/org/briarproject/messaging/PrivateMessageValidatorTest.java
+++ b/briar-tests/src/org/briarproject/messaging/PrivateMessageValidatorTest.java
@@ -4,11 +4,8 @@ import org.briarproject.TestUtils;
 import org.briarproject.ValidatorTestCase;
 import org.briarproject.api.FormatException;
 import org.briarproject.api.clients.BdfMessageContext;
-import org.briarproject.api.clients.ClientHelper;
 import org.briarproject.api.data.BdfDictionary;
 import org.briarproject.api.data.BdfList;
-import org.briarproject.api.data.MetadataEncoder;
-import org.briarproject.api.system.Clock;
 import org.junit.Test;
 
 import static org.briarproject.api.messaging.MessagingConstants.MAX_PRIVATE_MESSAGE_BODY_LENGTH;
@@ -18,11 +15,6 @@ import static org.junit.Assert.assertFalse;
 
 public class PrivateMessageValidatorTest extends ValidatorTestCase {
 
-	private final ClientHelper clientHelper = context.mock(ClientHelper.class);
-	private final MetadataEncoder metadataEncoder =
-			context.mock(MetadataEncoder.class);
-	private final Clock clock = context.mock(Clock.class);
-
 	@Test(expected = FormatException.class)
 	public void testRejectsTooShortBody() throws Exception {
 		PrivateMessageValidator v = new PrivateMessageValidator(clientHelper,
diff --git a/briar-tests/src/org/briarproject/sharing/ForumSharingValidatorTest.java b/briar-tests/src/org/briarproject/sharing/ForumSharingValidatorTest.java
index 099fa26327..7d3c6e22b2 100644
--- a/briar-tests/src/org/briarproject/sharing/ForumSharingValidatorTest.java
+++ b/briar-tests/src/org/briarproject/sharing/ForumSharingValidatorTest.java
@@ -5,12 +5,9 @@ import org.briarproject.ValidatorTestCase;
 import org.briarproject.api.FormatException;
 import org.briarproject.api.UniqueId;
 import org.briarproject.api.clients.BdfMessageContext;
-import org.briarproject.api.clients.ClientHelper;
 import org.briarproject.api.clients.SessionId;
 import org.briarproject.api.data.BdfDictionary;
 import org.briarproject.api.data.BdfList;
-import org.briarproject.api.data.MetadataEncoder;
-import org.briarproject.api.system.Clock;
 import org.junit.Test;
 
 import javax.annotation.Nullable;
@@ -35,11 +32,6 @@ import static org.junit.Assert.assertFalse;
 
 public class ForumSharingValidatorTest extends ValidatorTestCase {
 
-	private final ClientHelper clientHelper = context.mock(ClientHelper.class);
-	private final MetadataEncoder metadataEncoder =
-			context.mock(MetadataEncoder.class);
-	private final Clock clock = context.mock(Clock.class);
-
 	private final SessionId sessionId = new SessionId(TestUtils.getRandomId());
 	private final String forumName =
 			TestUtils.getRandomString(MAX_FORUM_NAME_LENGTH);
-- 
GitLab