{"action":"created","comment":{"url":"https://api.github.com/repos/is51/catan/pulls/comments/40267662","id":40267662,"diff_hunk":"@@ -0,0 +1,171 @@\n+package catan.controllers.play;\n+\n+import catan.config.ApplicationConfig;\n+import org.junit.Before;\n+import org.junit.Test;\n+import org.junit.runner.RunWith;\n+import org.springframework.boot.test.SpringApplicationConfiguration;\n+import org.springframework.boot.test.WebIntegrationTest;\n+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;\n+\n+import static org.hamcrest.Matchers.equalTo;\n+import static org.hamcrest.Matchers.is;\n+import static org.hamcrest.Matchers.nullValue;\n+\n+\n+@RunWith(SpringJUnit4ClassRunner.class)\n+@SpringApplicationConfiguration(classes = ApplicationConfig.class)\n+@WebIntegrationTest(\"server.port:8091\")\n+public class BuildSettlementTest extends PlayTestUtil {\n+\n+    public static final String USER_NAME_1 = \"user1_StartGameTest\";\n+    public static final String USER_PASSWORD_1 = \"password1\";\n+    public static final String USER_NAME_2 = \"user2_StartGameTest\";\n+    public static final String USER_PASSWORD_2 = \"password2\";\n+    public static final String USER_NAME_3 = \"user3_StartGameTest\";\n+    public static final String USER_PASSWORD_3 = \"password3\";\n+\n+    private static boolean initialized = false;\n+\n+    @Before\n+    public void setup() {\n+        if (!initialized) {\n+            registerUser(USER_NAME_1, USER_PASSWORD_1);\n+            registerUser(USER_NAME_2, USER_PASSWORD_2);\n+            registerUser(USER_NAME_3, USER_PASSWORD_3);\n+            initialized = true;\n+        }\n+    }\n+\n+    @Test\n+    public void should_successfully_build_settlement_on_empty_node() {\n+        String userToken1 = loginUser(USER_NAME_1, USER_PASSWORD_1);\n+        String userToken2 = loginUser(USER_NAME_2, USER_PASSWORD_2);\n+        String userToken3 = loginUser(USER_NAME_3, USER_PASSWORD_3);\n+\n+        int gameId = createNewGame(userToken1, false).path(\"gameId\");\n+        int node_id = viewGame(userToken1, gameId).path(\"map.nodes[0].nodeId\");\n+        //TODO: need to fetch gameUserId from JSON, but now it is not returned\n+        //int gameUser_1_Id = viewGame(userToken1, gameId).path(\"gameUsers[0].id\");\n+\n+\n+        joinPublicGame(userToken2, gameId);\n+        joinPublicGame(userToken3, gameId);\n+\n+        setUserReady(userToken1, gameId);\n+        setUserReady(userToken2, gameId);\n+        setUserReady(userToken3, gameId);\n+\n+        viewGame(userToken1, gameId)\n+                .then()\n+                .statusCode(200)\n+                .body(\"map.nodes[0].nodeId\", is(node_id))\n+                .body(\"map.nodes[0].building\", nullValue())\n+                .body(\"status\", equalTo(\"PLAYING\"));\n+\n+        buildSettlement(userToken1, gameId, node_id)\n+                .then()\n+                .statusCode(200)\n+                .body(\"map.nodes[0].nodeId\", is(node_id))\n+                .body(\"map.nodes[0].building.ownerGameUserId\", is(1))   //need to compare with gameUser_1_Id, when it will be available\n+                .body(\"map.nodes[0].building.built\", equalTo(\"SETTLEMENT\"))\n+                .body(\"status\", equalTo(\"PLAYING\"));\n+    }\n+\n+    @Test\n+    public void should_fail_if_try_to_build_settlement_on_existing_settlement() {\n+        String userToken1 = loginUser(USER_NAME_1, USER_PASSWORD_1);\n+        String userToken2 = loginUser(USER_NAME_2, USER_PASSWORD_2);\n+        String userToken3 = loginUser(USER_NAME_3, USER_PASSWORD_3);\n+\n+        int gameId = createNewGame(userToken1, false).path(\"gameId\");\n+        int node_id = viewGame(userToken1, gameId).path(\"map.nodes[0].nodeId\");\n+        //TODO: need to fetch gameUserId from JSON, but now it is not returned\n+        //int gameUser_1_Id = viewGame(userToken1, gameId).path(\"gameUsers[0].id\");\n+\n+        joinPublicGame(userToken2, gameId);\n+        joinPublicGame(userToken3, gameId);\n+\n+        setUserReady(userToken1, gameId);\n+        setUserReady(userToken2, gameId);\n+        setUserReady(userToken3, gameId);\n+\n+        viewGame(userToken1, gameId)\n+                .then()\n+                .statusCode(200)\n+                .body(\"map.nodes[0].nodeId\", is(node_id))\n+                .body(\"map.nodes[0].building\", nullValue())\n+                .body(\"status\", equalTo(\"PLAYING\"));\n+\n+        buildSettlement(userToken1, gameId, node_id)\n+                .then()\n+                .statusCode(200)\n+                .body(\"map.nodes[0].nodeId\", is(node_id))\n+                .body(\"map.nodes[0].building.ownerGameUserId\", is(1))   //need to compare with gameUser_1_Id, when it will be available\n+                .body(\"map.nodes[0].building.built\", equalTo(\"SETTLEMENT\"))\n+                .body(\"status\", equalTo(\"PLAYING\"));\n+\n+        buildSettlement(userToken2, gameId, node_id)\n+                .then()\n+                .statusCode(400)\n+                .body(\"errorCode\", equalTo(\"ERROR\"));\n+    }\n+\n+    @Test\n+    public void should_fail_if_try_to_build_settlement_close_to_another_settlement_less_than_2_roads() {\n+        String userToken1 = loginUser(USER_NAME_1, USER_PASSWORD_1);\n+        String userToken2 = loginUser(USER_NAME_2, USER_PASSWORD_2);\n+        String userToken3 = loginUser(USER_NAME_3, USER_PASSWORD_3);\n+\n+        int gameId = createNewGame(userToken1, false).path(\"gameId\");\n+        int node_id = viewGame(userToken1, gameId).path(\"map.nodes[0].nodeId\");\n+\n+        //TODO: need to fetch gameUserId from JSON, but now it is not returned\n+        //int gameUser_1_Id = viewGame(userToken1, gameId).path(\"gameUsers[0].id\");\n+\n+        joinPublicGame(userToken2, gameId);\n+        joinPublicGame(userToken3, gameId);\n+\n+        setUserReady(userToken1, gameId);\n+        setUserReady(userToken2, gameId);\n+        setUserReady(userToken3, gameId);\n+\n+        viewGame(userToken1, gameId)\n+                .then()\n+                .statusCode(200)\n+                .body(\"map.nodes[0].nodeId\", is(node_id))\n+                .body(\"map.nodes[0].building\", nullValue())\n+                .body(\"status\", equalTo(\"PLAYING\"));\n+\n+        buildSettlement(userToken1, gameId, node_id)\n+                .then()\n+                .statusCode(200)\n+                .body(\"map.nodes[0].nodeId\", is(node_id))\n+                .body(\"map.nodes[0].building.ownerGameUserId\", is(1))   //need to compare with gameUser_1_Id, when it will be available","path":"src/test/java/catan/controllers/play/BuildSettlementTest.java","position":144,"original_position":144,"commit_id":"3489d09567f209583ba0ebd773c22d63cf09fe92","original_commit_id":"3489d09567f209583ba0ebd773c22d63cf09fe92","user":{"login":"ypetrenko","id":13055024,"avatar_url":"https://avatars.githubusercontent.com/u/13055024?v=3","gravatar_id":"","url":"https://api.github.com/users/ypetrenko","html_url":"https://github.com/ypetrenko","followers_url":"https://api.github.com/users/ypetrenko/followers","following_url":"https://api.github.com/users/ypetrenko/following{/other_user}","gists_url":"https://api.github.com/users/ypetrenko/gists{/gist_id}","starred_url":"https://api.github.com/users/ypetrenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ypetrenko/subscriptions","organizations_url":"https://api.github.com/users/ypetrenko/orgs","repos_url":"https://api.github.com/users/ypetrenko/repos","events_url":"https://api.github.com/users/ypetrenko/events{/privacy}","received_events_url":"https://api.github.com/users/ypetrenko/received_events","type":"User","site_admin":false},"body":"we can check userId instead of gameUserId:\r\n.body(\"map.nodes[0].building.buildingOwner.user.id\", is(...))","created_at":"2015-09-23T22:46:13Z","updated_at":"2015-09-23T22:46:13Z","html_url":"https://github.com/is51/catan/pull/12#discussion_r40267662","pull_request_url":"https://api.github.com/repos/is51/catan/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/is51/catan/pulls/comments/40267662"},"html":{"href":"https://github.com/is51/catan/pull/12#discussion_r40267662"},"pull_request":{"href":"https://api.github.com/repos/is51/catan/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/is51/catan/pulls/12","id":45840764,"html_url":"https://github.com/is51/catan/pull/12","diff_url":"https://github.com/is51/catan/pull/12.diff","patch_url":"https://github.com/is51/catan/pull/12.patch","issue_url":"https://api.github.com/repos/is51/catan/issues/12","number":12,"state":"open","locked":false,"title":"Us 40 add build settlement functionality","user":{"login":"ypetrenko","id":13055024,"avatar_url":"https://avatars.githubusercontent.com/u/13055024?v=3","gravatar_id":"","url":"https://api.github.com/users/ypetrenko","html_url":"https://github.com/ypetrenko","followers_url":"https://api.github.com/users/ypetrenko/followers","following_url":"https://api.github.com/users/ypetrenko/following{/other_user}","gists_url":"https://api.github.com/users/ypetrenko/gists{/gist_id}","starred_url":"https://api.github.com/users/ypetrenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ypetrenko/subscriptions","organizations_url":"https://api.github.com/users/ypetrenko/orgs","repos_url":"https://api.github.com/users/ypetrenko/repos","events_url":"https://api.github.com/users/ypetrenko/events{/privacy}","received_events_url":"https://api.github.com/users/ypetrenko/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-23T22:41:25Z","updated_at":"2015-09-23T22:46:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e8043399841ced1dea67fb39076b90e895e19f89","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/is51/catan/pulls/12/commits","review_comments_url":"https://api.github.com/repos/is51/catan/pulls/12/comments","review_comment_url":"https://api.github.com/repos/is51/catan/pulls/comments{/number}","comments_url":"https://api.github.com/repos/is51/catan/issues/12/comments","statuses_url":"https://api.github.com/repos/is51/catan/statuses/3489d09567f209583ba0ebd773c22d63cf09fe92","head":{"label":"is51:US-40_Add_build_settlement_functionality","ref":"US-40_Add_build_settlement_functionality","sha":"3489d09567f209583ba0ebd773c22d63cf09fe92","user":{"login":"is51","id":13038634,"avatar_url":"https://avatars.githubusercontent.com/u/13038634?v=3","gravatar_id":"","url":"https://api.github.com/users/is51","html_url":"https://github.com/is51","followers_url":"https://api.github.com/users/is51/followers","following_url":"https://api.github.com/users/is51/following{/other_user}","gists_url":"https://api.github.com/users/is51/gists{/gist_id}","starred_url":"https://api.github.com/users/is51/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/is51/subscriptions","organizations_url":"https://api.github.com/users/is51/orgs","repos_url":"https://api.github.com/users/is51/repos","events_url":"https://api.github.com/users/is51/events{/privacy}","received_events_url":"https://api.github.com/users/is51/received_events","type":"Organization","site_admin":false},"repo":{"id":38006336,"name":"catan","full_name":"is51/catan","owner":{"login":"is51","id":13038634,"avatar_url":"https://avatars.githubusercontent.com/u/13038634?v=3","gravatar_id":"","url":"https://api.github.com/users/is51","html_url":"https://github.com/is51","followers_url":"https://api.github.com/users/is51/followers","following_url":"https://api.github.com/users/is51/following{/other_user}","gists_url":"https://api.github.com/users/is51/gists{/gist_id}","starred_url":"https://api.github.com/users/is51/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/is51/subscriptions","organizations_url":"https://api.github.com/users/is51/orgs","repos_url":"https://api.github.com/users/is51/repos","events_url":"https://api.github.com/users/is51/events{/privacy}","received_events_url":"https://api.github.com/users/is51/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/is51/catan","description":"","fork":false,"url":"https://api.github.com/repos/is51/catan","forks_url":"https://api.github.com/repos/is51/catan/forks","keys_url":"https://api.github.com/repos/is51/catan/keys{/key_id}","collaborators_url":"https://api.github.com/repos/is51/catan/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/is51/catan/teams","hooks_url":"https://api.github.com/repos/is51/catan/hooks","issue_events_url":"https://api.github.com/repos/is51/catan/issues/events{/number}","events_url":"https://api.github.com/repos/is51/catan/events","assignees_url":"https://api.github.com/repos/is51/catan/assignees{/user}","branches_url":"https://api.github.com/repos/is51/catan/branches{/branch}","tags_url":"https://api.github.com/repos/is51/catan/tags","blobs_url":"https://api.github.com/repos/is51/catan/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/is51/catan/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/is51/catan/git/refs{/sha}","trees_url":"https://api.github.com/repos/is51/catan/git/trees{/sha}","statuses_url":"https://api.github.com/repos/is51/catan/statuses/{sha}","languages_url":"https://api.github.com/repos/is51/catan/languages","stargazers_url":"https://api.github.com/repos/is51/catan/stargazers","contributors_url":"https://api.github.com/repos/is51/catan/contributors","subscribers_url":"https://api.github.com/repos/is51/catan/subscribers","subscription_url":"https://api.github.com/repos/is51/catan/subscription","commits_url":"https://api.github.com/repos/is51/catan/commits{/sha}","git_commits_url":"https://api.github.com/repos/is51/catan/git/commits{/sha}","comments_url":"https://api.github.com/repos/is51/catan/comments{/number}","issue_comment_url":"https://api.github.com/repos/is51/catan/issues/comments{/number}","contents_url":"https://api.github.com/repos/is51/catan/contents/{+path}","compare_url":"https://api.github.com/repos/is51/catan/compare/{base}...{head}","merges_url":"https://api.github.com/repos/is51/catan/merges","archive_url":"https://api.github.com/repos/is51/catan/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/is51/catan/downloads","issues_url":"https://api.github.com/repos/is51/catan/issues{/number}","pulls_url":"https://api.github.com/repos/is51/catan/pulls{/number}","milestones_url":"https://api.github.com/repos/is51/catan/milestones{/number}","notifications_url":"https://api.github.com/repos/is51/catan/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/is51/catan/labels{/name}","releases_url":"https://api.github.com/repos/is51/catan/releases{/id}","created_at":"2015-06-24T19:28:17Z","updated_at":"2015-06-26T22:01:06Z","pushed_at":"2015-09-23T22:41:25Z","git_url":"git://github.com/is51/catan.git","ssh_url":"git@github.com:is51/catan.git","clone_url":"https://github.com/is51/catan.git","svn_url":"https://github.com/is51/catan","homepage":null,"size":3196,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"is51:master","ref":"master","sha":"2f200284dc471d3becb31502ce41ce3fa8252f7a","user":{"login":"is51","id":13038634,"avatar_url":"https://avatars.githubusercontent.com/u/13038634?v=3","gravatar_id":"","url":"https://api.github.com/users/is51","html_url":"https://github.com/is51","followers_url":"https://api.github.com/users/is51/followers","following_url":"https://api.github.com/users/is51/following{/other_user}","gists_url":"https://api.github.com/users/is51/gists{/gist_id}","starred_url":"https://api.github.com/users/is51/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/is51/subscriptions","organizations_url":"https://api.github.com/users/is51/orgs","repos_url":"https://api.github.com/users/is51/repos","events_url":"https://api.github.com/users/is51/events{/privacy}","received_events_url":"https://api.github.com/users/is51/received_events","type":"Organization","site_admin":false},"repo":{"id":38006336,"name":"catan","full_name":"is51/catan","owner":{"login":"is51","id":13038634,"avatar_url":"https://avatars.githubusercontent.com/u/13038634?v=3","gravatar_id":"","url":"https://api.github.com/users/is51","html_url":"https://github.com/is51","followers_url":"https://api.github.com/users/is51/followers","following_url":"https://api.github.com/users/is51/following{/other_user}","gists_url":"https://api.github.com/users/is51/gists{/gist_id}","starred_url":"https://api.github.com/users/is51/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/is51/subscriptions","organizations_url":"https://api.github.com/users/is51/orgs","repos_url":"https://api.github.com/users/is51/repos","events_url":"https://api.github.com/users/is51/events{/privacy}","received_events_url":"https://api.github.com/users/is51/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/is51/catan","description":"","fork":false,"url":"https://api.github.com/repos/is51/catan","forks_url":"https://api.github.com/repos/is51/catan/forks","keys_url":"https://api.github.com/repos/is51/catan/keys{/key_id}","collaborators_url":"https://api.github.com/repos/is51/catan/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/is51/catan/teams","hooks_url":"https://api.github.com/repos/is51/catan/hooks","issue_events_url":"https://api.github.com/repos/is51/catan/issues/events{/number}","events_url":"https://api.github.com/repos/is51/catan/events","assignees_url":"https://api.github.com/repos/is51/catan/assignees{/user}","branches_url":"https://api.github.com/repos/is51/catan/branches{/branch}","tags_url":"https://api.github.com/repos/is51/catan/tags","blobs_url":"https://api.github.com/repos/is51/catan/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/is51/catan/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/is51/catan/git/refs{/sha}","trees_url":"https://api.github.com/repos/is51/catan/git/trees{/sha}","statuses_url":"https://api.github.com/repos/is51/catan/statuses/{sha}","languages_url":"https://api.github.com/repos/is51/catan/languages","stargazers_url":"https://api.github.com/repos/is51/catan/stargazers","contributors_url":"https://api.github.com/repos/is51/catan/contributors","subscribers_url":"https://api.github.com/repos/is51/catan/subscribers","subscription_url":"https://api.github.com/repos/is51/catan/subscription","commits_url":"https://api.github.com/repos/is51/catan/commits{/sha}","git_commits_url":"https://api.github.com/repos/is51/catan/git/commits{/sha}","comments_url":"https://api.github.com/repos/is51/catan/comments{/number}","issue_comment_url":"https://api.github.com/repos/is51/catan/issues/comments{/number}","contents_url":"https://api.github.com/repos/is51/catan/contents/{+path}","compare_url":"https://api.github.com/repos/is51/catan/compare/{base}...{head}","merges_url":"https://api.github.com/repos/is51/catan/merges","archive_url":"https://api.github.com/repos/is51/catan/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/is51/catan/downloads","issues_url":"https://api.github.com/repos/is51/catan/issues{/number}","pulls_url":"https://api.github.com/repos/is51/catan/pulls{/number}","milestones_url":"https://api.github.com/repos/is51/catan/milestones{/number}","notifications_url":"https://api.github.com/repos/is51/catan/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/is51/catan/labels{/name}","releases_url":"https://api.github.com/repos/is51/catan/releases{/id}","created_at":"2015-06-24T19:28:17Z","updated_at":"2015-06-26T22:01:06Z","pushed_at":"2015-09-23T22:41:25Z","git_url":"git://github.com/is51/catan.git","ssh_url":"git@github.com:is51/catan.git","clone_url":"https://github.com/is51/catan.git","svn_url":"https://github.com/is51/catan","homepage":null,"size":3196,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/is51/catan/pulls/12"},"html":{"href":"https://github.com/is51/catan/pull/12"},"issue":{"href":"https://api.github.com/repos/is51/catan/issues/12"},"comments":{"href":"https://api.github.com/repos/is51/catan/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/is51/catan/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/is51/catan/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/is51/catan/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/is51/catan/statuses/3489d09567f209583ba0ebd773c22d63cf09fe92"}}}}