diff options
-rw-r--r-- | plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/ast/check/UndocumentedApiCheckTest.java | 24 |
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)); } } |