]> source.dussan.org Git - sonarqube.git/commitdiff
Add JUnit test
authorJulien HENRY <julien.henry@sonarsource.com>
Mon, 12 Jan 2015 14:02:23 +0000 (15:02 +0100)
committerJulien HENRY <julien.henry@sonarsource.com>
Tue, 13 Jan 2015 13:08:00 +0000 (14:08 +0100)
sonar-batch/src/test/java/org/sonar/batch/phases/DefaultPhaseExecutorTest.java [new file with mode: 0644]

diff --git a/sonar-batch/src/test/java/org/sonar/batch/phases/DefaultPhaseExecutorTest.java b/sonar-batch/src/test/java/org/sonar/batch/phases/DefaultPhaseExecutorTest.java
new file mode 100644 (file)
index 0000000..b88413b
--- /dev/null
@@ -0,0 +1,34 @@
+package org.sonar.batch.phases;
+
+import org.junit.Test;
+import org.sonar.batch.index.MeasurePersister;
+import org.sonar.batch.index.ResourcePersister;
+import org.sonar.batch.index.ScanPersister;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+
+public class DefaultPhaseExecutorTest {
+
+  @Test
+  public void shouldSortPersisters() {
+    ScanPersister otherPersister = mock(ScanPersister.class);
+    MeasurePersister measurePersister = new MeasurePersister(null, null, null, null, null);
+    ResourcePersister resourcePersister = new ResourcePersister(null, null, null, null, null);
+    ScanPersister[] persisters = new ScanPersister[] {otherPersister, measurePersister, resourcePersister};
+    DefaultPhaseExecutor executor = new DefaultPhaseExecutor(null, null, null, null, null, null,
+      null, null, null, null, null, persisters, null, null, null, null, null, null, null);
+    assertThat(executor.sortedPersisters()).containsSubsequence(resourcePersister, measurePersister);
+
+    persisters = new ScanPersister[] {measurePersister, resourcePersister, otherPersister};
+    executor = new DefaultPhaseExecutor(null, null, null, null, null, null,
+      null, null, null, null, null, persisters, null, null, null, null, null, null, null);
+    assertThat(executor.sortedPersisters()).containsSubsequence(resourcePersister, measurePersister);
+
+    persisters = new ScanPersister[] {measurePersister, otherPersister, resourcePersister};
+    executor = new DefaultPhaseExecutor(null, null, null, null, null, null,
+      null, null, null, null, null, persisters, null, null, null, null, null, null, null);
+    assertThat(executor.sortedPersisters()).containsSubsequence(resourcePersister, measurePersister);
+  }
+
+}