From 22d68072fb1770cdc4262ede974bd0a6202d7062 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 1 Mar 2014 14:06:08 +0100 Subject: [PATCH] =?utf8?q?Make=20it=20possible=20to=20mock=20a=20Sone?= =?utf8?q?=E2=80=99s=20insert=20URI.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/test/java/net/pterodactylus/sone/data/Mocks.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/test/java/net/pterodactylus/sone/data/Mocks.java b/src/test/java/net/pterodactylus/sone/data/Mocks.java index 3e8880c..1962686 100644 --- a/src/test/java/net/pterodactylus/sone/data/Mocks.java +++ b/src/test/java/net/pterodactylus/sone/data/Mocks.java @@ -46,6 +46,7 @@ import net.pterodactylus.sone.database.Database; import net.pterodactylus.sone.database.PostBuilder.PostCreated; import net.pterodactylus.sone.database.PostReplyBuilder; import net.pterodactylus.sone.database.PostReplyBuilder.PostReplyCreated; +import net.pterodactylus.sone.freenet.wot.OwnIdentity; import net.pterodactylus.sone.utils.IntegerRangePredicate; import net.pterodactylus.sone.web.WebInterface; import net.pterodactylus.sone.web.page.FreenetRequest; @@ -217,6 +218,7 @@ public class Mocks { private final Sone mockedSone = mock(Sone.class); private final String id; + private String insertUrI; private boolean local; private boolean current; private Optional name = absent(); @@ -233,6 +235,11 @@ public class Mocks { return this; } + public SoneMocker insertUri(String insertUri) { + this.insertUrI = insertUri; + return this; + } + public SoneMocker current() { current = true; return this; @@ -266,6 +273,11 @@ public class Mocks { public Sone create() { when(mockedSone.getId()).thenReturn(id); when(mockedSone.isLocal()).thenReturn(local); + if (local) { + OwnIdentity ownIdentity = mock(OwnIdentity.class); + when(ownIdentity.getInsertUri()).thenReturn(insertUrI); + when(mockedSone.getIdentity()).thenReturn(ownIdentity); + } if (current) { currentSone = of(mockedSone); } -- 2.7.4