diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2012-05-29 14:48:21 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2012-05-29 14:48:40 +0200 |
commit | 9d7b312b6d6cd5487c232092abb1c5bd623b2654 (patch) | |
tree | 7f5ef140315a52214d4e4f038d3da28606dbaab7 /sonar-plugin-api | |
parent | c761abccb5c2a3a64e36f4bcafc21b111c591346 (diff) | |
download | sonarqube-9d7b312b6d6cd5487c232092abb1c5bd623b2654.tar.gz sonarqube-9d7b312b6d6cd5487c232092abb1c5bd623b2654.zip |
Add some unit tests
Diffstat (limited to 'sonar-plugin-api')
2 files changed, 55 insertions, 0 deletions
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/ProjectPropertyConditionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/ProjectPropertyConditionTest.java index 7e3344d528a..d0b77e6e87d 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/ProjectPropertyConditionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/condition/ProjectPropertyConditionTest.java @@ -19,13 +19,20 @@ */ package org.sonar.api.workflow.condition; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.sonar.api.workflow.Review; import org.sonar.api.workflow.WorkflowContext; +import javax.annotation.Nullable; + import static org.fest.assertions.Assertions.assertThat; public class ProjectPropertyConditionTest { + @Rule + public ExpectedException thrown = ExpectedException.none(); + @Test public void getPropertyKey() { ProjectPropertyCondition condition = new ProjectPropertyCondition("foo") { @@ -36,4 +43,15 @@ public class ProjectPropertyConditionTest { }; assertThat(condition.getPropertyKey()).isEqualTo("foo"); } + + @Test + public void keyIsMandatory() { + thrown.expect(IllegalArgumentException.class); + new ProjectPropertyCondition(""){ + @Override + public boolean doVerify(@Nullable Review review, WorkflowContext context) { + return false; + } + }; + } } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/workflow/internal/DefaultReviewTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/internal/DefaultReviewTest.java new file mode 100644 index 00000000000..e48208a0c69 --- /dev/null +++ b/sonar-plugin-api/src/test/java/org/sonar/api/workflow/internal/DefaultReviewTest.java @@ -0,0 +1,37 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2012 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * Sonar is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.api.workflow.internal; + +import org.junit.Test; +import org.sonar.api.workflow.MutableReview; + +import static org.fest.assertions.Assertions.assertThat; + +public class DefaultReviewTest { + @Test + public void createComment_keep_order() { + MutableReview review = new DefaultReview(); + review.createComment().setMarkdownText("first"); + review.createComment().setMarkdownText("second"); + assertThat(review.getNewComments()).hasSize(2); + assertThat(review.getNewComments().get(0).getMarkdownText()).isEqualTo("first"); + assertThat(review.getNewComments().get(1).getMarkdownText()).isEqualTo("second"); + } +} |