From: David ‘Bombe’ Roden Date: Sat, 26 Oct 2013 00:09:56 +0000 (+0200) Subject: Require a recipient when creating a post. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=fdd10f4115e66ea68249ac3dd2c3428da7248952;p=Sone.git Require a recipient when creating a post. --- diff --git a/src/test/java/net/pterodactylus/sone/fcp/AbstractSoneCommandTest.java b/src/test/java/net/pterodactylus/sone/fcp/AbstractSoneCommandTest.java index 54c1908..62285ea 100644 --- a/src/test/java/net/pterodactylus/sone/fcp/AbstractSoneCommandTest.java +++ b/src/test/java/net/pterodactylus/sone/fcp/AbstractSoneCommandTest.java @@ -17,6 +17,7 @@ package net.pterodactylus.sone.fcp; +import static com.google.common.base.Optional.fromNullable; import static com.google.common.base.Optional.of; import static java.util.Arrays.asList; import static java.util.UUID.randomUUID; @@ -325,7 +326,7 @@ public class AbstractSoneCommandTest { @Test public void testParsingAPost() throws FcpException { Sone sone = createSone("jXH8d-eFdm14R69WyaCgQoSjaY0jl-Ut6etlXjK0e6E", "Test", "First", "M.", "Last", (long) (Math.random() * Long.MAX_VALUE)); - Post post = createPost(sone, (long) (Math.random() * Long.MAX_VALUE), "Some Text."); + Post post = createPost(sone, null, (long) (Math.random() * Long.MAX_VALUE), "Some Text."); when(database.getPost(eq(post.getId()))).thenReturn(of(post)); SimpleFieldSet postFieldSet = new SimpleFieldSetBuilder().put("Post", post.getId()).get(); Post parsedPost = abstractSoneCommand.getPost(postFieldSet, "Post"); @@ -333,11 +334,11 @@ public class AbstractSoneCommandTest { assertThat(parsedPost, is(post)); } - private Post createPost(Sone sone, long time, String text) { + private Post createPost(Sone sone, String recipient, long time, String text) { Post post = mock(Post.class); when(post.getId()).thenReturn(randomUUID().toString()); when(post.getSone()).thenReturn(sone); - when(post.getRecipientId()).thenReturn(Optional.absent()); + when(post.getRecipientId()).thenReturn(fromNullable(recipient)); when(post.getTime()).thenReturn(time); when(post.getText()).thenReturn(text); return post; @@ -346,7 +347,7 @@ public class AbstractSoneCommandTest { @Test(expected = FcpException.class) public void testThatTryingToParseANonExistingPostCausesAnError() throws FcpException { Sone sone = createSone("jXH8d-eFdm14R69WyaCgQoSjaY0jl-Ut6etlXjK0e6E", "Test", "First", "M.", "Last", (long) (Math.random() * Long.MAX_VALUE)); - Post post = createPost(sone, (long) (Math.random() * Long.MAX_VALUE), "Some Text."); + Post post = createPost(sone, null, (long) (Math.random() * Long.MAX_VALUE), "Some Text."); when(database.getPost(Matchers.any())).thenReturn(Optional.absent()); SimpleFieldSet postFieldSet = new SimpleFieldSetBuilder().put("Post", post.getId()).get(); abstractSoneCommand.getPost(postFieldSet, "Post");