@Test public void testCreateIssue(){ String issueKey = TestHelper.createStory(bentenJiraClient); TestHelper.updateAssigneeAndReporter(bentenJiraClient,issueKey); JSONObject jsonObject = new JSONObject(); JSONObject metaData= jiraHttpClient.getCreateMetaData(TestHelper.project_key,TestHelper.issue_type); jsonObject.put("summary","test"); jsonObject.put(Field.DESCRIPTION,"test-description"); jsonObject.put(Field.PROJECT,JiraConverter.toJson(Field.PROJECT,TestHelper.project_key,metaData)); jsonObject.put(Field.ISSUE_TYPE ,JiraConverter.toJson(Field.ISSUE_TYPE,TestHelper.issue_type,metaData)); String issueUri = jiraHttpClient.createIssue(jsonObject); Assert.assertNotNull(issueUri); }
public String createIssue(Map<String,Object> fields){ try{ HttpPost httpPost = new HttpPost(JiraHttpHelper.createIssueUri()); JSONObject jsonObject = new JSONObject(); jsonObject.put("fields",fields); StringEntity stringEntity = formPayload(jsonObject); stringEntity.setContentType("application/json"); httpPost.setEntity(stringEntity); HttpResponse httpResponse = request(httpPost); if(httpResponse.getStatusLine().getStatusCode()!=201){ handleJiraException(httpResponse); } String json = EntityUtils.toString(httpResponse.getEntity()); JSONObject response = JiraConverter.objectMapper .readValue(json,JSONObject.class); return JiraHttpHelper.browseIssueUri((String)response.get("key")).toString(); }catch(Exception ex){ throw new RuntimeException(ex); } }
JiraHttpClient extends BentenHttpClient { public String createIssue(Map<String,Object> fields){ try{ HttpPost httpPost = new HttpPost(JiraHttpHelper.createIssueUri()); JSONObject jsonObject = new JSONObject(); jsonObject.put("fields",fields); StringEntity stringEntity = formPayload(jsonObject); stringEntity.setContentType("application/json"); httpPost.setEntity(stringEntity); HttpResponse httpResponse = request(httpPost); if(httpResponse.getStatusLine().getStatusCode()!=201){ handleJiraException(httpResponse); } String json = EntityUtils.toString(httpResponse.getEntity()); JSONObject response = JiraConverter.objectMapper .readValue(json,JSONObject.class); return JiraHttpHelper.browseIssueUri((String)response.get("key")).toString(); }catch(Exception ex){ throw new RuntimeException(ex); } } }
JiraHttpClient extends BentenHttpClient { public String createIssue(Map<String,Object> fields){ try{ HttpPost httpPost = new HttpPost(JiraHttpHelper.createIssueUri()); JSONObject jsonObject = new JSONObject(); jsonObject.put("fields",fields); StringEntity stringEntity = formPayload(jsonObject); stringEntity.setContentType("application/json"); httpPost.setEntity(stringEntity); HttpResponse httpResponse = request(httpPost); if(httpResponse.getStatusLine().getStatusCode()!=201){ handleJiraException(httpResponse); } String json = EntityUtils.toString(httpResponse.getEntity()); JSONObject response = JiraConverter.objectMapper .readValue(json,JSONObject.class); return JiraHttpHelper.browseIssueUri((String)response.get("key")).toString(); }catch(Exception ex){ throw new RuntimeException(ex); } }  }
JiraHttpClient extends BentenHttpClient { public String createIssue(Map<String,Object> fields){ try{ HttpPost httpPost = new HttpPost(JiraHttpHelper.createIssueUri()); JSONObject jsonObject = new JSONObject(); jsonObject.put("fields",fields); StringEntity stringEntity = formPayload(jsonObject); stringEntity.setContentType("application/json"); httpPost.setEntity(stringEntity); HttpResponse httpResponse = request(httpPost); if(httpResponse.getStatusLine().getStatusCode()!=201){ handleJiraException(httpResponse); } String json = EntityUtils.toString(httpResponse.getEntity()); JSONObject response = JiraConverter.objectMapper .readValue(json,JSONObject.class); return JiraHttpHelper.browseIssueUri((String)response.get("key")).toString(); }catch(Exception ex){ throw new RuntimeException(ex); } }  List<Issue> searchIssues(String jql,String expandedFields,int maxResults); Issue getIssueDetails(String issueKey,String expandedFields); void updateIssue(String issueKey,Map<String,Object> fields); void logWork(String issueKey,JSONObject jsonObject); void transitionIssue(String issueKey,JSONObject jsonObject); List<Transition> getPossibleTransitions(String issueKey); void comment(String issueKey,JSONObject jsonObject); JSONObject getCreateMetaData(String projectKey, String issueType); String createIssue(Map<String,Object> fields); }
JiraHttpClient extends BentenHttpClient { public String createIssue(Map<String,Object> fields){ try{ HttpPost httpPost = new HttpPost(JiraHttpHelper.createIssueUri()); JSONObject jsonObject = new JSONObject(); jsonObject.put("fields",fields); StringEntity stringEntity = formPayload(jsonObject); stringEntity.setContentType("application/json"); httpPost.setEntity(stringEntity); HttpResponse httpResponse = request(httpPost); if(httpResponse.getStatusLine().getStatusCode()!=201){ handleJiraException(httpResponse); } String json = EntityUtils.toString(httpResponse.getEntity()); JSONObject response = JiraConverter.objectMapper .readValue(json,JSONObject.class); return JiraHttpHelper.browseIssueUri((String)response.get("key")).toString(); }catch(Exception ex){ throw new RuntimeException(ex); } }  List<Issue> searchIssues(String jql,String expandedFields,int maxResults); Issue getIssueDetails(String issueKey,String expandedFields); void updateIssue(String issueKey,Map<String,Object> fields); void logWork(String issueKey,JSONObject jsonObject); void transitionIssue(String issueKey,JSONObject jsonObject); List<Transition> getPossibleTransitions(String issueKey); void comment(String issueKey,JSONObject jsonObject); JSONObject getCreateMetaData(String projectKey, String issueType); String createIssue(Map<String,Object> fields);  }