{"action":"created","comment":{"url":"https://api.github.com/repos/yegor256/netbout/pulls/comments/30865188","id":30865188,"diff_hunk":"@@ -0,0 +1,102 @@\n+/**\n+ * Copyright (c) 2009-2015, netbout.com\n+ * All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are PROHIBITED without prior written permission from\n+ * the author. This product may NOT be used anywhere and on any computer\n+ * except the server platform of netbout Inc. located at www.netbout.com.\n+ * Federal copyright law prohibits unauthorized reproduction by any means\n+ * and imposes fines up to $25,000 for violation. If you received\n+ * this code accidentally and without intent to use it, please report this\n+ * incident to the author by email.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT\n+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n+ * SUCH DAMAGE.\n+ */\n+package com.netbout.rest.bout;\n+\n+import com.jcabi.urn.URN;\n+import com.netbout.mock.MkBase;\n+import com.netbout.rest.RqWithTester;\n+import com.netbout.rest.TkStart;\n+import com.netbout.spi.Alias;\n+import com.netbout.spi.Bout;\n+import com.netbout.spi.Message;\n+import com.netbout.spi.User;\n+import java.util.regex.Matcher;\n+import java.util.regex.Pattern;\n+import org.hamcrest.MatcherAssert;\n+import org.hamcrest.Matchers;\n+import org.junit.Test;\n+import org.takes.facets.forward.TkForward;\n+import org.takes.rq.RqFake;\n+import org.takes.rs.RsPrint;\n+\n+/**\n+ * Test case for {@link TkStart}.\n+ * @author Ivan Inozemtsev (ivan.inozemtsev@gmail.com)\n+ * @version $Id$\n+ * @since 2.15\n+ */\n+public final class TkStartTest {\n+\n+    /**\n+     * TkStart can post message and invite friends to\n+     * newly created bouts.\n+     * @throws Exception If there is some problem inside\n+     */\n+    @Test\n+    public void postsMessageAndInvitesFriends() throws Exception {\n+        final MkBase base = new MkBase();\n+        final URN urn = new URN(\"urn:test:1\");\n+        final User user = base.user(urn);\n+        final String jeff = \"Jeff\";\n+        user.aliases().add(jeff);\n+        final String frank = \"Frank\";\n+        final User friend = base.user(new URN(\"urn:test:2\"));\n+        friend.aliases().add(frank);\n+        final String post = \"message\";\n+        final String head = new RsPrint(\n+            new TkForward(new TkStart(base)).act(\n+                new RqWithTester(\n+                    urn,\n+                    new RqFake(\n+                        \"GET\",\n+                        String.format(\n+                            \"/start?post=%s&invite=%s\",\n+                            post,\n+                            frank\n+                        )\n+                    )\n+                )\n+            )\n+        ).printHead();\n+        final Matcher matcher = Pattern.compile(\n+            \"^Location:.*/b/(\\\\d+)$\",\n+            Pattern.MULTILINE\n+        ).matcher(head);\n+        MatcherAssert.assertThat(\"Location header is correct\", matcher.find());\n+        final long number = Long.parseLong(matcher.group(1));\n+        final Alias alias = user.aliases().iterate().iterator().next();\n+        final Bout bout = alias.inbox().bout(number);\n+        final Message message = bout.messages().iterate().iterator().next();\n+        MatcherAssert.assertThat(message.author(), Matchers.equalTo(jeff));\n+        MatcherAssert.assertThat(message.text(), Matchers.equalTo(post));\n+        MatcherAssert.assertThat(\n+            bout.friends().iterate().iterator().next().alias(),\n+            Matchers.equalTo(frank)\n+        );\n+    }\n+\n+}","path":"netbout-web/src/test/java/com/netbout/rest/bout/TkStartTest.java","position":102,"original_position":102,"commit_id":"70b36223d6779aab3966a9770f2058d67f981257","original_commit_id":"70b36223d6779aab3966a9770f2058d67f981257","user":{"login":"caarlos0","id":245435,"avatar_url":"https://avatars.githubusercontent.com/u/245435?v=3","gravatar_id":"","url":"https://api.github.com/users/caarlos0","html_url":"https://github.com/caarlos0","followers_url":"https://api.github.com/users/caarlos0/followers","following_url":"https://api.github.com/users/caarlos0/following{/other_user}","gists_url":"https://api.github.com/users/caarlos0/gists{/gist_id}","starred_url":"https://api.github.com/users/caarlos0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caarlos0/subscriptions","organizations_url":"https://api.github.com/users/caarlos0/orgs","repos_url":"https://api.github.com/users/caarlos0/repos","events_url":"https://api.github.com/users/caarlos0/events{/privacy}","received_events_url":"https://api.github.com/users/caarlos0/received_events","type":"User","site_admin":false},"body":"@komaz I think you are missing tests for the error scenarios, like when a friend is not found...","created_at":"2015-05-22T02:12:31Z","updated_at":"2015-05-22T02:12:31Z","html_url":"https://github.com/yegor256/netbout/pull/619#discussion_r30865188","pull_request_url":"https://api.github.com/repos/yegor256/netbout/pulls/619","_links":{"self":{"href":"https://api.github.com/repos/yegor256/netbout/pulls/comments/30865188"},"html":{"href":"https://github.com/yegor256/netbout/pull/619#discussion_r30865188"},"pull_request":{"href":"https://api.github.com/repos/yegor256/netbout/pulls/619"}}},"pull_request":{"url":"https://api.github.com/repos/yegor256/netbout/pulls/619","id":35915044,"html_url":"https://github.com/yegor256/netbout/pull/619","diff_url":"https://github.com/yegor256/netbout/pull/619.diff","patch_url":"https://github.com/yegor256/netbout/pull/619.patch","issue_url":"https://api.github.com/repos/yegor256/netbout/issues/619","number":619,"state":"open","locked":false,"title":"#610 /start with arguments","user":{"login":"komaz","id":481692,"avatar_url":"https://avatars.githubusercontent.com/u/481692?v=3","gravatar_id":"","url":"https://api.github.com/users/komaz","html_url":"https://github.com/komaz","followers_url":"https://api.github.com/users/komaz/followers","following_url":"https://api.github.com/users/komaz/following{/other_user}","gists_url":"https://api.github.com/users/komaz/gists{/gist_id}","starred_url":"https://api.github.com/users/komaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/komaz/subscriptions","organizations_url":"https://api.github.com/users/komaz/orgs","repos_url":"https://api.github.com/users/komaz/repos","events_url":"https://api.github.com/users/komaz/events{/privacy}","received_events_url":"https://api.github.com/users/komaz/received_events","type":"User","site_admin":false},"body":"Proposed fix for issue #610 – `TkStart` now checks if 'post' and 'invite' parameters are specified and performs required actions. `TkStartTest.postsMessageAndInvitesFriends` added.","created_at":"2015-05-21T09:27:01Z","updated_at":"2015-05-22T02:12:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2bf50667e09f806d151be5be2789c1dbbd583b6d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/yegor256/netbout/pulls/619/commits","review_comments_url":"https://api.github.com/repos/yegor256/netbout/pulls/619/comments","review_comment_url":"https://api.github.com/repos/yegor256/netbout/pulls/comments{/number}","comments_url":"https://api.github.com/repos/yegor256/netbout/issues/619/comments","statuses_url":"https://api.github.com/repos/yegor256/netbout/statuses/70b36223d6779aab3966a9770f2058d67f981257","head":{"label":"komaz:610","ref":"610","sha":"70b36223d6779aab3966a9770f2058d67f981257","user":{"login":"komaz","id":481692,"avatar_url":"https://avatars.githubusercontent.com/u/481692?v=3","gravatar_id":"","url":"https://api.github.com/users/komaz","html_url":"https://github.com/komaz","followers_url":"https://api.github.com/users/komaz/followers","following_url":"https://api.github.com/users/komaz/following{/other_user}","gists_url":"https://api.github.com/users/komaz/gists{/gist_id}","starred_url":"https://api.github.com/users/komaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/komaz/subscriptions","organizations_url":"https://api.github.com/users/komaz/orgs","repos_url":"https://api.github.com/users/komaz/repos","events_url":"https://api.github.com/users/komaz/events{/privacy}","received_events_url":"https://api.github.com/users/komaz/received_events","type":"User","site_admin":false},"repo":{"id":35950012,"name":"netbout","full_name":"komaz/netbout","owner":{"login":"komaz","id":481692,"avatar_url":"https://avatars.githubusercontent.com/u/481692?v=3","gravatar_id":"","url":"https://api.github.com/users/komaz","html_url":"https://github.com/komaz","followers_url":"https://api.github.com/users/komaz/followers","following_url":"https://api.github.com/users/komaz/following{/other_user}","gists_url":"https://api.github.com/users/komaz/gists{/gist_id}","starred_url":"https://api.github.com/users/komaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/komaz/subscriptions","organizations_url":"https://api.github.com/users/komaz/orgs","repos_url":"https://api.github.com/users/komaz/repos","events_url":"https://api.github.com/users/komaz/events{/privacy}","received_events_url":"https://api.github.com/users/komaz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/komaz/netbout","description":"Private talks made easy","fork":true,"url":"https://api.github.com/repos/komaz/netbout","forks_url":"https://api.github.com/repos/komaz/netbout/forks","keys_url":"https://api.github.com/repos/komaz/netbout/keys{/key_id}","collaborators_url":"https://api.github.com/repos/komaz/netbout/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/komaz/netbout/teams","hooks_url":"https://api.github.com/repos/komaz/netbout/hooks","issue_events_url":"https://api.github.com/repos/komaz/netbout/issues/events{/number}","events_url":"https://api.github.com/repos/komaz/netbout/events","assignees_url":"https://api.github.com/repos/komaz/netbout/assignees{/user}","branches_url":"https://api.github.com/repos/komaz/netbout/branches{/branch}","tags_url":"https://api.github.com/repos/komaz/netbout/tags","blobs_url":"https://api.github.com/repos/komaz/netbout/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/komaz/netbout/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/komaz/netbout/git/refs{/sha}","trees_url":"https://api.github.com/repos/komaz/netbout/git/trees{/sha}","statuses_url":"https://api.github.com/repos/komaz/netbout/statuses/{sha}","languages_url":"https://api.github.com/repos/komaz/netbout/languages","stargazers_url":"https://api.github.com/repos/komaz/netbout/stargazers","contributors_url":"https://api.github.com/repos/komaz/netbout/contributors","subscribers_url":"https://api.github.com/repos/komaz/netbout/subscribers","subscription_url":"https://api.github.com/repos/komaz/netbout/subscription","commits_url":"https://api.github.com/repos/komaz/netbout/commits{/sha}","git_commits_url":"https://api.github.com/repos/komaz/netbout/git/commits{/sha}","comments_url":"https://api.github.com/repos/komaz/netbout/comments{/number}","issue_comment_url":"https://api.github.com/repos/komaz/netbout/issues/comments{/number}","contents_url":"https://api.github.com/repos/komaz/netbout/contents/{+path}","compare_url":"https://api.github.com/repos/komaz/netbout/compare/{base}...{head}","merges_url":"https://api.github.com/repos/komaz/netbout/merges","archive_url":"https://api.github.com/repos/komaz/netbout/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/komaz/netbout/downloads","issues_url":"https://api.github.com/repos/komaz/netbout/issues{/number}","pulls_url":"https://api.github.com/repos/komaz/netbout/pulls{/number}","milestones_url":"https://api.github.com/repos/komaz/netbout/milestones{/number}","notifications_url":"https://api.github.com/repos/komaz/netbout/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/komaz/netbout/labels{/name}","releases_url":"https://api.github.com/repos/komaz/netbout/releases{/id}","created_at":"2015-05-20T13:37:06Z","updated_at":"2015-05-20T13:37:07Z","pushed_at":"2015-05-21T12:04:27Z","git_url":"git://github.com/komaz/netbout.git","ssh_url":"git@github.com:komaz/netbout.git","clone_url":"https://github.com/komaz/netbout.git","svn_url":"https://github.com/komaz/netbout","homepage":"www.netbout.com","size":18756,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"yegor256:master","ref":"master","sha":"0f78840fae460bc92b4d96249c3df0441efbd1ab","user":{"login":"yegor256","id":526301,"avatar_url":"https://avatars.githubusercontent.com/u/526301?v=3","gravatar_id":"","url":"https://api.github.com/users/yegor256","html_url":"https://github.com/yegor256","followers_url":"https://api.github.com/users/yegor256/followers","following_url":"https://api.github.com/users/yegor256/following{/other_user}","gists_url":"https://api.github.com/users/yegor256/gists{/gist_id}","starred_url":"https://api.github.com/users/yegor256/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yegor256/subscriptions","organizations_url":"https://api.github.com/users/yegor256/orgs","repos_url":"https://api.github.com/users/yegor256/repos","events_url":"https://api.github.com/users/yegor256/events{/privacy}","received_events_url":"https://api.github.com/users/yegor256/received_events","type":"User","site_admin":false},"repo":{"id":9580819,"name":"netbout","full_name":"yegor256/netbout","owner":{"login":"yegor256","id":526301,"avatar_url":"https://avatars.githubusercontent.com/u/526301?v=3","gravatar_id":"","url":"https://api.github.com/users/yegor256","html_url":"https://github.com/yegor256","followers_url":"https://api.github.com/users/yegor256/followers","following_url":"https://api.github.com/users/yegor256/following{/other_user}","gists_url":"https://api.github.com/users/yegor256/gists{/gist_id}","starred_url":"https://api.github.com/users/yegor256/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yegor256/subscriptions","organizations_url":"https://api.github.com/users/yegor256/orgs","repos_url":"https://api.github.com/users/yegor256/repos","events_url":"https://api.github.com/users/yegor256/events{/privacy}","received_events_url":"https://api.github.com/users/yegor256/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yegor256/netbout","description":"Private talks made easy","fork":false,"url":"https://api.github.com/repos/yegor256/netbout","forks_url":"https://api.github.com/repos/yegor256/netbout/forks","keys_url":"https://api.github.com/repos/yegor256/netbout/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yegor256/netbout/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yegor256/netbout/teams","hooks_url":"https://api.github.com/repos/yegor256/netbout/hooks","issue_events_url":"https://api.github.com/repos/yegor256/netbout/issues/events{/number}","events_url":"https://api.github.com/repos/yegor256/netbout/events","assignees_url":"https://api.github.com/repos/yegor256/netbout/assignees{/user}","branches_url":"https://api.github.com/repos/yegor256/netbout/branches{/branch}","tags_url":"https://api.github.com/repos/yegor256/netbout/tags","blobs_url":"https://api.github.com/repos/yegor256/netbout/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yegor256/netbout/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yegor256/netbout/git/refs{/sha}","trees_url":"https://api.github.com/repos/yegor256/netbout/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yegor256/netbout/statuses/{sha}","languages_url":"https://api.github.com/repos/yegor256/netbout/languages","stargazers_url":"https://api.github.com/repos/yegor256/netbout/stargazers","contributors_url":"https://api.github.com/repos/yegor256/netbout/contributors","subscribers_url":"https://api.github.com/repos/yegor256/netbout/subscribers","subscription_url":"https://api.github.com/repos/yegor256/netbout/subscription","commits_url":"https://api.github.com/repos/yegor256/netbout/commits{/sha}","git_commits_url":"https://api.github.com/repos/yegor256/netbout/git/commits{/sha}","comments_url":"https://api.github.com/repos/yegor256/netbout/comments{/number}","issue_comment_url":"https://api.github.com/repos/yegor256/netbout/issues/comments{/number}","contents_url":"https://api.github.com/repos/yegor256/netbout/contents/{+path}","compare_url":"https://api.github.com/repos/yegor256/netbout/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yegor256/netbout/merges","archive_url":"https://api.github.com/repos/yegor256/netbout/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yegor256/netbout/downloads","issues_url":"https://api.github.com/repos/yegor256/netbout/issues{/number}","pulls_url":"https://api.github.com/repos/yegor256/netbout/pulls{/number}","milestones_url":"https://api.github.com/repos/yegor256/netbout/milestones{/number}","notifications_url":"https://api.github.com/repos/yegor256/netbout/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yegor256/netbout/labels{/name}","releases_url":"https://api.github.com/repos/yegor256/netbout/releases{/id}","created_at":"2013-04-21T14:49:21Z","updated_at":"2015-04-15T19:36:46Z","pushed_at":"2015-05-21T21:23:16Z","git_url":"git://github.com/yegor256/netbout.git","ssh_url":"git@github.com:yegor256/netbout.git","clone_url":"https://github.com/yegor256/netbout.git","svn_url":"https://github.com/yegor256/netbout","homepage":"www.netbout.com","size":18756,"stargazers_count":8,"watchers_count":8,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":8,"mirror_url":null,"open_issues_count":41,"forks":8,"open_issues":41,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/yegor256/netbout/pulls/619"},"html":{"href":"https://github.com/yegor256/netbout/pull/619"},"issue":{"href":"https://api.github.com/repos/yegor256/netbout/issues/619"},"comments":{"href":"https://api.github.com/repos/yegor256/netbout/issues/619/comments"},"review_comments":{"href":"https://api.github.com/repos/yegor256/netbout/pulls/619/comments"},"review_comment":{"href":"https://api.github.com/repos/yegor256/netbout/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/yegor256/netbout/pulls/619/commits"},"statuses":{"href":"https://api.github.com/repos/yegor256/netbout/statuses/70b36223d6779aab3966a9770f2058d67f981257"}}}}