aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/sonar-squid-java-plugin/src
diff options
context:
space:
mode:
authorGodin <mandrikov@gmail.com>2010-11-28 22:28:39 +0000
committerGodin <mandrikov@gmail.com>2010-11-28 22:28:39 +0000
commit4b56cc8557a72da0aaf34ac9e40adb53854343c2 (patch)
treec9c8cb367f6d9d5de2351d5853bb13f8af4fd415 /plugins/sonar-squid-java-plugin/src
parenta28163d9dee455299869ee2729e1aacb871d0f8c (diff)
downloadsonarqube-4b56cc8557a72da0aaf34ac9e40adb53854343c2.tar.gz
sonarqube-4b56cc8557a72da0aaf34ac9e40adb53854343c2.zip
SONAR-2015: Improve unit test
Diffstat (limited to 'plugins/sonar-squid-java-plugin/src')
-rw-r--r--plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/ast/check/UndocumentedApiCheckTest.java24
1 files changed, 20 insertions, 4 deletions
diff --git a/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/ast/check/UndocumentedApiCheckTest.java b/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/ast/check/UndocumentedApiCheckTest.java
index 99163079ff3..c48138680dd 100644
--- a/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/ast/check/UndocumentedApiCheckTest.java
+++ b/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/ast/check/UndocumentedApiCheckTest.java
@@ -24,6 +24,10 @@ import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.sonar.java.ast.SquidTestUtils.getFile;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
import org.junit.Before;
import org.junit.Test;
import org.sonar.java.ast.JavaAstScanner;
@@ -34,6 +38,8 @@ import org.sonar.squid.api.CheckMessage;
import org.sonar.squid.api.SourceFile;
import org.sonar.squid.measures.Metric;
+import com.google.common.collect.Lists;
+
public class UndocumentedApiCheckTest {
private Squid squid;
@@ -50,9 +56,19 @@ public class UndocumentedApiCheckTest {
@Test
public void testUndocumentedApi() {
SourceFile file = (SourceFile) squid.search("UndocumentedApi.java");
- assertThat(file.getInt(Metric.PUBLIC_API) - file.getInt(Metric.PUBLIC_DOC_API), is(1));
- assertThat(file.getCheckMessages().size(), is(1));
- CheckMessage message = file.getCheckMessages().iterator().next();
- assertThat(message.getLine(), is(10));
+
+ List<CheckMessage> messages = Lists.newArrayList(file.getCheckMessages());
+ Collections.sort(messages, new Comparator<CheckMessage>() {
+ public int compare(CheckMessage o1, CheckMessage o2) {
+ return o1.getLine() - o2.getLine();
+ }
+ });
+
+ assertThat(file.getInt(Metric.PUBLIC_API) - file.getInt(Metric.PUBLIC_DOC_API), is(3));
+ assertThat(file.getCheckMessages().size(), is(3));
+
+ assertThat(messages.get(0).getLine(), is(10));
+ assertThat(messages.get(1).getLine(), is(14));
+ assertThat(messages.get(2).getLine(), is(17));
}
}