{"action":"created","comment":{"url":"https://api.github.com/repos/hmcts/snl-events/pulls/comments/203299165","pull_request_review_id":138158157,"id":203299165,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMzI5OTE2NQ==","diff_hunk":"@@ -0,0 +1,145 @@\n+package uk.gov.hmcts.reform.sandl.snlevents.controllers;\n+\n+import com.fasterxml.jackson.core.type.TypeReference;\n+import com.fasterxml.jackson.databind.ObjectMapper;\n+import lombok.val;\n+import org.junit.Before;\n+import org.junit.Test;\n+import org.junit.runner.RunWith;\n+import org.springframework.beans.factory.annotation.Autowired;\n+import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;\n+import org.springframework.boot.test.json.JacksonTester;\n+import org.springframework.boot.test.mock.mockito.MockBean;\n+import org.springframework.http.MediaType;\n+import org.springframework.test.context.junit4.SpringRunner;\n+import org.springframework.test.web.servlet.MockMvc;\n+import uk.gov.hmcts.reform.sandl.snlevents.mappers.FactsMapper;\n+import uk.gov.hmcts.reform.sandl.snlevents.model.db.HearingPart;\n+import uk.gov.hmcts.reform.sandl.snlevents.model.request.CreateHearingPart;\n+import uk.gov.hmcts.reform.sandl.snlevents.service.HearingPartService;\n+import uk.gov.hmcts.reform.sandl.snlevents.service.RulesService;\n+\n+import java.time.Duration;\n+import java.time.OffsetDateTime;\n+import java.time.ZoneOffset;\n+import java.util.ArrayList;\n+import java.util.Arrays;\n+import java.util.List;\n+import java.util.UUID;\n+\n+import static org.assertj.core.api.Assertions.assertThat;\n+import static org.mockito.AdditionalAnswers.returnsFirstArg;\n+import static org.mockito.Matchers.any;\n+import static org.mockito.Mockito.when;\n+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;\n+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;\n+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;\n+\n+@RunWith(SpringRunner.class)\n+@WebMvcTest(HearingPartController.class)\n+public class HearingPartControllerTest {\n+    public static final String TYPE = \"type\";\n+    public static final String CASE_NUMBER = \"90\";\n+    public static final String TITLE = \"title\";\n+    public static final String HEARING_TYPE = \"hearing-type\";\n+    public static final String URL = \"/hearing-part\";\n+    @Autowired\n+    private MockMvc mvc;\n+\n+    @MockBean\n+    private HearingPartService hearingPartService;\n+\n+    @MockBean\n+    @SuppressWarnings(\"PMD.UnusedPrivateField\")\n+    private RulesService rulesService;\n+\n+    @MockBean\n+    @SuppressWarnings(\"PMD.UnusedPrivateField\")\n+    private FactsMapper factsMapper;\n+\n+    private JacksonTester<CreateHearingPart> createHearingPartSerializer;\n+\n+    @Autowired\n+    private ObjectMapper objectMapper;\n+\n+    @Before\n+    public void setup() {\n+        JacksonTester.initFields(this, objectMapper);\n+    }\n+\n+    @Test\n+    public void fetchAllHeartingParts_returnHearingPartsFromService() throws Exception {\n+        val hearingParts = createHearingParts();\n+        when(hearingPartService.getAllHearingParts()).thenReturn(hearingParts);\n+\n+        val response = mvc\n+            .perform(get(URL))\n+            .andExpect(status().isOk())\n+            .andReturn().getResponse();\n+\n+        val r = objectMapper.readValue(response.getContentAsString(), new TypeReference<List<HearingPart>>(){});\n+        assertThat(r).isEqualToComparingFieldByFieldRecursively(hearingParts);","path":"src/test/java/uk/gov/hmcts/reform/sandl/snlevents/controllers/HearingPartControllerTest.java","position":81,"original_position":81,"commit_id":"50c8d4f3a9cfc3a4c4aefd130c47e5ff1496f688","original_commit_id":"d18eb52698451ccaa6263934d43a405c6982c78d","user":{"login":"filipczyks","id":10515059,"node_id":"MDQ6VXNlcjEwNTE1MDU5","avatar_url":"https://avatars2.githubusercontent.com/u/10515059?v=4","gravatar_id":"","url":"https://api.github.com/users/filipczyks","html_url":"https://github.com/filipczyks","followers_url":"https://api.github.com/users/filipczyks/followers","following_url":"https://api.github.com/users/filipczyks/following{/other_user}","gists_url":"https://api.github.com/users/filipczyks/gists{/gist_id}","starred_url":"https://api.github.com/users/filipczyks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/filipczyks/subscriptions","organizations_url":"https://api.github.com/users/filipczyks/orgs","repos_url":"https://api.github.com/users/filipczyks/repos","events_url":"https://api.github.com/users/filipczyks/events{/privacy}","received_events_url":"https://api.github.com/users/filipczyks/received_events","type":"User","site_admin":false},"body":"Returned list is not equal to expected list as it has references to different HearingPart instances (ones created in test and ones created by objectMapper), we need to compare by value to check response vs expected.","created_at":"2018-07-18T08:51:11Z","updated_at":"2018-07-18T08:51:12Z","html_url":"https://github.com/hmcts/snl-events/pull/78#discussion_r203299165","pull_request_url":"https://api.github.com/repos/hmcts/snl-events/pulls/78","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/hmcts/snl-events/pulls/comments/203299165"},"html":{"href":"https://github.com/hmcts/snl-events/pull/78#discussion_r203299165"},"pull_request":{"href":"https://api.github.com/repos/hmcts/snl-events/pulls/78"}},"in_reply_to_id":202994445},"pull_request":{"url":"https://api.github.com/repos/hmcts/snl-events/pulls/78","id":201917443,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAxOTE3NDQz","html_url":"https://github.com/hmcts/snl-events/pull/78","diff_url":"https://github.com/hmcts/snl-events/pull/78.diff","patch_url":"https://github.com/hmcts/snl-events/pull/78.patch","issue_url":"https://api.github.com/repos/hmcts/snl-events/issues/78","number":78,"state":"open","locked":false,"title":"add HearingPartControllerTest, SearchControllerTest","user":{"login":"filipczyks","id":10515059,"node_id":"MDQ6VXNlcjEwNTE1MDU5","avatar_url":"https://avatars2.githubusercontent.com/u/10515059?v=4","gravatar_id":"","url":"https://api.github.com/users/filipczyks","html_url":"https://github.com/filipczyks","followers_url":"https://api.github.com/users/filipczyks/followers","following_url":"https://api.github.com/users/filipczyks/following{/other_user}","gists_url":"https://api.github.com/users/filipczyks/gists{/gist_id}","starred_url":"https://api.github.com/users/filipczyks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/filipczyks/subscriptions","organizations_url":"https://api.github.com/users/filipczyks/orgs","repos_url":"https://api.github.com/users/filipczyks/repos","events_url":"https://api.github.com/users/filipczyks/events{/privacy}","received_events_url":"https://api.github.com/users/filipczyks/received_events","type":"User","site_admin":false},"body":"**Before creating a pull request make sure that:**\r\n\r\n- [ ] commit messages are meaningful and follow good commit message guidelines\r\n- [ ] README and other documentation has been updated / added (if needed)\r\n- [ ] tests have been updated / new tests has been added (if needed)\r\n\r\nPlease remove this line and everything above and fill the following sections:\r\n\r\n\r\n### JIRA link (if applicable) ###\r\n\r\n\r\n\r\n### Change description ###\r\n\r\n\r\n\r\n**Does this PR introduce a breaking change?** (check one with \"x\")\r\n\r\n```\r\n[ ] Yes\r\n[ ] No\r\n```\r\n","created_at":"2018-07-17T12:00:05Z","updated_at":"2018-07-18T08:51:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"679523b5f5ce288b6a45cb0955f3a6d76293b6b2","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/hmcts/snl-events/pulls/78/commits","review_comments_url":"https://api.github.com/repos/hmcts/snl-events/pulls/78/comments","review_comment_url":"https://api.github.com/repos/hmcts/snl-events/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hmcts/snl-events/issues/78/comments","statuses_url":"https://api.github.com/repos/hmcts/snl-events/statuses/50c8d4f3a9cfc3a4c4aefd130c47e5ff1496f688","head":{"label":"hmcts:feature/SL-1053/unit-tests-for-controllers","ref":"feature/SL-1053/unit-tests-for-controllers","sha":"50c8d4f3a9cfc3a4c4aefd130c47e5ff1496f688","user":{"login":"hmcts","id":22817111,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIyODE3MTEx","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":129116735,"node_id":"MDEwOlJlcG9zaXRvcnkxMjkxMTY3MzU=","name":"snl-events","full_name":"hmcts/snl-events","owner":{"login":"hmcts","id":22817111,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIyODE3MTEx","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/snl-events","description":null,"fork":false,"url":"https://api.github.com/repos/hmcts/snl-events","forks_url":"https://api.github.com/repos/hmcts/snl-events/forks","keys_url":"https://api.github.com/repos/hmcts/snl-events/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hmcts/snl-events/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hmcts/snl-events/teams","hooks_url":"https://api.github.com/repos/hmcts/snl-events/hooks","issue_events_url":"https://api.github.com/repos/hmcts/snl-events/issues/events{/number}","events_url":"https://api.github.com/repos/hmcts/snl-events/events","assignees_url":"https://api.github.com/repos/hmcts/snl-events/assignees{/user}","branches_url":"https://api.github.com/repos/hmcts/snl-events/branches{/branch}","tags_url":"https://api.github.com/repos/hmcts/snl-events/tags","blobs_url":"https://api.github.com/repos/hmcts/snl-events/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hmcts/snl-events/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hmcts/snl-events/git/refs{/sha}","trees_url":"https://api.github.com/repos/hmcts/snl-events/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hmcts/snl-events/statuses/{sha}","languages_url":"https://api.github.com/repos/hmcts/snl-events/languages","stargazers_url":"https://api.github.com/repos/hmcts/snl-events/stargazers","contributors_url":"https://api.github.com/repos/hmcts/snl-events/contributors","subscribers_url":"https://api.github.com/repos/hmcts/snl-events/subscribers","subscription_url":"https://api.github.com/repos/hmcts/snl-events/subscription","commits_url":"https://api.github.com/repos/hmcts/snl-events/commits{/sha}","git_commits_url":"https://api.github.com/repos/hmcts/snl-events/git/commits{/sha}","comments_url":"https://api.github.com/repos/hmcts/snl-events/comments{/number}","issue_comment_url":"https://api.github.com/repos/hmcts/snl-events/issues/comments{/number}","contents_url":"https://api.github.com/repos/hmcts/snl-events/contents/{+path}","compare_url":"https://api.github.com/repos/hmcts/snl-events/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hmcts/snl-events/merges","archive_url":"https://api.github.com/repos/hmcts/snl-events/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hmcts/snl-events/downloads","issues_url":"https://api.github.com/repos/hmcts/snl-events/issues{/number}","pulls_url":"https://api.github.com/repos/hmcts/snl-events/pulls{/number}","milestones_url":"https://api.github.com/repos/hmcts/snl-events/milestones{/number}","notifications_url":"https://api.github.com/repos/hmcts/snl-events/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hmcts/snl-events/labels{/name}","releases_url":"https://api.github.com/repos/hmcts/snl-events/releases{/id}","deployments_url":"https://api.github.com/repos/hmcts/snl-events/deployments","created_at":"2018-04-11T15:40:39Z","updated_at":"2018-07-18T08:30:40Z","pushed_at":"2018-07-18T08:30:41Z","git_url":"git://github.com/hmcts/snl-events.git","ssh_url":"git@github.com:hmcts/snl-events.git","clone_url":"https://github.com/hmcts/snl-events.git","svn_url":"https://github.com/hmcts/snl-events","homepage":null,"size":2707,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":1,"open_issues":3,"watchers":2,"default_branch":"master"}},"base":{"label":"hmcts:master","ref":"master","sha":"efa1174eebe063dfb4947f93298cf5479b395ad7","user":{"login":"hmcts","id":22817111,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIyODE3MTEx","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":129116735,"node_id":"MDEwOlJlcG9zaXRvcnkxMjkxMTY3MzU=","name":"snl-events","full_name":"hmcts/snl-events","owner":{"login":"hmcts","id":22817111,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIyODE3MTEx","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/snl-events","description":null,"fork":false,"url":"https://api.github.com/repos/hmcts/snl-events","forks_url":"https://api.github.com/repos/hmcts/snl-events/forks","keys_url":"https://api.github.com/repos/hmcts/snl-events/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hmcts/snl-events/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hmcts/snl-events/teams","hooks_url":"https://api.github.com/repos/hmcts/snl-events/hooks","issue_events_url":"https://api.github.com/repos/hmcts/snl-events/issues/events{/number}","events_url":"https://api.github.com/repos/hmcts/snl-events/events","assignees_url":"https://api.github.com/repos/hmcts/snl-events/assignees{/user}","branches_url":"https://api.github.com/repos/hmcts/snl-events/branches{/branch}","tags_url":"https://api.github.com/repos/hmcts/snl-events/tags","blobs_url":"https://api.github.com/repos/hmcts/snl-events/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hmcts/snl-events/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hmcts/snl-events/git/refs{/sha}","trees_url":"https://api.github.com/repos/hmcts/snl-events/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hmcts/snl-events/statuses/{sha}","languages_url":"https://api.github.com/repos/hmcts/snl-events/languages","stargazers_url":"https://api.github.com/repos/hmcts/snl-events/stargazers","contributors_url":"https://api.github.com/repos/hmcts/snl-events/contributors","subscribers_url":"https://api.github.com/repos/hmcts/snl-events/subscribers","subscription_url":"https://api.github.com/repos/hmcts/snl-events/subscription","commits_url":"https://api.github.com/repos/hmcts/snl-events/commits{/sha}","git_commits_url":"https://api.github.com/repos/hmcts/snl-events/git/commits{/sha}","comments_url":"https://api.github.com/repos/hmcts/snl-events/comments{/number}","issue_comment_url":"https://api.github.com/repos/hmcts/snl-events/issues/comments{/number}","contents_url":"https://api.github.com/repos/hmcts/snl-events/contents/{+path}","compare_url":"https://api.github.com/repos/hmcts/snl-events/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hmcts/snl-events/merges","archive_url":"https://api.github.com/repos/hmcts/snl-events/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hmcts/snl-events/downloads","issues_url":"https://api.github.com/repos/hmcts/snl-events/issues{/number}","pulls_url":"https://api.github.com/repos/hmcts/snl-events/pulls{/number}","milestones_url":"https://api.github.com/repos/hmcts/snl-events/milestones{/number}","notifications_url":"https://api.github.com/repos/hmcts/snl-events/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hmcts/snl-events/labels{/name}","releases_url":"https://api.github.com/repos/hmcts/snl-events/releases{/id}","deployments_url":"https://api.github.com/repos/hmcts/snl-events/deployments","created_at":"2018-04-11T15:40:39Z","updated_at":"2018-07-18T08:30:40Z","pushed_at":"2018-07-18T08:30:41Z","git_url":"git://github.com/hmcts/snl-events.git","ssh_url":"git@github.com:hmcts/snl-events.git","clone_url":"https://github.com/hmcts/snl-events.git","svn_url":"https://github.com/hmcts/snl-events","homepage":null,"size":2707,"stargazers_count":2,"watchers_count":2,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":1,"open_issues":3,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hmcts/snl-events/pulls/78"},"html":{"href":"https://github.com/hmcts/snl-events/pull/78"},"issue":{"href":"https://api.github.com/repos/hmcts/snl-events/issues/78"},"comments":{"href":"https://api.github.com/repos/hmcts/snl-events/issues/78/comments"},"review_comments":{"href":"https://api.github.com/repos/hmcts/snl-events/pulls/78/comments"},"review_comment":{"href":"https://api.github.com/repos/hmcts/snl-events/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hmcts/snl-events/pulls/78/commits"},"statuses":{"href":"https://api.github.com/repos/hmcts/snl-events/statuses/50c8d4f3a9cfc3a4c4aefd130c47e5ff1496f688"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"filipczyks"}}