File tree Expand file tree Collapse file tree 5 files changed +228
-112
lines changed
src/it/java/org/greencodeinitiative/creedengo/java/integration/tests Expand file tree Collapse file tree 5 files changed +228
-112
lines changed Original file line number Diff line number Diff line change 198198 <version >1.5.6</version >
199199 <scope >test</scope >
200200 </dependency >
201+ <dependency >
202+ <groupId >org.projectlombok</groupId >
203+ <artifactId >lombok</artifactId >
204+ <version >1.18.36</version >
205+ <scope >test</scope >
206+ </dependency >
201207 </dependencies >
202208
203209 <build >
Original file line number Diff line number Diff line change 1+ package org .greencodeinitiative .creedengo .java .integration .tests ;
2+
3+ import org .junit .jupiter .api .Test ;
4+ import org .sonarqube .ws .Issues ;
5+ import org .sonarqube .ws .Measures ;
6+
7+ import java .util .*;
8+
9+ import static java .util .Optional .ofNullable ;
10+ import static org .assertj .core .api .Assertions .assertThat ;
11+
12+ class BaseIT extends LaunchSonarqubeAndBuildProject {
13+
14+ @ Test
15+ void testMeasuresAndIssues () {
16+ String projectKey = analyzedProjects .get (0 ).getProjectKey ();
17+
18+ Map <String , Measures .Measure > measures = getMeasures (projectKey );
19+
20+ assertThat (ofNullable (measures .get ("code_smells" )).map (Measures .Measure ::getValue ).map (Integer ::parseInt ).orElse (0 ))
21+ .isGreaterThan (1 );
22+
23+ List <Issues .Issue > projectIssues = issuesForComponent (projectKey );
24+ assertThat (projectIssues ).isNotEmpty ();
25+
26+ }
27+
28+ }
Original file line number Diff line number Diff line change 1+ package org .greencodeinitiative .creedengo .java .integration .tests ;
2+
3+ import org .junit .jupiter .api .Test ;
4+ import org .sonarqube .ws .Issues ;
5+
6+ import java .util .List ;
7+
8+ import static org .assertj .core .api .Assertions .assertThat ;
9+ import static org .sonarqube .ws .Common .RuleType .CODE_SMELL ;
10+ import static org .sonarqube .ws .Common .Severity .MINOR ;
11+
12+ class GCI69IT extends LaunchSonarqubeAndBuildProject {
13+
14+ @ Test
15+ void testGCI69 () {
16+ String projectKey = analyzedProjects .get (0 ).getProjectKey ();
17+
18+ List <Issues .Issue > issuesForArrayCopyCheck = issuesForFile (projectKey , "src/main/java/org/greencodeinitiative/creedengo/java/checks/AvoidGettingSizeCollectionInForLoopIgnored.java" );
19+
20+ assertThat (issuesForArrayCopyCheck )
21+ .hasSize (1 )
22+ .first ().satisfies (issue -> verifyIssue (issue , IssueDetails .builder ()
23+ .rule ("creedengo-java:GCI69" )
24+ .message ("Do not call a function when declaring a for-type loop" )
25+ .line (18 )
26+ .startLine (18 )
27+ .endLine (18 )
28+ .startOffset (15 )
29+ .endOffset (27 )
30+ .severity (MINOR )
31+ .type (CODE_SMELL )
32+ .debt ("5min" )
33+ .effort ("5min" )
34+ .build ())
35+ );
36+
37+ }
38+
39+ }
Original file line number Diff line number Diff line change 1+ package org .greencodeinitiative .creedengo .java .integration .tests ;
2+
3+ import org .junit .jupiter .api .Test ;
4+ import org .sonarqube .ws .Issues ;
5+
6+ import java .util .List ;
7+
8+ import static org .assertj .core .api .Assertions .assertThat ;
9+ import static org .sonarqube .ws .Common .RuleType .CODE_SMELL ;
10+ import static org .sonarqube .ws .Common .Severity .MINOR ;
11+
12+ class GCI94IT extends LaunchSonarqubeAndBuildProject {
13+
14+ @ Test
15+ void testGCI94 () {
16+ String projectKey = analyzedProjects .get (0 ).getProjectKey ();
17+
18+ List <Issues .Issue > issuesForArrayCopyCheck = issuesForFile (projectKey , "src/main/java/org/greencodeinitiative/creedengo/java/checks/UseOptionalOrElseGetVsOrElse.java" );
19+
20+ assertThat (issuesForArrayCopyCheck )
21+ .hasSize (1 )
22+ .first ().satisfies (issue -> verifyIssue (issue , IssueDetails .builder ()
23+ .rule ("creedengo-java:GCI94" )
24+ .message ("Use optional orElseGet instead of orElse." )
25+ .line (25 )
26+ .startLine (25 )
27+ .endLine (25 )
28+ .startOffset (38 )
29+ .endOffset (69 )
30+ .severity (MINOR )
31+ .type (CODE_SMELL )
32+ .debt ("1min" )
33+ .effort ("1min" )
34+ .build ())
35+ );
36+
37+ }
38+
39+ }
You can’t perform that action at this time.
0 commit comments