Hi @pavanbachuDexcom, Please have a look at the similar question at https://community.developer.atlassian.com/t/componentaccessor-not-initialised/1143.
Hope this helps you. Thanks.
@Rambabu Patina _Appfire_ I have tried that solution but it's throwing null pointer when setting assignee?
IssueManager mockIssueManager = mock(IssueManager.class);
final MockComponentWorker componentAccessorWorker = new MockComponentWorker();
componentAccessorWorker.addMock(IssueManager.class,mockIssueManager);
ComponentAccessor.initialiseWorker(componentAccessorWorker);
MutableIssue io = ComponentAccessor.getIssueManager().getIssueObject(issueID);
io.setAssignee(" ");
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@pavanbachuDexcom Here what's the user id you are providing in the method
setAssignee(<Provide valid user id>)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am passing a regular string, is there a better way to get the user id?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try this way:
setAssignee(ApplicationUser assignee)
// For this method you have to pass the type ApplicationUsersetAssigneeId(String assigneeId) // For this method you can provide user id.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You already have the ComponentAccessor reference, so
If you want to get the current logged in user try
ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
To get other users try:
ApplicationUser currentUser = ComponentAccessor.getUserManager().getUserByKey(String userKey);
or
ApplicationUser currentUser = ComponentAccessor.getUserManager().getUserByName(String userName);
Hope this helps you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Tried Code
IssueManager issueManager = ComponentAccessor.getIssueManager();
MutableIssue io = issueManager.getIssueObject(issueID);
io.setAssigneeId("XXXX");
Got exception
This is not expected to occur on a production system.
Developers that encounter this message within a unit test
should use n MockitoMocksInContainer rule to initialize mockito and ComponentAccessor.
For more detailed explanation read the documentation
for MockComponentWorker in the jira-tests artifact for more information
about what causes this error and how to address it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.