@Test public void getJIRAChangedIssues() throws Exception { final Date ua = new Date(); final Date ub = new Date(); IJIRAClient tested = new JIRA5RestClient(mockEsIntegrationComponent(), TEST_JIRA_URL, null, null, 5000, null) { @Override protected byte[] performJIRAChangedIssuesREST( String projectKey, int startAt, Date updatedAfter, Date updatedBefore) throws Exception { Assert.assertEquals("ORG", projectKey); Assert.assertEquals(ua, updatedAfter); Assert.assertEquals(ub, updatedBefore); Assert.assertEquals(10, startAt); return "{\"startAt\": 5, \"maxResults\" : 10, \"total\" : 50, \"issues\" : [{\"key\" : \"ORG-45\"}]}" .getBytes("UTF-8"); }; }; ChangedIssuesResults ret = tested.getJIRAChangedIssues("ORG", 10, ua, ub); Assert.assertEquals(5, ret.getStartAt()); Assert.assertEquals(10, ret.getMaxResults()); Assert.assertEquals(50, ret.getTotal()); Assert.assertNotNull(ret.getIssues()); Assert.assertEquals(1, ret.getIssuesCount()); }
/** * Main method used to run integration tests with real JIRA call. * * @param args not used * @throws Exception */ public static void main(String[] args) throws Exception { String username = null; String pwd = null; IJIRAClient tested = new JIRA5RestClient( mockEsIntegrationComponent(), "https://issues.jboss.org", username, pwd, 50000, null); // List<String> projects = tested.getAllJIRAProjects(); // System.out.println(projects); ChangedIssuesResults ret = tested.getJIRAChangedIssues( "ORG", 0, DateTimeUtils.parseISODateTime("2014-09-01T01:00:00Z"), null); System.out.println("total: " + ret.getTotal()); // System.out.println(ret); }
@Test public void getAllJIRAProjects() throws Exception { IJIRAClient tested = new JIRA5RestClient(mockEsIntegrationComponent(), TEST_JIRA_URL, null, null, 5000, null) { @Override protected byte[] performJIRAGetRESTCall(String restOperation, List<NameValuePair> params) throws Exception { Assert.assertEquals("project", restOperation); Assert.assertNull(params); return ("[{\"key\": \"ORG\", \"name\": \"ORG project\"},{\"key\": \"PPP\"}]") .getBytes("UTF-8"); }; }; List<String> ret = tested.getAllJIRAProjects(); Assert.assertNotNull(ret); Assert.assertEquals(2, ret.size()); Assert.assertTrue(ret.contains("ORG")); Assert.assertTrue(ret.contains("PPP")); }