From: David ‘Bombe’ Roden Date: Sat, 1 Mar 2014 13:06:08 +0000 (+0100) Subject: Make it possible to mock a Sone’s insert URI. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=22d68072fb1770cdc4262ede974bd0a6202d7062;p=Sone.git Make it possible to mock a Sone’s insert URI. --- 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); }