Implement getLocalSone in mocked Core.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 9 Feb 2014 11:37:14 +0000 (12:37 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 28 Feb 2014 21:26:08 +0000 (22:26 +0100)
src/test/java/net/pterodactylus/sone/data/Mocks.java

index 72a4e75..f56a1d4 100644 (file)
@@ -101,6 +101,13 @@ public class Mocks {
                                return sones.values();
                        }
                });
+               when(core.getLocalSone(anyString())).then(new Answer<Optional<Sone>>() {
+                       @Override
+                       public Optional<Sone> answer(InvocationOnMock invocation) throws Throwable {
+                               Sone localSone = sones.get(invocation.getArguments()[0]);
+                               return ((localSone == null) || (!localSone.isLocal())) ? Optional.<Sone>absent() : of(localSone);
+                       }
+               });
                when(core.getLocalSones()).then(new Answer<Collection<Sone>>() {
                        @Override
                        public Collection<Sone> answer(InvocationOnMock invocation) throws Throwable {