Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

IssueImpl class is missing in the Atlassian SDK 5.0.13 and the jira-api-6.4.4 jar

Eric Brown May 22, 2015

Has anyone else generated a post operation plugin module with the atlassian-plugin-sdk version 5.0.13 that created a test with the Jira-api-6.4.4 jar and tried to use IssueImpl in the test?

I used the atlas-create-jira-plugin-module to add a transition post operation plugin and the code that was generated for the test skeleton tries to create an IssueImpl object. Eclipse is saying that this class doesn't exist, and unpacking the jira-api-6.4.4 jar backs that up. The javadoc for the jar shows that this class should be present, the tutorials and documentation show that it should be there, and the code generator thought it should be there, but I am at a loss as to what I need to do.

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

4 votes
Answer accepted
crf
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 22, 2015

The IssueImpl class is the raw implementing class for the issue and is intentionally not in the API.

The test's author doesn't really seem to understand what unit testing is, as you can't very well call this a "Unit test" if it's going to try to use a real IssueImpl.

As for what you can do to move forward...

One way is to get the test access to this class by adding this to the pom.xml:

<dependency>
    <groupId>com.atlassian.jira</groupId>
    <artifactId>jira-core</artifactId>
    <version>${jira.version}</version>
    <scope>test</scope>
</dependency>

 

Unfortunately, the whole point of the API/core separation is to allow us to do things like change the constructors that internal implementations use, and that has happened here – the example no longer matches.  You would also have to add an additional mock for JiraAuthenticationContext and pass it into the IssueImpl constructor as well:

JiraAuthenticationContext jiraAuthenticationContext =
        mock(JiraAuthenticationContext.class);

return new IssueImpl(genericValue, issueManager, projectManager,
        versionManager, issueSecurityLevelManager, constantsManager,
        subTaskManager, attachmentManager, labelManager,
        projectComponentManager, userManager,
        jiraAuthenticationContext);

 

This works, but I want to reiterate that this is a terrible way to write a test and the example needs to be rewritten.  I have opened AMPS-1252 to get it fixed.

A better answer, I think, is to actually fix the test to do what it should without using jira-core.  This is what the test class should look like, with the MutableIssue properly mocked and verified:

package ut.com.atlassian.example.jira.workflow;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import com.atlassian.example.jira.workflow.MyPostFunction;
import com.atlassian.jira.exception.DataAccessException;
import com.atlassian.jira.issue.MutableIssue;

import org.junit.Before;
import org.junit.Test;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.verify;

public class MyPostFunctionTest
{
    public static final String MESSAGE = "my message";

    protected MyPostFunction function;
    protected MutableIssue issue;

    @Before
    public void setup() {

        issue = mock(MutableIssue.class);
        when(issue.getDescription()).thenReturn("");

        function = new MyPostFunction() {
            protected MutableIssue getIssue(Map transientVars) throws DataAccessException {
                return issue;
            }
        };
    }

    @Test
    public void testNullMessage() throws Exception
    {
        Map transientVars = Collections.emptyMap();
        function.execute(transientVars,null,null);
        verify(issue).setDescription("");
    }

    @Test
    public void testEmptyMessage() throws Exception
    {
        Map transientVars = new HashMap();
        transientVars.put("messageField","");
        function.execute(transientVars,null,null);

        verify(issue).setDescription("");

    }

    @Test
    public void testValidMessage() throws Exception
    {
        Map transientVars = new HashMap();
        transientVars.put("messageField",MESSAGE);
        function.execute(transientVars,null,null);

        verify(issue).setDescription(MESSAGE);
    }

}

 

 

 

Eric Brown May 25, 2015

Thanks Chris, that works great. I appreciate the help.

0 votes
Volodymyr Krupach
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.
May 22, 2015

I think you need to run:

atlas-mvn eclipse:eclipse

and then refresh your eclipse project.

Eric Brown May 22, 2015

I had run it before to generate the project, but I went ahead and tried it again. There was no change in the error.

TAGS
AUG Leaders

Atlassian Community Events