Need help with Issue Event Listener

I am kinda new with Jira and plugin development. Right now I am trying to do Issue EventListener. Well with atlas-run gives me no-error and I can see my plugin is enabled. However no idea if its working or not ? How could I test this ? Also need help with writing some functionly on event ( Look at TODO ). Would appriciate some help.

public class IssueEventListener extends AbstractIssueEventListener implements InitializingBean, DisposableBean {

EventPublisher eventPublisher;

@Inject
public IssueEventListener (EventPublisher eventPublisher) {
    this.eventPublisher = eventPublisher;
}


@Override
public void destroy() throws Exception {
    eventPublisher.unregister(this);
}

@Override
public void afterPropertiesSet() throws Exception {
    eventPublisher.register(this);
}

@EventListener
public void onIssueEvent(IssueEvent issueEvent) {
    Long eventTypeId = issueEvent.getEventTypeId();
    Issue issue = issueEvent.getIssue();

    if(eventTypeId.equals(EventType.ISSUE_CREATED_ID)) {
        // TODO: 7. 04. 2017 IF Original Estimate (time tracking) is null set to 1d;
    }

    if (eventTypeId.equals(EventType.ISSUE_WORKLOG_UPDATED_ID)) {
        // TODO: 7. 04. 2017 get Time Spent number user entered and time when he did and save it.
    }
}

}

Hi Mjafko,
You could test it by trying to print something in console.
like System.out.println(“Event Listened”);

if(issue.getOriginalEstimate()==null){
Try to find how to set the original estimate…
}

issue.getTimeSpent() will fetch you the logged time for the issue.

Well first thing I did was this way with println. But didn’t get any output, could be my plugin not working correct. Thank you for suggestion.

So if I run plugin via powershell with atlas-run and I have System.out.println(“bla”); it should give me output in console, if I understand you right ?

Yes if you create a Issue and put this SOP inside the if clause of EventType.ISSUE_CREATED_ID event, after creating the issue, you will have the value printed in console.

Else, if you put the SOP in the onIssueEvent Method then for all the 13 events call present in JIRA will print the value in console.

Great thank you! Will test it out. But first need to figure it out what I did wrong in code.

@Scanned
@Component
public class VersionChangeListener extends AbstractIssueEventListener implements InitializingBean, DisposableBean {
private static final Logger LOGGER = LoggerFactory.getLogger(VersionChangeListener.class);

@ComponentImport
private EventPublisher eventPublisher;

@Autowired
public VersionChangeListener(EventPublisher eventPublisher){
    this.eventPublisher = eventPublisher;
}

public void destroy() throws Exception {
    eventPublisher.unregister(this);
}
public void afterPropertiesSet() throws Exception {
    eventPublisher.register(this);
}

you may just lost some annotations .