aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch/src/test
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-03-28 09:33:44 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2014-03-28 09:34:33 +0100
commit9104d7e4e0728d367b00bb97596c29814b3ccbcd (patch)
treee14b8e0ad1e1735fe701889cdfdce38e7b0050a3 /sonar-batch/src/test
parentdf7eece07a8d3a3344f3c4649c8663afc310da92 (diff)
downloadsonarqube-9104d7e4e0728d367b00bb97596c29814b3ccbcd.tar.gz
sonarqube-9104d7e4e0728d367b00bb97596c29814b3ccbcd.zip
SONAR-4692 Fix regression with SONAR-4245
Diffstat (limited to 'sonar-batch/src/test')
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java17
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorValidatorTest.java21
2 files changed, 21 insertions, 17 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java
index a89a72bdd87..c4c7dfd4093 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java
@@ -30,7 +30,6 @@ import org.sonar.api.resources.File;
import org.sonar.api.resources.Library;
import org.sonar.api.resources.Project;
import org.sonar.api.security.ResourcePermissions;
-import org.sonar.api.utils.SonarException;
import org.sonar.jpa.test.AbstractDbUnitTestCase;
import java.text.ParseException;
@@ -122,22 +121,6 @@ public class DefaultResourcePersisterTest extends AbstractDbUnitTestCase {
checkTables("shouldSaveNewMultiModulesProject", new String[] {"build_date", "created_at"}, "projects", "snapshots");
}
- // SONAR-4245
- @Test
- public void shouldFailWhenTryingToConvertProjectIntoModule() {
- setupData("shared");
-
- ResourcePersister persister = new DefaultResourcePersister(getSession(), mock(ResourcePermissions.class), snapshotCache, resourceCache);
- existingProject.setParent(multiModuleProject);
- persister.saveProject(multiModuleProject, null);
-
- thrown.expect(SonarException.class);
- thrown.expectMessage("The project 'my:key' is already defined in SonarQube but not as a module of project 'root'. "
- + "If you really want to stop directly analysing project 'my:key', please first delete it from SonarQube and then relaunch the analysis of project 'root'.");
-
- persister.saveProject(existingProject, multiModuleProject);
- }
-
@Test
public void shouldSaveNewDirectory() {
setupData("shared");
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorValidatorTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorValidatorTest.java
index aae479813fc..491f5b9adc1 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorValidatorTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectReactorValidatorTest.java
@@ -112,6 +112,27 @@ public class ProjectReactorValidatorTest {
validator.validate(reactor);
}
+ // SONAR-4245
+ @Test
+ public void shouldFailWhenTryingToConvertProjectIntoModule() {
+ String rootProjectKey = "project-key";
+ String moduleKey = "module-key";
+ ResourceDto rootResource = mock(ResourceDto.class);
+
+ when(rootResource.getKey()).thenReturn(moduleKey);
+
+ when(resourceDao.getRootProjectByComponentKey(moduleKey)).thenReturn(rootResource);
+
+ ProjectReactor reactor = createProjectReactor(rootProjectKey);
+ reactor.getRoot().addSubProject(ProjectDefinition.create().setProperty(CoreProperties.PROJECT_KEY_PROPERTY, moduleKey));
+
+ thrown.expect(SonarException.class);
+ thrown.expectMessage("The project 'module-key' is already defined in SonarQube but not as a module of project 'project-key'. "
+ + "If you really want to stop directly analysing project 'module-key', please first delete it from SonarQube and then relaunch the analysis of project 'project-key'.");
+
+ validator.validate(reactor);
+ }
+
@Test
public void not_fail_with_valid_key() {
validator.validate(createProjectReactor("foo"));