@Test public void validateSuccessTest() throws IntegrationException { ProjectService projectService = Mockito.mock(ProjectService.class); UserSearchService userSearchService = Mockito.mock(UserSearchService.class); IssueTypeService issueTypeService = Mockito.mock(IssueTypeService.class); IssueMetaDataService issueMetaDataService = Mockito.mock(IssueMetaDataService.class); Mockito.when(issueMetaDataService.doesProjectContainIssueType(Mockito.anyString(), Mockito.anyString())).thenReturn(Boolean.TRUE); JiraCloudIssueConfigValidator jiraIssueConfigValidator = new JiraCloudIssueConfigValidator(projectService, userSearchService, issueTypeService, issueMetaDataService); String resolveTransitionString = "Resolve"; String projectName = "ProjectName"; String issueTypeString = "IssueType"; String issueCreatorString = "IssueCreator"; IssueConfig issueConfig = new IssueConfig(); issueConfig.setCommentOnIssues(true); issueConfig.setResolveTransition(resolveTransitionString); issueConfig.setProjectName(projectName); issueConfig.setIssueType(issueTypeString); issueConfig.setIssueCreator(issueCreatorString); IssueTypeResponseModel issue = Mockito.mock(IssueTypeResponseModel.class); Mockito.when(issue.getName()).thenReturn(issueTypeString); List<IssueTypeResponseModel> issueResponses = new ArrayList<>(1); issueResponses.add(issue); Mockito.when(issueTypeService.getAllIssueTypes()).thenReturn(issueResponses); UserDetailsResponseModel user = Mockito.mock(UserDetailsResponseModel.class); Mockito.when(user.getEmailAddress()).thenReturn(issueCreatorString); List<UserDetailsResponseModel> userResponses = new ArrayList<>(1); userResponses.add(user); Mockito.when(userSearchService.findUser(Mockito.anyString())).thenReturn(userResponses); ProjectComponent projectComponent = Mockito.mock(ProjectComponent.class); Mockito.when(projectComponent.getName()).thenReturn(projectName); PageOfProjectsResponseModel projectResponse = Mockito.mock(PageOfProjectsResponseModel.class); List<ProjectComponent> projectComponents = new ArrayList<>(1); projectComponents.add(projectComponent); Mockito.when(projectResponse.getProjects()).thenReturn(projectComponents); Mockito.when(projectService.getProjectsByName(Mockito.anyString())).thenReturn(projectResponse); try { IssueTrackerContext context = new IssueTrackerContext(null, issueConfig); jiraIssueConfigValidator.createValidIssueConfig(context); Assertions.assertEquals(resolveTransitionString, issueConfig.getResolveTransition().orElse("")); Assertions.assertEquals(projectName, issueConfig.getProjectName()); Assertions.assertEquals(issueCreatorString, issueConfig.getIssueCreator()); Assertions.assertEquals(issueTypeString, issueConfig.getIssueType()); } catch (AlertFieldException e) { fail(); } }
@Override public Collection<ProjectComponent> getProjectsByName(String jiraProjectName) throws IntegrationException { PageOfProjectsResponseModel projectsResponseModel = projectService.getProjectsByName(jiraProjectName); return projectsResponseModel.getProjects(); }
JiraCloudIssueConfigValidator extends JiraIssueConfigValidator { @Override public Collection<ProjectComponent> getProjectsByName(String jiraProjectName) throws IntegrationException { PageOfProjectsResponseModel projectsResponseModel = projectService.getProjectsByName(jiraProjectName); return projectsResponseModel.getProjects(); } }
JiraCloudIssueConfigValidator extends JiraIssueConfigValidator { @Override public Collection<ProjectComponent> getProjectsByName(String jiraProjectName) throws IntegrationException { PageOfProjectsResponseModel projectsResponseModel = projectService.getProjectsByName(jiraProjectName); return projectsResponseModel.getProjects(); } JiraCloudIssueConfigValidator(ProjectService projectService, UserSearchService userSearchService, IssueTypeService issueTypeService, IssueMetaDataService issueMetaDataService); }
JiraCloudIssueConfigValidator extends JiraIssueConfigValidator { @Override public Collection<ProjectComponent> getProjectsByName(String jiraProjectName) throws IntegrationException { PageOfProjectsResponseModel projectsResponseModel = projectService.getProjectsByName(jiraProjectName); return projectsResponseModel.getProjects(); } JiraCloudIssueConfigValidator(ProjectService projectService, UserSearchService userSearchService, IssueTypeService issueTypeService, IssueMetaDataService issueMetaDataService); @Override String getProjectFieldKey(); @Override String getIssueTypeFieldKey(); @Override String getIssueCreatorFieldKey(); @Override String getAddCommentsFieldKey(); @Override String getResolveTransitionFieldKey(); @Override String getOpenTransitionFieldKey(); @Override Collection<ProjectComponent> getProjectsByName(String jiraProjectName); @Override boolean isUserValid(String issueCreator); }
JiraCloudIssueConfigValidator extends JiraIssueConfigValidator { @Override public Collection<ProjectComponent> getProjectsByName(String jiraProjectName) throws IntegrationException { PageOfProjectsResponseModel projectsResponseModel = projectService.getProjectsByName(jiraProjectName); return projectsResponseModel.getProjects(); } JiraCloudIssueConfigValidator(ProjectService projectService, UserSearchService userSearchService, IssueTypeService issueTypeService, IssueMetaDataService issueMetaDataService); @Override String getProjectFieldKey(); @Override String getIssueTypeFieldKey(); @Override String getIssueCreatorFieldKey(); @Override String getAddCommentsFieldKey(); @Override String getResolveTransitionFieldKey(); @Override String getOpenTransitionFieldKey(); @Override Collection<ProjectComponent> getProjectsByName(String jiraProjectName); @Override boolean isUserValid(String issueCreator);  }