diff --git a/AUTHORS.md b/AUTHORS.md index 3b155c7..ffd2b46 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -5,3 +5,4 @@ Javier Molina @javinovich Joseph McCarthy Magnus Lundberg Anders Kreinøe @Kreinoee +Andrey Kuzmin @nach-o-man diff --git a/pom.xml b/pom.xml index 31d727c..a1b9203 100644 --- a/pom.xml +++ b/pom.xml @@ -85,6 +85,5 @@ test - diff --git a/src/main/java/net/rcarz/jiraclient/Issue.java b/src/main/java/net/rcarz/jiraclient/Issue.java index eafb6e8..45b4c8d 100644 --- a/src/main/java/net/rcarz/jiraclient/Issue.java +++ b/src/main/java/net/rcarz/jiraclient/Issue.java @@ -1,7 +1,7 @@ /** * jira-client - a simple JIRA REST client * Copyright (c) 2013 Bob Carroll (bob.carroll@alum.rit.edu) - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either @@ -876,7 +876,7 @@ public class Issue extends Resource { restclient); if (projects.isEmpty() || projects.get(0).getIssueTypes().isEmpty()) - throw new JiraException("Project '"+ project + "' or issue type '" + issueType + + throw new JiraException("Project '"+ project + "' or issue type '" + issueType + "' missing from create metadata. Do you have enough permissions?"); return projects.get(0).getIssueTypes().get(0).getFields(); @@ -947,7 +947,7 @@ public class Issue extends Resource { throw new JiraException("Failed add attachment to issue " + key, ex); } } - + /** * Adds a remote link to this issue. * @@ -1248,7 +1248,7 @@ public class Issue extends Resource { *
  • summary,comment - include just the summary and comments
  • *
  • *all,-comment - include all fields
  • * - * + * * @param expand fields to expand when obtaining the issue * * @return an issue instance @@ -1329,10 +1329,10 @@ public class Issue extends Resource { *
  • summary,comment - include just the summary and comments
  • *
  • *all,-comment - include all fields
  • * - * + * * @param maxResults if non-null, defines the maximum number of * results that can be returned - * + * * @param startAt if non-null, defines the first issue to * return * @@ -1611,7 +1611,7 @@ public class Issue extends Resource { public User getReporter() { return reporter; } - + public List getRemoteLinks() throws JiraException { JSONArray obj; try { @@ -1696,5 +1696,17 @@ public class Issue extends Resource { return updatedDate; } + public boolean delete(final boolean deleteSubtasks) throws JiraException { + boolean result; + try { + URI uri = restclient.buildURI(getBaseUri() + "issue/" + this.key, new HashMap() {{ + put("deleteSubtasks", String.valueOf(deleteSubtasks)); + }}); + result = (restclient.delete(uri) == null); + } catch (Exception ex) { + throw new JiraException("Failed to delete issue " + key, ex); + } + return result; + } } diff --git a/src/test/java/net/rcarz/jiraclient/IssueTest.java b/src/test/java/net/rcarz/jiraclient/IssueTest.java index f50e6e6..c95507d 100644 --- a/src/test/java/net/rcarz/jiraclient/IssueTest.java +++ b/src/test/java/net/rcarz/jiraclient/IssueTest.java @@ -5,6 +5,7 @@ import static junit.framework.Assert.assertTrue; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; +import java.net.URI; import java.util.List; import java.util.Map; @@ -16,6 +17,9 @@ import org.joda.time.DateTimeZone; import org.junit.Assert; import org.junit.Test; +import static org.mockito.Mockito.*; +import static org.mockito.Mockito.mock; + public class IssueTest { /** @@ -199,4 +203,16 @@ public class IssueTest { } + /** + * false is bu default so we test positive case only + */ + @Test + public void testDelete() throws Exception { + RestClient restClient = mock(RestClient.class); + URI uri = new URI("DUMMY"); + when(restClient.buildURI(anyString(), any(Map.class))).thenReturn(uri); + when(restClient.delete(eq(uri))).thenReturn(null); + Issue issue = new Issue(restClient, Utils.getTestIssue()); + Assert.assertTrue(issue.delete(true)); + } }