-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactoring IT classes and add GCI94 IT
- Loading branch information
Showing
5 changed files
with
228 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/it/java/org/greencodeinitiative/creedengo/java/integration/tests/BaseIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.greencodeinitiative.creedengo.java.integration.tests; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.sonarqube.ws.Issues; | ||
import org.sonarqube.ws.Measures; | ||
|
||
import java.util.*; | ||
|
||
import static java.util.Optional.ofNullable; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class BaseIT extends LaunchSonarqubeAndBuildProject { | ||
|
||
@Test | ||
void testMeasuresAndIssues() { | ||
String projectKey = analyzedProjects.get(0).getProjectKey(); | ||
|
||
Map<String, Measures.Measure> measures = getMeasures(projectKey); | ||
|
||
assertThat(ofNullable(measures.get("code_smells")).map(Measures.Measure::getValue).map(Integer::parseInt).orElse(0)) | ||
.isGreaterThan(1); | ||
|
||
List<Issues.Issue> projectIssues = issuesForComponent(projectKey); | ||
assertThat(projectIssues).isNotEmpty(); | ||
|
||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
src/it/java/org/greencodeinitiative/creedengo/java/integration/tests/GCI69IT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.greencodeinitiative.creedengo.java.integration.tests; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.sonarqube.ws.Issues; | ||
|
||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.sonarqube.ws.Common.RuleType.CODE_SMELL; | ||
import static org.sonarqube.ws.Common.Severity.MINOR; | ||
|
||
class GCI69IT extends LaunchSonarqubeAndBuildProject { | ||
|
||
@Test | ||
void testGCI69() { | ||
String projectKey = analyzedProjects.get(0).getProjectKey(); | ||
|
||
List<Issues.Issue> issuesForArrayCopyCheck = issuesForFile(projectKey, "src/main/java/org/greencodeinitiative/creedengo/java/checks/AvoidGettingSizeCollectionInForLoopIgnored.java"); | ||
|
||
assertThat(issuesForArrayCopyCheck) | ||
.hasSize(1) | ||
.first().satisfies(issue -> verifyIssue(issue, IssueDetails.builder() | ||
.rule("creedengo-java:GCI69") | ||
.message("Do not call a function when declaring a for-type loop") | ||
.line(18) | ||
.startLine(18) | ||
.endLine(18) | ||
.startOffset(15) | ||
.endOffset(27) | ||
.severity(MINOR) | ||
.type(CODE_SMELL) | ||
.debt("5min") | ||
.effort("5min") | ||
.build()) | ||
); | ||
|
||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
src/it/java/org/greencodeinitiative/creedengo/java/integration/tests/GCI94IT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.greencodeinitiative.creedengo.java.integration.tests; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.sonarqube.ws.Issues; | ||
|
||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.sonarqube.ws.Common.RuleType.CODE_SMELL; | ||
import static org.sonarqube.ws.Common.Severity.MINOR; | ||
|
||
class GCI94IT extends LaunchSonarqubeAndBuildProject { | ||
|
||
@Test | ||
void testGCI94() { | ||
String projectKey = analyzedProjects.get(0).getProjectKey(); | ||
|
||
List<Issues.Issue> issuesForArrayCopyCheck = issuesForFile(projectKey, "src/main/java/org/greencodeinitiative/creedengo/java/checks/UseOptionalOrElseGetVsOrElse.java"); | ||
|
||
assertThat(issuesForArrayCopyCheck) | ||
.hasSize(1) | ||
.first().satisfies(issue -> verifyIssue(issue, IssueDetails.builder() | ||
.rule("creedengo-java:GCI94") | ||
.message("Use optional orElseGet instead of orElse.") | ||
.line(25) | ||
.startLine(25) | ||
.endLine(25) | ||
.startOffset(38) | ||
.endOffset(69) | ||
.severity(MINOR) | ||
.type(CODE_SMELL) | ||
.debt("1min") | ||
.effort("1min") | ||
.build()) | ||
); | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.