]> source.dussan.org Git - sonarqube.git/commitdiff
use testFixtures instead of test configuration of webserver-es
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 29 Aug 2019 12:52:26 +0000 (14:52 +0200)
committerSonarTech <sonartech@sonarsource.com>
Mon, 2 Sep 2019 18:21:05 +0000 (20:21 +0200)
server/sonar-webserver-core/build.gradle
server/sonar-webserver-es/build.gradle
server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/FooIndexDefinition.java [deleted file]
server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/PermissionIndexerTester.java [deleted file]
server/sonar-webserver-es/src/testFixtures/java/org/sonar/server/permission/index/FooIndexDefinition.java [new file with mode: 0644]
server/sonar-webserver-es/src/testFixtures/java/org/sonar/server/permission/index/PermissionIndexerTester.java [new file with mode: 0644]
server/sonar-webserver-webapi/build.gradle
server/sonar-webserver/build.gradle

index 5c2bf7046e107f813a3b897d47cf6739264463fa..221d8981d55a41ab9e74a47432274bc8bb2ddb3f 100644 (file)
@@ -72,7 +72,7 @@ dependencies {
   testCompile 'org.subethamail:subethasmtp'
   testCompile testFixtures(project(':server:sonar-server-common'))
   testCompile testFixtures(project(':server:sonar-webserver-auth'))
-  testCompile project(path: ":server:sonar-webserver-es", configuration: "tests")
+  testCompile testFixtures(project(':server:sonar-webserver-es'))
   testCompile testFixtures(project(':server:sonar-webserver-ws'))
   testCompile project(':sonar-testing-harness')
 
index c95cc907dfe6c95ea043af5fae91fc150e46e101..1e72c130fc707b64581eb141f5c105bf50d8a420 100644 (file)
@@ -4,12 +4,6 @@ sonarqube {
   }
 }
 
