This JUnit ExternalResource has to be used as @Rule but not @ClassRule in order to prepare move to Elasticsearch 2.x.tags/6.0-RC1
@@ -23,7 +23,6 @@ import java.util.List; | |||
import java.util.Map; | |||
import org.assertj.core.data.MapEntry; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
@@ -45,8 +44,8 @@ public class ActivityServiceTest { | |||
@Rule | |||
public DbTester db = DbTester.create(System2.INSTANCE); | |||
@ClassRule | |||
public static EsTester es = new EsTester().addDefinitions(new ActivityIndexDefinition(new Settings())); | |||
@Rule | |||
public EsTester es = new EsTester(new ActivityIndexDefinition(new Settings())); | |||
@Rule | |||
public UserSessionRule userSession = UserSessionRule.standalone().login(); |
@@ -20,8 +20,10 @@ | |||
package org.sonar.server.activity.index; | |||
import com.google.common.collect.ImmutableMap; | |||
import java.util.Arrays; | |||
import java.util.Date; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.server.activity.Activity; | |||
@@ -29,15 +31,12 @@ import org.sonar.server.es.EsTester; | |||
import org.sonar.server.es.SearchOptions; | |||
import org.sonar.server.es.SearchResult; | |||
import java.util.Arrays; | |||
import java.util.Date; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
public class ActivityIndexTest { | |||
@ClassRule | |||
public static EsTester es = new EsTester().addDefinitions(new ActivityIndexDefinition(new Settings())); | |||
@Rule | |||
public EsTester es = new EsTester(new ActivityIndexDefinition(new Settings())); | |||
ActivityIndex underTest; | |||
@@ -22,7 +22,6 @@ package org.sonar.server.activity.index; | |||
import java.util.Map; | |||
import org.assertj.core.data.MapEntry; | |||
import org.elasticsearch.action.update.UpdateRequest; | |||
import org.junit.Before; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.utils.DateUtils; | |||
@@ -37,11 +36,6 @@ public class ActivityResultSetIteratorTest { | |||
@Rule | |||
public DbTester dbTester = DbTester.create(System2.INSTANCE); | |||
@Before | |||
public void setUp() { | |||
dbTester.truncateTables(); | |||
} | |||
/** | |||
* Iterate over two rows in table. | |||
*/ |
@@ -23,7 +23,6 @@ import java.io.ByteArrayInputStream; | |||
import java.util.Arrays; | |||
import javax.annotation.Nullable; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
@@ -71,8 +70,8 @@ public class IssuesActionTest { | |||
@Rule | |||
public DbTester db = DbTester.create(System2.INSTANCE); | |||
@ClassRule | |||
public static EsTester es = new EsTester().addDefinitions(new IssueIndexDefinition(new Settings())); | |||
@Rule | |||
public EsTester es = new EsTester(new IssueIndexDefinition(new Settings())); | |||
@Rule | |||
public UserSessionRule userSessionRule = UserSessionRule.standalone(); | |||
@@ -87,9 +86,6 @@ public class IssuesActionTest { | |||
@Before | |||
public void before() { | |||
db.truncateTables(); | |||
es.truncateIndices(); | |||
issueIndex = new IssueIndex(es.client(), System2.INSTANCE, userSessionRule); | |||
issueIndexer = new IssueIndexer(null, es.client()); | |||
issueAuthorizationIndexer = new IssueAuthorizationIndexer(null, es.client()); |
@@ -23,7 +23,6 @@ import java.io.ByteArrayInputStream; | |||
import java.util.Arrays; | |||
import java.util.List; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
@@ -46,8 +45,8 @@ public class UsersActionTest { | |||
@Rule | |||
public ExpectedException thrown = ExpectedException.none(); | |||
@ClassRule | |||
public static EsTester es = new EsTester().addDefinitions(new UserIndexDefinition(new Settings())); | |||
@Rule | |||
public EsTester es = new EsTester(new UserIndexDefinition(new Settings())); | |||
@Rule | |||
public UserSessionRule userSessionRule = UserSessionRule.standalone(); | |||
@@ -60,11 +59,8 @@ public class UsersActionTest { | |||
@Before | |||
public void before() { | |||
es.truncateIndices(); | |||
userIndex = new UserIndex(es.client()); | |||
usersAction = new UsersAction(userIndex, userSessionRule); | |||
tester = new WsTester(new BatchWs(new BatchIndex(mock(Server.class)), usersAction)); | |||
} | |||
@@ -75,7 +75,6 @@ public class ComponentServiceTest { | |||
@Before | |||
public void setUp() { | |||
dbTester.truncateTables(); | |||
when(i18n.message(Locale.getDefault(), "qualifier.TRK", "Project")).thenReturn("Project"); | |||
service = new ComponentService(dbClient, i18n, userSessionRule, System2.INSTANCE, new ComponentFinder(dbClient)); | |||
} |
@@ -50,7 +50,6 @@ public class SearchViewComponentsActionTest { | |||
@Before | |||
public void setUp() { | |||
db.truncateTables(); | |||
ws = new WsTester(new ComponentsWs(mock(AppAction.class), new SearchViewComponentsAction(db.getDbClient(), userSessionRule, new ComponentFinder(db.getDbClient())))); | |||
} | |||
@@ -55,7 +55,6 @@ public class SettingsRepositoryTest { | |||
@Before | |||
public void createDao() { | |||
dbTester.truncateTables(); | |||
globalSettings = new Settings(); | |||
PropertiesDao propertiesDao = new PropertiesDao(dbTester.myBatis()); | |||
session = dbClient.openSession(false); |
@@ -20,8 +20,6 @@ | |||
package org.sonar.server.computation.issue; | |||
import java.util.Collections; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.api.utils.log.LogTester; | |||
@@ -37,16 +35,11 @@ import static org.junit.Assert.fail; | |||
public class ScmAccountToUserLoaderTest { | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new UserIndexDefinition(new Settings())); | |||
@org.junit.Rule | |||
public EsTester esTester = new EsTester(new UserIndexDefinition(new Settings())); | |||
@ClassRule | |||
public static LogTester logTester = new LogTester(); | |||
@Before | |||
public void setUp() { | |||
esTester.truncateIndices(); | |||
} | |||
@org.junit.Rule | |||
public LogTester logTester = new LogTester(); | |||
@Test | |||
public void load_login_for_scm_account() throws Exception { |
@@ -19,7 +19,6 @@ | |||
*/ | |||
package org.sonar.server.computation.metric; | |||
import org.junit.Before; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
@@ -42,11 +41,6 @@ public class MetricRepositoryImplTest { | |||
private DbClient dbClient = dbTester.getDbClient(); | |||
private MetricRepositoryImpl underTest = new MetricRepositoryImpl(dbClient); | |||
@Before | |||
public void setUp() { | |||
dbTester.truncateTables(); | |||
} | |||
@Test(expected = NullPointerException.class) | |||
public void getByKey_throws_NPE_if_arg_is_null() { | |||
underTest.getByKey(null); |
@@ -24,7 +24,6 @@ import java.util.Map; | |||
import org.elasticsearch.search.SearchHit; | |||
import org.junit.After; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
@@ -61,8 +60,8 @@ public class ApplyPermissionsStepTest extends BaseStepTest { | |||
private static final String ROOT_UUID = "ROOT_UUID"; | |||
private static final long SOME_DATE = 1000L; | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new IssueIndexDefinition(new Settings())); | |||
@Rule | |||
public EsTester esTester = new EsTester(new IssueIndexDefinition(new Settings())); | |||
@Rule | |||
public DbTester dbTester = DbTester.create(System2.INSTANCE); | |||
@@ -77,7 +76,7 @@ public class ApplyPermissionsStepTest extends BaseStepTest { | |||
DbClient dbClient = dbTester.getDbClient(); | |||
Settings settings; | |||
Settings settings = new Settings(); | |||
IssueAuthorizationIndexer issueAuthorizationIndexer; | |||
@@ -86,8 +85,6 @@ public class ApplyPermissionsStepTest extends BaseStepTest { | |||
@Before | |||
public void setUp() { | |||
dbSession = dbClient.openSession(false); | |||
settings = new Settings(); | |||
esTester.truncateIndices(); | |||
issueAuthorizationIndexer = new IssueAuthorizationIndexer(dbClient, esTester.client()); | |||
issueAuthorizationIndexer.setEnabled(true); |
@@ -21,8 +21,6 @@ package org.sonar.server.computation.step; | |||
import java.util.List; | |||
import org.elasticsearch.search.SearchHit; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
@@ -45,19 +43,14 @@ public class IndexTestsStepTest extends BaseStepTest { | |||
@Rule | |||
public DbTester dbTester = DbTester.create(System2.INSTANCE); | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new TestIndexDefinition(new Settings())); | |||
@Rule | |||
public EsTester esTester = new EsTester(new TestIndexDefinition(new Settings())); | |||
@Rule | |||
public TreeRootHolderRule treeRootHolder = new TreeRootHolderRule(); | |||
DbClient dbClient = dbTester.getDbClient(); | |||
@Before | |||
public void setUp() { | |||
esTester.truncateIndices(); | |||
} | |||
@Override | |||
protected ComputationStep step() { | |||
TestIndexer testIndexer = new TestIndexer(dbClient, esTester.client()); |
@@ -85,7 +85,6 @@ public class PersistFileSourcesStepTest extends BaseStepTest { | |||
@Before | |||
public void setup() { | |||
dbTester.truncateTables(); | |||
when(system2.now()).thenReturn(NOW); | |||
underTest = new PersistFileSourcesStep(dbClient, system2, treeRootHolder, reportReader, fileSourceRepository, scmInfoRepository, duplicationRepository); | |||
} |
@@ -80,7 +80,6 @@ public class PersistIssuesStepTest extends BaseStepTest { | |||
@Before | |||
public void setup() throws Exception { | |||
dbTester.truncateTables(); | |||
issueCache = new IssueCache(temp.newFile(), System2.INSTANCE); | |||
system2 = mock(System2.class); | |||
when(system2.now()).thenReturn(NOW); |
@@ -34,12 +34,10 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
public class BulkIndexerTest { | |||
@Rule | |||
public EsTester esTester = new EsTester().addDefinitions(new FakeIndexDefinition().setReplicas(1)); | |||
public EsTester esTester = new EsTester(new FakeIndexDefinition().setReplicas(1)); | |||
@Test | |||
public void index_nothing() { | |||
esTester.truncateIndices(); | |||
BulkIndexer indexer = new BulkIndexer(esTester.client(), FakeIndexDefinition.INDEX); | |||
indexer.start(); | |||
indexer.stop(); |
@@ -24,7 +24,9 @@ import com.google.common.base.Throwables; | |||
import com.google.common.collect.Collections2; | |||
import com.google.common.collect.FluentIterable; | |||
import com.google.common.collect.Iterables; | |||
import java.util.Collections; | |||
import java.io.IOException; | |||
import java.nio.file.Files; | |||
import java.nio.file.Path; | |||
import java.util.List; | |||
import java.util.Map; | |||
import javax.annotation.Nonnull; | |||
@@ -49,58 +51,30 @@ import org.junit.rules.ExternalResource; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.core.platform.ComponentContainer; | |||
import static com.google.common.base.Preconditions.checkState; | |||
import static com.google.common.collect.Lists.newArrayList; | |||
import static java.util.Arrays.asList; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; | |||
public class EsTester extends ExternalResource { | |||
private static final int INSTANCE_ID = RandomUtils.nextInt(); | |||
private Node node; | |||
private EsClient client; | |||
private final List<IndexDefinition> definitions = newArrayList(); | |||
private final List<IndexDefinition> indexDefinitions; | |||
private EsClient client = new EsClient(new Settings(), NodeHolder.INSTANCE.node.client()); | |||
private ComponentContainer container; | |||
public EsTester addDefinitions(IndexDefinition... defs) { | |||
Collections.addAll(definitions, defs); | |||
return this; | |||
public EsTester(IndexDefinition... defs) { | |||
this.indexDefinitions = asList(defs); | |||
} | |||
@Override | |||
protected void before() throws Throwable { | |||
String nodeName = "tmp-es-" + INSTANCE_ID; | |||
node = NodeBuilder.nodeBuilder().local(true).data(true).settings(ImmutableSettings.builder() | |||
.put("cluster.name", nodeName) | |||
.put("node.name", nodeName) | |||
// the two following properties are probably not used because they are | |||
// declared on indices too | |||
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) | |||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0) | |||
// limit the number of threads created (see org.elasticsearch.common.util.concurrent.EsExecutors) | |||
.put("processors", 1) | |||
.put("http.enabled", false) | |||
.put("config.ignore_system_properties", true) | |||
// reuse the same directory than other tests for faster initialization | |||
.put("path.home", "target/" + nodeName) | |||
.put("gateway.type", "none")) | |||
.build(); | |||
node.start(); | |||
assertThat(DiscoveryNode.localNode(node.settings())).isTrue(); | |||
// wait for node to be ready | |||
node.client().admin().cluster().prepareHealth() | |||
.setWaitForGreenStatus() | |||
.get(); | |||
// delete the indices created by previous tests | |||
DeleteIndexResponse response = node.client().admin().indices().prepareDelete("_all").get(); | |||
assertThat(response.isAcknowledged()).isTrue(); | |||
client = new EsClient(new Settings(), node.client()); | |||
client.start(); | |||
truncateIndices(); | |||
if (!definitions.isEmpty()) { | |||
ComponentContainer container = new ComponentContainer(); | |||
if (!indexDefinitions.isEmpty()) { | |||
container = new ComponentContainer(); | |||
container.addSingleton(new Settings()); | |||
container.addSingletons(definitions); | |||
container.addSingletons(indexDefinitions); | |||
container.addSingleton(client); | |||
container.addSingleton(IndexDefinitions.class); | |||
container.addSingleton(IndexCreator.class); | |||
@@ -110,20 +84,16 @@ public class EsTester extends ExternalResource { | |||
@Override | |||
protected void after() { | |||
if (container != null) { | |||
container.stopComponents(); | |||
} | |||
if (client != null) { | |||
client.stop(); | |||
} | |||
if (node != null) { | |||
node.stop(); | |||
node.close(); | |||
} | |||
} | |||
public void truncateIndices() { | |||
String[] indices = client.prepareState().get().getState().getMetaData().concreteAllIndices(); | |||
for (String index : indices) { | |||
BulkIndexer.delete(client, index, client().prepareSearch(index).setQuery(matchAllQuery())); | |||
} | |||
private void truncateIndices() { | |||
client.nativeClient().admin().indices().prepareDelete("_all").get(); | |||
} | |||
public void putDocuments(String index, String type, BaseDoc... docs) throws Exception { | |||
@@ -141,7 +111,7 @@ public class EsTester extends ExternalResource { | |||
} | |||
public long countDocuments(String indexName, String typeName) { | |||
return client().prepareCount(indexName).setTypes(typeName).get().getCount(); | |||
return client().prepareSearch(indexName).setTypes(typeName).setSize(0).get().getHits().totalHits(); | |||
} | |||
/** | |||
@@ -200,10 +170,6 @@ public class EsTester extends ExternalResource { | |||
return FluentIterable.from(getDocuments(indexName, typeName)).transform(SearchHitToId.INSTANCE).toList(); | |||
} | |||
public Node node() { | |||
return node; | |||
} | |||
public EsClient client() { | |||
return client; | |||
} | |||
@@ -217,4 +183,43 @@ public class EsTester extends ExternalResource { | |||
} | |||
} | |||
private static class NodeHolder { | |||
private static final NodeHolder INSTANCE = new NodeHolder(); | |||
private final Node node; | |||
private NodeHolder() { | |||
try { | |||
String nodeName = "tmp-es-" + RandomUtils.nextInt(); | |||
Path tmpDir = Files.createTempDirectory("tmp-es"); | |||
tmpDir.toFile().deleteOnExit(); | |||
node = NodeBuilder.nodeBuilder().local(true).data(true).settings(ImmutableSettings.builder() | |||
.put("cluster.name", nodeName) | |||
.put("node.name", nodeName) | |||
// the two following properties are probably not used because they are | |||
// declared on indices too | |||
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) | |||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0) | |||
// limit the number of threads created (see org.elasticsearch.common.util.concurrent.EsExecutors) | |||
.put("processors", 1) | |||
.put("http.enabled", false) | |||
.put("config.ignore_system_properties", true) | |||
.put("path.home", tmpDir)) | |||
.build(); | |||
node.start(); | |||
checkState(DiscoveryNode.localNode(node.settings())); | |||
checkState(!node.isClosed()); | |||
// wait for node to be ready | |||
node.client().admin().cluster().prepareHealth().setWaitForGreenStatus().get(); | |||
// delete the indices (should not exist) | |||
DeleteIndexResponse response = node.client().admin().indices().prepareDelete("_all").get(); | |||
checkState(response.isAcknowledged()); | |||
} catch (IOException e) { | |||
throw Throwables.propagate(e); | |||
} | |||
} | |||
} | |||
} |
@@ -25,7 +25,6 @@ import org.elasticsearch.action.delete.DeleteRequest; | |||
import org.elasticsearch.action.index.IndexRequest; | |||
import org.elasticsearch.action.update.UpdateRequest; | |||
import org.elasticsearch.common.unit.TimeValue; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.utils.log.LogTester; | |||
@@ -37,8 +36,8 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
public class ProxyBulkRequestBuilderTest { | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new FakeIndexDefinition()); | |||
@Rule | |||
public EsTester esTester = new EsTester(new FakeIndexDefinition()); | |||
@Rule | |||
public LogTester logTester = new LogTester(); | |||
@@ -47,14 +46,14 @@ public class ProxyBulkRequestBuilderTest { | |||
public void no_trace_logs() { | |||
logTester.setLevel(LoggerLevel.INFO); | |||
testBulk(); | |||
assertThat(logTester.logs()).isEmpty(); | |||
assertThat(logTester.logs(LoggerLevel.TRACE)).isEmpty(); | |||
} | |||
@Test | |||
public void trace_logs() { | |||
logTester.setLevel(LoggerLevel.TRACE); | |||
testBulk(); | |||
assertThat(logTester.logs()).hasSize(1); | |||
assertThat(logTester.logs(LoggerLevel.TRACE)).hasSize(1); | |||
} | |||
private void testBulk() { |
@@ -20,7 +20,6 @@ | |||
package org.sonar.server.es.request; | |||
import org.elasticsearch.common.unit.TimeValue; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.utils.log.LogTester; | |||
@@ -33,8 +32,8 @@ import static org.junit.Assert.fail; | |||
public class ProxyCountRequestBuilderTest { | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new FakeIndexDefinition()); | |||
@Rule | |||
public EsTester esTester = new EsTester(new FakeIndexDefinition()); | |||
@Rule | |||
public LogTester logTester = new LogTester(); | |||
@@ -56,7 +55,7 @@ public class ProxyCountRequestBuilderTest { | |||
logTester.setLevel(LoggerLevel.TRACE); | |||
esTester.client().prepareCount(FakeIndexDefinition.INDEX).get(); | |||
assertThat(logTester.logs()).hasSize(1); | |||
assertThat(logTester.logs(LoggerLevel.TRACE)).hasSize(1); | |||
} | |||
@Test |
@@ -21,7 +21,6 @@ package org.sonar.server.es.request; | |||
import org.elasticsearch.common.unit.TimeValue; | |||
import org.elasticsearch.index.query.QueryBuilders; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.utils.log.LogTester; | |||
@@ -34,8 +33,8 @@ import static org.junit.Assert.fail; | |||
public class ProxyDeleteByQueryRequestBuilderTest { | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new FakeIndexDefinition()); | |||
@Rule | |||
public EsTester esTester = new EsTester(new FakeIndexDefinition()); | |||
@Rule | |||
public LogTester logTester = new LogTester(); | |||
@@ -58,7 +57,7 @@ public class ProxyDeleteByQueryRequestBuilderTest { | |||
esTester.client().prepareDeleteByQuery(FakeIndexDefinition.INDEX).setQuery(QueryBuilders.matchAllQuery()).get(); | |||
assertThat(logTester.logs()).hasSize(1); | |||
assertThat(logTester.logs(LoggerLevel.TRACE)).hasSize(1); | |||
} | |||
@Test |
@@ -20,7 +20,6 @@ | |||
package org.sonar.server.es.request; | |||
import org.elasticsearch.common.unit.TimeValue; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.utils.log.LogTester; | |||
@@ -33,8 +32,8 @@ import static org.junit.Assert.fail; | |||
public class ProxyFlushRequestBuilderTest { | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new FakeIndexDefinition()); | |||
@Rule | |||
public EsTester esTester = new EsTester(new FakeIndexDefinition()); | |||
@Rule | |||
public LogTester logTester = new LogTester(); | |||
@@ -55,7 +54,7 @@ public class ProxyFlushRequestBuilderTest { | |||
logTester.setLevel(LoggerLevel.TRACE); | |||
esTester.client().prepareFlush(FakeIndexDefinition.INDEX).get(); | |||
assertThat(logTester.logs()).hasSize(1); | |||
assertThat(logTester.logs(LoggerLevel.TRACE)).hasSize(1); | |||
} | |||
@Test |
@@ -21,7 +21,6 @@ package org.sonar.server.es.request; | |||
import org.elasticsearch.action.get.GetRequestBuilder; | |||
import org.elasticsearch.common.unit.TimeValue; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.utils.log.LogTester; | |||
@@ -34,8 +33,8 @@ import static org.junit.Assert.fail; | |||
public class ProxyGetRequestBuilderTest { | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new FakeIndexDefinition()); | |||
@Rule | |||
public EsTester esTester = new EsTester(new FakeIndexDefinition()); | |||
@Rule | |||
public LogTester logTester = new LogTester(); | |||
@@ -58,7 +57,7 @@ public class ProxyGetRequestBuilderTest { | |||
.setType(FakeIndexDefinition.TYPE) | |||
.setId("ruleKey") | |||
.get(); | |||
assertThat(logTester.logs()).hasSize(1); | |||
assertThat(logTester.logs(LoggerLevel.TRACE)).hasSize(1); | |||
} | |||
@Test |
@@ -22,7 +22,6 @@ package org.sonar.server.es.request; | |||
import org.elasticsearch.action.index.IndexRequestBuilder; | |||
import org.elasticsearch.action.index.IndexResponse; | |||
import org.elasticsearch.common.unit.TimeValue; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.utils.log.LogTester; | |||
@@ -35,8 +34,8 @@ import static org.junit.Assert.fail; | |||
public class ProxyIndexRequestBuilderTest { | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new FakeIndexDefinition()); | |||
@Rule | |||
public EsTester esTester = new EsTester(new FakeIndexDefinition()); | |||
@Rule | |||
public LogTester logTester = new LogTester(); | |||
@@ -56,7 +55,7 @@ public class ProxyIndexRequestBuilderTest { | |||
.setSource(FakeIndexDefinition.newDoc(42).getFields()) | |||
.get(); | |||
assertThat(response.isCreated()).isTrue(); | |||
assertThat(logTester.logs()).hasSize(1); | |||
assertThat(logTester.logs(LoggerLevel.TRACE)).hasSize(1); | |||
} | |||
@Test |
@@ -20,7 +20,6 @@ | |||
package org.sonar.server.es.request; | |||
import org.elasticsearch.common.unit.TimeValue; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.utils.log.LogTester; | |||
@@ -33,8 +32,8 @@ import static org.junit.Assert.fail; | |||
public class ProxyIndicesExistsRequestBuilderTest { | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new FakeIndexDefinition()); | |||
@Rule | |||
public EsTester esTester = new EsTester(new FakeIndexDefinition()); | |||
@Rule | |||
public LogTester logTester = new LogTester(); | |||
@@ -51,7 +50,7 @@ public class ProxyIndicesExistsRequestBuilderTest { | |||
esTester.client().prepareIndicesExist(FakeIndexDefinition.INDEX).get(); | |||
assertThat(logTester.logs()).hasSize(1); | |||
assertThat(logTester.logs(LoggerLevel.TRACE)).hasSize(1); | |||
} | |||
@Test |
@@ -20,7 +20,6 @@ | |||
package org.sonar.server.es.request; | |||
import org.elasticsearch.common.unit.TimeValue; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.utils.log.LogTester; | |||
@@ -33,8 +32,8 @@ import static org.junit.Assert.fail; | |||
public class ProxyIndicesStatsRequestBuilderTest { | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new FakeIndexDefinition()); | |||
@Rule | |||
public EsTester esTester = new EsTester(new FakeIndexDefinition()); | |||
@Rule | |||
public LogTester logTester = new LogTester(); | |||
@@ -56,7 +55,7 @@ public class ProxyIndicesStatsRequestBuilderTest { | |||
esTester.client().prepareStats(FakeIndexDefinition.INDEX).get(); | |||
assertThat(logTester.logs()).hasSize(1); | |||
assertThat(logTester.logs(LoggerLevel.TRACE)).hasSize(1); | |||
} | |||
@Test |
@@ -23,7 +23,6 @@ import org.elasticsearch.action.get.MultiGetRequest; | |||
import org.elasticsearch.action.get.MultiGetRequestBuilder; | |||
import org.elasticsearch.common.unit.TimeValue; | |||
import org.elasticsearch.search.fetch.source.FetchSourceContext; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.utils.log.LogTester; | |||
@@ -36,8 +35,8 @@ import static org.junit.Assert.fail; | |||
public class ProxyMultiGetRequestBuilderTest { | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new FakeIndexDefinition()); | |||
@Rule | |||
public EsTester esTester = new EsTester(new FakeIndexDefinition()); | |||
@Rule | |||
public LogTester logTester = new LogTester(); | |||
@@ -69,7 +68,7 @@ public class ProxyMultiGetRequestBuilderTest { | |||
.fetchSourceContext(FetchSourceContext.FETCH_SOURCE)); | |||
request.get(); | |||
assertThat(logTester.logs()).hasSize(1); | |||
assertThat(logTester.logs(LoggerLevel.TRACE)).hasSize(1); | |||
} | |||
@Test |
@@ -20,9 +20,10 @@ | |||
package org.sonar.server.es.request; | |||
import com.google.common.collect.ImmutableMap; | |||
import java.util.HashMap; | |||
import java.util.Map; | |||
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequestBuilder; | |||
import org.elasticsearch.common.unit.TimeValue; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.utils.log.LogTester; | |||
@@ -30,16 +31,13 @@ import org.sonar.api.utils.log.LoggerLevel; | |||
import org.sonar.server.es.EsTester; | |||
import org.sonar.server.es.FakeIndexDefinition; | |||
import java.util.HashMap; | |||
import java.util.Map; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.junit.Assert.fail; | |||
public class ProxyPutMappingRequestBuilderTest { | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new FakeIndexDefinition()); | |||
@Rule | |||
public EsTester esTester = new EsTester(new FakeIndexDefinition()); | |||
@Rule | |||
public LogTester logTester = new LogTester(); | |||
@@ -71,7 +69,7 @@ public class ProxyPutMappingRequestBuilderTest { | |||
.setSource(mapDomain()); | |||
requestBuilder.get(); | |||
assertThat(logTester.logs()).hasSize(1); | |||
assertThat(logTester.logs(LoggerLevel.TRACE)).hasSize(1); | |||
} | |||
@Test |
@@ -21,7 +21,6 @@ package org.sonar.server.es.request; | |||
import org.elasticsearch.action.admin.indices.refresh.RefreshRequestBuilder; | |||
import org.elasticsearch.common.unit.TimeValue; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.utils.log.LogTester; | |||
@@ -34,8 +33,8 @@ import static org.junit.Assert.fail; | |||
public class ProxyRefreshRequestBuilderTest { | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new FakeIndexDefinition()); | |||
@Rule | |||
public EsTester esTester = new EsTester(new FakeIndexDefinition()); | |||
@Rule | |||
public LogTester logTester = new LogTester(); | |||
@@ -58,7 +57,7 @@ public class ProxyRefreshRequestBuilderTest { | |||
RefreshRequestBuilder requestBuilder = esTester.client().prepareRefresh(FakeIndexDefinition.INDEX); | |||
requestBuilder.get(); | |||
assertThat(logTester.logs()).hasSize(1); | |||
assertThat(logTester.logs(LoggerLevel.TRACE)).hasSize(1); | |||
} | |||
@Test |
@@ -20,7 +20,6 @@ | |||
package org.sonar.server.es.request; | |||
import org.elasticsearch.common.unit.TimeValue; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.utils.log.LogTester; | |||
@@ -33,8 +32,8 @@ import static org.junit.Assert.fail; | |||
public class ProxySearchRequestBuilderTest { | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new FakeIndexDefinition()); | |||
@Rule | |||
public EsTester esTester = new EsTester(new FakeIndexDefinition()); | |||
@Rule | |||
public LogTester logTester = new LogTester(); | |||
@@ -57,7 +56,7 @@ public class ProxySearchRequestBuilderTest { | |||
logTester.setLevel(LoggerLevel.TRACE); | |||
esTester.client().prepareSearch(FakeIndexDefinition.INDEX).get(); | |||
assertThat(logTester.logs()).hasSize(1); | |||
assertThat(logTester.logs(LoggerLevel.TRACE)).hasSize(1); | |||
} | |||
@Test |
@@ -22,7 +22,6 @@ package org.sonar.server.es.request; | |||
import org.elasticsearch.action.search.SearchResponse; | |||
import org.elasticsearch.action.search.SearchType; | |||
import org.elasticsearch.common.unit.TimeValue; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.utils.log.LogTester; | |||
@@ -35,8 +34,8 @@ import static org.junit.Assert.fail; | |||
public class ProxySearchScrollRequestBuilderTest { | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new FakeIndexDefinition()); | |||
@Rule | |||
public EsTester esTester = new EsTester(new FakeIndexDefinition()); | |||
@Rule | |||
public LogTester logTester = new LogTester(); |
@@ -23,8 +23,6 @@ import java.util.Arrays; | |||
import java.util.Collection; | |||
import java.util.List; | |||
import org.elasticsearch.search.SearchHit; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
@@ -41,14 +39,8 @@ public class IssueAuthorizationIndexerTest { | |||
@Rule | |||
public DbTester dbTester = DbTester.create(System2.INSTANCE); | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new IssueIndexDefinition(new Settings())); | |||
@Before | |||
public void setUp() { | |||
dbTester.truncateTables(); | |||
esTester.truncateIndices(); | |||
} | |||
@Rule | |||
public EsTester esTester = new EsTester(new IssueIndexDefinition(new Settings())); | |||
@Test | |||
public void index_nothing() { |
@@ -24,7 +24,6 @@ import java.util.Map; | |||
import java.util.TimeZone; | |||
import javax.annotation.Nullable; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
@@ -56,8 +55,9 @@ import static org.sonarqube.ws.client.issue.IssueFilterParameters.FACET_MODE_EFF | |||
public class IssueIndexDebtTest { | |||
@ClassRule | |||
public static EsTester tester = new EsTester().addDefinitions(new IssueIndexDefinition(new Settings()), new ViewIndexDefinition(new Settings())); | |||
@Rule | |||
public EsTester tester = new EsTester(new IssueIndexDefinition(new Settings()), new ViewIndexDefinition(new Settings())); | |||
@Rule | |||
public UserSessionRule userSessionRule = UserSessionRule.standalone(); | |||
@@ -69,14 +69,12 @@ public class IssueIndexDebtTest { | |||
@Before | |||
public void setUp() { | |||
tester.truncateIndices(); | |||
issueIndexer = new IssueIndexer(null, tester.client()); | |||
issueAuthorizationIndexer = new IssueAuthorizationIndexer(null, tester.client()); | |||
viewIndexer = new ViewIndexer(null, tester.client()); | |||
System2 system = mock(System2.class); | |||
when(system.getDefaultTimeZone()).thenReturn(TimeZone.getTimeZone("+01:00")); | |||
when(system.now()).thenReturn(System.currentTimeMillis()); | |||
index = new IssueIndex(tester.client(), system, userSessionRule); | |||
} | |||
@@ -30,7 +30,6 @@ import java.util.TimeZone; | |||
import javax.annotation.Nullable; | |||
import org.assertj.core.api.Fail; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
@@ -66,8 +65,9 @@ import static org.sonar.api.utils.DateUtils.parseDateTime; | |||
public class IssueIndexTest { | |||
@ClassRule | |||
public static EsTester tester = new EsTester().addDefinitions(new IssueIndexDefinition(new Settings()), new ViewIndexDefinition(new Settings())); | |||
@Rule | |||
public EsTester tester = new EsTester(new IssueIndexDefinition(new Settings()), new ViewIndexDefinition(new Settings())); | |||
@Rule | |||
public UserSessionRule userSessionRule = UserSessionRule.standalone(); | |||
@@ -79,7 +79,6 @@ public class IssueIndexTest { | |||
@Before | |||
public void setUp() { | |||
tester.truncateIndices(); | |||
issueIndexer = new IssueIndexer(null, tester.client()); | |||
issueAuthorizationIndexer = new IssueAuthorizationIndexer(null, tester.client()); | |||
viewIndexer = new ViewIndexer(null, tester.client()); |
@@ -26,8 +26,6 @@ import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.List; | |||
import javax.annotation.Nonnull; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
@@ -44,16 +42,11 @@ import static org.sonar.server.issue.IssueTesting.newDoc; | |||
public class IssueIndexerTest { | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new IssueIndexDefinition(new Settings())); | |||
@Rule | |||
public DbTester dbTester = DbTester.create(System2.INSTANCE); | |||
public EsTester esTester = new EsTester(new IssueIndexDefinition(new Settings())); | |||
@Before | |||
public void setUp() { | |||
dbTester.truncateTables(); | |||
esTester.truncateIndices(); | |||
} | |||
@Rule | |||
public DbTester dbTester = DbTester.create(System2.INSTANCE); | |||
@Test | |||
public void index_nothing() { |
@@ -23,7 +23,6 @@ import java.util.List; | |||
import org.assertj.core.data.Offset; | |||
import org.junit.After; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
@@ -78,8 +77,8 @@ public class CreateActionTest { | |||
@Rule | |||
public DbTester db = DbTester.create(System2.INSTANCE); | |||
@ClassRule | |||
public static EsTester es = new EsTester().addDefinitions(new UserIndexDefinition(new Settings())); | |||
@Rule | |||
public EsTester es = new EsTester(new UserIndexDefinition(new Settings())); | |||
DbClient dbClient = db.getDbClient(); | |||
@@ -91,7 +90,6 @@ public class CreateActionTest { | |||
public void setUp() { | |||
ws = new WsTester(new CustomMeasuresWs(new CreateAction(dbClient, userSession, System2.INSTANCE, new CustomMeasureValidator(newFullTypeValidations()), | |||
new CustomMeasureJsonWriter(new UserJsonWriter(userSession)), new ComponentFinder(dbClient)))); | |||
db.truncateTables(); | |||
userSession.login("login").setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN); | |||
db.getDbClient().userDao().insert(dbSession, new UserDto() |
@@ -20,8 +20,6 @@ | |||
package org.sonar.server.measure.custom.ws; | |||
import org.junit.Before; | |||
import org.junit.BeforeClass; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
@@ -56,8 +54,8 @@ public class MetricsActionTest { | |||
private static final String DEFAULT_PROJECT_UUID = "project-uuid"; | |||
private static final String DEFAULT_PROJECT_KEY = "project-key"; | |||
@ClassRule | |||
public static EsTester es = new EsTester().addDefinitions(new UserIndexDefinition(new Settings())); | |||
@Rule | |||
public EsTester es = new EsTester(new UserIndexDefinition(new Settings())); | |||
@Rule | |||
public ExpectedException expectedException = ExpectedException.none(); | |||
@Rule | |||
@@ -70,17 +68,13 @@ public class MetricsActionTest { | |||
WsTester ws; | |||
ComponentDto defaultProject; | |||
@BeforeClass | |||
public static void setUpClass() throws Exception { | |||
@Before | |||
public void setUp() throws Exception { | |||
es.putDocuments(UserIndexDefinition.INDEX, UserIndexDefinition.TYPE_USER, new UserDoc() | |||
.setLogin("login") | |||
.setName("Login") | |||
.setEmail("login@login.com") | |||
.setActive(true)); | |||
} | |||
@Before | |||
public void setUp() { | |||
ws = new WsTester(new CustomMeasuresWs(new MetricsAction(dbClient, userSession, new ComponentFinder(dbClient)))); | |||
userSession.login("login").setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN); | |||
defaultProject = insertDefaultProject(); |
@@ -22,7 +22,6 @@ package org.sonar.server.measure.custom.ws; | |||
import java.util.Date; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
@@ -70,8 +69,8 @@ public class SearchActionTest { | |||
@Rule | |||
public DbTester db = DbTester.create(System2.INSTANCE); | |||
@ClassRule | |||
public static EsTester es = new EsTester().addDefinitions(new UserIndexDefinition(new Settings())); | |||
@Rule | |||
public EsTester es = new EsTester(new UserIndexDefinition(new Settings())); | |||
WsTester ws; | |||
DbClient dbClient = db.getDbClient(); |
@@ -20,7 +20,6 @@ | |||
package org.sonar.server.measure.custom.ws; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
@@ -64,10 +63,10 @@ public class UpdateActionTest { | |||
public UserSessionRule userSessionRule = UserSessionRule.standalone(); | |||
@Rule | |||
public DbTester db = DbTester.create(System2.INSTANCE); | |||
@ClassRule | |||
public static EsTester es = new EsTester().addDefinitions(new UserIndexDefinition(new Settings())); | |||
@Rule | |||
public EsTester es = new EsTester(new UserIndexDefinition(new Settings())); | |||
DbClient dbClient = db.getDbClient(); | |||
final DbSession dbSession = db.getSession(); | |||
DbSession dbSession = db.getSession(); | |||
System2 system = mock(System2.class); | |||
WsTester ws; | |||
@@ -20,8 +20,6 @@ | |||
package org.sonar.server.platform; | |||
import com.google.common.collect.ImmutableMap; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
@@ -41,8 +39,8 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
public class BackendCleanupMediumTest { | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions( | |||
@Rule | |||
public EsTester esTester = new EsTester( | |||
new RuleIndexDefinition(new Settings()), | |||
new IssueIndexDefinition(new Settings()), | |||
new ViewIndexDefinition(new Settings()) | |||
@@ -51,12 +49,7 @@ public class BackendCleanupMediumTest { | |||
@Rule | |||
public DbTester dbTester = DbTester.create(System2.INSTANCE); | |||
BackendCleanup backendCleanup; | |||
@Before | |||
public void setUp() { | |||
backendCleanup = new BackendCleanup(esTester.client(), dbTester.myBatis()); | |||
} | |||
BackendCleanup backendCleanup = new BackendCleanup(esTester.client(), dbTester.myBatis()); | |||
@Test | |||
public void clear_db() { |
@@ -21,7 +21,7 @@ package org.sonar.server.platform.monitoring; | |||
import java.util.Map; | |||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.server.es.EsTester; | |||
@@ -32,8 +32,8 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
public class EsMonitorTest { | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new IssueIndexDefinition(new Settings())); | |||
@Rule | |||
public EsTester esTester = new EsTester(new IssueIndexDefinition(new Settings())); | |||
EsMonitor underTest = new EsMonitor(esTester.client()); | |||
@@ -22,7 +22,6 @@ package org.sonar.server.project.ws; | |||
import com.google.common.collect.ImmutableMap; | |||
import java.util.Arrays; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
@@ -71,11 +70,12 @@ import static org.sonar.server.project.ws.BulkDeleteAction.PARAM_KEYS; | |||
public class BulkDeleteActionTest { | |||
private static final String ACTION = "bulk_delete"; | |||
@Rule | |||
public DbTester db = DbTester.create(System2.INSTANCE); | |||
@ClassRule | |||
public static EsTester es = new EsTester().addDefinitions(new IssueIndexDefinition(new Settings()), | |||
@Rule | |||
public EsTester es = new EsTester(new IssueIndexDefinition(new Settings()), | |||
new TestIndexDefinition(new Settings())); | |||
@Rule | |||
@@ -104,8 +104,6 @@ public class BulkDeleteActionTest { | |||
dbClient, | |||
userSessionRule))); | |||
userSessionRule.setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN); | |||
db.truncateTables(); | |||
es.truncateIndices(); | |||
} | |||
@Test |
@@ -21,7 +21,6 @@ package org.sonar.server.project.ws; | |||
import com.google.common.collect.ImmutableMap; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
@@ -71,8 +70,9 @@ public class DeleteActionTest { | |||
@Rule | |||
public DbTester db = DbTester.create(System2.INSTANCE); | |||
@ClassRule | |||
public static EsTester es = new EsTester().addDefinitions(new IssueIndexDefinition(new Settings()), | |||
@Rule | |||
public EsTester es = new EsTester( | |||
new IssueIndexDefinition(new Settings()), | |||
new TestIndexDefinition(new Settings())); | |||
@Rule | |||
@@ -108,8 +108,6 @@ public class DeleteActionTest { | |||
dbClient, | |||
userSessionRule))); | |||
userSessionRule.login("login").setGlobalPermissions(UserRole.ADMIN); | |||
db.truncateTables(); | |||
es.truncateIndices(); | |||
} | |||
@Test |
@@ -25,7 +25,7 @@ import java.util.ArrayList; | |||
import java.util.List; | |||
import java.util.Map; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.api.rule.RuleKey; | |||
@@ -52,23 +52,20 @@ import static org.sonar.server.rule.index.RuleIndexDefinition.TYPE_ACTIVE_RULE; | |||
public class ActiveRuleIndexTest { | |||
static final RuleKey RULE_KEY_1 = RuleTesting.XOO_X1; | |||
static final RuleKey RULE_KEY_2 = RuleTesting.XOO_X2; | |||
private static final RuleKey RULE_KEY_1 = RuleTesting.XOO_X1; | |||
private static final RuleKey RULE_KEY_2 = RuleTesting.XOO_X2; | |||
private static final String QUALITY_PROFILE_KEY1 = "qp1"; | |||
private static final String QUALITY_PROFILE_KEY2 = "qp2"; | |||
static final String QUALITY_PROFILE_KEY1 = "qp1"; | |||
static final String QUALITY_PROFILE_KEY2 = "qp2"; | |||
@ClassRule | |||
public static EsTester tester = new EsTester().addDefinitions(new RuleIndexDefinition(new Settings())); | |||
@Rule | |||
public EsTester tester = new EsTester(new RuleIndexDefinition(new Settings())); | |||
ActiveRuleIndex index; | |||
ActiveRuleIndexer activeRuleIndexer; | |||
RuleIndexer ruleIndexer; | |||
@Before | |||
public void setUp() { | |||
tester.truncateIndices(); | |||
activeRuleIndexer = new ActiveRuleIndexer(null, tester.client()); | |||
ruleIndexer = new RuleIndexer(null, tester.client()); | |||
index = new ActiveRuleIndex(tester.client()); |
@@ -22,7 +22,6 @@ package org.sonar.server.qualityprofile.index; | |||
import com.google.common.collect.Iterators; | |||
import java.util.Arrays; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
@@ -58,8 +57,8 @@ public class ActiveRuleIndexerTest { | |||
static final String QUALITY_PROFILE_KEY1 = "qp1"; | |||
static final String QUALITY_PROFILE_KEY2 = "qp2"; | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new RuleIndexDefinition(new Settings())); | |||
@Rule | |||
public EsTester esTester = new EsTester(new RuleIndexDefinition(new Settings())); | |||
@Rule | |||
public DbTester dbTester = DbTester.create(System2.INSTANCE); | |||
@@ -68,7 +67,6 @@ public class ActiveRuleIndexerTest { | |||
@Before | |||
public void setUp() { | |||
esTester.truncateIndices(); | |||
indexer = new ActiveRuleIndexer(dbTester.getDbClient(), esTester.client()); | |||
indexer.setEnabled(true); | |||
} |
@@ -24,7 +24,6 @@ import java.util.Date; | |||
import java.util.Map; | |||
import org.joda.time.DateTime; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
@@ -61,8 +60,8 @@ public class ChangelogActionTest { | |||
@Rule | |||
public DbTester dbTester = DbTester.create(System2.INSTANCE); | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new ActivityIndexDefinition(new Settings())); | |||
@Rule | |||
public EsTester esTester = new EsTester(new ActivityIndexDefinition(new Settings())); | |||
private DbClient db = dbTester.getDbClient(); | |||
private DbSession dbSession = dbTester.getSession(); | |||
@@ -71,11 +70,6 @@ public class ChangelogActionTest { | |||
@Before | |||
public void before() { | |||
dbTester.truncateTables(); | |||
esTester.truncateIndices(); | |||
System2 system = mock(System2.class); | |||
// create pre-defined rules | |||
RuleDto xooRule1 = RuleTesting.newXooX1().setSeverity("MINOR"); | |||
db.ruleDao().insert(dbSession, xooRule1); |
@@ -22,7 +22,6 @@ package org.sonar.server.rule; | |||
import java.util.Date; | |||
import java.util.List; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.api.resources.Language; | |||
@@ -69,8 +68,8 @@ public class RegisterRulesTest { | |||
@org.junit.Rule | |||
public DbTester dbTester = DbTester.create(system); | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new RuleIndexDefinition(new Settings())); | |||
@org.junit.Rule | |||
public EsTester esTester = new EsTester(new RuleIndexDefinition(new Settings())); | |||
RuleActivator ruleActivator = mock(RuleActivator.class); | |||
@@ -83,7 +82,6 @@ public class RegisterRulesTest { | |||
@Before | |||
public void before() { | |||
esTester.truncateIndices(); | |||
when(system.now()).thenReturn(DATE1.getTime()); | |||
ruleIndexer = new RuleIndexer(dbClient, esTester.client()); | |||
ruleIndexer.setEnabled(true); |
@@ -43,7 +43,7 @@ public class RuleIndexDefinitionTest { | |||
RuleIndexDefinition underTest = new RuleIndexDefinition(settings); | |||
@Rule | |||
public EsTester tester = new EsTester().addDefinitions(underTest); | |||
public EsTester tester = new EsTester(underTest); | |||
@Test | |||
public void test_definition_of_index() { |
@@ -25,7 +25,7 @@ import java.util.Collections; | |||
import java.util.List; | |||
import java.util.Map; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.api.rule.RuleKey; | |||
@@ -74,17 +74,15 @@ public class RuleIndexTest { | |||
static final String QUALITY_PROFILE_KEY1 = "qp1"; | |||
static final String QUALITY_PROFILE_KEY2 = "qp2"; | |||
@ClassRule | |||
public static EsTester tester = new EsTester().addDefinitions(new RuleIndexDefinition(new Settings())); | |||
@Rule | |||
public EsTester tester = new EsTester(new RuleIndexDefinition(new Settings())); | |||
RuleIndex index; | |||
RuleIndexer ruleIndexer; | |||
ActiveRuleIndexer activeRuleIndexer; | |||
@Before | |||
public void setUp() { | |||
tester.truncateIndices(); | |||
ruleIndexer = new RuleIndexer(null, tester.client()); | |||
activeRuleIndexer = new ActiveRuleIndexer(null, tester.client()); | |||
index = new RuleIndex(tester.client()); |
@@ -20,8 +20,6 @@ | |||
package org.sonar.server.rule.index; | |||
import com.google.common.collect.Iterators; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
@@ -41,8 +39,8 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
public class RuleIndexerTest { | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new RuleIndexDefinition(new Settings())); | |||
@Rule | |||
public EsTester esTester = new EsTester(new RuleIndexDefinition(new Settings())); | |||
@Rule | |||
public DbTester dbTester = DbTester.create(System2.INSTANCE); | |||
@@ -68,11 +66,6 @@ public class RuleIndexerTest { | |||
.setCreatedAt(1500000000000L) | |||
.setUpdatedAt(1600000000000L); | |||
@Before | |||
public void setUp() { | |||
esTester.truncateIndices(); | |||
} | |||
@Test | |||
public void index_nothing() { | |||
RuleIndexer indexer = createIndexer(); |
@@ -27,8 +27,7 @@ import org.elasticsearch.action.search.SearchRequestBuilder; | |||
import org.elasticsearch.action.search.SearchResponse; | |||
import org.elasticsearch.search.aggregations.AggregationBuilders; | |||
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogram.Interval; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.utils.DateUtils; | |||
import org.sonar.server.es.EsTester; | |||
@@ -45,13 +44,8 @@ public class FacetsMediumTest { | |||
private static final String FIELD_TAGS = "tags"; | |||
private static final String FIELD_CREATED_AT = "createdAt"; | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new FacetsTestDefinition()); | |||
@Before | |||
public void setUp() { | |||
esTester.truncateIndices(); | |||
} | |||
@Rule | |||
public EsTester esTester = new EsTester(new FacetsTestDefinition()); | |||
@Test | |||
public void should_ignore_result_without_aggregations() { |
@@ -20,7 +20,6 @@ | |||
package org.sonar.server.startup; | |||
import javax.annotation.Nullable; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
@@ -54,8 +53,8 @@ public class ClearRulesOverloadedDebtTest { | |||
@Rule | |||
public DbTester tester = DbTester.create(system2); | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new RuleIndexDefinition(new Settings())); | |||
@Rule | |||
public EsTester esTester = new EsTester(new RuleIndexDefinition(new Settings())); | |||
@Rule | |||
public LogTester logTester = new LogTester(); |
@@ -22,8 +22,7 @@ package org.sonar.server.test.index; | |||
import com.google.common.base.Optional; | |||
import java.util.Arrays; | |||
import java.util.List; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.server.es.EsTester; | |||
@@ -33,16 +32,11 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.assertj.guava.api.Assertions.assertThat; | |||
public class TestIndexTest { | |||
@ClassRule | |||
public static EsTester es = new EsTester().addDefinitions(new TestIndexDefinition(new Settings())); | |||
@Rule | |||
public EsTester es = new EsTester(new TestIndexDefinition(new Settings())); | |||
TestIndex underTest = new TestIndex(es.client()); | |||
@Before | |||
public void setup() { | |||
es.truncateIndices(); | |||
} | |||
@Test | |||
public void coveredFiles() throws Exception { | |||
es.putDocuments(TestIndexDefinition.INDEX, TestIndexDefinition.TYPE, |
@@ -31,7 +31,6 @@ import org.elasticsearch.action.search.SearchResponse; | |||
import org.elasticsearch.index.query.QueryBuilders; | |||
import org.elasticsearch.search.SearchHit; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
@@ -59,19 +58,16 @@ import static org.sonar.server.test.index.TestIndexDefinition.TYPE; | |||
public class TestIndexerTest { | |||
@ClassRule | |||
public static EsTester es = new EsTester().addDefinitions(new TestIndexDefinition(new Settings())); | |||
@Rule | |||
public EsTester es = new EsTester(new TestIndexDefinition(new Settings())); | |||
@Rule | |||
public DbTester db = DbTester.create(System2.INSTANCE); | |||
private TestIndexer underTest; | |||
private TestIndexer underTest = new TestIndexer(db.getDbClient(), es.client()); | |||
@Before | |||
public void setUp() { | |||
es.truncateIndices(); | |||
db.truncateTables(); | |||
underTest = new TestIndexer(db.getDbClient(), es.client()); | |||
underTest.setEnabled(true); | |||
} | |||
@@ -22,7 +22,6 @@ package org.sonar.server.test.ws; | |||
import java.util.Arrays; | |||
import java.util.List; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
@@ -43,18 +42,20 @@ import org.sonar.server.test.index.TestIndexDefinition; | |||
import org.sonar.server.tester.UserSessionRule; | |||
import org.sonar.server.ws.WsTester; | |||
public class ListActionTest { | |||
@ClassRule | |||
public static EsTester es = new EsTester().addDefinitions(new TestIndexDefinition(new Settings())); | |||
@Rule | |||
public EsTester es = new EsTester(new TestIndexDefinition(new Settings())); | |||
@Rule | |||
public ExpectedException expectedException = ExpectedException.none(); | |||
@Rule | |||
public UserSessionRule userSessionRule = UserSessionRule.standalone(); | |||
@Rule | |||
public DbTester db = DbTester.create(System2.INSTANCE); | |||
DbClient dbClient = db.getDbClient(); | |||
TestIndex testIndex; | |||
@@ -62,10 +63,7 @@ public class ListActionTest { | |||
@Before | |||
public void setUp() { | |||
db.truncateTables(); | |||
es.truncateIndices(); | |||
testIndex = new TestIndex(es.client()); | |||
ws = new WsTester(new TestsWs(new ListAction(dbClient, testIndex, userSessionRule, new ComponentFinder(dbClient)))); | |||
} | |||
@@ -23,7 +23,6 @@ import com.google.common.base.Strings; | |||
import java.util.List; | |||
import org.elasticsearch.search.SearchHit; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.mockito.ArgumentCaptor; | |||
@@ -65,8 +64,8 @@ public class UserUpdaterTest { | |||
static final String DEFAULT_LOGIN = "marius"; | |||
@ClassRule | |||
public static EsTester es = new EsTester().addDefinitions(new UserIndexDefinition(new Settings())); | |||
@Rule | |||
public EsTester es = new EsTester(new UserIndexDefinition(new Settings())); | |||
System2 system2 = mock(System2.class); | |||
@@ -90,8 +89,6 @@ public class UserUpdaterTest { | |||
@Before | |||
public void setUp() { | |||
es.truncateIndices(); | |||
userIndexer = (UserIndexer) new UserIndexer(dbClient, es.client()).setEnabled(true); | |||
userUpdater = new UserUpdater(newUserNotifier, settings, dbClient, | |||
userIndexer, system2); |
@@ -24,7 +24,7 @@ import java.util.Collections; | |||
import java.util.List; | |||
import java.util.Locale; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.server.es.EsTester; | |||
@@ -42,14 +42,13 @@ public class UserIndexTest { | |||
private static final long DATE_1 = 1_500_000_000_000L; | |||
private static final long DATE_2 = 1_500_000_000_001L; | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new UserIndexDefinition(new Settings())); | |||
@Rule | |||
public EsTester esTester = new EsTester(new UserIndexDefinition(new Settings())); | |||
private UserIndex index; | |||
@Before | |||
public void setUp() { | |||
esTester.truncateIndices(); | |||
index = new UserIndex(esTester.client()); | |||
} | |||
@@ -20,8 +20,6 @@ | |||
package org.sonar.server.user.index; | |||
import java.util.List; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
@@ -32,20 +30,13 @@ import org.sonar.server.es.EsTester; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
public class UserIndexerTest { | |||
@Rule | |||
public DbTester dbTester = DbTester.create(System2.INSTANCE); | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new UserIndexDefinition(new Settings())); | |||
@Before | |||
public void setUp() { | |||
dbTester.truncateTables(); | |||
esTester.truncateIndices(); | |||
} | |||
@Rule | |||
public EsTester esTester = new EsTester(new UserIndexDefinition(new Settings())); | |||
@Test | |||
public void index_nothing() { |
@@ -21,7 +21,6 @@ package org.sonar.server.user.ws; | |||
import org.junit.After; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
@@ -62,8 +61,8 @@ public class ChangePasswordActionTest { | |||
@Rule | |||
public DbTester dbTester = DbTester.create(System2.INSTANCE); | |||
@ClassRule | |||
public static final EsTester esTester = new EsTester().addDefinitions(new UserIndexDefinition(settings)); | |||
@Rule | |||
public EsTester esTester = new EsTester(new UserIndexDefinition(settings)); | |||
@Rule | |||
public UserSessionRule userSessionRule = UserSessionRule.standalone().login("admin").setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN); | |||
@@ -86,9 +85,6 @@ public class ChangePasswordActionTest { | |||
@Before | |||
public void setUp() { | |||
dbTester.truncateTables(); | |||
esTester.truncateIndices(); | |||
System2 system2 = new System2(); | |||
UserDao userDao = new UserDao(dbTester.myBatis(), system2); | |||
UserGroupDao userGroupDao = new UserGroupDao(); |
@@ -22,7 +22,6 @@ package org.sonar.server.user.ws; | |||
import java.util.Locale; | |||
import org.junit.After; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
@@ -55,13 +54,13 @@ import static org.mockito.Mockito.when; | |||
public class CreateActionTest { | |||
static final Settings settings = new Settings().setProperty("sonar.defaultGroup", "sonar-users"); | |||
private static final Settings settings = new Settings().setProperty("sonar.defaultGroup", "sonar-users"); | |||
@Rule | |||
public DbTester dbTester = DbTester.create(System2.INSTANCE); | |||
@ClassRule | |||
public static final EsTester esTester = new EsTester().addDefinitions(new UserIndexDefinition(settings)); | |||
@Rule | |||
public EsTester esTester = new EsTester(new UserIndexDefinition(settings)); | |||
@Rule | |||
public UserSessionRule userSessionRule = UserSessionRule.standalone(); | |||
@@ -82,9 +81,6 @@ public class CreateActionTest { | |||
@Before | |||
public void setUp() { | |||
dbTester.truncateTables(); | |||
esTester.truncateIndices(); | |||
System2 system2 = new System2(); | |||
UserDao userDao = new UserDao(dbTester.myBatis(), system2); | |||
UserGroupDao userGroupDao = new UserGroupDao(); |
@@ -20,7 +20,6 @@ | |||
package org.sonar.server.user.ws; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
@@ -57,8 +56,10 @@ public class DeactivateActionTest { | |||
@Rule | |||
public DbTester db = DbTester.create(System2.INSTANCE); | |||
@ClassRule | |||
public static final EsTester esTester = new EsTester().addDefinitions(new UserIndexDefinition(settings)); | |||
@Rule | |||
public EsTester esTester = new EsTester(new UserIndexDefinition(settings)); | |||
@Rule | |||
public UserSessionRule userSessionRule = UserSessionRule.standalone(); | |||
@@ -67,13 +68,10 @@ public class DeactivateActionTest { | |||
UserIndex index; | |||
DbClient dbClient; | |||
UserIndexer userIndexer; | |||
DbSession dbSession; | |||
@Before | |||
public void setUp() { | |||
esTester.truncateIndices(); | |||
System2 system2 = new System2(); | |||
UserDao userDao = new UserDao(db.myBatis(), system2); | |||
dbClient = new DbClient(db.database(), db.myBatis(), userDao, new GroupMembershipDao(db.myBatis()), new UserTokenDao()); |
@@ -22,7 +22,6 @@ package org.sonar.server.user.ws; | |||
import com.google.common.collect.Lists; | |||
import java.util.List; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
@@ -55,23 +54,25 @@ import static org.sonar.test.JsonAssert.assertJson; | |||
public class SearchActionTest { | |||
@ClassRule | |||
public static final EsTester esTester = new EsTester().addDefinitions(new UserIndexDefinition(new Settings())); | |||
@Rule | |||
public EsTester esTester = new EsTester(new UserIndexDefinition(new Settings())); | |||
@Rule | |||
public UserSessionRule userSession = UserSessionRule.standalone(); | |||
@Rule | |||
public DbTester db = DbTester.create(System2.INSTANCE); | |||
UserDbTester userDb = new UserDbTester(db); | |||
GroupDbTester groupDb = new GroupDbTester(db); | |||
DbClient dbClient = db.getDbClient(); | |||
final DbSession dbSession = db.getSession(); | |||
DbSession dbSession = db.getSession(); | |||
WsTester ws; | |||
UserIndex index; | |||
@Before | |||
public void setUp() { | |||
esTester.truncateIndices(); | |||
index = new UserIndex(esTester.client()); | |||
ws = new WsTester(new UsersWs(new SearchAction(index, dbClient, new UserJsonWriter(userSession)))); | |||
} |
@@ -21,7 +21,6 @@ package org.sonar.server.user.ws; | |||
import org.junit.After; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
@@ -55,8 +54,8 @@ public class UpdateActionTest { | |||
@Rule | |||
public DbTester dbTester = DbTester.create(system2); | |||
@ClassRule | |||
public static final EsTester esTester = new EsTester().addDefinitions(new UserIndexDefinition(settings)); | |||
@Rule | |||
public EsTester esTester = new EsTester(new UserIndexDefinition(settings)); | |||
@Rule | |||
public final UserSessionRule userSessionRule = UserSessionRule.standalone().login("admin") | |||
.setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN); | |||
@@ -73,9 +72,6 @@ public class UpdateActionTest { | |||
@Before | |||
public void setUp() { | |||
dbTester.truncateTables(); | |||
esTester.truncateIndices(); | |||
dbClient.groupDao().insert(session, new GroupDto().setName("sonar-users")); | |||
session.commit(); | |||
@@ -20,8 +20,7 @@ | |||
package org.sonar.server.view.index; | |||
import java.util.List; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.server.es.EsTester; | |||
@@ -34,16 +33,10 @@ import static org.sonar.server.view.index.ViewIndexDefinition.TYPE_VIEW; | |||
public class ViewIndexTest { | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new ViewIndexDefinition(new Settings())); | |||
@Rule | |||
public EsTester esTester = new EsTester(new ViewIndexDefinition(new Settings())); | |||
private ViewIndex index; | |||
@Before | |||
public void setUp() { | |||
esTester.truncateIndices(); | |||
index = new ViewIndex(esTester.client()); | |||
} | |||
ViewIndex index = new ViewIndex(esTester.client()); | |||
@Test | |||
public void find_all_view_uuids() throws Exception { |
@@ -23,8 +23,6 @@ import com.google.common.base.Function; | |||
import com.google.common.collect.Maps; | |||
import java.util.List; | |||
import java.util.Map; | |||
import org.junit.Before; | |||
import org.junit.ClassRule; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.Settings; | |||
@@ -60,8 +58,8 @@ public class ViewIndexerTest { | |||
@Rule | |||
public DbTester dbTester = DbTester.create(System2.INSTANCE); | |||
@ClassRule | |||
public static EsTester esTester = new EsTester().addDefinitions(new IssueIndexDefinition(new Settings()), new ViewIndexDefinition(new Settings())); | |||
@Rule | |||
public EsTester esTester = new EsTester(new IssueIndexDefinition(new Settings()), new ViewIndexDefinition(new Settings())); | |||
@Rule | |||
public UserSessionRule userSessionRule = UserSessionRule.standalone(); | |||
@@ -72,12 +70,6 @@ public class ViewIndexerTest { | |||
ViewIndexer indexer = (ViewIndexer) new ViewIndexer(dbClient, esTester.client()).setEnabled(true); | |||
@Before | |||
public void setUp() { | |||
dbTester.truncateTables(); | |||
esTester.truncateIndices(); | |||
} | |||
@Test | |||
public void index_nothing() { | |||
indexer.index(); |