@Test public void testInvalidSession() { JiraQueryUtil jiraQueryUtil = new JiraQueryUtil(new MyWebAPIResolver(false)); try { jiraQueryUtil.queryJira("http: Assert.fail("Should have failed"); } catch (InternalServerErrorException ex) { } }
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 { 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 { 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); }
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); }
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);  }