{"action":"created","comment":{"url":"https://api.github.com/repos/zerocracy/farm/pulls/comments/200846329","pull_request_review_id":135238715,"id":200846329,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMDg0NjMyOQ==","diff_hunk":"@@ -0,0 +1,121 @@\n+/**\n+ * Copyright (c) 2016-2018 Zerocracy\n+ *\n+ * Permission is hereby granted, free of charge, to any person obtaining a copy\n+ * of this software and associated documentation files (the \"Software\"), to read\n+ * the Software only. Permissions is hereby NOT GRANTED to use, copy, modify,\n+ * merge, publish, distribute, sublicense, and/or sell copies of the Software.\n+ *\n+ * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n+ * SOFTWARE.\n+ */\n+package com.zerocracy.pm.staff.votes;\n+\n+import com.zerocracy.Project;\n+import com.zerocracy.farm.fake.FkProject;\n+import com.zerocracy.pm.staff.Elections;\n+import com.zerocracy.pm.staff.Votes;\n+import org.cactoos.Proc;\n+import org.cactoos.iterable.RangeOf;\n+import org.cactoos.list.ListOf;\n+import org.cactoos.map.MapEntry;\n+import org.cactoos.map.MapOf;\n+import org.cactoos.scalar.And;\n+import org.hamcrest.MatcherAssert;\n+import org.hamcrest.Matchers;\n+import org.junit.Test;\n+\n+/**\n+ * Test case for {@link VsOverElected}.\n+ *\n+ * @author Kirill (g4s8.public@gmail.com)\n+ * @version $Id$\n+ * @since 0.24\n+ * @checkstyle JavadocMethodCheck (500 lines)\n+ * @checkstyle MagicNumberCheck (500 lines)\n+ */\n+public final class VsOverElectedTest {\n+    @Test\n+    public void voteForOverElected() throws Exception {\n+        final int max = 9;\n+        final FkProject pkt = new FkProject();\n+        final String login = \"user1\";\n+        new VsOverElectedTest.Elect(pkt, max + 1).exec(login);\n+        MatcherAssert.assertThat(\n+            new VsOverElected(pkt, max).take(login, new StringBuilder(1)),\n+            Matchers.closeTo(1.0, 0.001)\n+        );\n+    }\n+\n+    @Test\n+    public void ignoreForNotOverElected() throws Exception {\n+        final int max = 4;\n+        final FkProject pkt = new FkProject();\n+        final String login = \"user2\";\n+        new VsOverElectedTest.Elect(pkt, max).exec(login);\n+        MatcherAssert.assertThat(\n+            new VsOverElected(pkt, max).take(login, new StringBuilder(1)),\n+            Matchers.closeTo(0.0, 0.001)\n+        );\n+    }\n+\n+    /**\n+     * Fake votes.\n+     */\n+    private static final class VsFake implements Votes {\n+        @Override\n+        public double take(final String login, final StringBuilder log) {\n+            return 1.0;\n+        }\n+    }\n+\n+    /**\n+     * Elect a performer multiple times.\n+     */\n+    private static final class Elect implements Proc<String> {\n+\n+        /**\n+         * Project.\n+         */\n+        private final Project pkt;\n+\n+        /**\n+         * Times to elect.\n+         */\n+        private final int cnt;\n+\n+        /**\n+         * Ctor.\n+         *\n+         * @param project Project\n+         * @param count Times to elect\n+         */\n+        private Elect(final Project project, final int count) {\n+            this.pkt = project;\n+            this.cnt = count;\n+        }\n+\n+        @Override\n+        public void exec(final String login) throws Exception {\n+            final Elections elections = new Elections(this.pkt).bootstrap();\n+            new And(\n+                (Integer num) -> elections.elect(\n+                    String.format(\"gh:test/test#%d\", num),\n+                    new ListOf<>(login),\n+                    new MapOf<Votes, Integer>(","path":"src/test/java/com/zerocracy/pm/staff/votes/VsOverElectedTest.java","position":106,"original_position":110,"commit_id":"78a5654841354aa66ba7bc18b3a0ce63666ebef7","original_commit_id":"ac943ebe5210d9e7143b049741aab7fa5e4bc7d6","user":{"login":"g4s8","id":1524988,"node_id":"MDQ6VXNlcjE1MjQ5ODg=","avatar_url":"https://avatars0.githubusercontent.com/u/1524988?v=4","gravatar_id":"","url":"https://api.github.com/users/g4s8","html_url":"https://github.com/g4s8","followers_url":"https://api.github.com/users/g4s8/followers","following_url":"https://api.github.com/users/g4s8/following{/other_user}","gists_url":"https://api.github.com/users/g4s8/gists{/gist_id}","starred_url":"https://api.github.com/users/g4s8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/g4s8/subscriptions","organizations_url":"https://api.github.com/users/g4s8/orgs","repos_url":"https://api.github.com/users/g4s8/repos","events_url":"https://api.github.com/users/g4s8/events{/privacy}","received_events_url":"https://api.github.com/users/g4s8/received_events","type":"User","site_admin":false},"body":"@krzyk same here (about `javac` warning)","created_at":"2018-07-08T16:45:42Z","updated_at":"2018-07-08T16:45:42Z","html_url":"https://github.com/zerocracy/farm/pull/1375#discussion_r200846329","pull_request_url":"https://api.github.com/repos/zerocracy/farm/pulls/1375","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/zerocracy/farm/pulls/comments/200846329"},"html":{"href":"https://github.com/zerocracy/farm/pull/1375#discussion_r200846329"},"pull_request":{"href":"https://api.github.com/repos/zerocracy/farm/pulls/1375"}},"in_reply_to_id":200822239},"pull_request":{"url":"https://api.github.com/repos/zerocracy/farm/pulls/1375","id":199912155,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk5OTEyMTU1","html_url":"https://github.com/zerocracy/farm/pull/1375","diff_url":"https://github.com/zerocracy/farm/pull/1375.diff","patch_url":"https://github.com/zerocracy/farm/pull/1375.patch","issue_url":"https://api.github.com/repos/zerocracy/farm/issues/1375","number":1375,"state":"open","locked":false,"title":"Prevent over-election","user":{"login":"g4s8","id":1524988,"node_id":"MDQ6VXNlcjE1MjQ5ODg=","avatar_url":"https://avatars0.githubusercontent.com/u/1524988?v=4","gravatar_id":"","url":"https://api.github.com/users/g4s8","html_url":"https://github.com/g4s8","followers_url":"https://api.github.com/users/g4s8/followers","following_url":"https://api.github.com/users/g4s8/following{/other_user}","gists_url":"https://api.github.com/users/g4s8/gists{/gist_id}","starred_url":"https://api.github.com/users/g4s8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/g4s8/subscriptions","organizations_url":"https://api.github.com/users/g4s8/orgs","repos_url":"https://api.github.com/users/g4s8/repos","events_url":"https://api.github.com/users/g4s8/events{/privacy}","received_events_url":"https://api.github.com/users/g4s8/received_events","type":"User","site_admin":false},"body":"#926 - prevent over-election in one project added todo to synchonize multi-project election.","created_at":"2018-07-07T20:20:12Z","updated_at":"2018-07-08T16:45:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"74d6a94ad33374810a7db7231e2495ed7e092b89","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":817441668,"node_id":"MDU6TGFiZWw4MTc0NDE2Njg=","url":"https://api.github.com/repos/zerocracy/farm/labels/scope","name":"scope","color":"3a6622","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/zerocracy/farm/pulls/1375/commits","review_comments_url":"https://api.github.com/repos/zerocracy/farm/pulls/1375/comments","review_comment_url":"https://api.github.com/repos/zerocracy/farm/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zerocracy/farm/issues/1375/comments","statuses_url":"https://api.github.com/repos/zerocracy/farm/statuses/78a5654841354aa66ba7bc18b3a0ce63666ebef7","head":{"label":"zerocracy:926","ref":"926","sha":"78a5654841354aa66ba7bc18b3a0ce63666ebef7","user":{"login":"zerocracy","id":24234201,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI0MjM0MjAx","avatar_url":"https://avatars2.githubusercontent.com/u/24234201?v=4","gravatar_id":"","url":"https://api.github.com/users/zerocracy","html_url":"https://github.com/zerocracy","followers_url":"https://api.github.com/users/zerocracy/followers","following_url":"https://api.github.com/users/zerocracy/following{/other_user}","gists_url":"https://api.github.com/users/zerocracy/gists{/gist_id}","starred_url":"https://api.github.com/users/zerocracy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zerocracy/subscriptions","organizations_url":"https://api.github.com/users/zerocracy/orgs","repos_url":"https://api.github.com/users/zerocracy/repos","events_url":"https://api.github.com/users/zerocracy/events{/privacy}","received_events_url":"https://api.github.com/users/zerocracy/received_events","type":"Organization","site_admin":false},"repo":{"id":75332684,"node_id":"MDEwOlJlcG9zaXRvcnk3NTMzMjY4NA==","name":"farm","full_name":"zerocracy/farm","owner":{"login":"zerocracy","id":24234201,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI0MjM0MjAx","avatar_url":"https://avatars2.githubusercontent.com/u/24234201?v=4","gravatar_id":"","url":"https://api.github.com/users/zerocracy","html_url":"https://github.com/zerocracy","followers_url":"https://api.github.com/users/zerocracy/followers","following_url":"https://api.github.com/users/zerocracy/following{/other_user}","gists_url":"https://api.github.com/users/zerocracy/gists{/gist_id}","starred_url":"https://api.github.com/users/zerocracy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zerocracy/subscriptions","organizations_url":"https://api.github.com/users/zerocracy/orgs","repos_url":"https://api.github.com/users/zerocracy/repos","events_url":"https://api.github.com/users/zerocracy/events{/privacy}","received_events_url":"https://api.github.com/users/zerocracy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zerocracy/farm","description":"Zerocrat Core Engine","fork":false,"url":"https://api.github.com/repos/zerocracy/farm","forks_url":"https://api.github.com/repos/zerocracy/farm/forks","keys_url":"https://api.github.com/repos/zerocracy/farm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zerocracy/farm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zerocracy/farm/teams","hooks_url":"https://api.github.com/repos/zerocracy/farm/hooks","issue_events_url":"https://api.github.com/repos/zerocracy/farm/issues/events{/number}","events_url":"https://api.github.com/repos/zerocracy/farm/events","assignees_url":"https://api.github.com/repos/zerocracy/farm/assignees{/user}","branches_url":"https://api.github.com/repos/zerocracy/farm/branches{/branch}","tags_url":"https://api.github.com/repos/zerocracy/farm/tags","blobs_url":"https://api.github.com/repos/zerocracy/farm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zerocracy/farm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zerocracy/farm/git/refs{/sha}","trees_url":"https://api.github.com/repos/zerocracy/farm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zerocracy/farm/statuses/{sha}","languages_url":"https://api.github.com/repos/zerocracy/farm/languages","stargazers_url":"https://api.github.com/repos/zerocracy/farm/stargazers","contributors_url":"https://api.github.com/repos/zerocracy/farm/contributors","subscribers_url":"https://api.github.com/repos/zerocracy/farm/subscribers","subscription_url":"https://api.github.com/repos/zerocracy/farm/subscription","commits_url":"https://api.github.com/repos/zerocracy/farm/commits{/sha}","git_commits_url":"https://api.github.com/repos/zerocracy/farm/git/commits{/sha}","comments_url":"https://api.github.com/repos/zerocracy/farm/comments{/number}","issue_comment_url":"https://api.github.com/repos/zerocracy/farm/issues/comments{/number}","contents_url":"https://api.github.com/repos/zerocracy/farm/contents/{+path}","compare_url":"https://api.github.com/repos/zerocracy/farm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zerocracy/farm/merges","archive_url":"https://api.github.com/repos/zerocracy/farm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zerocracy/farm/downloads","issues_url":"https://api.github.com/repos/zerocracy/farm/issues{/number}","pulls_url":"https://api.github.com/repos/zerocracy/farm/pulls{/number}","milestones_url":"https://api.github.com/repos/zerocracy/farm/milestones{/number}","notifications_url":"https://api.github.com/repos/zerocracy/farm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zerocracy/farm/labels{/name}","releases_url":"https://api.github.com/repos/zerocracy/farm/releases{/id}","deployments_url":"https://api.github.com/repos/zerocracy/farm/deployments","created_at":"2016-12-01T21:05:11Z","updated_at":"2018-07-07T08:15:56Z","pushed_at":"2018-07-08T16:43:30Z","git_url":"git://github.com/zerocracy/farm.git","ssh_url":"git@github.com:zerocracy/farm.git","clone_url":"https://github.com/zerocracy/farm.git","svn_url":"https://github.com/zerocracy/farm","homepage":"https://www.0crat.com","size":6234,"stargazers_count":132,"watchers_count":132,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":33,"mirror_url":null,"archived":false,"open_issues_count":262,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":33,"open_issues":262,"watchers":132,"default_branch":"master"}},"base":{"label":"zerocracy:master","ref":"master","sha":"448d42486ba16d928bff86384510b53520836a10","user":{"login":"zerocracy","id":24234201,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI0MjM0MjAx","avatar_url":"https://avatars2.githubusercontent.com/u/24234201?v=4","gravatar_id":"","url":"https://api.github.com/users/zerocracy","html_url":"https://github.com/zerocracy","followers_url":"https://api.github.com/users/zerocracy/followers","following_url":"https://api.github.com/users/zerocracy/following{/other_user}","gists_url":"https://api.github.com/users/zerocracy/gists{/gist_id}","starred_url":"https://api.github.com/users/zerocracy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zerocracy/subscriptions","organizations_url":"https://api.github.com/users/zerocracy/orgs","repos_url":"https://api.github.com/users/zerocracy/repos","events_url":"https://api.github.com/users/zerocracy/events{/privacy}","received_events_url":"https://api.github.com/users/zerocracy/received_events","type":"Organization","site_admin":false},"repo":{"id":75332684,"node_id":"MDEwOlJlcG9zaXRvcnk3NTMzMjY4NA==","name":"farm","full_name":"zerocracy/farm","owner":{"login":"zerocracy","id":24234201,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI0MjM0MjAx","avatar_url":"https://avatars2.githubusercontent.com/u/24234201?v=4","gravatar_id":"","url":"https://api.github.com/users/zerocracy","html_url":"https://github.com/zerocracy","followers_url":"https://api.github.com/users/zerocracy/followers","following_url":"https://api.github.com/users/zerocracy/following{/other_user}","gists_url":"https://api.github.com/users/zerocracy/gists{/gist_id}","starred_url":"https://api.github.com/users/zerocracy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zerocracy/subscriptions","organizations_url":"https://api.github.com/users/zerocracy/orgs","repos_url":"https://api.github.com/users/zerocracy/repos","events_url":"https://api.github.com/users/zerocracy/events{/privacy}","received_events_url":"https://api.github.com/users/zerocracy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zerocracy/farm","description":"Zerocrat Core Engine","fork":false,"url":"https://api.github.com/repos/zerocracy/farm","forks_url":"https://api.github.com/repos/zerocracy/farm/forks","keys_url":"https://api.github.com/repos/zerocracy/farm/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zerocracy/farm/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zerocracy/farm/teams","hooks_url":"https://api.github.com/repos/zerocracy/farm/hooks","issue_events_url":"https://api.github.com/repos/zerocracy/farm/issues/events{/number}","events_url":"https://api.github.com/repos/zerocracy/farm/events","assignees_url":"https://api.github.com/repos/zerocracy/farm/assignees{/user}","branches_url":"https://api.github.com/repos/zerocracy/farm/branches{/branch}","tags_url":"https://api.github.com/repos/zerocracy/farm/tags","blobs_url":"https://api.github.com/repos/zerocracy/farm/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zerocracy/farm/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zerocracy/farm/git/refs{/sha}","trees_url":"https://api.github.com/repos/zerocracy/farm/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zerocracy/farm/statuses/{sha}","languages_url":"https://api.github.com/repos/zerocracy/farm/languages","stargazers_url":"https://api.github.com/repos/zerocracy/farm/stargazers","contributors_url":"https://api.github.com/repos/zerocracy/farm/contributors","subscribers_url":"https://api.github.com/repos/zerocracy/farm/subscribers","subscription_url":"https://api.github.com/repos/zerocracy/farm/subscription","commits_url":"https://api.github.com/repos/zerocracy/farm/commits{/sha}","git_commits_url":"https://api.github.com/repos/zerocracy/farm/git/commits{/sha}","comments_url":"https://api.github.com/repos/zerocracy/farm/comments{/number}","issue_comment_url":"https://api.github.com/repos/zerocracy/farm/issues/comments{/number}","contents_url":"https://api.github.com/repos/zerocracy/farm/contents/{+path}","compare_url":"https://api.github.com/repos/zerocracy/farm/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zerocracy/farm/merges","archive_url":"https://api.github.com/repos/zerocracy/farm/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zerocracy/farm/downloads","issues_url":"https://api.github.com/repos/zerocracy/farm/issues{/number}","pulls_url":"https://api.github.com/repos/zerocracy/farm/pulls{/number}","milestones_url":"https://api.github.com/repos/zerocracy/farm/milestones{/number}","notifications_url":"https://api.github.com/repos/zerocracy/farm/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zerocracy/farm/labels{/name}","releases_url":"https://api.github.com/repos/zerocracy/farm/releases{/id}","deployments_url":"https://api.github.com/repos/zerocracy/farm/deployments","created_at":"2016-12-01T21:05:11Z","updated_at":"2018-07-07T08:15:56Z","pushed_at":"2018-07-08T16:43:30Z","git_url":"git://github.com/zerocracy/farm.git","ssh_url":"git@github.com:zerocracy/farm.git","clone_url":"https://github.com/zerocracy/farm.git","svn_url":"https://github.com/zerocracy/farm","homepage":"https://www.0crat.com","size":6234,"stargazers_count":132,"watchers_count":132,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":33,"mirror_url":null,"archived":false,"open_issues_count":262,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":33,"open_issues":262,"watchers":132,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/zerocracy/farm/pulls/1375"},"html":{"href":"https://github.com/zerocracy/farm/pull/1375"},"issue":{"href":"https://api.github.com/repos/zerocracy/farm/issues/1375"},"comments":{"href":"https://api.github.com/repos/zerocracy/farm/issues/1375/comments"},"review_comments":{"href":"https://api.github.com/repos/zerocracy/farm/pulls/1375/comments"},"review_comment":{"href":"https://api.github.com/repos/zerocracy/farm/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zerocracy/farm/pulls/1375/commits"},"statuses":{"href":"https://api.github.com/repos/zerocracy/farm/statuses/78a5654841354aa66ba7bc18b3a0ce63666ebef7"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"g4s8"}}