-configurations {
-  tests
-
-  testCompile.extendsFrom tests
-}
-
 dependencies {
   // please keep the list grouped by configuration and ordered by name
 
@@ -28,15 +22,7 @@ dependencies {
   testCompile 'com.tngtech.java:junit-dataprovider'
   testCompile 'org.mockito:mockito-core'
   testCompile testFixtures(project(':server:sonar-webserver-auth'))
-  testCompile testFixtures(project(':server:sonar-server-common'))
   testCompile project(':sonar-testing-harness')
-}
-
-task testJar(type: Jar) {
-  classifier = 'tests'
-  from sourceSets.test.output
-}
-
-artifacts {
-  tests testJar
+    
+  testFixturesApi testFixtures(project(':server:sonar-server-common'))
 }
diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/FooIndexDefinition.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/FooIndexDefinition.java
deleted file mode 100644 (file)
index 2dfe93c..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2019 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.server.permission.index;
-
-import org.sonar.api.config.internal.MapSettings;
-import org.sonar.server.es.Index;
-import org.sonar.server.es.IndexDefinition;
-import org.sonar.server.es.IndexType;
-import org.sonar.server.es.newindex.NewAuthorizedIndex;
-
-import static org.sonar.server.es.newindex.SettingsConfiguration.MANUAL_REFRESH_INTERVAL;
-import static org.sonar.server.es.newindex.SettingsConfiguration.newBuilder;
-
-public class FooIndexDefinition implements IndexDefinition {
-
-  public static final Index DESCRIPTOR = Index.withRelations("foos");
-  public static final String FOO_TYPE = "foo";
-  public static final IndexType.IndexMainType TYPE_AUTHORIZATION = IndexType.main(DESCRIPTOR, IndexAuthorizationConstants.TYPE_AUTHORIZATION);
-  public static final IndexType.IndexRelationType TYPE_FOO = IndexType.relation(TYPE_AUTHORIZATION, FOO_TYPE);
-  public static final String FIELD_NAME = "name";
-  public static final String FIELD_PROJECT_UUID = "projectUuid";
-
-  @Override
-  public void define(IndexDefinitionContext context) {
-    NewAuthorizedIndex newIndex = context.createWithAuthorization(
-      DESCRIPTOR,
-      newBuilder(new MapSettings().asConfig())
-        .setRefreshInterval(MANUAL_REFRESH_INTERVAL)
-        .build());
-
-    newIndex.createTypeMapping(TYPE_FOO)
-      .keywordFieldBuilder(FIELD_NAME).build()
-      .keywordFieldBuilder(FIELD_PROJECT_UUID).build();
-  }
-}
diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/PermissionIndexerTester.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/PermissionIndexerTester.java
deleted file mode 100644 (file)
index 9fb5f83..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2019 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.server.permission.index;
-
-import java.util.List;
-import java.util.stream.Stream;
-import org.sonar.db.component.ComponentDto;
-import org.sonar.db.user.GroupDto;
-import org.sonar.db.user.UserDto;
-import org.sonar.server.es.EsTester;
-
-import static java.util.Arrays.stream;
-import static java.util.stream.Collectors.toList;
-
-public class PermissionIndexerTester {
-
-  private final PermissionIndexer permissionIndexer;
-
-  public PermissionIndexerTester(EsTester esTester, NeedAuthorizationIndexer indexer, NeedAuthorizationIndexer... others) {
-    NeedAuthorizationIndexer[] indexers = Stream.concat(Stream.of(indexer), stream(others)).toArray(NeedAuthorizationIndexer[]::new);
-    this.permissionIndexer = new PermissionIndexer(null, esTester.client(), indexers);
-  }
-
-  public PermissionIndexerTester allowOnlyAnyone(ComponentDto... projects) {
-    return allow(stream(projects).map(project -> new IndexPermissions(project.uuid(), project.qualifier()).allowAnyone()).collect(toList()));
-  }
-
-  public PermissionIndexerTester allowOnlyUser(ComponentDto project, UserDto user) {
-    IndexPermissions dto = new IndexPermissions(project.uuid(), project.qualifier())
-      .addUserId(user.getId());
-    return allow(dto);
-  }
-
-  public PermissionIndexerTester allowOnlyGroup(ComponentDto project, GroupDto group) {
-    IndexPermissions dto = new IndexPermissions(project.uuid(), project.qualifier())
-      .addGroupId(group.getId());
-    return allow(dto);
-  }
-
-  public PermissionIndexerTester allow(IndexPermissions... indexPermissions) {
-    return allow(stream(indexPermissions).collect(toList()));
-  }
-
-  public PermissionIndexerTester allow(List<IndexPermissions> indexPermissions) {
-    permissionIndexer.index(indexPermissions);
-    return this;
-  }
-}
diff --git a/server/sonar-webserver-es/src/testFixtures/java/org/sonar/server/permission/index/FooIndexDefinition.java b/server/sonar-webserver-es/src/testFixtures/java/org/sonar/server/permission/index/FooIndexDefinition.java
new file mode 100644 (file)
index 0000000..2dfe93c
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.server.permission.index;
+
+import org.sonar.api.config.internal.MapSettings;
+import org.sonar.server.es.Index;
+import org.sonar.server.es.IndexDefinition;
+import org.sonar.server.es.IndexType;
+import org.sonar.server.es.newindex.NewAuthorizedIndex;
+
+import static org.sonar.server.es.newindex.SettingsConfiguration.MANUAL_REFRESH_INTERVAL;
+import static org.sonar.server.es.newindex.SettingsConfiguration.newBuilder;
+
+public class FooIndexDefinition implements IndexDefinition {
+
+  public static final Index DESCRIPTOR = Index.withRelations("foos");
+  public static final String FOO_TYPE = "foo";
+  public static final IndexType.IndexMainType TYPE_AUTHORIZATION = IndexType.main(DESCRIPTOR, IndexAuthorizationConstants.TYPE_AUTHORIZATION);
+  public static final IndexType.IndexRelationType TYPE_FOO = IndexType.relation(TYPE_AUTHORIZATION, FOO_TYPE);
+  public static final String FIELD_NAME = "name";
+  public static final String FIELD_PROJECT_UUID = "projectUuid";
+
+  @Override
+  public void define(IndexDefinitionContext context) {
+    NewAuthorizedIndex newIndex = context.createWithAuthorization(
+      DESCRIPTOR,
+      newBuilder(new MapSettings().asConfig())
+        .setRefreshInterval(MANUAL_REFRESH_INTERVAL)
+        .build());
+
+    newIndex.createTypeMapping(TYPE_FOO)
+      .keywordFieldBuilder(FIELD_NAME).build()
+      .keywordFieldBuilder(FIELD_PROJECT_UUID).build();
+  }
+}
diff --git a/server/sonar-webserver-es/src/testFixtures/java/org/sonar/server/permission/index/PermissionIndexerTester.java b/server/sonar-webserver-es/src/testFixtures/java/org/sonar/server/permission/index/PermissionIndexerTester.java
new file mode 100644 (file)
index 0000000..9fb5f83
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.server.permission.index;
+
+import java.util.List;
+import java.util.stream.Stream;
+import org.sonar.db.component.ComponentDto;
+import org.sonar.db.user.GroupDto;
+import org.sonar.db.user.UserDto;
+import org.sonar.server.es.EsTester;
+
+import static java.util.Arrays.stream;
+import static java.util.stream.Collectors.toList;
+
+public class PermissionIndexerTester {
+
+  private final PermissionIndexer permissionIndexer;
+
+  public PermissionIndexerTester(EsTester esTester, NeedAuthorizationIndexer indexer, NeedAuthorizationIndexer... others) {
+    NeedAuthorizationIndexer[] indexers = Stream.concat(Stream.of(indexer), stream(others)).toArray(NeedAuthorizationIndexer[]::new);
+    this.permissionIndexer = new PermissionIndexer(null, esTester.client(), indexers);
+  }
+
+  public PermissionIndexerTester allowOnlyAnyone(ComponentDto... projects) {
+    return allow(stream(projects).map(project -> new IndexPermissions(project.uuid(), project.qualifier()).allowAnyone()).collect(toList()));
+  }
+
+  public PermissionIndexerTester allowOnlyUser(ComponentDto project, UserDto user) {
+    IndexPermissions dto = new IndexPermissions(project.uuid(), project.qualifier())
+      .addUserId(user.getId());
+    return allow(dto);
+  }
+
+  public PermissionIndexerTester allowOnlyGroup(ComponentDto project, GroupDto group) {
+    IndexPermissions dto = new IndexPermissions(project.uuid(), project.qualifier())
+      .addGroupId(group.getId());
+    return allow(dto);
+  }
+
+  public PermissionIndexerTester allow(IndexPermissions... indexPermissions) {
+    return allow(stream(indexPermissions).collect(toList()));
+  }
+
+  public PermissionIndexerTester allow(List<IndexPermissions> indexPermissions) {
+    permissionIndexer.index(indexPermissions);
+    return this;
+  }
+}
index 28fc251563238cd6f2ea3ae6a6a99c9180a16b18..8f763ddc2a960ba47799fa069cf5e678a16015da 100644 (file)
@@ -29,7 +29,7 @@ dependencies {
   testCompile 'org.mockito:mockito-core'
   testCompile testFixtures(project(':server:sonar-server-common'))
   testCompile testFixtures(project(':server:sonar-webserver-auth'))
-  testCompile project(path: ":server:sonar-webserver-es", configuration: "tests")
+  testCompile testFixtures(project(':server:sonar-webserver-es'))
   testCompile testFixtures(project(':server:sonar-webserver-ws'))
   testCompile project(':sonar-testing-harness')
 }
index 7ff5d71250d5af23a8754f5443a954c14f21ec5b..4fc1039102ffac7340e0f724efbc909746f0b389 100644 (file)
@@ -28,6 +28,6 @@ dependencies {
   testCompile 'org.eclipse.jetty:jetty-servlet'
   testCompile testFixtures(project(':server:sonar-server-common'))
   testCompile testFixtures(project(':server:sonar-webserver-auth'))
-  testCompile project(path: ":server:sonar-webserver-es", configuration: "tests")
+  testCompile testFixtures(project(':server:sonar-webserver-es'))
   testCompile project(':sonar-testing-harness')
 }