-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement ReportTest for SQ compliance
- Loading branch information
Showing
1 changed file
with
119 additions
and
0 deletions.
There are no files selected for viewing
119 changes: 119 additions & 0 deletions
119
src/test/ut/java/fr/cnes/sonar/report/model/ReportTest.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,119 @@ | ||
package fr.cnes.sonar.report.model; | ||
|
||
import fr.cnes.sonar.report.CommonTest; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.util.*; | ||
|
||
public class ReportTest extends CommonTest{ | ||
|
||
@Test | ||
public void getComplianceTest() { | ||
Report report = new Report(); | ||
Assert.assertEquals("0.0", report.getCompliance()); | ||
} | ||
|
||
@Test | ||
public void MetricsStatsTest() { | ||
Report report = new Report(); | ||
Map<String, Double> metrics = new HashMap<>(); | ||
metrics.put("metric1", 1.0); | ||
metrics.put("metric2", 2.0); | ||
report.setMetricsStats(metrics); | ||
Assert.assertEquals((Double) 1.0, report.getMetricsStats().get("metric1")); | ||
Assert.assertEquals((Double) 2.0, report.getMetricsStats().get("metric2")); | ||
} | ||
|
||
@Test | ||
public void ComponentsTest() { | ||
Report report = new Report(); | ||
List<Map<String, String>> components = new ArrayList<>(); | ||
Map<String, String> component = new HashMap<>(); | ||
component.put("id", "1"); | ||
component.put("name", "test"); | ||
component.put("path", "path/to/test"); | ||
components.add(component); | ||
report.setComponents(components); | ||
Assert.assertEquals("1", report.getComponents().get(0).get("id")); | ||
Assert.assertEquals("test", report.getComponents().get(0).get("name")); | ||
Assert.assertEquals("path/to/test", report.getComponents().get(0).get("path")); | ||
} | ||
|
||
@Test | ||
public void IssuesTest() { | ||
Report report = new Report(); | ||
List<Issue> issues = new ArrayList<>(); | ||
Issue issue = new Issue(); | ||
issue.setKey("1"); | ||
issue.setRule("rule"); | ||
issue.setSeverity("severity"); | ||
issues.add(issue); | ||
report.setIssues(issues); | ||
Assert.assertEquals("1", report.getIssues().getIssuesList().get(0).getKey()); | ||
Assert.assertEquals("rule", report.getIssues().getIssuesList().get(0).getRule()); | ||
Assert.assertEquals("severity", report.getIssues().getIssuesList().get(0).getSeverity()); | ||
} | ||
|
||
@Test | ||
public void toReviewSecurityHotspotsTest(){ | ||
Report report = new Report(); | ||
List<SecurityHotspot> securityHotspots = new ArrayList<>(); | ||
SecurityHotspot securityHotspot = new SecurityHotspot(); | ||
securityHotspot.setKey("1"); | ||
securityHotspot.setRule("rule"); | ||
securityHotspot.setSeverity("severity"); | ||
securityHotspots.add(securityHotspot); | ||
report.setToReviewSecurityHotspots(securityHotspots); | ||
Assert.assertEquals("1", report.getToReviewSecurityHotspots().get(0).getKey()); | ||
Assert.assertEquals("rule", report.getToReviewSecurityHotspots().get(0).getRule()); | ||
Assert.assertEquals("severity", report.getToReviewSecurityHotspots().get(0).getSeverity()); | ||
} | ||
|
||
@Test | ||
public void reviewedSecurityHotspotsTest(){ | ||
Report report = new Report(); | ||
List<SecurityHotspot> securityHotspots = new ArrayList<>(); | ||
SecurityHotspot securityHotspot = new SecurityHotspot(); | ||
securityHotspot.setKey("1"); | ||
securityHotspot.setRule("rule"); | ||
securityHotspot.setSeverity("severity"); | ||
securityHotspots.add(securityHotspot); | ||
report.setReviewedSecurityHotspots(securityHotspots); | ||
Assert.assertEquals("1", report.getReviewedSecurityHotspots().get(0).getKey()); | ||
Assert.assertEquals("rule", report.getReviewedSecurityHotspots().get(0).getRule()); | ||
Assert.assertEquals("severity", report.getReviewedSecurityHotspots().get(0).getSeverity()); | ||
} | ||
|
||
@Test | ||
public void projetNameTest() { | ||
Report report = new Report(); | ||
report.setProjectName("projectName"); | ||
Assert.assertEquals("projectName", report.getProjectName()); | ||
} | ||
|
||
@Test | ||
public void projectBranchTest() { | ||
Report report = new Report(); | ||
report.setProjectBranch("projectBranch"); | ||
Assert.assertEquals("projectBranch", report.getProjectBranch()); | ||
} | ||
|
||
@Test | ||
public void projectAuthorTest() { | ||
Report report = new Report(); | ||
report.setProjectAuthor("projectAuthor"); | ||
Assert.assertEquals("projectAuthor", report.getProjectAuthor()); | ||
} | ||
|
||
@Test | ||
public void projectDateTest() { | ||
Report report = new Report(); | ||
report.setProjectDate("projectDate"); | ||
Assert.assertEquals("projectDate", report.getProjectDate()); | ||
} | ||
|
||
|
||
|
||
} |