{"action":"created","comment":{"url":"https://api.github.com/repos/yegor256/takes/pulls/comments/27348159","id":27348159,"diff_hunk":"@@ -23,34 +23,149 @@\n  */\n package org.takes.facets.auth;\n \n+import com.google.common.collect.ImmutableMap;\n import java.io.IOException;\n import org.hamcrest.MatcherAssert;\n import org.hamcrest.Matchers;\n+import org.junit.Before;\n import org.junit.Test;\n+import org.mockito.Mock;\n+import org.takes.Response;\n import org.takes.rq.RqFake;\n+import org.takes.rs.RsWithBody;\n+import org.takes.rs.RsWithStatus;\n+import org.takes.rs.RsWithType;\n \n /**\n  * Test case for {@link PsByFlag}.\n+ *\n  * @author Yegor Bugayenko (yegor@teamed.io)\n  * @version $Id$\n  * @since 0.10\n  */\n public final class PsByFlagTest {\n+    /**\n+     * Testable PsByFlag object.\n+     */\n+    private static PsByFlag psbyflag;\n+    /**\n+     * Key.\n+     */\n+    private static final String KEY = \"some-key\";\n+    /**\n+     * HTTP request method.\n+     */\n+    private static final String METHOD = \"GET\";\n+\n+    /**\n+     * Mocked Identity object used to test exit method.\n+     */\n+    @Mock\n+    private static Identity identity;\n+\n+    /**\n+     * Test set up.\n+     *\n+     * @throws Exception If some problem inside\n+     */\n+    @Before\n+    public void setUp() throws Exception {\n+        psbyflag = new PsByFlag(\n+            new PsByFlag.Pair(\n+                KEY, new PsFake(true)\n+            )\n+        );\n+    }\n \n     /**\n      * PsByFlag can skip if nothing found.\n+     *\n      * @throws IOException If some problem inside\n      */\n     @Test\n     public void skipsIfNothingFound() throws IOException {\n         MatcherAssert.assertThat(\n+            psbyflag.enter(\n+                new RqFake(METHOD, \"/?PsByFlag=x\")\n+            ).hasNext(),\n+            Matchers.is(false)\n+        );\n+    }\n+\n+    /**\n+     * PsByFlag finds flag and authenticates user.\n+     *\n+     * @throws IOException If some problem inside\n+     */\n+    @Test\n+    public void flagIsFoundUserAuthenticated() throws IOException {\n+        MatcherAssert.assertThat(\n+            psbyflag.enter(\n+                new RqFake(METHOD, \"/?PsByFlag=some-key\")\n+            ).next().urn(),\n+            Matchers.is(\"urn:test:1\")\n+        );\n+    }\n+\n+    /**\n+     * PsByFlag wraps response with authenticated user.\n+     *\n+     * @throws IOException If some problem inside\n+     */\n+    @Test\n+    public void exitTest() throws IOException {\n+        final Response response = new RsWithStatus(\n+            new RsWithType(\n+                new RsWithBody(\"<html>This is test response</html>\"),\n+                    \"text/html\"\n+            ),\n+            200\n+        );\n+        MatcherAssert.assertThat(\n             new PsByFlag(\n                 new PsByFlag.Pair(\n-                    \"some-key\", new PsFake(true)\n+                    KEY, new PsFake(true)\n                 )\n-            ).enter(new RqFake(\"GET\", \"/?PsByFlag=x\")).hasNext(),\n-            Matchers.is(false)\n+            ).exit(response, identity),\n+            Matchers.is(response)\n         );\n     }\n \n+    /**\n+     * Checks PsByFlag equality.\n+     *\n+     * @throws Exception If some problem inside\n+     */\n+    @Test\n+    public void equalsAndHashCodeEqualTest() throws Exception {\n+        MatcherAssert.assertThat(\n+            psbyflag.equals(\n+                new PsByFlag(\n+                    new PsByFlag.Pair(\n+                        KEY, new PsFake(true)\n+                    )\n+                )\n+            ),\n+            Matchers.is(true)\n+        );\n+    }\n+\n+    /**\n+     * Checks PsByFlag inequality.\n+     *\n+     * @throws Exception If some problem inside\n+     */\n+    @Test\n+    public void equalsAndHashCodeNotEqualTest() throws Exception {","path":"src/test/java/org/takes/facets/auth/PsByFlagTest.java","position":140,"original_position":140,"commit_id":"72a8374682884a950d75fde1a7c711f48e250afc","original_commit_id":"72a8374682884a950d75fde1a7c711f48e250afc","user":{"login":"longtimeago","id":1388994,"avatar_url":"https://avatars.githubusercontent.com/u/1388994?v=3","gravatar_id":"","url":"https://api.github.com/users/longtimeago","html_url":"https://github.com/longtimeago","followers_url":"https://api.github.com/users/longtimeago/followers","following_url":"https://api.github.com/users/longtimeago/following{/other_user}","gists_url":"https://api.github.com/users/longtimeago/gists{/gist_id}","starred_url":"https://api.github.com/users/longtimeago/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/longtimeago/subscriptions","organizations_url":"https://api.github.com/users/longtimeago/orgs","repos_url":"https://api.github.com/users/longtimeago/repos","events_url":"https://api.github.com/users/longtimeago/events{/privacy}","received_events_url":"https://api.github.com/users/longtimeago/received_events","type":"User","site_admin":false},"body":"same here","created_at":"2015-03-28T20:23:37Z","updated_at":"2015-03-28T20:23:37Z","html_url":"https://github.com/yegor256/takes/pull/81#discussion_r27348159","pull_request_url":"https://api.github.com/repos/yegor256/takes/pulls/81","_links":{"self":{"href":"https://api.github.com/repos/yegor256/takes/pulls/comments/27348159"},"html":{"href":"https://github.com/yegor256/takes/pull/81#discussion_r27348159"},"pull_request":{"href":"https://api.github.com/repos/yegor256/takes/pulls/81"}}},"pull_request":{"url":"https://api.github.com/repos/yegor256/takes/pulls/81","id":32069692,"html_url":"https://github.com/yegor256/takes/pull/81","diff_url":"https://github.com/yegor256/takes/pull/81.diff","patch_url":"https://github.com/yegor256/takes/pull/81.patch","issue_url":"https://api.github.com/repos/yegor256/takes/issues/81","number":81,"state":"open","locked":false,"title":" PsByFlag is not tested #40","user":{"login":"ikhvostenkov","id":861305,"avatar_url":"https://avatars.githubusercontent.com/u/861305?v=3","gravatar_id":"","url":"https://api.github.com/users/ikhvostenkov","html_url":"https://github.com/ikhvostenkov","followers_url":"https://api.github.com/users/ikhvostenkov/followers","following_url":"https://api.github.com/users/ikhvostenkov/following{/other_user}","gists_url":"https://api.github.com/users/ikhvostenkov/gists{/gist_id}","starred_url":"https://api.github.com/users/ikhvostenkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ikhvostenkov/subscriptions","organizations_url":"https://api.github.com/users/ikhvostenkov/orgs","repos_url":"https://api.github.com/users/ikhvostenkov/repos","events_url":"https://api.github.com/users/ikhvostenkov/events{/privacy}","received_events_url":"https://api.github.com/users/ikhvostenkov/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-03-26T22:57:09Z","updated_at":"2015-03-28T20:23:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"84844cb1bee1a35dd5ac4f579cc8afb5fe9ddc30","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/yegor256/takes/pulls/81/commits","review_comments_url":"https://api.github.com/repos/yegor256/takes/pulls/81/comments","review_comment_url":"https://api.github.com/repos/yegor256/takes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/yegor256/takes/issues/81/comments","statuses_url":"https://api.github.com/repos/yegor256/takes/statuses/72a8374682884a950d75fde1a7c711f48e250afc","head":{"label":"ikhvostenkov:master","ref":"master","sha":"72a8374682884a950d75fde1a7c711f48e250afc","user":{"login":"ikhvostenkov","id":861305,"avatar_url":"https://avatars.githubusercontent.com/u/861305?v=3","gravatar_id":"","url":"https://api.github.com/users/ikhvostenkov","html_url":"https://github.com/ikhvostenkov","followers_url":"https://api.github.com/users/ikhvostenkov/followers","following_url":"https://api.github.com/users/ikhvostenkov/following{/other_user}","gists_url":"https://api.github.com/users/ikhvostenkov/gists{/gist_id}","starred_url":"https://api.github.com/users/ikhvostenkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ikhvostenkov/subscriptions","organizations_url":"https://api.github.com/users/ikhvostenkov/orgs","repos_url":"https://api.github.com/users/ikhvostenkov/repos","events_url":"https://api.github.com/users/ikhvostenkov/events{/privacy}","received_events_url":"https://api.github.com/users/ikhvostenkov/received_events","type":"User","site_admin":false},"repo":{"id":32858587,"name":"takes","full_name":"ikhvostenkov/takes","owner":{"login":"ikhvostenkov","id":861305,"avatar_url":"https://avatars.githubusercontent.com/u/861305?v=3","gravatar_id":"","url":"https://api.github.com/users/ikhvostenkov","html_url":"https://github.com/ikhvostenkov","followers_url":"https://api.github.com/users/ikhvostenkov/followers","following_url":"https://api.github.com/users/ikhvostenkov/following{/other_user}","gists_url":"https://api.github.com/users/ikhvostenkov/gists{/gist_id}","starred_url":"https://api.github.com/users/ikhvostenkov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ikhvostenkov/subscriptions","organizations_url":"https://api.github.com/users/ikhvostenkov/orgs","repos_url":"https://api.github.com/users/ikhvostenkov/repos","events_url":"https://api.github.com/users/ikhvostenkov/events{/privacy}","received_events_url":"https://api.github.com/users/ikhvostenkov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ikhvostenkov/takes","description":"True Object-Oriented and Immutable Java Web Framework","fork":true,"url":"https://api.github.com/repos/ikhvostenkov/takes","forks_url":"https://api.github.com/repos/ikhvostenkov/takes/forks","keys_url":"https://api.github.com/repos/ikhvostenkov/takes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ikhvostenkov/takes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ikhvostenkov/takes/teams","hooks_url":"https://api.github.com/repos/ikhvostenkov/takes/hooks","issue_events_url":"https://api.github.com/repos/ikhvostenkov/takes/issues/events{/number}","events_url":"https://api.github.com/repos/ikhvostenkov/takes/events","assignees_url":"https://api.github.com/repos/ikhvostenkov/takes/assignees{/user}","branches_url":"https://api.github.com/repos/ikhvostenkov/takes/branches{/branch}","tags_url":"https://api.github.com/repos/ikhvostenkov/takes/tags","blobs_url":"https://api.github.com/repos/ikhvostenkov/takes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ikhvostenkov/takes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ikhvostenkov/takes/git/refs{/sha}","trees_url":"https://api.github.com/repos/ikhvostenkov/takes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ikhvostenkov/takes/statuses/{sha}","languages_url":"https://api.github.com/repos/ikhvostenkov/takes/languages","stargazers_url":"https://api.github.com/repos/ikhvostenkov/takes/stargazers","contributors_url":"https://api.github.com/repos/ikhvostenkov/takes/contributors","subscribers_url":"https://api.github.com/repos/ikhvostenkov/takes/subscribers","subscription_url":"https://api.github.com/repos/ikhvostenkov/takes/subscription","commits_url":"https://api.github.com/repos/ikhvostenkov/takes/commits{/sha}","git_commits_url":"https://api.github.com/repos/ikhvostenkov/takes/git/commits{/sha}","comments_url":"https://api.github.com/repos/ikhvostenkov/takes/comments{/number}","issue_comment_url":"https://api.github.com/repos/ikhvostenkov/takes/issues/comments{/number}","contents_url":"https://api.github.com/repos/ikhvostenkov/takes/contents/{+path}","compare_url":"https://api.github.com/repos/ikhvostenkov/takes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ikhvostenkov/takes/merges","archive_url":"https://api.github.com/repos/ikhvostenkov/takes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ikhvostenkov/takes/downloads","issues_url":"https://api.github.com/repos/ikhvostenkov/takes/issues{/number}","pulls_url":"https://api.github.com/repos/ikhvostenkov/takes/pulls{/number}","milestones_url":"https://api.github.com/repos/ikhvostenkov/takes/milestones{/number}","notifications_url":"https://api.github.com/repos/ikhvostenkov/takes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ikhvostenkov/takes/labels{/name}","releases_url":"https://api.github.com/repos/ikhvostenkov/takes/releases{/id}","created_at":"2015-03-25T10:46:39Z","updated_at":"2015-03-27T22:53:47Z","pushed_at":"2015-03-27T22:53:47Z","git_url":"git://github.com/ikhvostenkov/takes.git","ssh_url":"git@github.com:ikhvostenkov/takes.git","clone_url":"https://github.com/ikhvostenkov/takes.git","svn_url":"https://github.com/ikhvostenkov/takes","homepage":"http://www.takes.org","size":8549,"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":"75edd65b0da181d5c6f3dd07163102077695bbc7","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":28924109,"name":"takes","full_name":"yegor256/takes","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/takes","description":"True Object-Oriented and Immutable Java Web Framework","fork":false,"url":"https://api.github.com/repos/yegor256/takes","forks_url":"https://api.github.com/repos/yegor256/takes/forks","keys_url":"https://api.github.com/repos/yegor256/takes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yegor256/takes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yegor256/takes/teams","hooks_url":"https://api.github.com/repos/yegor256/takes/hooks","issue_events_url":"https://api.github.com/repos/yegor256/takes/issues/events{/number}","events_url":"https://api.github.com/repos/yegor256/takes/events","assignees_url":"https://api.github.com/repos/yegor256/takes/assignees{/user}","branches_url":"https://api.github.com/repos/yegor256/takes/branches{/branch}","tags_url":"https://api.github.com/repos/yegor256/takes/tags","blobs_url":"https://api.github.com/repos/yegor256/takes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yegor256/takes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yegor256/takes/git/refs{/sha}","trees_url":"https://api.github.com/repos/yegor256/takes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yegor256/takes/statuses/{sha}","languages_url":"https://api.github.com/repos/yegor256/takes/languages","stargazers_url":"https://api.github.com/repos/yegor256/takes/stargazers","contributors_url":"https://api.github.com/repos/yegor256/takes/contributors","subscribers_url":"https://api.github.com/repos/yegor256/takes/subscribers","subscription_url":"https://api.github.com/repos/yegor256/takes/subscription","commits_url":"https://api.github.com/repos/yegor256/takes/commits{/sha}","git_commits_url":"https://api.github.com/repos/yegor256/takes/git/commits{/sha}","comments_url":"https://api.github.com/repos/yegor256/takes/comments{/number}","issue_comment_url":"https://api.github.com/repos/yegor256/takes/issues/comments{/number}","contents_url":"https://api.github.com/repos/yegor256/takes/contents/{+path}","compare_url":"https://api.github.com/repos/yegor256/takes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yegor256/takes/merges","archive_url":"https://api.github.com/repos/yegor256/takes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yegor256/takes/downloads","issues_url":"https://api.github.com/repos/yegor256/takes/issues{/number}","pulls_url":"https://api.github.com/repos/yegor256/takes/pulls{/number}","milestones_url":"https://api.github.com/repos/yegor256/takes/milestones{/number}","notifications_url":"https://api.github.com/repos/yegor256/takes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yegor256/takes/labels{/name}","releases_url":"https://api.github.com/repos/yegor256/takes/releases{/id}","created_at":"2015-01-07T16:57:47Z","updated_at":"2015-03-28T18:17:56Z","pushed_at":"2015-03-28T19:52:29Z","git_url":"git://github.com/yegor256/takes.git","ssh_url":"git@github.com:yegor256/takes.git","clone_url":"https://github.com/yegor256/takes.git","svn_url":"https://github.com/yegor256/takes","homepage":"http://www.takes.org","size":12166,"stargazers_count":30,"watchers_count":30,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":7,"mirror_url":null,"open_issues_count":24,"forks":7,"open_issues":24,"watchers":30,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/yegor256/takes/pulls/81"},"html":{"href":"https://github.com/yegor256/takes/pull/81"},"issue":{"href":"https://api.github.com/repos/yegor256/takes/issues/81"},"comments":{"href":"https://api.github.com/repos/yegor256/takes/issues/81/comments"},"review_comments":{"href":"https://api.github.com/repos/yegor256/takes/pulls/81/comments"},"review_comment":{"href":"https://api.github.com/repos/yegor256/takes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/yegor256/takes/pulls/81/commits"},"statuses":{"href":"https://api.github.com/repos/yegor256/takes/statuses/72a8374682884a950d75fde1a7c711f48e250afc"}}}}