{"action":"created","comment":{"url":"https://api.github.com/repos/openenglish/pp-api-gateway/pulls/comments/41322898","id":41322898,"diff_hunk":"@@ -0,0 +1,113 @@\n+package com.openenglish.pp.controller;\n+\n+import com.openenglish.commons.fnc.json.SerializationUtils;\n+import com.openenglish.pp.common.api.model.PaymentInfo;\n+import com.openenglish.pp.persistence.entity.Workflow;\n+import com.openenglish.pp.service.ImmediatePaymentService;\n+\n+import org.junit.Test;\n+import org.springframework.http.MediaType;\n+import org.springframework.test.web.servlet.MockMvc;\n+import org.springframework.test.web.servlet.ResultActions;\n+import org.springframework.test.web.servlet.setup.MockMvcBuilders;\n+\n+import mockit.Expectations;\n+import mockit.Injectable;\n+import mockit.Tested;\n+\n+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;\n+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;\n+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;\n+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;\n+\n+public class ImmediatePaymentControllerTest {\n+\n+  @Tested\n+  private ImmediatePaymentController immediatePaymentController;\n+\n+  @Injectable\n+  private ImmediatePaymentService immediatePaymentService;\n+\n+  private MockMvc mockMvc;\n+\n+  @Test\n+  public void testPayAndCreateAccount() throws Exception {\n+    mockMvc = MockMvcBuilders.standaloneSetup(immediatePaymentController).build();\n+\n+    //test happy path\n+    final Long paymentId = 12L;\n+    final PaymentInfo paymentInfo = new PaymentInfo();\n+    new Expectations() {{\n+      immediatePaymentService.process(paymentInfo);\n+      returns(paymentId);\n+    }};\n+\n+    String payload = SerializationUtils.serialize(paymentInfo);\n+    String postUrl = \"/payment/immediate-capture\";\n+    mockMvc.perform(post(postUrl).contentType(MediaType.APPLICATION_JSON).content(payload))\n+                        .andExpect(status().isAccepted())\n+                        .andExpect(content().string(String.valueOf(paymentId)));\n+\n+    //test fail validation\n+    new Expectations() {{\n+      immediatePaymentService.process(paymentInfo);\n+      result = (new IllegalArgumentException(\"Failed validation\"));\n+    }};\n+\n+    payload = SerializationUtils.serialize(paymentInfo);\n+    mockMvc.perform(post(postUrl).contentType(MediaType.APPLICATION_JSON).content(payload))\n+        .andExpect(status().isBadRequest());\n+\n+    //test exception thrown\n+    new Expectations() {{\n+      immediatePaymentService.process(paymentInfo);\n+      result = (new Exception(\"Generic exception\"));\n+    }};\n+\n+    payload = SerializationUtils.serialize(paymentInfo);\n+    mockMvc.perform(post(postUrl).contentType(MediaType.APPLICATION_JSON).content(payload))\n+        .andExpect(status().is5xxServerError());\n+\n+\n+  }\n+\n+  @Test\n+  public void testCheckPaymentStatus() throws Exception {\n+    mockMvc = MockMvcBuilders.standaloneSetup(immediatePaymentController).build();\n+\n+    //test happy path\n+    final Long paymentId = 12L;\n+    final Workflow workflow = new Workflow(paymentId);\n+    new Expectations() {{\n+      immediatePaymentService.checkStatus(paymentId);\n+      returns(workflow);\n+    }};\n+\n+    String getUrl = \"/payment/immediate-capture/{paymentId}\";\n+    ResultActions perform = mockMvc.perform(get(getUrl, paymentId));\n+    perform\n+        .andExpect(status().isOk())\n+        .andExpect(content().contentType(MediaType.APPLICATION_JSON))\n+        .andExpect(content().bytes(SerializationUtils.serialize(workflow).getBytes()));\n+\n+    //test not found path\n+    new Expectations() {{","path":"pp-api-gateway-webapp/src/test/java/com/openenglish/pp/controller/ImmediatePaymentControllerTest.java","position":94,"original_position":94,"commit_id":"1c18b404363c68c96be112bd62a6ea2bed2cafd4","original_commit_id":"b02fdcf3caf70d1d054484c25df89acbef8bd9c6","user":{"login":"johntran777","id":1626553,"avatar_url":"https://avatars.githubusercontent.com/u/1626553?v=3","gravatar_id":"","url":"https://api.github.com/users/johntran777","html_url":"https://github.com/johntran777","followers_url":"https://api.github.com/users/johntran777/followers","following_url":"https://api.github.com/users/johntran777/following{/other_user}","gists_url":"https://api.github.com/users/johntran777/gists{/gist_id}","starred_url":"https://api.github.com/users/johntran777/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johntran777/subscriptions","organizations_url":"https://api.github.com/users/johntran777/orgs","repos_url":"https://api.github.com/users/johntran777/repos","events_url":"https://api.github.com/users/johntran777/events{/privacy}","received_events_url":"https://api.github.com/users/johntran777/received_events","type":"User","site_admin":false},"body":"Fixed","created_at":"2015-10-06T21:11:04Z","updated_at":"2015-10-06T21:11:04Z","html_url":"https://github.com/openenglish/pp-api-gateway/pull/24#discussion_r41322898","pull_request_url":"https://api.github.com/repos/openenglish/pp-api-gateway/pulls/24","_links":{"self":{"href":"https://api.github.com/repos/openenglish/pp-api-gateway/pulls/comments/41322898"},"html":{"href":"https://github.com/openenglish/pp-api-gateway/pull/24#discussion_r41322898"},"pull_request":{"href":"https://api.github.com/repos/openenglish/pp-api-gateway/pulls/24"}}},"pull_request":{"url":"https://api.github.com/repos/openenglish/pp-api-gateway/pulls/24","id":46899888,"html_url":"https://github.com/openenglish/pp-api-gateway/pull/24","diff_url":"https://github.com/openenglish/pp-api-gateway/pull/24.diff","patch_url":"https://github.com/openenglish/pp-api-gateway/pull/24.patch","issue_url":"https://api.github.com/repos/openenglish/pp-api-gateway/issues/24","number":24,"state":"open","locked":false,"title":"Unit tests","user":{"login":"johntran777","id":1626553,"avatar_url":"https://avatars.githubusercontent.com/u/1626553?v=3","gravatar_id":"","url":"https://api.github.com/users/johntran777","html_url":"https://github.com/johntran777","followers_url":"https://api.github.com/users/johntran777/followers","following_url":"https://api.github.com/users/johntran777/following{/other_user}","gists_url":"https://api.github.com/users/johntran777/gists{/gist_id}","starred_url":"https://api.github.com/users/johntran777/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johntran777/subscriptions","organizations_url":"https://api.github.com/users/johntran777/orgs","repos_url":"https://api.github.com/users/johntran777/repos","events_url":"https://api.github.com/users/johntran777/events{/privacy}","received_events_url":"https://api.github.com/users/johntran777/received_events","type":"User","site_admin":false},"body":"Please review and merge.","created_at":"2015-10-06T13:07:07Z","updated_at":"2015-10-06T21:11:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2bf3cda26bdbb0a40fd85a015de020286c01d264","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/openenglish/pp-api-gateway/pulls/24/commits","review_comments_url":"https://api.github.com/repos/openenglish/pp-api-gateway/pulls/24/comments","review_comment_url":"https://api.github.com/repos/openenglish/pp-api-gateway/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openenglish/pp-api-gateway/issues/24/comments","statuses_url":"https://api.github.com/repos/openenglish/pp-api-gateway/statuses/1c18b404363c68c96be112bd62a6ea2bed2cafd4","head":{"label":"openenglish:unit_tests","ref":"unit_tests","sha":"1c18b404363c68c96be112bd62a6ea2bed2cafd4","user":{"login":"openenglish","id":2280802,"avatar_url":"https://avatars.githubusercontent.com/u/2280802?v=3","gravatar_id":"","url":"https://api.github.com/users/openenglish","html_url":"https://github.com/openenglish","followers_url":"https://api.github.com/users/openenglish/followers","following_url":"https://api.github.com/users/openenglish/following{/other_user}","gists_url":"https://api.github.com/users/openenglish/gists{/gist_id}","starred_url":"https://api.github.com/users/openenglish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openenglish/subscriptions","organizations_url":"https://api.github.com/users/openenglish/orgs","repos_url":"https://api.github.com/users/openenglish/repos","events_url":"https://api.github.com/users/openenglish/events{/privacy}","received_events_url":"https://api.github.com/users/openenglish/received_events","type":"Organization","site_admin":false},"repo":{"id":41930885,"name":"pp-api-gateway","full_name":"openenglish/pp-api-gateway","owner":{"login":"openenglish","id":2280802,"avatar_url":"https://avatars.githubusercontent.com/u/2280802?v=3","gravatar_id":"","url":"https://api.github.com/users/openenglish","html_url":"https://github.com/openenglish","followers_url":"https://api.github.com/users/openenglish/followers","following_url":"https://api.github.com/users/openenglish/following{/other_user}","gists_url":"https://api.github.com/users/openenglish/gists{/gist_id}","starred_url":"https://api.github.com/users/openenglish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openenglish/subscriptions","organizations_url":"https://api.github.com/users/openenglish/orgs","repos_url":"https://api.github.com/users/openenglish/repos","events_url":"https://api.github.com/users/openenglish/events{/privacy}","received_events_url":"https://api.github.com/users/openenglish/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openenglish/pp-api-gateway","description":"","fork":false,"url":"https://api.github.com/repos/openenglish/pp-api-gateway","forks_url":"https://api.github.com/repos/openenglish/pp-api-gateway/forks","keys_url":"https://api.github.com/repos/openenglish/pp-api-gateway/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openenglish/pp-api-gateway/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openenglish/pp-api-gateway/teams","hooks_url":"https://api.github.com/repos/openenglish/pp-api-gateway/hooks","issue_events_url":"https://api.github.com/repos/openenglish/pp-api-gateway/issues/events{/number}","events_url":"https://api.github.com/repos/openenglish/pp-api-gateway/events","assignees_url":"https://api.github.com/repos/openenglish/pp-api-gateway/assignees{/user}","branches_url":"https://api.github.com/repos/openenglish/pp-api-gateway/branches{/branch}","tags_url":"https://api.github.com/repos/openenglish/pp-api-gateway/tags","blobs_url":"https://api.github.com/repos/openenglish/pp-api-gateway/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openenglish/pp-api-gateway/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openenglish/pp-api-gateway/git/refs{/sha}","trees_url":"https://api.github.com/repos/openenglish/pp-api-gateway/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openenglish/pp-api-gateway/statuses/{sha}","languages_url":"https://api.github.com/repos/openenglish/pp-api-gateway/languages","stargazers_url":"https://api.github.com/repos/openenglish/pp-api-gateway/stargazers","contributors_url":"https://api.github.com/repos/openenglish/pp-api-gateway/contributors","subscribers_url":"https://api.github.com/repos/openenglish/pp-api-gateway/subscribers","subscription_url":"https://api.github.com/repos/openenglish/pp-api-gateway/subscription","commits_url":"https://api.github.com/repos/openenglish/pp-api-gateway/commits{/sha}","git_commits_url":"https://api.github.com/repos/openenglish/pp-api-gateway/git/commits{/sha}","comments_url":"https://api.github.com/repos/openenglish/pp-api-gateway/comments{/number}","issue_comment_url":"https://api.github.com/repos/openenglish/pp-api-gateway/issues/comments{/number}","contents_url":"https://api.github.com/repos/openenglish/pp-api-gateway/contents/{+path}","compare_url":"https://api.github.com/repos/openenglish/pp-api-gateway/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openenglish/pp-api-gateway/merges","archive_url":"https://api.github.com/repos/openenglish/pp-api-gateway/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openenglish/pp-api-gateway/downloads","issues_url":"https://api.github.com/repos/openenglish/pp-api-gateway/issues{/number}","pulls_url":"https://api.github.com/repos/openenglish/pp-api-gateway/pulls{/number}","milestones_url":"https://api.github.com/repos/openenglish/pp-api-gateway/milestones{/number}","notifications_url":"https://api.github.com/repos/openenglish/pp-api-gateway/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openenglish/pp-api-gateway/labels{/name}","releases_url":"https://api.github.com/repos/openenglish/pp-api-gateway/releases{/id}","created_at":"2015-09-04T18:12:25Z","updated_at":"2015-09-04T18:27:13Z","pushed_at":"2015-10-06T20:04:58Z","git_url":"git://github.com/openenglish/pp-api-gateway.git","ssh_url":"git@github.com:openenglish/pp-api-gateway.git","clone_url":"https://github.com/openenglish/pp-api-gateway.git","svn_url":"https://github.com/openenglish/pp-api-gateway","homepage":null,"size":1000,"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":"openenglish:master","ref":"master","sha":"8a9be43ad3e6b022a8c925e9d0dbeaff03ef1b12","user":{"login":"openenglish","id":2280802,"avatar_url":"https://avatars.githubusercontent.com/u/2280802?v=3","gravatar_id":"","url":"https://api.github.com/users/openenglish","html_url":"https://github.com/openenglish","followers_url":"https://api.github.com/users/openenglish/followers","following_url":"https://api.github.com/users/openenglish/following{/other_user}","gists_url":"https://api.github.com/users/openenglish/gists{/gist_id}","starred_url":"https://api.github.com/users/openenglish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openenglish/subscriptions","organizations_url":"https://api.github.com/users/openenglish/orgs","repos_url":"https://api.github.com/users/openenglish/repos","events_url":"https://api.github.com/users/openenglish/events{/privacy}","received_events_url":"https://api.github.com/users/openenglish/received_events","type":"Organization","site_admin":false},"repo":{"id":41930885,"name":"pp-api-gateway","full_name":"openenglish/pp-api-gateway","owner":{"login":"openenglish","id":2280802,"avatar_url":"https://avatars.githubusercontent.com/u/2280802?v=3","gravatar_id":"","url":"https://api.github.com/users/openenglish","html_url":"https://github.com/openenglish","followers_url":"https://api.github.com/users/openenglish/followers","following_url":"https://api.github.com/users/openenglish/following{/other_user}","gists_url":"https://api.github.com/users/openenglish/gists{/gist_id}","starred_url":"https://api.github.com/users/openenglish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openenglish/subscriptions","organizations_url":"https://api.github.com/users/openenglish/orgs","repos_url":"https://api.github.com/users/openenglish/repos","events_url":"https://api.github.com/users/openenglish/events{/privacy}","received_events_url":"https://api.github.com/users/openenglish/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openenglish/pp-api-gateway","description":"","fork":false,"url":"https://api.github.com/repos/openenglish/pp-api-gateway","forks_url":"https://api.github.com/repos/openenglish/pp-api-gateway/forks","keys_url":"https://api.github.com/repos/openenglish/pp-api-gateway/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openenglish/pp-api-gateway/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openenglish/pp-api-gateway/teams","hooks_url":"https://api.github.com/repos/openenglish/pp-api-gateway/hooks","issue_events_url":"https://api.github.com/repos/openenglish/pp-api-gateway/issues/events{/number}","events_url":"https://api.github.com/repos/openenglish/pp-api-gateway/events","assignees_url":"https://api.github.com/repos/openenglish/pp-api-gateway/assignees{/user}","branches_url":"https://api.github.com/repos/openenglish/pp-api-gateway/branches{/branch}","tags_url":"https://api.github.com/repos/openenglish/pp-api-gateway/tags","blobs_url":"https://api.github.com/repos/openenglish/pp-api-gateway/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openenglish/pp-api-gateway/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openenglish/pp-api-gateway/git/refs{/sha}","trees_url":"https://api.github.com/repos/openenglish/pp-api-gateway/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openenglish/pp-api-gateway/statuses/{sha}","languages_url":"https://api.github.com/repos/openenglish/pp-api-gateway/languages","stargazers_url":"https://api.github.com/repos/openenglish/pp-api-gateway/stargazers","contributors_url":"https://api.github.com/repos/openenglish/pp-api-gateway/contributors","subscribers_url":"https://api.github.com/repos/openenglish/pp-api-gateway/subscribers","subscription_url":"https://api.github.com/repos/openenglish/pp-api-gateway/subscription","commits_url":"https://api.github.com/repos/openenglish/pp-api-gateway/commits{/sha}","git_commits_url":"https://api.github.com/repos/openenglish/pp-api-gateway/git/commits{/sha}","comments_url":"https://api.github.com/repos/openenglish/pp-api-gateway/comments{/number}","issue_comment_url":"https://api.github.com/repos/openenglish/pp-api-gateway/issues/comments{/number}","contents_url":"https://api.github.com/repos/openenglish/pp-api-gateway/contents/{+path}","compare_url":"https://api.github.com/repos/openenglish/pp-api-gateway/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openenglish/pp-api-gateway/merges","archive_url":"https://api.github.com/repos/openenglish/pp-api-gateway/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openenglish/pp-api-gateway/downloads","issues_url":"https://api.github.com/repos/openenglish/pp-api-gateway/issues{/number}","pulls_url":"https://api.github.com/repos/openenglish/pp-api-gateway/pulls{/number}","milestones_url":"https://api.github.com/repos/openenglish/pp-api-gateway/milestones{/number}","notifications_url":"https://api.github.com/repos/openenglish/pp-api-gateway/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openenglish/pp-api-gateway/labels{/name}","releases_url":"https://api.github.com/repos/openenglish/pp-api-gateway/releases{/id}","created_at":"2015-09-04T18:12:25Z","updated_at":"2015-09-04T18:27:13Z","pushed_at":"2015-10-06T20:04:58Z","git_url":"git://github.com/openenglish/pp-api-gateway.git","ssh_url":"git@github.com:openenglish/pp-api-gateway.git","clone_url":"https://github.com/openenglish/pp-api-gateway.git","svn_url":"https://github.com/openenglish/pp-api-gateway","homepage":null,"size":1000,"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/openenglish/pp-api-gateway/pulls/24"},"html":{"href":"https://github.com/openenglish/pp-api-gateway/pull/24"},"issue":{"href":"https://api.github.com/repos/openenglish/pp-api-gateway/issues/24"},"comments":{"href":"https://api.github.com/repos/openenglish/pp-api-gateway/issues/24/comments"},"review_comments":{"href":"https://api.github.com/repos/openenglish/pp-api-gateway/pulls/24/comments"},"review_comment":{"href":"https://api.github.com/repos/openenglish/pp-api-gateway/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openenglish/pp-api-gateway/pulls/24/commits"},"statuses":{"href":"https://api.github.com/repos/openenglish/pp-api-gateway/statuses/1c18b404363c68c96be112bd62a6ea2bed2cafd4"}}}}