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

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

Accepted Answer
0 votes

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/

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.

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.

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
Community showcase
Posted Tuesday in Featured Groups

Tuesday tips & tricks: What is the Atlassian Community?

It's officially Tuesday, which means it's officially time for another tip to help you better navigate this space we call the Atlassian Community. 😄 I got a great question from community member, Sa...

54 views 2 4
View post

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you