diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2013-10-15 14:20:18 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2013-10-15 14:20:18 +0200 |
commit | bd02f1ce636cd4257731c3c9b0e093e4c17bcae5 (patch) | |
tree | 17b8562947b4bb892462ecad960dbdd56907999d /sonar-batch | |
parent | 44acd4b3748df33c4f46b2cf5f265c1c5c1355a0 (diff) | |
download | sonarqube-bd02f1ce636cd4257731c3c9b0e093e4c17bcae5.tar.gz sonarqube-bd02f1ce636cd4257731c3c9b0e093e4c17bcae5.zip |
Add unit test for AnalysisMode
Diffstat (limited to 'sonar-batch')
-rw-r--r-- | sonar-batch/src/test/java/org/sonar/batch/bootstrap/AnalysisModeTest.java | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/AnalysisModeTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/AnalysisModeTest.java new file mode 100644 index 00000000000..3026faf9d34 --- /dev/null +++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/AnalysisModeTest.java @@ -0,0 +1,92 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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 this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.batch.bootstrap; + +import org.junit.Before; +import org.junit.Test; +import org.sonar.api.CoreProperties; + +import java.util.Collections; + +import static org.fest.assertions.Assertions.assertThat; + +public class AnalysisModeTest { + + BootstrapSettings bootstrapSettings; + + @Before + public void prepare() { + bootstrapSettings = new BootstrapSettings(new BootstrapProperties(Collections.<String, String>emptyMap())); + } + + @Test + public void regular_analysis_by_default() { + AnalysisMode mode = new AnalysisMode(bootstrapSettings); + + assertThat(mode.isPreview()).isFalse(); + assertThat(mode.isIncremental()).isFalse(); + + bootstrapSettings.properties().put(CoreProperties.ANALYSIS_MODE, "pouet"); + mode = new AnalysisMode(bootstrapSettings); + + assertThat(mode.isPreview()).isFalse(); + assertThat(mode.isIncremental()).isFalse(); + } + + @Test + public void support_analysis_mode() { + bootstrapSettings.properties().put(CoreProperties.ANALYSIS_MODE, CoreProperties.ANALYSIS_MODE_ANALYSIS); + AnalysisMode mode = new AnalysisMode(bootstrapSettings); + + assertThat(mode.isPreview()).isFalse(); + assertThat(mode.isIncremental()).isFalse(); + } + + @Test + public void support_preview_mode() { + bootstrapSettings.properties().put(CoreProperties.ANALYSIS_MODE, CoreProperties.ANALYSIS_MODE_PREVIEW); + AnalysisMode mode = new AnalysisMode(bootstrapSettings); + + assertThat(mode.isPreview()).isTrue(); + assertThat(mode.isIncremental()).isFalse(); + + assertThat(bootstrapSettings.property(CoreProperties.DRY_RUN)).isEqualTo("true"); + } + + @Test + public void support_incremental_mode() { + bootstrapSettings.properties().put(CoreProperties.ANALYSIS_MODE, CoreProperties.ANALYSIS_MODE_INCREMENTAL); + AnalysisMode mode = new AnalysisMode(bootstrapSettings); + + assertThat(mode.isPreview()).isTrue(); + assertThat(mode.isIncremental()).isTrue(); + + assertThat(bootstrapSettings.property(CoreProperties.DRY_RUN)).isEqualTo("true"); + } + + @Test + public void support_deprecated_dryrun_property() { + bootstrapSettings.properties().put(CoreProperties.DRY_RUN, "true"); + AnalysisMode mode = new AnalysisMode(bootstrapSettings); + + assertThat(mode.isPreview()).isTrue(); + assertThat(mode.isIncremental()).isFalse(); + } +} |