aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver-es/src
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2021-11-18 16:45:02 -0600
committersonartech <sonartech@sonarsource.com>2021-11-20 20:03:51 +0000
commit3f9445c25962f914ccdd889c002ddd8e19b0cf89 (patch)
treeeb4f34a62b7164a71fd0bbe34d6f59621a687d8d /server/sonar-webserver-es/src
parentaa640be9e2b9cfa2c027ef0768940b31ebb5536c (diff)
downloadsonarqube-3f9445c25962f914ccdd889c002ddd8e19b0cf89.tar.gz
sonarqube-3f9445c25962f914ccdd889c002ddd8e19b0cf89.zip
Improve code quality
Diffstat (limited to 'server/sonar-webserver-es/src')
-rw-r--r--server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQuery.java1
-rw-r--r--server/sonar-webserver-es/src/test/java/org/sonar/server/es/IndexCreatorTest.java8
-rw-r--r--server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/FooIndex.java1
-rw-r--r--server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/PermissionIndexerTest.java16
4 files changed, 12 insertions, 14 deletions
diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQuery.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQuery.java
index d76d1f10e82..d3be5a82a4f 100644
--- a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQuery.java
+++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQuery.java
@@ -19,7 +19,6 @@
*/
package org.sonar.server.issue.index;
-import com.google.common.collect.ImmutableSet;
import java.time.ZoneId;
import java.util.Collection;
import java.util.Collections;
diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/es/IndexCreatorTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/es/IndexCreatorTest.java
index 09130fbe76a..cbfcc521a51 100644
--- a/server/sonar-webserver-es/src/test/java/org/sonar/server/es/IndexCreatorTest.java
+++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/es/IndexCreatorTest.java
@@ -108,8 +108,8 @@ public class IndexCreatorTest {
ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetadata>> mappings = mappings();
MappingMetadata mapping = mappings.get("fakes").get("fake");
assertThat(countMappingFields(mapping)).isEqualTo(3);
- assertThat(field(mapping, "updatedAt").get("type")).isEqualTo("date");
- assertThat(field(mapping, "newField").get("type")).isEqualTo("integer");
+ assertThat(field(mapping, "updatedAt")).containsEntry("type", "date");
+ assertThat(field(mapping, "newField")).containsEntry("type", "integer");
assertThat(es.client().get(new GetRequest(fakeIndexType.getIndex().getName(), fakeIndexType.getType(), id)).isExists()).isFalse();
}
@@ -230,7 +230,7 @@ public class IndexCreatorTest {
.contains("Create type fakes/fake")
.contains("Create type metadatas/metadata");
putFakeDocument();
- assertThat(es.countDocuments(FakeIndexDefinition.INDEX_TYPE)).isEqualTo(1);
+ assertThat(es.countDocuments(FakeIndexDefinition.INDEX_TYPE)).isOne();
afterFirstStart.accept(esDbCompatibility);
logTester.clear();
@@ -278,7 +278,7 @@ public class IndexCreatorTest {
assertThat(mapping.type()).isEqualTo("fake");
assertThat(mapping.getSourceAsMap()).isNotEmpty();
assertThat(countMappingFields(mapping)).isEqualTo(2);
- assertThat(field(mapping, "updatedAt").get("type")).isEqualTo("date");
+ assertThat(field(mapping, "updatedAt")).containsEntry("type", "date");
}
private static class FakeIndexDefinition implements IndexDefinition {
diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/FooIndex.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/FooIndex.java
index 1ffef6b5763..e3a7788e261 100644
--- a/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/FooIndex.java
+++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/FooIndex.java
@@ -21,7 +21,6 @@ package org.sonar.server.permission.index;
import java.util.Arrays;
import java.util.List;
-import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.builder.SearchSourceBuilder;
diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/PermissionIndexerTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/PermissionIndexerTest.java
index dc1e577f9ac..a3a1a20ec91 100644
--- a/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/PermissionIndexerTest.java
+++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/PermissionIndexerTest.java
@@ -97,13 +97,13 @@ public class PermissionIndexerTest {
// Simulate a indexation issue
db.getDbClient().purgeDao().deleteProject(db.getSession(), project1.uuid(), PROJECT, project1.name(), project1.getKey());
underTest.prepareForRecovery(db.getSession(), asList(project1.uuid()), ProjectIndexer.Cause.PROJECT_DELETION);
- assertThat(db.countRowsOfTable(db.getSession(), "es_queue")).isEqualTo(1);
+ assertThat(db.countRowsOfTable(db.getSession(), "es_queue")).isOne();
Collection<EsQueueDto> esQueueDtos = db.getDbClient().esQueueDao().selectForRecovery(db.getSession(), Long.MAX_VALUE, 2);
underTest.index(db.getSession(), esQueueDtos);
assertThat(db.countRowsOfTable(db.getSession(), "es_queue")).isZero();
- assertThat(es.countDocuments(INDEX_TYPE_FOO_AUTH)).isEqualTo(1);
+ assertThat(es.countDocuments(INDEX_TYPE_FOO_AUTH)).isOne();
}
@Test
@@ -324,21 +324,21 @@ public class PermissionIndexerTest {
es.lockWrites(INDEX_TYPE_FOO_AUTH);
IndexingResult result = indexPermissions(project, PERMISSION_CHANGE);
- assertThat(result.getTotal()).isEqualTo(1L);
- assertThat(result.getFailures()).isEqualTo(1L);
+ assertThat(result.getTotal()).isOne();
+ assertThat(result.getFailures()).isOne();
// index is still read-only, fail to recover
result = recover();
- assertThat(result.getTotal()).isEqualTo(1L);
- assertThat(result.getFailures()).isEqualTo(1L);
+ assertThat(result.getTotal()).isOne();
+ assertThat(result.getFailures()).isOne();
assertThatAuthIndexHasSize(0);
assertThatEsQueueTableHasSize(1);
es.unlockWrites(INDEX_TYPE_FOO_AUTH);
result = recover();
- assertThat(result.getTotal()).isEqualTo(1L);
- assertThat(result.getFailures()).isEqualTo(0L);
+ assertThat(result.getTotal()).isOne();
+ assertThat(result.getFailures()).isZero();
verifyAnyoneAuthorized(project);
assertThatEsQueueTableHasSize(0);
}