Diamond operators.

This commit is contained in:
akwizgran
2017-11-15 17:28:01 +00:00
committed by Torsten Grote
parent 2d26af1ae2
commit 27328afe3c
83 changed files with 268 additions and 326 deletions

View File

@@ -131,7 +131,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
context.mock(ValidationManager.class);
final AtomicReference<MessageValidator> captured =
new AtomicReference<MessageValidator>();
new AtomicReference<>();
final QueueMessageValidator queueMessageValidator =
context.mock(QueueMessageValidator.class);
// The message is too short to be a valid queue message
@@ -142,7 +142,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
context.checking(new Expectations() {{
oneOf(validationManager).registerMessageValidator(with(clientId),
with(any(MessageValidator.class)));
will(new CaptureArgumentAction<MessageValidator>(captured,
will(new CaptureArgumentAction<>(captured,
MessageValidator.class, 1));
}});
@@ -175,7 +175,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
context.mock(ValidationManager.class);
final AtomicReference<MessageValidator> captured =
new AtomicReference<MessageValidator>();
new AtomicReference<>();
final QueueMessageValidator queueMessageValidator =
context.mock(QueueMessageValidator.class);
// The message has a negative queue position
@@ -188,7 +188,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
context.checking(new Expectations() {{
oneOf(validationManager).registerMessageValidator(with(clientId),
with(any(MessageValidator.class)));
will(new CaptureArgumentAction<MessageValidator>(captured,
will(new CaptureArgumentAction<>(captured,
MessageValidator.class, 1));
}});
@@ -221,7 +221,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
context.mock(ValidationManager.class);
final AtomicReference<MessageValidator> captured =
new AtomicReference<MessageValidator>();
new AtomicReference<>();
final QueueMessageValidator queueMessageValidator =
context.mock(QueueMessageValidator.class);
final Metadata metadata = new Metadata();
@@ -235,7 +235,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
context.checking(new Expectations() {{
oneOf(validationManager).registerMessageValidator(with(clientId),
with(any(MessageValidator.class)));
will(new CaptureArgumentAction<MessageValidator>(captured,
will(new CaptureArgumentAction<>(captured,
MessageValidator.class, 1));
// The message should be delegated
oneOf(queueMessageValidator).validateMessage(
@@ -268,7 +268,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
final ValidationManager validationManager =
context.mock(ValidationManager.class);
final AtomicReference<IncomingMessageHook> captured =
new AtomicReference<IncomingMessageHook>();
new AtomicReference<>();
final IncomingQueueMessageHook incomingQueueMessageHook =
context.mock(IncomingQueueMessageHook.class);
@@ -284,7 +284,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
context.checking(new Expectations() {{
oneOf(validationManager).registerIncomingMessageHook(with(clientId),
with(any(IncomingMessageHook.class)));
will(new CaptureArgumentAction<IncomingMessageHook>(captured,
will(new CaptureArgumentAction<>(captured,
IncomingMessageHook.class, 1));
oneOf(db).getGroupMetadata(txn, groupId);
will(returnValue(groupMetadata));
@@ -320,7 +320,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
final ValidationManager validationManager =
context.mock(ValidationManager.class);
final AtomicReference<IncomingMessageHook> captured =
new AtomicReference<IncomingMessageHook>();
new AtomicReference<>();
final IncomingQueueMessageHook incomingQueueMessageHook =
context.mock(IncomingQueueMessageHook.class);
@@ -338,7 +338,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
context.checking(new Expectations() {{
oneOf(validationManager).registerIncomingMessageHook(with(clientId),
with(any(IncomingMessageHook.class)));
will(new CaptureArgumentAction<IncomingMessageHook>(captured,
will(new CaptureArgumentAction<>(captured,
IncomingMessageHook.class, 1));
oneOf(db).getGroupMetadata(txn, groupId);
will(returnValue(groupMetadata));
@@ -376,7 +376,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
final ValidationManager validationManager =
context.mock(ValidationManager.class);
final AtomicReference<IncomingMessageHook> captured =
new AtomicReference<IncomingMessageHook>();
new AtomicReference<>();
final IncomingQueueMessageHook incomingQueueMessageHook =
context.mock(IncomingQueueMessageHook.class);
@@ -393,7 +393,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
context.checking(new Expectations() {{
oneOf(validationManager).registerIncomingMessageHook(with(clientId),
with(any(IncomingMessageHook.class)));
will(new CaptureArgumentAction<IncomingMessageHook>(captured,
will(new CaptureArgumentAction<>(captured,
IncomingMessageHook.class, 1));
oneOf(db).getGroupMetadata(txn, groupId);
will(returnValue(groupMetadata));
@@ -434,7 +434,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
final ValidationManager validationManager =
context.mock(ValidationManager.class);
final AtomicReference<IncomingMessageHook> captured =
new AtomicReference<IncomingMessageHook>();
new AtomicReference<>();
final IncomingQueueMessageHook incomingQueueMessageHook =
context.mock(IncomingQueueMessageHook.class);
@@ -458,7 +458,7 @@ public class MessageQueueManagerImplTest extends BriarTestCase {
context.checking(new Expectations() {{
oneOf(validationManager).registerIncomingMessageHook(with(clientId),
with(any(IncomingMessageHook.class)));
will(new CaptureArgumentAction<IncomingMessageHook>(captured,
will(new CaptureArgumentAction<>(captured,
IncomingMessageHook.class, 1));
oneOf(db).getGroupMetadata(txn, groupId);
will(returnValue(groupMetadata));

View File

@@ -19,7 +19,7 @@ public class MessageTreeImplTest {
@Test
public void testMessageTree() {
tree = new MessageTreeImpl<TestNode>();
tree = new MessageTreeImpl<>();
testSimpleTree();
tree.clear();
testSimpleTree();

View File

@@ -105,7 +105,7 @@ public class FeedManagerImplTest extends BrambleMockTestCase {
@Test
public void testPostFeedEntriesEmptyDate() throws Exception {
final Transaction txn = new Transaction(null, false);
List<SyndEntry> entries = new ArrayList<SyndEntry>();
List<SyndEntry> entries = new ArrayList<>();
entries.add(new SyndEntryImpl());
final SyndEntry entry = new SyndEntryImpl();
entry.setUpdatedDate(new Date());

View File

@@ -464,7 +464,7 @@ public class IntroductionIntegrationTest
assertTrue(listener1.requestReceived);
// get SessionId
List<IntroductionMessage> list = new ArrayList<IntroductionMessage>(
List<IntroductionMessage> list = new ArrayList<>(
introductionManager1.getIntroductionMessages(contactId0From1));
assertEquals(2, list.size());
assertTrue(list.get(0) instanceof IntroductionRequest);

View File

@@ -172,7 +172,7 @@ public class GroupMessageValidatorTest extends ValidatorTestCase {
BdfMessageContext messageContext =
validator.validateMessage(message, group, body);
assertExpectedMessageContext(messageContext, JOIN, creator,
Collections.<MessageId>emptyList());
Collections.emptyList());
assertTrue(messageContext.getDictionary()
.getBoolean(KEY_INITIAL_JOIN_MSG));
}
@@ -325,7 +325,7 @@ public class GroupMessageValidatorTest extends ValidatorTestCase {
BdfMessageContext messageContext =
validator.validateMessage(message, group, body);
assertExpectedMessageContext(messageContext, JOIN, member,
Collections.<MessageId>emptyList());
Collections.emptyList());
assertFalse(messageContext.getDictionary()
.getBoolean(KEY_INITIAL_JOIN_MSG));
}

View File

@@ -631,8 +631,7 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
final BdfDictionary query = BdfDictionary.of(new BdfEntry("q", "u"));
final MessageId messageId2 = new MessageId(TestUtils.getRandomId());
final BdfDictionary meta2 = BdfDictionary.of(new BdfEntry("m2", "e"));
final Map<MessageId, BdfDictionary> results =
new HashMap<MessageId, BdfDictionary>();
final Map<MessageId, BdfDictionary> results = new HashMap<>();
results.put(message.getId(), meta);
results.put(messageId2, meta2);
final long time1 = 1L, time2 = 2L;
@@ -705,8 +704,7 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
final BdfDictionary query = BdfDictionary.of(new BdfEntry("q", "u"));
final MessageId messageId2 = new MessageId(TestUtils.getRandomId());
final BdfDictionary meta2 = BdfDictionary.of(new BdfEntry("m2", "e"));
final Map<MessageId, BdfDictionary> results =
new HashMap<MessageId, BdfDictionary>();
final Map<MessageId, BdfDictionary> results = new HashMap<>();
results.put(message.getId(), meta);
results.put(messageId2, meta2);
final Message message2 = new Message(messageId2, contactGroup.getId(),

View File

@@ -146,9 +146,8 @@ public class BlogSharingIntegrationTest
assertTrue(blogManager1.getBlogs().contains(blog2));
// invitee has one invitation message from sharer
List<InvitationMessage> list =
new ArrayList<InvitationMessage>(blogSharingManager1
.getInvitationMessages(contactId0From1));
List<InvitationMessage> list = new ArrayList<>(
blogSharingManager1.getInvitationMessages(contactId0From1));
assertEquals(2, list.size());
// check other things are alright with the message
for (InvitationMessage m : list) {
@@ -222,9 +221,8 @@ public class BlogSharingIntegrationTest
assertTrue(blogManager1.getBlogs().contains(rssBlog));
// invitee has one invitation message from sharer
List<InvitationMessage> list =
new ArrayList<InvitationMessage>(blogSharingManager1
.getInvitationMessages(contactId0From1));
List<InvitationMessage> list = new ArrayList<>(
blogSharingManager1.getInvitationMessages(contactId0From1));
assertEquals(2, list.size());
// check other things are alright with the message
for (InvitationMessage m : list) {
@@ -286,9 +284,8 @@ public class BlogSharingIntegrationTest
assertEquals(0, blogSharingManager1.getInvitations().size());
// invitee has one invitation message from sharer and one response
List<InvitationMessage> list =
new ArrayList<InvitationMessage>(blogSharingManager1
.getInvitationMessages(contactId0From1));
List<InvitationMessage> list = new ArrayList<>(
blogSharingManager1.getInvitationMessages(contactId0From1));
assertEquals(2, list.size());
// check things are alright with the message
for (InvitationMessage m : list) {

View File

@@ -94,23 +94,20 @@ public class BlogSharingManagerImplTest extends BrambleMockTestCase {
@Test
public void testAddingContactFreshState() throws Exception {
Map<MessageId, BdfDictionary> sessions =
new HashMap<MessageId, BdfDictionary>(0);
Map<MessageId, BdfDictionary> sessions = new HashMap<>(0);
testAddingContact(sessions);
}
@Test
public void testAddingContactExistingState() throws Exception {
Map<MessageId, BdfDictionary> sessions =
new HashMap<MessageId, BdfDictionary>(1);
Map<MessageId, BdfDictionary> sessions = new HashMap<>(1);
sessions.put(new MessageId(getRandomId()), new BdfDictionary());
testAddingContact(sessions);
}
@Test(expected = DbException.class)
public void testAddingContactMultipleSessions() throws Exception {
Map<MessageId, BdfDictionary> sessions =
new HashMap<MessageId, BdfDictionary>(2);
Map<MessageId, BdfDictionary> sessions = new HashMap<>(2);
sessions.put(new MessageId(getRandomId()), new BdfDictionary());
sessions.put(new MessageId(getRandomId()), new BdfDictionary());
testAddingContact(sessions);
@@ -118,23 +115,20 @@ public class BlogSharingManagerImplTest extends BrambleMockTestCase {
@Test
public void testRemovingBlogFreshState() throws Exception {
Map<MessageId, BdfDictionary> sessions =
new HashMap<MessageId, BdfDictionary>(0);
Map<MessageId, BdfDictionary> sessions = new HashMap<>(0);
testRemovingBlog(sessions);
}
@Test
public void testRemovingBlogExistingState() throws Exception {
Map<MessageId, BdfDictionary> sessions =
new HashMap<MessageId, BdfDictionary>(1);
Map<MessageId, BdfDictionary> sessions = new HashMap<>(1);
sessions.put(new MessageId(getRandomId()), new BdfDictionary());
testRemovingBlog(sessions);
}
@Test(expected = DbException.class)
public void testRemovingBlogMultipleSessions() throws Exception {
Map<MessageId, BdfDictionary> sessions =
new HashMap<MessageId, BdfDictionary>(2);
Map<MessageId, BdfDictionary> sessions = new HashMap<>(2);
sessions.put(new MessageId(getRandomId()), new BdfDictionary());
sessions.put(new MessageId(getRandomId()), new BdfDictionary());
testRemovingBlog(sessions);

View File

@@ -129,9 +129,8 @@ public class ForumSharingIntegrationTest
assertEquals(1, forumManager1.getForums().size());
// invitee has one invitation message from sharer
List<InvitationMessage> list =
new ArrayList<InvitationMessage>(forumSharingManager1
.getInvitationMessages(contactId0From1));
List<InvitationMessage> list = new ArrayList<>(
forumSharingManager1.getInvitationMessages(contactId0From1));
assertEquals(2, list.size());
// check other things are alright with the forum message
for (InvitationMessage m : list) {
@@ -189,9 +188,8 @@ public class ForumSharingIntegrationTest
assertEquals(0, forumSharingManager1.getInvitations().size());
// invitee has one invitation message from sharer and one response
List<InvitationMessage> list =
new ArrayList<InvitationMessage>(forumSharingManager1
.getInvitationMessages(contactId0From1));
List<InvitationMessage> list = new ArrayList<>(
forumSharingManager1.getInvitationMessages(contactId0From1));
assertEquals(2, list.size());
// check things are alright with the forum message
for (InvitationMessage m : list) {