From: David ‘Bombe’ Roden Date: Mon, 4 Nov 2013 05:24:45 +0000 (+0100) Subject: Store sones as a Map. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=5bee7fb48ebff210d2b68f1939acbdb4ea10d1c1;p=Sone.git Store sones as a Map. --- diff --git a/src/test/java/net/pterodactylus/sone/data/Mocks.java b/src/test/java/net/pterodactylus/sone/data/Mocks.java index 51a24fd..88baf22 100644 --- a/src/test/java/net/pterodactylus/sone/data/Mocks.java +++ b/src/test/java/net/pterodactylus/sone/data/Mocks.java @@ -21,8 +21,8 @@ import static com.google.common.base.Optional.absent; import static com.google.common.base.Optional.fromNullable; import static com.google.common.base.Optional.of; import static com.google.common.collect.ArrayListMultimap.create; +import static com.google.common.collect.Maps.newHashMap; import static com.google.common.collect.Ordering.from; -import static com.google.common.collect.Sets.newHashSet; import static java.util.Collections.emptySet; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; @@ -31,6 +31,7 @@ import static org.mockito.Mockito.when; import java.util.Collection; import java.util.List; +import java.util.Map; import net.pterodactylus.sone.core.Core; import net.pterodactylus.sone.data.impl.DefaultPostBuilder; @@ -53,7 +54,7 @@ import org.mockito.stubbing.Answer; public class Mocks { private final Multimap sonePosts = create(); - private final Collection sones = newHashSet(); + private final Map sones = newHashMap(); private final Multimap postReplies = create(); private final Multimap directedPosts = create(); public final Database database; @@ -65,7 +66,7 @@ public class Mocks { when(core.getLocalSones()).then(new Answer>() { @Override public Collection answer(InvocationOnMock invocation) throws Throwable { - return FluentIterable.from(sones).filter(Sone.LOCAL_SONE_FILTER).toList(); + return FluentIterable.from(sones.values()).filter(Sone.LOCAL_SONE_FILTER).toList(); } }); when(database.getDirectedPosts(anyString())).then(new Answer>() { @@ -184,7 +185,7 @@ public class Mocks { } }); when(mockedSone.toString()).thenReturn(String.format("Sone[%s]", id)); - sones.add(mockedSone); + sones.put(id, mockedSone); return mockedSone; }