Skip to content

Commit bce0bd0

Browse files
authored
MSONAR-211 Remove compatibility with old SQ modules( > 7.6 ) in ITs (#205)
1 parent 495d1c9 commit bce0bd0

File tree

1 file changed

+30
-89
lines changed

1 file changed

+30
-89
lines changed

its/src/test/java/com/sonar/maven/it/suite/MavenTest.java

+30-89
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,20 @@
2525
import com.sonar.orchestrator.build.MavenBuild;
2626
import java.io.File;
2727
import java.nio.file.Path;
28-
import java.util.List;
2928
import java.util.Map;
3029
import org.apache.commons.io.FileUtils;
3130

3231
import org.junit.jupiter.api.AfterEach;
3332
import org.junit.jupiter.api.Test;
3433
import org.junit.jupiter.api.io.TempDir;
35-
import org.sonarqube.ws.Components.Component;
3634
import org.sonarqube.ws.client.settings.SetRequest;
3735
import org.sonarqube.ws.client.users.CreateRequest;
3836

3937
import static org.assertj.core.api.Assertions.assertThat;
4038

4139
class MavenTest extends AbstractMavenTest {
4240

43-
private static final String MODULE_START_7_6 = "------------- Run sensors on module ";
44-
private static final String MODULE_START = "------------- Scan ";
41+
private static final String MODULE_START = "------------- Run sensors on module ";
4542

4643
@TempDir
4744
public Path temp;
@@ -152,11 +149,7 @@ void shouldSupportJarWithoutSources() {
152149
ORCHESTRATOR.executeBuild(build);
153150

154151
assertThat(getMeasureAsInteger("com.sonarsource.it.samples.project-with-module-without-sources:parent", "files")).isEqualTo(4);
155-
if (hasModules()) {
156-
assertThat(getComponent("com.sonarsource.it.samples.project-with-module-without-sources:without-sources")).isNotNull();
157-
} else {
158-
assertThat(getComponent("com.sonarsource.it.samples.project-with-module-without-sources:parent:without-sources")).isNotNull();
159-
}
152+
assertThat(getComponent("com.sonarsource.it.samples.project-with-module-without-sources:parent:without-sources")).isNotNull();
160153
}
161154

162155
/**
@@ -171,11 +164,6 @@ void shouldSupportJeeProjects() {
171164
// src/main/webapp is analyzed by web and xml plugin
172165
// including resources, so one more file (ejb-module/src/main/resources/META-INF/ejb-jar.xml)
173166
assertThat(getMeasureAsInteger("com.sonarsource.it.samples.jee:parent", "files")).isEqualTo(9);
174-
175-
if (hasModules()) {
176-
List<Component> modules = getModules("com.sonarsource.it.samples.jee:parent");
177-
assertThat(modules).hasSize(4);
178-
}
179167
}
180168

181169
/**
@@ -200,7 +188,7 @@ void testBadMavenParameters() {
200188
.setGoals(cleanSonarGoal());
201189
ORCHESTRATOR.executeBuild(build);
202190

203-
assertThat(getMeasureAsInteger("com.sonarsource.it.samples.maven-bad-parameters:parent", "files")).isGreaterThan(0);
191+
assertThat(getMeasureAsInteger("com.sonarsource.it.samples.maven-bad-parameters:parent", "files")).isPositive();
204192
}
205193

206194
@Test
@@ -211,24 +199,13 @@ void shouldAnalyzeMultiModules() {
211199

212200
assertThat(getComponent("org.sonar.tests.modules-order:root").getName()).isEqualTo("Sonar tests - modules order");
213201

214-
if (hasModules()) {
215-
assertThat(getComponent("org.sonar.tests.modules-order:parent").getName()).isEqualTo("Parent");
216-
217-
assertThat(getComponent("org.sonar.tests.modules-order:module_a").getName()).isEqualTo("Module A");
218-
assertThat(getComponent("org.sonar.tests.modules-order:module_b").getName()).isEqualTo("Module B");
219-
220-
assertThat(getComponent("org.sonar.tests.modules-order:module_a:src/main/java/HelloA.java").getName()).isEqualTo("HelloA.java");
221-
assertThat(getComponent("org.sonar.tests.modules-order:module_b:src/main/java/HelloB.java").getName()).isEqualTo("HelloB.java");
222-
} else {
223-
224-
assertThat(getComponent("org.sonar.tests.modules-order:root:parent").getName()).isEqualTo("parent");
202+
assertThat(getComponent("org.sonar.tests.modules-order:root:parent").getName()).isEqualTo("parent");
225203

226-
assertThat(getComponent("org.sonar.tests.modules-order:root:module_a").getName()).isEqualTo("module_a");
227-
assertThat(getComponent("org.sonar.tests.modules-order:root:module_b").getName()).isEqualTo("module_b");
204+
assertThat(getComponent("org.sonar.tests.modules-order:root:module_a").getName()).isEqualTo("module_a");
205+
assertThat(getComponent("org.sonar.tests.modules-order:root:module_b").getName()).isEqualTo("module_b");
228206

229-
assertThat(getComponent("org.sonar.tests.modules-order:root:module_a/src/main/java/HelloA.java").getName()).isEqualTo("HelloA.java");
230-
assertThat(getComponent("org.sonar.tests.modules-order:root:module_b/src/main/java/HelloB.java").getName()).isEqualTo("HelloB.java");
231-
}
207+
assertThat(getComponent("org.sonar.tests.modules-order:root:module_a/src/main/java/HelloA.java").getName()).isEqualTo("HelloA.java");
208+
assertThat(getComponent("org.sonar.tests.modules-order:root:module_b/src/main/java/HelloB.java").getName()).isEqualTo("HelloB.java");
232209
}
233210

234211
@Test
@@ -242,7 +219,7 @@ void shouldEvaluateSourceVersionOnEachModule() {
242219
}
243220

244221
private String findScanSectionOfModule(String logs, String moduleName) {
245-
String start = hasModules() ? MODULE_START : MODULE_START_7_6;
222+
String start = MODULE_START;
246223
int startSection = logs.indexOf(start + moduleName);
247224
assertThat(startSection).isNotEqualTo(-1);
248225
// This will match either a next section or the end of a maven plugin execution
@@ -262,11 +239,6 @@ void shouldAnalyzeMultiModulesAttachedToPhase() {
262239

263240
assertThat(getComponent("com.sonarsource.it.samples:attach-sonar-to-verify")).isNotNull();
264241
assertThat(getMeasureAsInteger("com.sonarsource.it.samples:attach-sonar-to-verify", "files")).isEqualTo(11);
265-
266-
if (hasModules()) {
267-
List<Component> modules = getModules("com.sonarsource.it.samples:attach-sonar-to-verify");
268-
assertThat(modules).hasSize(6);
269-
}
270242
}
271243

272244
/**
@@ -280,32 +252,18 @@ void shouldSupportDifferentDeclarationsForModules() {
280252

281253
assertThat(getComponent("org.sonar.tests.modules-declaration:root").getName()).isEqualTo("Root");
282254

283-
if (hasModules()) {
284-
assertThat(getComponent("org.sonar.tests.modules-declaration:module_a").getName()).isEqualTo("Module A");
285-
assertThat(getComponent("org.sonar.tests.modules-declaration:module_b").getName()).isEqualTo("Module B");
286-
assertThat(getComponent("org.sonar.tests.modules-declaration:module_c").getName()).isEqualTo("Module C");
287-
assertThat(getComponent("org.sonar.tests.modules-declaration:module_d").getName()).isEqualTo("Module D");
288-
assertThat(getComponent("org.sonar.tests.modules-declaration:module_e").getName()).isEqualTo("Module E");
289-
290-
assertThat(getComponent("org.sonar.tests.modules-declaration:module_a:src/main/java/HelloA.java").getName()).isEqualTo("HelloA.java");
291-
assertThat(getComponent("org.sonar.tests.modules-declaration:module_b:src/main/java/HelloB.java").getName()).isEqualTo("HelloB.java");
292-
assertThat(getComponent("org.sonar.tests.modules-declaration:module_c:src/main/java/HelloC.java").getName()).isEqualTo("HelloC.java");
293-
assertThat(getComponent("org.sonar.tests.modules-declaration:module_d:src/main/java/HelloD.java").getName()).isEqualTo("HelloD.java");
294-
assertThat(getComponent("org.sonar.tests.modules-declaration:module_e:src/main/java/HelloE.java").getName()).isEqualTo("HelloE.java");
295-
} else {
296-
assertThat(getComponent("org.sonar.tests.modules-declaration:root:module_a").getName()).isEqualTo("module_a");
297-
assertThat(getComponent("org.sonar.tests.modules-declaration:root:module_b").getName()).isEqualTo("module_b");
298-
assertThat(getComponent("org.sonar.tests.modules-declaration:root:module_c").getName()).isEqualTo("module_c");
299-
assertThat(getComponent("org.sonar.tests.modules-declaration:root:module_d").getName()).isEqualTo("module_d");
300-
// directories get collapsed
301-
assertThat(getComponent("org.sonar.tests.modules-declaration:root:module_e/src/main/java").getName()).isEqualTo("module_e/src/main/java");
302-
303-
assertThat(getComponent("org.sonar.tests.modules-declaration:root:module_a/src/main/java/HelloA.java").getName()).isEqualTo("HelloA.java");
304-
assertThat(getComponent("org.sonar.tests.modules-declaration:root:module_b/src/main/java/HelloB.java").getName()).isEqualTo("HelloB.java");
305-
assertThat(getComponent("org.sonar.tests.modules-declaration:root:module_c/src/main/java/HelloC.java").getName()).isEqualTo("HelloC.java");
306-
assertThat(getComponent("org.sonar.tests.modules-declaration:root:module_d/src/main/java/HelloD.java").getName()).isEqualTo("HelloD.java");
307-
assertThat(getComponent("org.sonar.tests.modules-declaration:root:module_e/src/main/java/HelloE.java").getName()).isEqualTo("HelloE.java");
308-
}
255+
assertThat(getComponent("org.sonar.tests.modules-declaration:root:module_a").getName()).isEqualTo("module_a");
256+
assertThat(getComponent("org.sonar.tests.modules-declaration:root:module_b").getName()).isEqualTo("module_b");
257+
assertThat(getComponent("org.sonar.tests.modules-declaration:root:module_c").getName()).isEqualTo("module_c");
258+
assertThat(getComponent("org.sonar.tests.modules-declaration:root:module_d").getName()).isEqualTo("module_d");
259+
// directories get collapsed
260+
assertThat(getComponent("org.sonar.tests.modules-declaration:root:module_e/src/main/java").getName()).isEqualTo("module_e/src/main/java");
261+
262+
assertThat(getComponent("org.sonar.tests.modules-declaration:root:module_a/src/main/java/HelloA.java").getName()).isEqualTo("HelloA.java");
263+
assertThat(getComponent("org.sonar.tests.modules-declaration:root:module_b/src/main/java/HelloB.java").getName()).isEqualTo("HelloB.java");
264+
assertThat(getComponent("org.sonar.tests.modules-declaration:root:module_c/src/main/java/HelloC.java").getName()).isEqualTo("HelloC.java");
265+
assertThat(getComponent("org.sonar.tests.modules-declaration:root:module_d/src/main/java/HelloD.java").getName()).isEqualTo("HelloD.java");
266+
assertThat(getComponent("org.sonar.tests.modules-declaration:root:module_e/src/main/java/HelloE.java").getName()).isEqualTo("HelloE.java");
309267
}
310268

311269
/**
@@ -316,7 +274,7 @@ void should_support_shade_with_dependency_reduced_pom_with_clean_install_sonar_g
316274
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/shade-with-dependency-reduced-pom"))
317275
.setGoals(cleanInstallSonarGoal());
318276
BuildResult result = ORCHESTRATOR.executeBuildQuietly(build);
319-
assertThat(result.getLastStatus()).isEqualTo(0);
277+
assertThat(result.getLastStatus()).isZero();
320278
assertThat(result.getLogs()).doesNotContain(
321279
"Unable to determine structure of project. Probably you use Maven Advanced Reactor Options, which is not supported by Sonar and should not be used.");
322280
}
@@ -354,11 +312,8 @@ void override_sources_in_multi_module() {
354312
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/multi-modules-override-sources")).setGoals(sonarGoal());
355313
ORCHESTRATOR.executeBuild(build);
356314

357-
if (hasModules()) {
358-
assertThat(getMeasureAsInteger("com.sonarsource.it.samples:module_a1", "files")).isEqualTo(1);
359-
} else {
360-
assertThat(getMeasureAsInteger("com.sonarsource.it.samples:multi-modules-sample:module_a", "files")).isEqualTo(2);
361-
}
315+
316+
assertThat(getMeasureAsInteger("com.sonarsource.it.samples:multi-modules-sample:module_a", "files")).isEqualTo(2);
362317
}
363318

364319
/**
@@ -370,11 +325,7 @@ void override_sources_in_multi_module_aggregator() {
370325
.setGoals(sonarGoal());
371326
ORCHESTRATOR.executeBuild(build);
372327

373-
if (hasModules()) {
374-
assertThat(getMeasureAsInteger("edu.marcelo:module-web", "files")).isEqualTo(2);
375-
} else {
376-
assertThat(getMeasureAsInteger("edu.marcelo:multi-module-aggregator:module-web/src/main/webapp", "files")).isEqualTo(2);
377-
}
328+
assertThat(getMeasureAsInteger("edu.marcelo:multi-module-aggregator:module-web/src/main/webapp", "files")).isEqualTo(2);
378329
}
379330

380331
/**
@@ -396,7 +347,7 @@ void inclusions_apply_to_source_dirs() {
396347
void fail_if_bad_value_of_sonar_sources_property() {
397348
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-bad-sources-property")).setGoals(sonarGoal());
398349
BuildResult result = ORCHESTRATOR.executeBuildQuietly(build);
399-
assertThat(result.getLastStatus()).isNotEqualTo(0);
350+
assertThat(result.getLastStatus()).isNotZero();
400351
assertThat(result.getLogs()).contains(
401352
"java2' does not exist for Maven module com.sonarsource.it.samples:maven-bad-sources-property:jar:1.0-SNAPSHOT. Please check the property sonar.sources");
402353
}
@@ -408,7 +359,7 @@ void fail_if_bad_value_of_sonar_sources_property() {
408359
void fail_if_bad_value_of_sonar_tests_property() {
409360
MavenBuild build = MavenBuild.create(ItUtils.locateProjectPom("maven/maven-bad-tests-property")).setGoals(sonarGoal());
410361
BuildResult result = ORCHESTRATOR.executeBuildQuietly(build);
411-
assertThat(result.getLastStatus()).isNotEqualTo(0);
362+
assertThat(result.getLastStatus()).isNotZero();
412363
assertThat(result.getLogs()).contains(
413364
"java2' does not exist for Maven module com.sonarsource.it.samples:maven-bad-tests-property:jar:1.0-SNAPSHOT. Please check the property sonar.tests");
414365
}
@@ -420,15 +371,9 @@ void shouldSkipModules() {
420371
.setGoals(cleanSonarGoal());
421372
ORCHESTRATOR.executeBuild(build);
422373

423-
if (hasModules()) {
424-
assertThat(getComponent("com.sonarsource.it.samples:module_a1")).isNull();
425-
assertThat(getComponent("com.sonarsource.it.samples:module_a2").getName()).isEqualTo("Sub-module A2");
426-
assertThat(getComponent("com.sonarsource.it.samples:module_b").getName()).isEqualTo("Module B");
427-
} else {
428-
assertThat(getComponent("com.sonarsource.it.samples:multi-modules-sample:module_a/module_a1")).isNull();
429-
assertThat(getComponent("com.sonarsource.it.samples:multi-modules-sample:module_a/module_a2").getName()).isEqualTo("module_a2");
430-
assertThat(getComponent("com.sonarsource.it.samples:multi-modules-sample:module_b").getName()).isEqualTo("module_b");
431-
}
374+
assertThat(getComponent("com.sonarsource.it.samples:multi-modules-sample:module_a/module_a1")).isNull();
375+
assertThat(getComponent("com.sonarsource.it.samples:multi-modules-sample:module_a/module_a2").getName()).isEqualTo("module_a2");
376+
assertThat(getComponent("com.sonarsource.it.samples:multi-modules-sample:module_b").getName()).isEqualTo("module_b");
432377
}
433378

434379
// MSONAR-150
@@ -464,8 +409,4 @@ void supportMavenEncryption() throws Exception {
464409
ORCHESTRATOR.executeBuild(build);
465410
}
466411

467-
private boolean hasModules() {
468-
return !ORCHESTRATOR.getServer().version().isGreaterThanOrEquals(7, 6);
469-
}
470-
471412
}

0 commit comments

Comments
 (0)