{"action":"created","comment":{"url":"https://api.github.com/repos/hmcts/sscs-case-loader/pulls/comments/186010608","pull_request_review_id":117517084,"id":186010608,"diff_hunk":"@@ -0,0 +1,131 @@\n+package uk.gov.hmcts.reform.sscs.services.mapper;\n+\n+import java.time.ZonedDateTime;\n+import java.util.ArrayList;\n+import java.util.Collections;\n+import java.util.List;\n+import java.util.stream.Collectors;\n+import org.springframework.stereotype.Service;\n+import uk.gov.hmcts.reform.sscs.models.GapsEvent;\n+import uk.gov.hmcts.reform.sscs.models.deserialize.gaps2.AppealCase;\n+import uk.gov.hmcts.reform.sscs.models.deserialize.gaps2.MajorStatus;\n+import uk.gov.hmcts.reform.sscs.models.deserialize.gaps2.MinorStatus;\n+import uk.gov.hmcts.reform.sscs.models.serialize.ccd.Event;\n+import uk.gov.hmcts.reform.sscs.models.serialize.ccd.Events;\n+\n+@Service\n+class CaseDataEventBuilder {\n+\n+    List<Events> buildPostponedEvent(AppealCase appealCase) {\n+        if (minorStatusIsNotNullAndIsNotEmpty(appealCase.getMinorStatus())) {\n+            return appealCase.getMinorStatus().stream()\n+                .filter(minorStatus -> areConditionsToCreatePostponedEventMet(minorStatus.getStatusId(), appealCase))\n+                .filter(minorStatus -> postponedEventIsNotPresentAlready(minorStatus.getDateSet(),\n+                    appealCase.getMajorStatus()))\n+                .map(minorStatus -> buildNewPostponedEvent(minorStatus.getDateSet()))\n+                .distinct()\n+                .collect(Collectors.toList());\n+        }\n+        return Collections.emptyList();\n+    }\n+\n+    private boolean areConditionsToCreatePostponedEventMet(String statusId, AppealCase appealCase) {\n+        //fixme remove minor status id 26 logic\n+        if (\"26\".equals(statusId)) {\n+            return true;\n+        }\n+\n+        if (minorStatusIdIs27AndThereIsOnlyOnePostponementRequest(statusId, appealCase)) {\n+            return true;\n+        }\n+\n+        if (minorStatusIdIs27AndMoreThanOnePostponementRequest(statusId, appealCase)) {\n+            return !appealCase.getPostponementRequests().stream()\n+                .filter(postponementRequest -> \"Y\".equals(postponementRequest.getPostponementGranted()))\n+                .filter(postponementRequest -> postponementRequest.getAppealHearingId().equals(\n+                    appealCase.getHearing().get(0).getHearingId()))\n+                .collect(Collectors.toList())\n+                .isEmpty();\n+        }\n+        return false;\n+    }\n+","path":"src/main/java/uk/gov/hmcts/reform/sscs/services/mapper/CaseDataEventBuilder.java","position":52,"original_position":52,"commit_id":"5b81be88bbf22e68561253f43418cf307faa2b40","original_commit_id":"5b81be88bbf22e68561253f43418cf307faa2b40","user":{"login":"sathishbabuj","id":31729677,"avatar_url":"https://avatars2.githubusercontent.com/u/31729677?v=4","gravatar_id":"","url":"https://api.github.com/users/sathishbabuj","html_url":"https://github.com/sathishbabuj","followers_url":"https://api.github.com/users/sathishbabuj/followers","following_url":"https://api.github.com/users/sathishbabuj/following{/other_user}","gists_url":"https://api.github.com/users/sathishbabuj/gists{/gist_id}","starred_url":"https://api.github.com/users/sathishbabuj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sathishbabuj/subscriptions","organizations_url":"https://api.github.com/users/sathishbabuj/orgs","repos_url":"https://api.github.com/users/sathishbabuj/repos","events_url":"https://api.github.com/users/sathishbabuj/events{/privacy}","received_events_url":"https://api.github.com/users/sathishbabuj/received_events","type":"User","site_admin":false},"body":"Why minor status 26 is still being handled?","created_at":"2018-05-04T07:54:26Z","updated_at":"2018-05-04T07:54:26Z","html_url":"https://github.com/hmcts/sscs-case-loader/pull/167#discussion_r186010608","pull_request_url":"https://api.github.com/repos/hmcts/sscs-case-loader/pulls/167","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/hmcts/sscs-case-loader/pulls/comments/186010608"},"html":{"href":"https://github.com/hmcts/sscs-case-loader/pull/167#discussion_r186010608"},"pull_request":{"href":"https://api.github.com/repos/hmcts/sscs-case-loader/pulls/167"}}},"pull_request":{"url":"https://api.github.com/repos/hmcts/sscs-case-loader/pulls/167","id":185902361,"html_url":"https://github.com/hmcts/sscs-case-loader/pull/167","diff_url":"https://github.com/hmcts/sscs-case-loader/pull/167.diff","patch_url":"https://github.com/hmcts/sscs-case-loader/pull/167.patch","issue_url":"https://api.github.com/repos/hmcts/sscs-case-loader/issues/167","number":167,"state":"open","locked":false,"title":"Feature/sscs 3129 postponed req2","user":{"login":"iguannago","id":3930991,"avatar_url":"https://avatars2.githubusercontent.com/u/3930991?v=4","gravatar_id":"","url":"https://api.github.com/users/iguannago","html_url":"https://github.com/iguannago","followers_url":"https://api.github.com/users/iguannago/followers","following_url":"https://api.github.com/users/iguannago/following{/other_user}","gists_url":"https://api.github.com/users/iguannago/gists{/gist_id}","starred_url":"https://api.github.com/users/iguannago/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iguannago/subscriptions","organizations_url":"https://api.github.com/users/iguannago/orgs","repos_url":"https://api.github.com/users/iguannago/repos","events_url":"https://api.github.com/users/iguannago/events{/privacy}","received_events_url":"https://api.github.com/users/iguannago/received_events","type":"User","site_admin":false},"body":"### JIRA link (if applicable) ###\r\nhttps://tools.hmcts.net/jira/browse/SSCS-3129\r\n\r\n\r\n### Change description ###\r\nthis change will handle postponed events for the requirements specified in the jira ticket. \r\n\r\n**Does this PR introduce a breaking change?** (check one with \"x\")\r\n\r\n```\r\n[ ] Yes\r\n[ x] No\r\n```\r\n","created_at":"2018-05-04T06:37:59Z","updated_at":"2018-05-04T07:54:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"08586cf9e579473cc0151a4b7843cb9c78bf417c","assignee":null,"assignees":[],"requested_reviewers":[{"login":"Edlyne","id":5550471,"avatar_url":"https://avatars1.githubusercontent.com/u/5550471?v=4","gravatar_id":"","url":"https://api.github.com/users/Edlyne","html_url":"https://github.com/Edlyne","followers_url":"https://api.github.com/users/Edlyne/followers","following_url":"https://api.github.com/users/Edlyne/following{/other_user}","gists_url":"https://api.github.com/users/Edlyne/gists{/gist_id}","starred_url":"https://api.github.com/users/Edlyne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Edlyne/subscriptions","organizations_url":"https://api.github.com/users/Edlyne/orgs","repos_url":"https://api.github.com/users/Edlyne/repos","events_url":"https://api.github.com/users/Edlyne/events{/privacy}","received_events_url":"https://api.github.com/users/Edlyne/received_events","type":"User","site_admin":false},{"login":"savirneni","id":28218570,"avatar_url":"https://avatars2.githubusercontent.com/u/28218570?v=4","gravatar_id":"","url":"https://api.github.com/users/savirneni","html_url":"https://github.com/savirneni","followers_url":"https://api.github.com/users/savirneni/followers","following_url":"https://api.github.com/users/savirneni/following{/other_user}","gists_url":"https://api.github.com/users/savirneni/gists{/gist_id}","starred_url":"https://api.github.com/users/savirneni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/savirneni/subscriptions","organizations_url":"https://api.github.com/users/savirneni/orgs","repos_url":"https://api.github.com/users/savirneni/repos","events_url":"https://api.github.com/users/savirneni/events{/privacy}","received_events_url":"https://api.github.com/users/savirneni/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/hmcts/sscs-case-loader/pulls/167/commits","review_comments_url":"https://api.github.com/repos/hmcts/sscs-case-loader/pulls/167/comments","review_comment_url":"https://api.github.com/repos/hmcts/sscs-case-loader/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hmcts/sscs-case-loader/issues/167/comments","statuses_url":"https://api.github.com/repos/hmcts/sscs-case-loader/statuses/5b81be88bbf22e68561253f43418cf307faa2b40","head":{"label":"hmcts:feature/SSCS-3129-postponed-req2","ref":"feature/SSCS-3129-postponed-req2","sha":"5b81be88bbf22e68561253f43418cf307faa2b40","user":{"login":"hmcts","id":22817111,"avatar_url":"https://avatars1.githubusercontent.com/u/22817111?v=4","gravatar_id":"","url":"https://api.github.com/users/hmcts","html_url":"https://github.com/hmcts","followers_url":"https://api.github.com/users/hmcts/followers","following_url":"https://api.github.com/users/hmcts/following{/other_user}","gists_url":"https://api.github.com/users/hmcts/gists{/gist_id}","starred_url":"https://api.github.com/users/hmcts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmcts/subscriptions","organizations_url":"https://api.github.com/users/hmcts/orgs","repos_url":"https://api.github.com/users/hmcts/repos","events_url":"https://api.github.com/users/hmcts/events{/privacy}","received_events_url":"https://api.github.com/users/hmcts/received_events","type":"Organization","site_admin":false},"repo":{"id":117238362,"name":"sscs-case-loader","full_name":"hmcts/sscs-case-loader","owner":{"login":"hmcts","id":22817111,"avatar_url":"https://avatars1.githubusercontent.com/u/22817111?v=4","gravatar_id":"","url":"https://api.github.com/users/hmcts","html_url":"https://github.com/hmcts","followers_url":"https://api.github.com/users/hmcts/followers","following_url":"https://api.github.com/users/hmcts/following{/other_user}","gists_url":"https://api.github.com/users/hmcts/gists{/gist_id}","starred_url":"https://api.github.com/users/hmcts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmcts/subscriptions","organizations_url":"https://api.github.com/users/hmcts/orgs","repos_url":"https://api.github.com/users/hmcts/repos","events_url":"https://api.github.com/users/hmcts/events{/privacy}","received_events_url":"https://api.github.com/users/hmcts/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hmcts/sscs-case-loader","description":"Loader service for HMCTS Cases","fork":false,"url":"https://api.github.com/repos/hmcts/sscs-case-loader","forks_url":"https://api.github.com/repos/hmcts/sscs-case-loader/forks","keys_url":"https://api.github.com/repos/hmcts/sscs-case-loader/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hmcts/sscs-case-loader/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hmcts/sscs-case-loader/teams","hooks_url":"https://api.github.com/repos/hmcts/sscs-case-loader/hooks","issue_events_url":"https://api.github.com/repos/hmcts/sscs-case-loader/issues/events{/number}","events_url":"https://api.github.com/repos/hmcts/sscs-case-loader/events","assignees_url":"https://api.github.com/repos/hmcts/sscs-case-loader/assignees{/user}","branches_url":"https://api.github.com/repos/hmcts/sscs-case-loader/branches{/branch}","tags_url":"https://api.github.com/repos/hmcts/sscs-case-loader/tags","blobs_url":"https://api.github.com/repos/hmcts/sscs-case-loader/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hmcts/sscs-case-loader/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hmcts/sscs-case-loader/git/refs{/sha}","trees_url":"https://api.github.com/repos/hmcts/sscs-case-loader/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hmcts/sscs-case-loader/statuses/{sha}","languages_url":"https://api.github.com/repos/hmcts/sscs-case-loader/languages","stargazers_url":"https://api.github.com/repos/hmcts/sscs-case-loader/stargazers","contributors_url":"https://api.github.com/repos/hmcts/sscs-case-loader/contributors","subscribers_url":"https://api.github.com/repos/hmcts/sscs-case-loader/subscribers","subscription_url":"https://api.github.com/repos/hmcts/sscs-case-loader/subscription","commits_url":"https://api.github.com/repos/hmcts/sscs-case-loader/commits{/sha}","git_commits_url":"https://api.github.com/repos/hmcts/sscs-case-loader/git/commits{/sha}","comments_url":"https://api.github.com/repos/hmcts/sscs-case-loader/comments{/number}","issue_comment_url":"https://api.github.com/repos/hmcts/sscs-case-loader/issues/comments{/number}","contents_url":"https://api.github.com/repos/hmcts/sscs-case-loader/contents/{+path}","compare_url":"https://api.github.com/repos/hmcts/sscs-case-loader/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hmcts/sscs-case-loader/merges","archive_url":"https://api.github.com/repos/hmcts/sscs-case-loader/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hmcts/sscs-case-loader/downloads","issues_url":"https://api.github.com/repos/hmcts/sscs-case-loader/issues{/number}","pulls_url":"https://api.github.com/repos/hmcts/sscs-case-loader/pulls{/number}","milestones_url":"https://api.github.com/repos/hmcts/sscs-case-loader/milestones{/number}","notifications_url":"https://api.github.com/repos/hmcts/sscs-case-loader/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hmcts/sscs-case-loader/labels{/name}","releases_url":"https://api.github.com/repos/hmcts/sscs-case-loader/releases{/id}","deployments_url":"https://api.github.com/repos/hmcts/sscs-case-loader/deployments","created_at":"2018-01-12T12:25:52Z","updated_at":"2018-05-03T13:19:31Z","pushed_at":"2018-05-04T06:38:00Z","git_url":"git://github.com/hmcts/sscs-case-loader.git","ssh_url":"git@github.com:hmcts/sscs-case-loader.git","clone_url":"https://github.com/hmcts/sscs-case-loader.git","svn_url":"https://github.com/hmcts/sscs-case-loader","homepage":"","size":1287,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"hmcts:master","ref":"master","sha":"ffe31647d66ca129034d9954bd71712181946cf9","user":{"login":"hmcts","id":22817111,"avatar_url":"https://avatars1.githubusercontent.com/u/22817111?v=4","gravatar_id":"","url":"https://api.github.com/users/hmcts","html_url":"https://github.com/hmcts","followers_url":"https://api.github.com/users/hmcts/followers","following_url":"https://api.github.com/users/hmcts/following{/other_user}","gists_url":"https://api.github.com/users/hmcts/gists{/gist_id}","starred_url":"https://api.github.com/users/hmcts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmcts/subscriptions","organizations_url":"https://api.github.com/users/hmcts/orgs","repos_url":"https://api.github.com/users/hmcts/repos","events_url":"https://api.github.com/users/hmcts/events{/privacy}","received_events_url":"https://api.github.com/users/hmcts/received_events","type":"Organization","site_admin":false},"repo":{"id":117238362,"name":"sscs-case-loader","full_name":"hmcts/sscs-case-loader","owner":{"login":"hmcts","id":22817111,"avatar_url":"https://avatars1.githubusercontent.com/u/22817111?v=4","gravatar_id":"","url":"https://api.github.com/users/hmcts","html_url":"https://github.com/hmcts","followers_url":"https://api.github.com/users/hmcts/followers","following_url":"https://api.github.com/users/hmcts/following{/other_user}","gists_url":"https://api.github.com/users/hmcts/gists{/gist_id}","starred_url":"https://api.github.com/users/hmcts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hmcts/subscriptions","organizations_url":"https://api.github.com/users/hmcts/orgs","repos_url":"https://api.github.com/users/hmcts/repos","events_url":"https://api.github.com/users/hmcts/events{/privacy}","received_events_url":"https://api.github.com/users/hmcts/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hmcts/sscs-case-loader","description":"Loader service for HMCTS Cases","fork":false,"url":"https://api.github.com/repos/hmcts/sscs-case-loader","forks_url":"https://api.github.com/repos/hmcts/sscs-case-loader/forks","keys_url":"https://api.github.com/repos/hmcts/sscs-case-loader/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hmcts/sscs-case-loader/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hmcts/sscs-case-loader/teams","hooks_url":"https://api.github.com/repos/hmcts/sscs-case-loader/hooks","issue_events_url":"https://api.github.com/repos/hmcts/sscs-case-loader/issues/events{/number}","events_url":"https://api.github.com/repos/hmcts/sscs-case-loader/events","assignees_url":"https://api.github.com/repos/hmcts/sscs-case-loader/assignees{/user}","branches_url":"https://api.github.com/repos/hmcts/sscs-case-loader/branches{/branch}","tags_url":"https://api.github.com/repos/hmcts/sscs-case-loader/tags","blobs_url":"https://api.github.com/repos/hmcts/sscs-case-loader/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hmcts/sscs-case-loader/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hmcts/sscs-case-loader/git/refs{/sha}","trees_url":"https://api.github.com/repos/hmcts/sscs-case-loader/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hmcts/sscs-case-loader/statuses/{sha}","languages_url":"https://api.github.com/repos/hmcts/sscs-case-loader/languages","stargazers_url":"https://api.github.com/repos/hmcts/sscs-case-loader/stargazers","contributors_url":"https://api.github.com/repos/hmcts/sscs-case-loader/contributors","subscribers_url":"https://api.github.com/repos/hmcts/sscs-case-loader/subscribers","subscription_url":"https://api.github.com/repos/hmcts/sscs-case-loader/subscription","commits_url":"https://api.github.com/repos/hmcts/sscs-case-loader/commits{/sha}","git_commits_url":"https://api.github.com/repos/hmcts/sscs-case-loader/git/commits{/sha}","comments_url":"https://api.github.com/repos/hmcts/sscs-case-loader/comments{/number}","issue_comment_url":"https://api.github.com/repos/hmcts/sscs-case-loader/issues/comments{/number}","contents_url":"https://api.github.com/repos/hmcts/sscs-case-loader/contents/{+path}","compare_url":"https://api.github.com/repos/hmcts/sscs-case-loader/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hmcts/sscs-case-loader/merges","archive_url":"https://api.github.com/repos/hmcts/sscs-case-loader/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hmcts/sscs-case-loader/downloads","issues_url":"https://api.github.com/repos/hmcts/sscs-case-loader/issues{/number}","pulls_url":"https://api.github.com/repos/hmcts/sscs-case-loader/pulls{/number}","milestones_url":"https://api.github.com/repos/hmcts/sscs-case-loader/milestones{/number}","notifications_url":"https://api.github.com/repos/hmcts/sscs-case-loader/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hmcts/sscs-case-loader/labels{/name}","releases_url":"https://api.github.com/repos/hmcts/sscs-case-loader/releases{/id}","deployments_url":"https://api.github.com/repos/hmcts/sscs-case-loader/deployments","created_at":"2018-01-12T12:25:52Z","updated_at":"2018-05-03T13:19:31Z","pushed_at":"2018-05-04T06:38:00Z","git_url":"git://github.com/hmcts/sscs-case-loader.git","ssh_url":"git@github.com:hmcts/sscs-case-loader.git","clone_url":"https://github.com/hmcts/sscs-case-loader.git","svn_url":"https://github.com/hmcts/sscs-case-loader","homepage":"","size":1287,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hmcts/sscs-case-loader/pulls/167"},"html":{"href":"https://github.com/hmcts/sscs-case-loader/pull/167"},"issue":{"href":"https://api.github.com/repos/hmcts/sscs-case-loader/issues/167"},"comments":{"href":"https://api.github.com/repos/hmcts/sscs-case-loader/issues/167/comments"},"review_comments":{"href":"https://api.github.com/repos/hmcts/sscs-case-loader/pulls/167/comments"},"review_comment":{"href":"https://api.github.com/repos/hmcts/sscs-case-loader/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hmcts/sscs-case-loader/pulls/167/commits"},"statuses":{"href":"https://api.github.com/repos/hmcts/sscs-case-loader/statuses/5b81be88bbf22e68561253f43418cf307faa2b40"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"sathishbabuj"}}