Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get IssueLink for MockIssue? (Atlassian JIRA 4.4 API)

ryan McCullough May 30, 2012

I am experiencing great difficulty making an IssueLink for some mock issues...

to be clear, I am speaking of:

com.atlassian.jira.issue.link.IssueLink

and NOT:

com.atlassian.jira.issue.issuelink.IssueLink

(which seems to have little purpose in 4.4, but much more in 5.x)

I am looking for a simple, straight forward, non-spring, pojo-esque approach to getting an IssueLink for my junits. even a way to create a from scratch GenericValue that would define/encapsulate an IssueLink would be helpful.

Thank you :)

1 answer

1 accepted

1 vote
Answer accepted
Carl Myers
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 1, 2012

Have you considered creating actual mock objects? Mockito, jMock, and Easymock all make this pretty easy.

IssueLink issueLink = Mockito.mock(IssueLink.class);

Mockito.when(issueLink.getId()).thenReturn(123L);
Mockito.when(issueLink.someOtherMethod(args)).thenReturn(answer);

You can then pass the issueLink object around for your tests. For details about Mockito (my preferred mock library) see: http://code.google.com/p/mockito/

ryan McCullough June 1, 2012

lets just say there is more red tape than usual around this specific project. Downloading FOSS tools, I.E. Mockito, is not permitted.

As I'm sure you are aware, the IssueLink type is NOT an interface. My end scenario has to involve using only JUnit and JIRA 4.4 API.

Basically, I'm looking for an easy way to Unit Test Issue Link lookups without having to write some strange/convoluted hack to get around the existing infrastructure.

if Jira 4.4 API is not capable of this in a simple fashioned, a solid explanation of WHY would get you an answer awarded, preferably by someone with a respectable karma tally.

Carl Myers
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 1, 2012

Yeah, I can't speak definitively about the Jira 4.4 API, hopefully someone else can. Sorry to hear about the red tape, I really hate that =( For what it's worth, the Atlassian Plugin SDK comes with Mockito built in I think (at least, it isn't listed in my POM anywhere, it "just works") so you might already have it just the same.

Carl Myers
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 4, 2012

If nobody answers in a few days, I'd really appreciate you accepting my answer, since it is a valid answer to the question (and not relevant to most people that you can't use third party libraries which are actually bundled with the atlassian plugin SDK)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events