@Test public void shouldInitRemoteIssueWithComponent() throws Exception { // Given that settings.setProperty(JiraConstants.JIRA_ISSUE_COMPONENT_ID, "123"); RemoteIssue expectedIssue = new RemoteIssue(); expectedIssue.setProject("TEST"); expectedIssue.setType("3"); expectedIssue.setPriority("4"); expectedIssue.setSummary("Sonar Issue #ABCD - Avoid cycle between java packages"); expectedIssue.setDescription( "Issue detail:\n{quote}\nThe Cyclomatic Complexity of this method is 14 which is greater than 10 authorized.\n" + "{quote}\n\n\nCheck it on Sonar: http://my.sonar.com/issue/show/ABCD"); expectedIssue.setComponents(new RemoteComponent[] {new RemoteComponent("123", null)}); // Verify RemoteIssue returnedIssue = jiraIssueCreator.initRemoteIssue(sonarIssue, settings, ""); assertThat(returnedIssue).isEqualTo(expectedIssue); }
@Test public void shouldInitRemoteIssueWithoutName() throws Exception { // Given that when(ruleFinder.findByKey(RuleKey.of("squid", "CycleBetweenPackages"))) .thenReturn(org.sonar.api.rules.Rule.create().setName(null)); RemoteIssue expectedIssue = new RemoteIssue(); expectedIssue.setProject("TEST"); expectedIssue.setType("3"); expectedIssue.setPriority("4"); expectedIssue.setSummary("Sonar Issue #ABCD"); expectedIssue.setDescription( "Issue detail:\n{quote}\nThe Cyclomatic Complexity of this method is 14 which is greater than 10 authorized.\n" + "{quote}\n\n\nCheck it on Sonar: http://my.sonar.com/issue/show/ABCD"); // Verify RemoteIssue returnedIssue = jiraIssueCreator.initRemoteIssue(sonarIssue, settings, ""); assertThat(returnedIssue.getSummary()).isEqualTo(expectedIssue.getSummary()); assertThat(returnedIssue.getDescription()).isEqualTo(expectedIssue.getDescription()); assertThat(returnedIssue).isEqualTo(expectedIssue); }