1
0
Fork 0

Merge pull request #139 from nach-o-man/master

master
Bob Carroll 2016-05-30 10:46:43 -07:00
commit ba58b45df6
4 changed files with 36 additions and 8 deletions

View File

@ -5,3 +5,4 @@ Javier Molina <javinovich@gmail.com> @javinovich
Joseph McCarthy <luckymikuhatsune@gmail.com>
Magnus Lundberg <ludde89l@gmail.com>
Anders Kreinøe <anders@kreinoee.dk> @Kreinoee
Andrey Kuzmin <agkoozmin@gmail.com> @nach-o-man

View File

@ -85,6 +85,5 @@
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -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<String, String>() {{
put("deleteSubtasks", String.valueOf(deleteSubtasks));
}});
result = (restclient.delete(uri) == null);
} catch (Exception ex) {
throw new JiraException("Failed to delete issue " + key, ex);
}
return result;
}
}

View File

@ -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));
}
}