diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2015-01-07 17:09:55 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2015-01-07 17:12:34 +0100 |
commit | bde531603464da7c5dacf2e7f4c5ea2e4555a986 (patch) | |
tree | af7260e77b169f904a84a2cd38e5d23d89db024e /sonar-batch/src/test | |
parent | 5e0ae3ee7eb976ecf1bcac626535c5889ef2f5be (diff) | |
download | sonarqube-bde531603464da7c5dacf2e7f4c5ea2e4555a986.tar.gz sonarqube-bde531603464da7c5dacf2e7f4c5ea2e4555a986.zip |
SONAR-6014 Isolate persistence of resources to ease its removal in preview mode
Diffstat (limited to 'sonar-batch/src/test')
21 files changed, 58 insertions, 63 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java index e943cf779ca..42ca92d27b2 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/index/DefaultIndexTest.java @@ -25,7 +25,6 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.sonar.api.batch.bootstrap.ProjectDefinition; import org.sonar.api.batch.measure.MetricFinder; -import org.sonar.api.database.model.Snapshot; import org.sonar.api.measures.CoreMetrics; import org.sonar.api.measures.Measure; import org.sonar.api.measures.MeasuresFilters; @@ -45,13 +44,11 @@ import org.sonar.batch.ProjectTree; import org.sonar.batch.issue.DeprecatedViolations; import org.sonar.batch.issue.ModuleIssues; import org.sonar.batch.scan.measure.MeasureCache; -import org.sonar.core.component.ScanGraph; import java.io.IOException; import static com.google.common.collect.Lists.newArrayList; import static org.fest.assertions.Assertions.assertThat; -import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -80,8 +77,8 @@ public class DefaultIndexTest { ruleFinder = mock(RuleFinder.class); ProjectTree projectTree = mock(ProjectTree.class); - ResourcePersister resourcePersister = mock(ResourcePersister.class); - index = new DefaultIndex(resourcePersister, null, null, null, projectTree, metricFinder, mock(ScanGraph.class), deprecatedViolations, + ResourceCache resourceCache = new ResourceCache(); + index = new DefaultIndex(resourceCache, null, null, null, projectTree, metricFinder, deprecatedViolations, mock(ResourceKeyMigration.class), mock(MeasureCache.class)); @@ -95,9 +92,6 @@ public class DefaultIndexTest { moduleB1 = new Project("moduleB1").setParent(moduleB); when(projectTree.getProjectDefinition(moduleB1)).thenReturn(ProjectDefinition.create().setBaseDir(new java.io.File(baseDir, "moduleB/moduleB1"))); - when(resourcePersister.saveResource(any(Project.class), any(Resource.class), any(Resource.class))).thenReturn( - new BatchResource(1, mock(Resource.class), new Snapshot().setId(1), null)); - RulesProfile rulesProfile = RulesProfile.create(); rule = Rule.create("repoKey", "ruleKey", "Rule"); rule.setId(1); diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/FileHashesPersisterTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/FileHashesPersisterTest.java index c66809ec396..5d01dde9045 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/index/FileHashesPersisterTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/index/FileHashesPersisterTest.java @@ -57,7 +57,7 @@ public class FileHashesPersisterTest extends AbstractDaoTestCase { Snapshot snapshot = new Snapshot(); snapshot.setId(100); snapshot.setResourceId(200); - resourceCache.add(new Project("myProject").setId(200), null, snapshot); + resourceCache.add(new Project("myProject").setId(200), null).setSnapshot(snapshot); data = new ComponentDataCache(caches); data.setStringData("myProject", SnapshotDataTypes.FILE_HASHES, "org/struts/Action.java=123ABC"); diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/MeasurePersisterTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/MeasurePersisterTest.java index 3ebb40264a2..8beab279cbf 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/index/MeasurePersisterTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/index/MeasurePersisterTest.java @@ -201,7 +201,7 @@ public class MeasurePersisterTest extends AbstractDaoTestCase { private static BatchResource batchResource(Resource resource, int id) { Snapshot snapshot = mock(Snapshot.class); when(snapshot.getId()).thenReturn(id); - return new BatchResource(1, resource, snapshot, null); + return new BatchResource(1, resource, null).setSnapshot(snapshot); } private static Metric ncloc() { diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/ResourceCacheTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/ResourceCacheTest.java index bc4330f8734..466947602c0 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/index/ResourceCacheTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/index/ResourceCacheTest.java @@ -20,7 +20,6 @@ package org.sonar.batch.index; import org.junit.Test; -import org.sonar.api.database.model.Snapshot; import org.sonar.api.resources.File; import org.sonar.api.resources.Resource; @@ -33,7 +32,7 @@ public class ResourceCacheTest { ResourceCache cache = new ResourceCache(); String componentKey = "struts:src/org/struts/Action.java"; Resource resource = new File("org/struts/Action.java").setEffectiveKey(componentKey); - cache.add(resource, null, new Snapshot()); + cache.add(resource, null); assertThat(cache.get(componentKey).resource()).isSameAs(resource); assertThat(cache.get("other")).isNull(); @@ -44,7 +43,7 @@ public class ResourceCacheTest { ResourceCache cache = new ResourceCache(); Resource resource = new File("org/struts/Action.java").setEffectiveKey(null); try { - cache.add(resource, null, new Snapshot()); + cache.add(resource, null); fail(); } catch (IllegalStateException e) { // success diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/ResourcePersisterTest.java index d08e6b9ded3..33da7d65bed 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/index/ResourcePersisterTest.java @@ -57,7 +57,7 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -public class DefaultResourcePersisterTest extends AbstractDbUnitTestCase { +public class ResourcePersisterTest extends AbstractDbUnitTestCase { @Rule public ExpectedException thrown = ExpectedException.none(); @@ -68,6 +68,12 @@ public class DefaultResourcePersisterTest extends AbstractDbUnitTestCase { private Project singleProject, singleCopyProject, multiModuleProject, moduleA, moduleB, moduleB1, existingProject; private ResourceCache resourceCache; + private ResourcePersister persister; + + private ProjectTree projectTree; + + private ResourcePermissions permissions; + @Before public void before() throws ParseException { resourceCache = new ResourceCache(); @@ -99,14 +105,17 @@ public class DefaultResourcePersisterTest extends AbstractDbUnitTestCase { moduleB1.setName("B1").setAnalysisDate(format.parse("25/12/2010")); moduleB1.setParent(moduleB); moduleB1.setPath("/moduleB1"); + + projectTree = mock(ProjectTree.class); + permissions = mock(ResourcePermissions.class); + persister = new ResourcePersister(projectTree, getSession(), permissions, resourceCache, mock(ScanGraph.class)); } @Test public void shouldSaveNewProject() { setupData("shared"); - ResourcePersister persister = new DefaultResourcePersister(getSession(), mock(ResourcePermissions.class), resourceCache); - persister.saveProject(singleProject, null); + persister.persist(null, singleProject, null); checkTables("shouldSaveNewProject", new String[] {"build_date", "created_at", "authorization_updated_at", "uuid", "project_uuid", "module_uuid", "module_uuid_path"}, "projects", "snapshots"); @@ -128,8 +137,7 @@ public class DefaultResourcePersisterTest extends AbstractDbUnitTestCase { public void shouldSaveCopyProject() { setupData("shared"); - ResourcePersister persister = new DefaultResourcePersister(getSession(), mock(ResourcePermissions.class), resourceCache); - persister.saveProject(singleCopyProject, null); + persister.persist(null, singleCopyProject, null); checkTables("shouldSaveCopyProject", new String[] {"build_date", "created_at", "authorization_updated_at", "uuid", "project_uuid", "module_uuid", "module_uuid_path"}, "projects", "snapshots"); @@ -148,15 +156,14 @@ public class DefaultResourcePersisterTest extends AbstractDbUnitTestCase { public void shouldSaveNewMultiModulesProject() { setupData("shared"); - ResourcePersister persister = new DefaultResourcePersister(getSession(), mock(ResourcePermissions.class), resourceCache); - persister.saveProject(multiModuleProject, null); - persister.saveProject(moduleA, multiModuleProject); - persister.saveProject(moduleB, multiModuleProject); - persister.saveProject(moduleB1, moduleB); + resourceCache.add(multiModuleProject, null).setSnapshot(persister.persist(null, multiModuleProject, null)); + resourceCache.add(moduleA, multiModuleProject).setSnapshot(persister.persist(null, moduleA, multiModuleProject)); + resourceCache.add(moduleB, multiModuleProject).setSnapshot(persister.persist(null, moduleB, multiModuleProject)); + resourceCache.add(moduleB1, moduleB).setSnapshot(persister.persist(null, moduleB1, moduleB)); Resource file = File.create("src/main/java/org/Foo.java").setEffectiveKey("b1:src/main/java/org/Foo.java"); file.getParent().setEffectiveKey("b1:src/main/java/org"); - persister.saveResource(moduleB1, file.getParent()); - persister.saveResource(moduleB1, file, file.getParent()); + resourceCache.add(file.getParent(), moduleB1).setSnapshot(persister.persist(moduleB1, file.getParent(), null)); + persister.persist(moduleB1, file, file.getParent()); checkTables("shouldSaveNewMultiModulesProject", new String[] {"build_date", "created_at", "authorization_updated_at", "uuid", "project_uuid", "module_uuid", "module_uuid_path"}, "projects", "snapshots"); @@ -209,16 +216,13 @@ public class DefaultResourcePersisterTest extends AbstractDbUnitTestCase { java.io.File baseDir = temp.newFolder(); - ResourcePersister persister = new DefaultResourcePersister(getSession(), mock(ResourcePermissions.class), resourceCache); - - ProjectTree projectTree = mock(ProjectTree.class); when(projectTree.getRootProject()).thenReturn(multiModuleProject); when(projectTree.getProjectDefinition(multiModuleProject)).thenReturn(ProjectDefinition.create().setBaseDir(baseDir)); when(projectTree.getProjectDefinition(moduleA)).thenReturn(ProjectDefinition.create().setBaseDir(new java.io.File(baseDir, "moduleA"))); when(projectTree.getProjectDefinition(moduleB)).thenReturn(ProjectDefinition.create().setBaseDir(new java.io.File(baseDir, "moduleB"))); when(projectTree.getProjectDefinition(moduleB1)).thenReturn(ProjectDefinition.create().setBaseDir(new java.io.File(baseDir, "moduleB/moduleB1"))); - DefaultIndex index = new DefaultIndex(persister, null, null, null, projectTree, mock(MetricFinder.class), mock(ScanGraph.class), + DefaultIndex index = new DefaultIndex(resourceCache, null, null, null, projectTree, mock(MetricFinder.class), mock(DeprecatedViolations.class), mock(ResourceKeyMigration.class), mock(MeasureCache.class)); @@ -233,6 +237,8 @@ public class DefaultResourcePersisterTest extends AbstractDbUnitTestCase { // Emulate another project having library dependency on moduleA index.addResource(new Library(moduleA.getKey(), "1.0")); + persister.persist(); + checkTables("shouldSaveNewMultiModulesProjectAndLibrary", new String[] {"build_date", "created_at", "authorization_updated_at", "uuid", "project_uuid", "module_uuid", "module_uuid_path"}, "projects", "snapshots"); @@ -285,10 +291,8 @@ public class DefaultResourcePersisterTest extends AbstractDbUnitTestCase { public void shouldSaveNewDirectory() { setupData("shared"); - ResourcePersister persister = new DefaultResourcePersister(getSession(), mock(ResourcePermissions.class), resourceCache); - persister.saveProject(singleProject, null); - persister.saveResource(singleProject, - Directory.create("src/main/java/org/foo", "org.foo").setEffectiveKey("foo:src/main/java/org/foo")); + resourceCache.add(singleProject, null).setSnapshot(persister.persist(null, singleProject, null)); + persister.persist(singleProject, Directory.create("src/main/java/org/foo", "org.foo").setEffectiveKey("foo:src/main/java/org/foo"), null); // check that the directory is attached to the project checkTables("shouldSaveNewDirectory", new String[] {"build_date", "created_at", "authorization_updated_at", "uuid", "project_uuid", "module_uuid", "module_uuid_path"}, "projects", "snapshots"); @@ -319,11 +323,11 @@ public class DefaultResourcePersisterTest extends AbstractDbUnitTestCase { public void shouldSaveNewLibrary() { setupData("shared"); - ResourcePersister persister = new DefaultResourcePersister(getSession(), mock(ResourcePermissions.class), resourceCache); - persister.saveProject(singleProject, null); - persister.saveResource(singleProject, new Library("junit:junit", "4.8.2").setEffectiveKey("junit:junit")); - persister.saveResource(singleProject, new Library("junit:junit", "4.8.2").setEffectiveKey("junit:junit"));// do nothing, already saved - persister.saveResource(singleProject, new Library("junit:junit", "3.2").setEffectiveKey("junit:junit")); + persister.persist(null, singleProject, null); + persister.persist(singleProject, new Library("junit:junit", "4.8.2").setEffectiveKey("junit:junit"), null); + persister.persist(singleProject, new Library("junit:junit", "4.8.2").setEffectiveKey("junit:junit"), null);// do nothing, already + // saved + persister.persist(singleProject, new Library("junit:junit", "3.2").setEffectiveKey("junit:junit"), null); checkTables("shouldSaveNewLibrary", new String[] {"build_date", "created_at", "authorization_updated_at", "uuid", "project_uuid", "module_uuid", "module_uuid_path"}, "projects", "snapshots"); @@ -344,10 +348,9 @@ public class DefaultResourcePersisterTest extends AbstractDbUnitTestCase { public void shouldUpdateExistingResource() { setupData("shouldUpdateExistingResource"); - ResourcePersister persister = new DefaultResourcePersister(getSession(), mock(ResourcePermissions.class), resourceCache); singleProject.setName("new name"); singleProject.setDescription("new description"); - persister.saveProject(singleProject, null); + persister.persist(null, singleProject, null); checkTables("shouldUpdateExistingResource", new String[] {"build_date", "created_at", "authorization_updated_at"}, "projects", "snapshots"); } @@ -357,8 +360,7 @@ public class DefaultResourcePersisterTest extends AbstractDbUnitTestCase { public void shouldRemoveRootIndexIfResourceIsProject() { setupData("shouldRemoveRootIndexIfResourceIsProject"); - ResourcePersister persister = new DefaultResourcePersister(getSession(), mock(ResourcePermissions.class), resourceCache); - persister.saveProject(singleProject, null); + persister.persist(null, singleProject, null); checkTables("shouldRemoveRootIndexIfResourceIsProject", new String[] {"build_date", "created_at", "authorization_updated_at"}, "projects", "snapshots"); } @@ -367,11 +369,9 @@ public class DefaultResourcePersisterTest extends AbstractDbUnitTestCase { public void shouldGrantDefaultPermissionsIfNewProject() { setupData("shared"); - ResourcePermissions permissions = mock(ResourcePermissions.class); when(permissions.hasRoles(singleProject)).thenReturn(false); - ResourcePersister persister = new DefaultResourcePersister(getSession(), permissions, resourceCache); - persister.saveProject(singleProject, null); + persister.persist(null, singleProject, null); verify(permissions).grantDefaultRoles(singleProject); } @@ -380,11 +380,9 @@ public class DefaultResourcePersisterTest extends AbstractDbUnitTestCase { public void shouldNotGrantDefaultPermissionsIfExistingProject() { setupData("shared"); - ResourcePermissions permissions = mock(ResourcePermissions.class); when(permissions.hasRoles(singleProject)).thenReturn(true); - ResourcePersister persister = new DefaultResourcePersister(getSession(), permissions, resourceCache); - persister.saveProject(singleProject, null); + persister.persist(null, singleProject, null); verify(permissions, never()).grantDefaultRoles(singleProject); } diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/SourcePersisterTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/SourcePersisterTest.java index 40d6d14ce34..8f7289f2466 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/index/SourcePersisterTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/index/SourcePersisterTest.java @@ -384,7 +384,7 @@ public class SourcePersisterTest extends AbstractDaoTestCase { private void mockResourceCache(String relativePathEmpty, String projectKey, String uuid) { File sonarFile = File.create(relativePathEmpty); sonarFile.setUuid(uuid); - when(resourceCache.get(projectKey + ":" + relativePathEmpty)).thenReturn(new BatchResource(1, sonarFile, new Snapshot(), null)); + when(resourceCache.get(projectKey + ":" + relativePathEmpty)).thenReturn(new BatchResource(1, sonarFile, null)); } private byte[] md5(String string) { diff --git a/sonar-batch/src/test/java/org/sonar/batch/issue/DeprecatedViolationsTest.java b/sonar-batch/src/test/java/org/sonar/batch/issue/DeprecatedViolationsTest.java index a94578a5769..b5c7862c740 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/issue/DeprecatedViolationsTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/issue/DeprecatedViolationsTest.java @@ -20,7 +20,6 @@ package org.sonar.batch.issue; import org.junit.Test; -import org.sonar.api.database.model.Snapshot; import org.sonar.api.issue.internal.DefaultIssue; import org.sonar.api.resources.Project; import org.sonar.api.rule.RuleKey; @@ -50,7 +49,7 @@ public class DeprecatedViolationsTest { public void test_toViolation() throws Exception { RuleKey ruleKey = RuleKey.of("squid", "AvoidCycles"); when(ruleFinder.findByKey(ruleKey)).thenReturn(new Rule("squid", "AvoidCycles")); - when(resourceCache.get("org.apache:struts")).thenReturn(new BatchResource(1, new Project("org.apache:struts"), new Snapshot(), null)); + when(resourceCache.get("org.apache:struts")).thenReturn(new BatchResource(1, new Project("org.apache:struts"), null)); DefaultIssue issue = newIssue(ruleKey); @@ -80,7 +79,7 @@ public class DeprecatedViolationsTest { public void test_get() throws Exception { RuleKey ruleKey = RuleKey.of("squid", "AvoidCycles"); when(ruleFinder.findByKey(ruleKey)).thenReturn(new Rule("squid", "AvoidCycles")); - when(resourceCache.get("org.apache:struts")).thenReturn(new BatchResource(1, new Project("org.apache:struts"), new Snapshot(), null)); + when(resourceCache.get("org.apache:struts")).thenReturn(new BatchResource(1, new Project("org.apache:struts"), null)); when(issueCache.byComponent("org.apache:struts")).thenReturn(Arrays.asList(newIssue(ruleKey))); List<Violation> violations = deprecatedViolations.get("org.apache:struts"); diff --git a/sonar-batch/src/test/java/org/sonar/batch/qualitygate/QualityGateVerifierTest.java b/sonar-batch/src/test/java/org/sonar/batch/qualitygate/QualityGateVerifierTest.java index f323737ca37..f33205097d1 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/qualitygate/QualityGateVerifierTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/qualitygate/QualityGateVerifierTest.java @@ -95,7 +95,7 @@ public class QualityGateVerifierTest { project = new Project("foo"); resourceCache = new ResourceCache(); - resourceCache.add(project, null, snapshot); + resourceCache.add(project, null).setSnapshot(snapshot); verifier = new QualityGateVerifier(qualityGate, resourceCache, periods, i18n, durations); } diff --git a/sonar-batch/src/test/java/org/sonar/batch/report/ComponentsPublisherTest.java b/sonar-batch/src/test/java/org/sonar/batch/report/ComponentsPublisherTest.java index 28932c22148..8c2722d11bc 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/report/ComponentsPublisherTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/report/ComponentsPublisherTest.java @@ -28,7 +28,12 @@ import org.skyscreamer.jsonassert.JSONAssert; import org.sonar.api.batch.bootstrap.ProjectDefinition; import org.sonar.api.batch.bootstrap.ProjectReactor; import org.sonar.api.database.model.Snapshot; -import org.sonar.api.resources.*; +import org.sonar.api.resources.Directory; +import org.sonar.api.resources.Java; +import org.sonar.api.resources.Language; +import org.sonar.api.resources.Project; +import org.sonar.api.resources.Qualifiers; +import org.sonar.api.resources.Scopes; import org.sonar.batch.index.ResourceCache; import java.io.File; @@ -47,27 +52,27 @@ public class ComponentsPublisherTest { Project root = new Project("foo").setName("Root project").setAnalysisDate(new SimpleDateFormat("dd/MM/yyyy").parse("12/12/2012")); root.setId(1); - resourceCache.add(root, null, new Snapshot().setId(11)); + resourceCache.add(root, null).setSnapshot(new Snapshot().setId(11)); Project module1 = new Project("module1").setName("Module1"); module1.setParent(root); module1.setId(2); - resourceCache.add(module1, root, new Snapshot().setId(12)); + resourceCache.add(module1, root).setSnapshot(new Snapshot().setId(12)); Directory dir1 = Directory.create("src"); dir1.setEffectiveKey("foo:src"); dir1.setId(3); - resourceCache.add(dir1, module1, new Snapshot().setId(13)); + resourceCache.add(dir1, module1).setSnapshot(new Snapshot().setId(13)); org.sonar.api.resources.File mainFile = org.sonar.api.resources.File.create("src/Foo.java", "Foo.java", Java.INSTANCE, false); mainFile.setEffectiveKey("foo:src/Foo.java"); mainFile.setId(4); - resourceCache.add(mainFile, dir1, new Snapshot().setId(14)); + resourceCache.add(mainFile, dir1).setSnapshot(new Snapshot().setId(14)); Directory dir2 = Directory.create("test"); dir2.setEffectiveKey("foo:test"); dir2.setId(5); - resourceCache.add(dir2, module1, new Snapshot().setId(15)); + resourceCache.add(dir2, module1).setSnapshot(new Snapshot().setId(15)); org.sonar.api.resources.File testFile = org.sonar.api.resources.File.create("test/FooTest.java", "FooTest.java", Java.INSTANCE, true); testFile.setEffectiveKey("foo:test/FooTest.java"); testFile.setId(6); - resourceCache.add(testFile, dir2, new Snapshot().setId(16)); + resourceCache.add(testFile, dir2).setSnapshot(new Snapshot().setId(16)); File exportDir = temp.newFolder(); publisher.export(exportDir); @@ -87,12 +92,12 @@ public class ComponentsPublisherTest { View view = new View("ALL_PROJECT"); view.setId(1); view.setAnalysisDate(new SimpleDateFormat("dd/MM/yyyy").parse("12/12/2012")); - resourceCache.add(view, null, new Snapshot().setId(11)); + resourceCache.add(view, null).setSnapshot(new Snapshot().setId(11)); org.sonar.api.resources.File mainFile = org.sonar.api.resources.File.create("ALL_PROJECTsample", "ALL_PROJECTsample", null, false); mainFile.setEffectiveKey("ALL_PROJECTsample"); mainFile.setId(2); - resourceCache.add(mainFile, view, new Snapshot().setId(12)); + resourceCache.add(mainFile, view).setSnapshot(new Snapshot().setId(12)); File exportDir = temp.newFolder(); publisher.export(exportDir); diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/PreviousFileHashLoaderTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/PreviousFileHashLoaderTest.java index 86fa1d726b5..6ae7fef716a 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/PreviousFileHashLoaderTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/PreviousFileHashLoaderTest.java @@ -59,7 +59,7 @@ public class PreviousFileHashLoaderTest { @Before public void prepare() { resourceCache = new ResourceCache(); - resourceCache.add(project, null, snapshot); + resourceCache.add(project, null).setSnapshot(snapshot); loader = new PreviousFileHashLoader(project, resourceCache, snapshotDataDao, pastSnapshotFinder); } diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shared.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/ResourcePersisterTest/shared.xml index e031ae4ef66..e031ae4ef66 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shared.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/ResourcePersisterTest/shared.xml diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/ResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject-result.xml index 283baaf3dde..283baaf3dde 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/ResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject-result.xml diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/ResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject.xml index 81d3d953079..81d3d953079 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/ResourcePersisterTest/shouldRemoveRootIndexIfResourceIsProject.xml diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveCopyProject-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/ResourcePersisterTest/shouldSaveCopyProject-result.xml index 833ebcd5438..833ebcd5438 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveCopyProject-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/ResourcePersisterTest/shouldSaveCopyProject-result.xml diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewDirectory-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/ResourcePersisterTest/shouldSaveNewDirectory-result.xml index 4ac03aed376..4ac03aed376 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewDirectory-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/ResourcePersisterTest/shouldSaveNewDirectory-result.xml diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewLibrary-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/ResourcePersisterTest/shouldSaveNewLibrary-result.xml index 1f2478a3fc3..1f2478a3fc3 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewLibrary-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/ResourcePersisterTest/shouldSaveNewLibrary-result.xml diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewMultiModulesProject-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/ResourcePersisterTest/shouldSaveNewMultiModulesProject-result.xml index f25ce3cbece..f25ce3cbece 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewMultiModulesProject-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/ResourcePersisterTest/shouldSaveNewMultiModulesProject-result.xml diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewMultiModulesProjectAndLibrary-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/ResourcePersisterTest/shouldSaveNewMultiModulesProjectAndLibrary-result.xml index c16c139570f..c16c139570f 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewMultiModulesProjectAndLibrary-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/ResourcePersisterTest/shouldSaveNewMultiModulesProjectAndLibrary-result.xml diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewProject-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/ResourcePersisterTest/shouldSaveNewProject-result.xml index 7b0e006507a..7b0e006507a 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldSaveNewProject-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/ResourcePersisterTest/shouldSaveNewProject-result.xml diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/ResourcePersisterTest/shouldUpdateExistingResource-result.xml index d04674f42b8..d04674f42b8 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource-result.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/ResourcePersisterTest/shouldUpdateExistingResource-result.xml diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/ResourcePersisterTest/shouldUpdateExistingResource.xml index 674397123dd..674397123dd 100644 --- a/sonar-batch/src/test/resources/org/sonar/batch/index/DefaultResourcePersisterTest/shouldUpdateExistingResource.xml +++ b/sonar-batch/src/test/resources/org/sonar/batch/index/ResourcePersisterTest/shouldUpdateExistingResource.xml |