### Question:
GithubMapper { List<GithubIssue> jsonToIssueList(String json) { try { return this.objectMapper.readValue(json, TYPE_REFERENCE_TO_LIST_GITHUB_ISSUE); } catch (IOException ex) { log.warn("Unable to cast this json to a list of github issues : " + json, ex); return new ArrayList<>(); } }    }### Answer:
@Test public void jsonToIssueList_should_return_a_filled_list() throws IOException { String json = "[ {\"key\": 42 }, {\"key\": 24 } ]"; GithubIssue issue1 = new GithubIssue(); issue1.setNumber(42); issue1.setState("open"); GithubIssue issue2 = new GithubIssue(); issue2.setNumber(24); issue2.setState("closed"); List<GithubIssue> issueList = Lists.list(issue1, issue2); Mockito.doReturn(issueList).when(this.objectMapper).readValue(json, GithubMapper.TYPE_REFERENCE_TO_LIST_GITHUB_ISSUE); List<GithubIssue> githubIssues = this.cut.jsonToIssueList(json); Assertions.assertThat(githubIssues).isNotNull(); Assertions.assertThat(githubIssues).hasSize(2); Assertions.assertThat(githubIssues.get(0).getNumber()).isEqualTo(42); Assertions.assertThat(githubIssues.get(1).getNumber()).isEqualTo(24); }
@Test public void jsonToIssueList_should_return_an_empty_list_on_error() throws IOException { String json = "[ {\"key\": 42 }, {\"key\": 24 } ]"; Mockito.doThrow(JsonParseException.class).when(this.objectMapper).readValue(json, GithubMapper.TYPE_REFERENCE_TO_LIST_GITHUB_ISSUE); List<GithubIssue> githubIssues = this.cut.jsonToIssueList(json); Assertions.assertThat(githubIssues).isNotNull(); Assertions.assertThat(githubIssues).isEmpty(); }