### Question:
JiraQueryUtil { public UIJiraLoginResponse queryJira(String url, String userName, String password) { JiraAPI jiraTarget = webAPIResolver.getWebAPI(url, JiraAPI.class); JiraSession session = jiraTarget.autenticate( MapBuilder.<String, String>newHashMap() .with("username", userName) .with("password", password) .build()) .session; if (!"JSESSIONID".equals(session.name)) { throw new InternalServerErrorException("jira session not identified by JSESSIONID but by " + session.name); } return new UIJiraLoginResponse( jiraTarget.listProjects(session.value).stream() .map(o -> new UIJiraLoginResponseProjects(o.id, o.name)) .collect(Collectors.toList()), jiraTarget.listIssueTypes(session.value).stream() .map(o -> new UIJiraLoginResponseProjects(o.id, o.name)) .collect(Collectors.toList()) ); } JiraQueryUtil(WebAPIResolver resolver); UIJiraLoginResponse queryJira(String url, String userName, String password);  }### Answer:
@Test public void testJiraQuery() { JiraQueryUtil jiraQueryUtil = new JiraQueryUtil(new MyWebAPIResolver()); final UIJiraLoginResponse jiraData = jiraQueryUtil.queryJira("http: Assert.assertEquals(1, jiraData.getIssueTypes().size()); Assert.assertEquals("iId", jiraData.getIssueTypes().iterator().next().getId()); Assert.assertEquals("iName", jiraData.getIssueTypes().iterator().next().getName()); Assert.assertEquals(1, jiraData.getProjects().size()); Assert.assertEquals("pId", jiraData.getProjects().iterator().next().getId()); Assert.assertEquals("pName", jiraData.getProjects().iterator().next().getName()); }
@Test public void testInvalidSession() { JiraQueryUtil jiraQueryUtil = new JiraQueryUtil(new MyWebAPIResolver(false)); try { jiraQueryUtil.queryJira("http: Assert.fail("Should have failed"); } catch (InternalServerErrorException ex) { } }