in order to wrap call to System.currentTimeMillis(). That is needed to bypass the condition "if (requestedAt > lastUpdatedAt)" in tests.tags/6.2-RC1
@@ -24,6 +24,7 @@ import java.util.Date; | |||
import java.util.Iterator; | |||
import javax.annotation.Nullable; | |||
import org.elasticsearch.action.index.IndexRequest; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.db.DbClient; | |||
import org.sonar.db.DbSession; | |||
import org.sonar.db.measure.ProjectMeasuresIndexerIterator; | |||
@@ -41,8 +42,8 @@ public class ProjectMeasuresIndexer extends BaseIndexer { | |||
private final DbClient dbClient; | |||
public ProjectMeasuresIndexer(DbClient dbClient, EsClient esClient) { | |||
super(esClient, 300, INDEX_PROJECT_MEASURES, TYPE_PROJECT_MEASURES, FIELD_ANALYSED_AT); | |||
public ProjectMeasuresIndexer(System2 system2, DbClient dbClient, EsClient esClient) { | |||
super(system2, esClient, 300, INDEX_PROJECT_MEASURES, TYPE_PROJECT_MEASURES, FIELD_ANALYSED_AT); | |||
this.dbClient = dbClient; | |||
} | |||
@@ -27,18 +27,21 @@ import java.util.concurrent.LinkedBlockingQueue; | |||
import java.util.concurrent.ThreadPoolExecutor; | |||
import java.util.concurrent.TimeUnit; | |||
import org.picocontainer.Startable; | |||
import org.sonar.api.utils.System2; | |||
public abstract class BaseIndexer implements Startable { | |||
private final System2 system2; | |||
private final ThreadPoolExecutor executor; | |||
private final String indexName; | |||
private final String typeName; | |||
private final String dateFieldName; | |||
protected final EsClient esClient; | |||
private final String dateFieldName; | |||
private volatile long lastUpdatedAt = -1L; | |||
protected BaseIndexer(EsClient client, long threadKeepAliveSeconds, String indexName, String typeName, | |||
protected BaseIndexer(System2 system2, EsClient client, long threadKeepAliveSeconds, String indexName, String typeName, | |||
String dateFieldName) { | |||
this.system2 = system2; | |||
this.indexName = indexName; | |||
this.typeName = typeName; | |||
this.dateFieldName = dateFieldName; | |||
@@ -48,7 +51,7 @@ public abstract class BaseIndexer implements Startable { | |||
} | |||
public void index(final IndexerTask task) { | |||
final long requestedAt = System.currentTimeMillis(); | |||
final long requestedAt = system2.now(); | |||
Future submit = executor.submit(() -> { | |||
if (lastUpdatedAt == -1L) { | |||
lastUpdatedAt = esClient.getMaxFieldValue(indexName, typeName, dateFieldName); |
@@ -25,6 +25,7 @@ import javax.annotation.Nullable; | |||
import org.elasticsearch.action.bulk.BulkRequestBuilder; | |||
import org.elasticsearch.action.index.IndexRequest; | |||
import org.elasticsearch.action.search.SearchRequestBuilder; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.db.DbClient; | |||
import org.sonar.db.DbSession; | |||
import org.sonar.server.es.BaseIndexer; | |||
@@ -47,8 +48,8 @@ public class IssueIndexer extends BaseIndexer { | |||
private final DbClient dbClient; | |||
public IssueIndexer(DbClient dbClient, EsClient esClient) { | |||
super(esClient, 300, INDEX, TYPE_ISSUE, FIELD_ISSUE_TECHNICAL_UPDATED_AT); | |||
public IssueIndexer(System2 system2, DbClient dbClient, EsClient esClient) { | |||
super(system2, esClient, 300, INDEX, TYPE_ISSUE, FIELD_ISSUE_TECHNICAL_UPDATED_AT); | |||
this.dbClient = dbClient; | |||
} | |||
@@ -28,6 +28,7 @@ import javax.annotation.Nonnull; | |||
import org.elasticsearch.action.index.IndexRequest; | |||
import org.elasticsearch.action.search.SearchRequestBuilder; | |||
import org.elasticsearch.index.query.QueryBuilders; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.db.DbClient; | |||
import org.sonar.db.DbSession; | |||
import org.sonar.db.qualityprofile.ActiveRuleKey; | |||
@@ -47,8 +48,8 @@ public class ActiveRuleIndexer extends BaseIndexer { | |||
private final DbClient dbClient; | |||
public ActiveRuleIndexer(DbClient dbClient, EsClient esClient) { | |||
super(esClient, 300, INDEX, TYPE_ACTIVE_RULE, FIELD_ACTIVE_RULE_UPDATED_AT); | |||
public ActiveRuleIndexer(System2 system2, DbClient dbClient, EsClient esClient) { | |||
super(system2, esClient, 300, INDEX, TYPE_ACTIVE_RULE, FIELD_ACTIVE_RULE_UPDATED_AT); | |||
this.dbClient = dbClient; | |||
} | |||
@@ -21,6 +21,7 @@ package org.sonar.server.rule.index; | |||
import java.util.Iterator; | |||
import org.elasticsearch.action.index.IndexRequest; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.db.DbClient; | |||
import org.sonar.db.DbSession; | |||
import org.sonar.server.es.BaseIndexer; | |||
@@ -35,8 +36,8 @@ public class RuleIndexer extends BaseIndexer { | |||
private final DbClient dbClient; | |||
public RuleIndexer(DbClient dbClient, EsClient esClient) { | |||
super(esClient, 300, INDEX, TYPE_RULE, FIELD_RULE_UPDATED_AT); | |||
public RuleIndexer(System2 system2, DbClient dbClient, EsClient esClient) { | |||
super(system2, esClient, 300, INDEX, TYPE_RULE, FIELD_RULE_UPDATED_AT); | |||
this.dbClient = dbClient; | |||
} | |||
@@ -19,15 +19,11 @@ | |||
*/ | |||
package org.sonar.server.test.index; | |||
import static org.sonar.server.test.index.TestIndexDefinition.FIELD_FILE_UUID; | |||
import static org.sonar.server.test.index.TestIndexDefinition.FIELD_UPDATED_AT; | |||
import static org.sonar.server.test.index.TestIndexDefinition.INDEX; | |||
import static org.sonar.server.test.index.TestIndexDefinition.TYPE; | |||
import java.util.Iterator; | |||
import javax.annotation.Nullable; | |||
import org.elasticsearch.action.search.SearchRequestBuilder; | |||
import org.elasticsearch.index.query.QueryBuilders; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.db.DbClient; | |||
import org.sonar.db.DbSession; | |||
import org.sonar.server.es.BaseIndexer; | |||
@@ -35,6 +31,11 @@ import org.sonar.server.es.BulkIndexer; | |||
import org.sonar.server.es.EsClient; | |||
import org.sonar.server.source.index.FileSourcesUpdaterHelper; | |||
import static org.sonar.server.test.index.TestIndexDefinition.FIELD_FILE_UUID; | |||
import static org.sonar.server.test.index.TestIndexDefinition.FIELD_UPDATED_AT; | |||
import static org.sonar.server.test.index.TestIndexDefinition.INDEX; | |||
import static org.sonar.server.test.index.TestIndexDefinition.TYPE; | |||
/** | |||
* Add to Elasticsearch index {@link TestIndexDefinition} the rows of | |||
* db table FILE_SOURCES of type TEST that are not indexed yet | |||
@@ -43,8 +44,8 @@ public class TestIndexer extends BaseIndexer { | |||
private final DbClient dbClient; | |||
public TestIndexer(DbClient dbClient, EsClient esClient) { | |||
super(esClient, 0L, INDEX, TYPE, FIELD_UPDATED_AT); | |||
public TestIndexer(System2 system2, DbClient dbClient, EsClient esClient) { | |||
super(system2, esClient, 0L, INDEX, TYPE, FIELD_UPDATED_AT); | |||
this.dbClient = dbClient; | |||
} | |||
@@ -21,6 +21,7 @@ package org.sonar.server.user.index; | |||
import java.util.Iterator; | |||
import org.elasticsearch.action.index.IndexRequest; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.db.DbClient; | |||
import org.sonar.db.DbSession; | |||
import org.sonar.server.es.BaseIndexer; | |||
@@ -31,8 +32,8 @@ public class UserIndexer extends BaseIndexer { | |||
private final DbClient dbClient; | |||
public UserIndexer(DbClient dbClient, EsClient esClient) { | |||
super(esClient, 300, UserIndexDefinition.INDEX, UserIndexDefinition.TYPE_USER, UserIndexDefinition.FIELD_UPDATED_AT); | |||
public UserIndexer(System2 system2, DbClient dbClient, EsClient esClient) { | |||
super(system2, esClient, 300, UserIndexDefinition.INDEX, UserIndexDefinition.TYPE_USER, UserIndexDefinition.FIELD_UPDATED_AT); | |||
this.dbClient = dbClient; | |||
} | |||
@@ -22,6 +22,7 @@ package org.sonar.server.view.index; | |||
import java.util.List; | |||
import java.util.Map; | |||
import org.elasticsearch.action.index.IndexRequest; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.db.DbClient; | |||
import org.sonar.db.DbSession; | |||
import org.sonar.db.component.ComponentDto; | |||
@@ -36,8 +37,8 @@ public class ViewIndexer extends BaseIndexer { | |||
private final DbClient dbClient; | |||
public ViewIndexer(DbClient dbClient, EsClient esClient) { | |||
super(esClient, 300, ViewIndexDefinition.INDEX, ViewIndexDefinition.TYPE_VIEW, "updatedAt"); | |||
public ViewIndexer(System2 system2, DbClient dbClient, EsClient esClient) { | |||
super(system2, esClient, 300, ViewIndexDefinition.INDEX, ViewIndexDefinition.TYPE_VIEW, "updatedAt"); | |||
this.dbClient = dbClient; | |||
} | |||
@@ -54,20 +54,20 @@ import static org.mockito.Mockito.mock; | |||
public class IssuesActionTest { | |||
final static String PROJECT_KEY = "struts"; | |||
static final String PROJECT_UUID = "ABCD"; | |||
private static final String PROJECT_KEY = "struts"; | |||
private static final String PROJECT_UUID = "ABCD"; | |||
private static final String MODULE_KEY = "struts-core"; | |||
private static final String MODULE_UUID = "BCDE"; | |||
private final static String FILE_KEY = "Action.java"; | |||
private static final String FILE_UUID = "CDEF"; | |||
final static String MODULE_KEY = "struts-core"; | |||
static final String MODULE_UUID = "BCDE"; | |||
final static String FILE_KEY = "Action.java"; | |||
static final String FILE_UUID = "CDEF"; | |||
private System2 system2 = System2.INSTANCE; | |||
@Rule | |||
public ExpectedException thrown = ExpectedException.none(); | |||
@Rule | |||
public DbTester db = DbTester.create(System2.INSTANCE); | |||
public DbTester db = DbTester.create(system2); | |||
@Rule | |||
public EsTester es = new EsTester(new IssueIndexDefinition(new MapSettings())); | |||
@@ -79,15 +79,13 @@ public class IssuesActionTest { | |||
private IssueIndexer issueIndexer; | |||
private PermissionIndexerTester authorizationIndexerTester = new PermissionIndexerTester(es); | |||
private ServerFileSystem fs = mock(ServerFileSystem.class); | |||
WsTester tester; | |||
IssuesAction issuesAction; | |||
private WsTester tester; | |||
private IssuesAction issuesAction; | |||
@Before | |||
public void before() { | |||
issueIndex = new IssueIndex(es.client(), System2.INSTANCE, userSessionRule); | |||
issueIndexer = new IssueIndexer(null, es.client()); | |||
issueIndex = new IssueIndex(es.client(), system2, userSessionRule); | |||
issueIndexer = new IssueIndexer(system2, null, es.client()); | |||
issuesAction = new IssuesAction(db.getDbClient(), issueIndex, userSessionRule, new ComponentFinder(db.getDbClient())); | |||
tester = new WsTester(new BatchWs(new BatchIndex(fs), issuesAction)); |
@@ -61,8 +61,10 @@ import static org.sonar.server.issue.index.IssueIndexDefinition.TYPE_ISSUE; | |||
public class ComponentCleanerServiceTest { | |||
private System2 system2 = System2.INSTANCE; | |||
@Rule | |||
public DbTester db = DbTester.create(System2.INSTANCE); | |||
public DbTester db = DbTester.create(system2); | |||
@Rule | |||
public EsTester es = new EsTester( | |||
@@ -73,17 +75,15 @@ public class ComponentCleanerServiceTest { | |||
@Rule | |||
public ExpectedException expectedException = ExpectedException.none(); | |||
DbClient dbClient = db.getDbClient(); | |||
DbSession dbSession = db.getSession(); | |||
PermissionIndexer permissionIndexer = new PermissionIndexer(dbClient, es.client()); | |||
IssueIndexer issueIndexer = new IssueIndexer(dbClient, es.client()); | |||
TestIndexer testIndexer = new TestIndexer(dbClient, es.client()); | |||
ProjectMeasuresIndexer projectMeasuresIndexer = new ProjectMeasuresIndexer(dbClient, es.client()); | |||
ResourceTypes mockResourceTypes = mock(ResourceTypes.class); | |||
private DbClient dbClient = db.getDbClient(); | |||
private DbSession dbSession = db.getSession(); | |||
private PermissionIndexer permissionIndexer = new PermissionIndexer(dbClient, es.client()); | |||
private IssueIndexer issueIndexer = new IssueIndexer(system2, dbClient, es.client()); | |||
private TestIndexer testIndexer = new TestIndexer(system2, dbClient, es.client()); | |||
private ProjectMeasuresIndexer projectMeasuresIndexer = new ProjectMeasuresIndexer(system2, dbClient, es.client()); | |||
private ResourceTypes mockResourceTypes = mock(ResourceTypes.class); | |||
ComponentCleanerService underTest = new ComponentCleanerService(dbClient, issueIndexer, testIndexer, projectMeasuresIndexer, mockResourceTypes, | |||
private ComponentCleanerService underTest = new ComponentCleanerService(dbClient, issueIndexer, testIndexer, projectMeasuresIndexer, mockResourceTypes, | |||
new ComponentFinder(dbClient)); | |||
@Test |
@@ -63,6 +63,8 @@ import static org.sonar.server.component.es.ProjectMeasuresIndexDefinition.TYPE_ | |||
public class ComponentServiceTest { | |||
private System2 system2 = System2.INSTANCE; | |||
@Rule | |||
public UserSessionRule userSession = UserSessionRule.standalone(); | |||
@@ -75,21 +77,19 @@ public class ComponentServiceTest { | |||
@Rule | |||
public DbTester dbTester = DbTester.create(System2.INSTANCE); | |||
ComponentDbTester componentDb = new ComponentDbTester(dbTester); | |||
DbClient dbClient = dbTester.getDbClient(); | |||
DbSession dbSession = dbTester.getSession(); | |||
I18nRule i18n = new I18nRule(); | |||
private ComponentDbTester componentDb = new ComponentDbTester(dbTester); | |||
private DbClient dbClient = dbTester.getDbClient(); | |||
private DbSession dbSession = dbTester.getSession(); | |||
private I18nRule i18n = new I18nRule(); | |||
private ProjectMeasuresIndexer projectMeasuresIndexer = new ProjectMeasuresIndexer(system2, dbClient, es.client()); | |||
ProjectMeasuresIndexer projectMeasuresIndexer = new ProjectMeasuresIndexer(dbClient, es.client()); | |||
ComponentService underTest; | |||
private ComponentService underTest; | |||
@Before | |||
public void setUp() { | |||
i18n.put("qualifier.TRK", "Project"); | |||
underTest = new ComponentService(dbClient, i18n, userSession, System2.INSTANCE, new ComponentFinder(dbClient), projectMeasuresIndexer); | |||
underTest = new ComponentService(dbClient, i18n, userSession, system2, new ComponentFinder(dbClient), projectMeasuresIndexer); | |||
} | |||
@Test |
@@ -56,6 +56,8 @@ import static org.sonar.server.component.es.ProjectMeasuresIndexDefinition.TYPE_ | |||
public class ComponentServiceUpdateKeyTest { | |||
private System2 system2 = System2.INSTANCE; | |||
@Rule | |||
public UserSessionRule userSession = UserSessionRule.standalone(); | |||
@@ -66,7 +68,7 @@ public class ComponentServiceUpdateKeyTest { | |||
public EsTester es = new EsTester(new ProjectMeasuresIndexDefinition(new MapSettings())); | |||
@Rule | |||
public DbTester db = DbTester.create(System2.INSTANCE); | |||
public DbTester db = DbTester.create(system2); | |||
ComponentDbTester componentDb = new ComponentDbTester(db); | |||
DbClient dbClient = db.getDbClient(); | |||
@@ -74,7 +76,7 @@ public class ComponentServiceUpdateKeyTest { | |||
I18nRule i18n = new I18nRule(); | |||
ProjectMeasuresIndexer projectMeasuresIndexer = new ProjectMeasuresIndexer(dbClient, es.client()); | |||
ProjectMeasuresIndexer projectMeasuresIndexer = new ProjectMeasuresIndexer(system2, dbClient, es.client()); | |||
ComponentService underTest; | |||
@@ -82,7 +84,7 @@ public class ComponentServiceUpdateKeyTest { | |||
public void setUp() { | |||
i18n.put("qualifier.TRK", "Project"); | |||
underTest = new ComponentService(dbClient, i18n, userSession, System2.INSTANCE, new ComponentFinder(dbClient), projectMeasuresIndexer); | |||
underTest = new ComponentService(dbClient, i18n, userSession, system2, new ComponentFinder(dbClient), projectMeasuresIndexer); | |||
} | |||
@Test |
@@ -52,8 +52,10 @@ import static org.sonar.core.permission.GlobalPermissions.PROVISIONING; | |||
public class DefaultRubyComponentServiceTest { | |||
private System2 system2 = mock(System2.class); | |||
@Rule | |||
public DbTester db = DbTester.create(System2.INSTANCE); | |||
public DbTester db = DbTester.create(system2); | |||
@Rule | |||
public UserSessionRule userSession = UserSessionRule.standalone(); | |||
@@ -67,8 +69,8 @@ public class DefaultRubyComponentServiceTest { | |||
private DbSession dbSession = db.getSession(); | |||
private ResourceDao resourceDao = dbClient.resourceDao(); | |||
private ComponentService componentService = new ComponentService(dbClient, i18n, userSession, System2.INSTANCE, new ComponentFinder(dbClient), | |||
new ProjectMeasuresIndexer(dbClient, es.client())); | |||
private ComponentService componentService = new ComponentService(dbClient, i18n, userSession, system2, new ComponentFinder(dbClient), | |||
new ProjectMeasuresIndexer(system2, dbClient, es.client())); | |||
private PermissionTemplateService permissionTemplateService = mock(PermissionTemplateService.class); | |||
private FavoriteService favoriteService = mock(FavoriteService.class); | |||
@@ -45,16 +45,18 @@ import static org.sonar.server.component.es.ProjectMeasuresIndexDefinition.TYPE_ | |||
public class ProjectMeasuresIndexerTest { | |||
private System2 system2 = System2.INSTANCE; | |||
@Rule | |||
public EsTester esTester = new EsTester(new ProjectMeasuresIndexDefinition(new MapSettings())); | |||
@Rule | |||
public DbTester dbTester = DbTester.create(System2.INSTANCE); | |||
public DbTester dbTester = DbTester.create(system2); | |||
ComponentDbTester componentDbTester = new ComponentDbTester(dbTester); | |||
PermissionIndexerTester authorizationIndexerTester = new PermissionIndexerTester(esTester); | |||
ProjectMeasuresIndexer underTest = new ProjectMeasuresIndexer(dbTester.getDbClient(), esTester.client()); | |||
ProjectMeasuresIndexer underTest = new ProjectMeasuresIndexer(system2, dbTester.getDbClient(), esTester.client()); | |||
@Test | |||
public void index_nothing() { |
@@ -70,6 +70,8 @@ public class BulkUpdateKeyActionTest { | |||
static final String FROM = "my_"; | |||
static final String TO = "your_"; | |||
private System2 system2 = System2.INSTANCE; | |||
@Rule | |||
public ExpectedException expectedException = ExpectedException.none(); | |||
@@ -80,7 +82,7 @@ public class BulkUpdateKeyActionTest { | |||
public EsTester es = new EsTester(new ProjectMeasuresIndexDefinition(new MapSettings())); | |||
@Rule | |||
public DbTester db = DbTester.create(System2.INSTANCE); | |||
public DbTester db = DbTester.create(system2); | |||
ComponentDbTester componentDb = new ComponentDbTester(db); | |||
DbClient dbClient = db.getDbClient(); | |||
@@ -89,7 +91,7 @@ public class BulkUpdateKeyActionTest { | |||
ComponentFinder componentFinder = new ComponentFinder(dbClient); | |||
WsActionTester ws = new WsActionTester( | |||
new BulkUpdateKeyAction(dbClient, componentFinder, new ComponentService(dbClient, null, null, null, null, new ProjectMeasuresIndexer(dbClient, es.client())), userSession)); | |||
new BulkUpdateKeyAction(dbClient, componentFinder, new ComponentService(dbClient, null, null, null, null, new ProjectMeasuresIndexer(system2, dbClient, es.client())), userSession)); | |||
@Before | |||
public void setUp() { |
@@ -41,8 +41,10 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
public class IndexTestsStepTest extends BaseStepTest { | |||
private System2 system2 = System2.INSTANCE; | |||
@Rule | |||
public DbTester dbTester = DbTester.create(System2.INSTANCE); | |||
public DbTester dbTester = DbTester.create(system2); | |||
@Rule | |||
public EsTester esTester = new EsTester(new TestIndexDefinition(new MapSettings())); | |||
@@ -54,7 +56,7 @@ public class IndexTestsStepTest extends BaseStepTest { | |||
@Override | |||
protected ComputationStep step() { | |||
TestIndexer testIndexer = new TestIndexer(dbClient, esTester.client()); | |||
TestIndexer testIndexer = new TestIndexer(system2, dbClient, esTester.client()); | |||
return new IndexTestsStep(testIndexer, treeRootHolder); | |||
} | |||
@@ -63,6 +63,7 @@ public class IssueIndexDebtTest { | |||
@Rule | |||
public UserSessionRule userSessionRule = UserSessionRule.standalone(); | |||
private System2 system2 = System2.INSTANCE; | |||
IssueIndex index; | |||
IssueIndexer issueIndexer; | |||
@@ -71,8 +72,8 @@ public class IssueIndexDebtTest { | |||
@Before | |||
public void setUp() { | |||
issueIndexer = new IssueIndexer(null, tester.client()); | |||
viewIndexer = new ViewIndexer(null, tester.client()); | |||
issueIndexer = new IssueIndexer(system2, null, tester.client()); | |||
viewIndexer = new ViewIndexer(system2, null, tester.client()); | |||
System2 system = mock(System2.class); | |||
when(system.getDefaultTimeZone()).thenReturn(TimeZone.getTimeZone("+01:00")); | |||
when(system.now()).thenReturn(System.currentTimeMillis()); |
@@ -68,6 +68,8 @@ import static org.sonar.api.utils.DateUtils.parseDateTime; | |||
public class IssueIndexTest { | |||
private System2 system2 = System2.INSTANCE; | |||
@Rule | |||
public EsTester tester = new EsTester(new IssueIndexDefinition(new MapSettings()), new ViewIndexDefinition(new MapSettings())); | |||
@@ -84,8 +86,8 @@ public class IssueIndexTest { | |||
@Before | |||
public void setUp() { | |||
issueIndexer = new IssueIndexer(null, tester.client()); | |||
viewIndexer = new ViewIndexer(null, tester.client()); | |||
issueIndexer = new IssueIndexer(system2, null, tester.client()); | |||
viewIndexer = new ViewIndexer(system2, null, tester.client()); | |||
System2 system = mock(System2.class); | |||
when(system.getDefaultTimeZone()).thenReturn(TimeZone.getTimeZone("GMT-1:00")); | |||
when(system.now()).thenReturn(System.currentTimeMillis()); |
@@ -44,11 +44,13 @@ public class IssueIndexerTest { | |||
private static final String A_PROJECT_UUID = "P1"; | |||
private System2 system2 = System2.INSTANCE; | |||
@Rule | |||
public EsTester esTester = new EsTester(new IssueIndexDefinition(new MapSettings())); | |||
@Rule | |||
public DbTester dbTester = DbTester.create(System2.INSTANCE); | |||
public DbTester dbTester = DbTester.create(system2); | |||
@Test | |||
public void index_nothing() { | |||
@@ -156,7 +158,7 @@ public class IssueIndexerTest { | |||
} | |||
private IssueIndexer createIndexer() { | |||
return new IssueIndexer(new DbClient(dbTester.database(), dbTester.myBatis()), esTester.client()); | |||
return new IssueIndexer(system2, new DbClient(dbTester.database(), dbTester.myBatis()), esTester.client()); | |||
} | |||
private void addIssue(String projectUuid, String issueKey) throws Exception { |
@@ -70,8 +70,10 @@ public class BulkDeleteActionTest { | |||
private static final String ACTION = "bulk_delete"; | |||
private System2 system2 = System2.INSTANCE; | |||
@Rule | |||
public DbTester db = DbTester.create(System2.INSTANCE); | |||
public DbTester db = DbTester.create(system2); | |||
@Rule | |||
public EsTester es = new EsTester(new IssueIndexDefinition(new MapSettings()), | |||
@@ -83,10 +85,10 @@ public class BulkDeleteActionTest { | |||
@Rule | |||
public ExpectedException expectedException = ExpectedException.none(); | |||
WsTester ws; | |||
DbClient dbClient = db.getDbClient(); | |||
private WsTester ws; | |||
private DbClient dbClient = db.getDbClient(); | |||
final DbSession dbSession = db.getSession(); | |||
ResourceType resourceType; | |||
private ResourceType resourceType; | |||
@Before | |||
public void setUp() { | |||
@@ -97,9 +99,9 @@ public class BulkDeleteActionTest { | |||
ws = new WsTester(new ProjectsWs( | |||
new BulkDeleteAction( | |||
new ComponentCleanerService(dbClient, | |||
new IssueIndexer(dbClient, es.client()), | |||
new TestIndexer(dbClient, es.client()), | |||
new ProjectMeasuresIndexer(dbClient, es.client()), | |||
new IssueIndexer(system2, dbClient, es.client()), | |||
new TestIndexer(system2, dbClient, es.client()), | |||
new ProjectMeasuresIndexer(system2, dbClient, es.client()), | |||
mockResourceTypes, | |||
new ComponentFinder(dbClient)), | |||
dbClient, |
@@ -67,8 +67,10 @@ public class DeleteActionTest { | |||
private static final String ACTION = "delete"; | |||
private System2 system2 = System2.INSTANCE; | |||
@Rule | |||
public DbTester db = DbTester.create(System2.INSTANCE); | |||
public DbTester db = DbTester.create(system2); | |||
@Rule | |||
public EsTester es = new EsTester( | |||
@@ -81,13 +83,10 @@ public class DeleteActionTest { | |||
@Rule | |||
public ExpectedException expectedException = ExpectedException.none(); | |||
WsTester ws; | |||
DbClient dbClient = db.getDbClient(); | |||
final DbSession dbSession = db.getSession(); | |||
ResourceType resourceType; | |||
private WsTester ws; | |||
private DbClient dbClient = db.getDbClient(); | |||
private final DbSession dbSession = db.getSession(); | |||
private ResourceType resourceType; | |||
@Before | |||
public void setUp() { | |||
@@ -99,9 +98,9 @@ public class DeleteActionTest { | |||
new DeleteAction( | |||
new ComponentCleanerService( | |||
dbClient, | |||
new IssueIndexer(dbClient, es.client()), | |||
new TestIndexer(dbClient, es.client()), | |||
new ProjectMeasuresIndexer(dbClient, es.client()), | |||
new IssueIndexer(system2, dbClient, es.client()), | |||
new TestIndexer(system2, dbClient, es.client()), | |||
new ProjectMeasuresIndexer(system2, dbClient, es.client()), | |||
mockResourceTypes, | |||
new ComponentFinder(dbClient)), | |||
new ComponentFinder(dbClient), |
@@ -29,6 +29,7 @@ import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.config.MapSettings; | |||
import org.sonar.api.rule.RuleKey; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.db.qualityprofile.ActiveRuleKey; | |||
import org.sonar.db.rule.RuleTesting; | |||
import org.sonar.server.es.EsTester; | |||
@@ -57,6 +58,8 @@ public class ActiveRuleIndexTest { | |||
private static final String QUALITY_PROFILE_KEY1 = "qp1"; | |||
private static final String QUALITY_PROFILE_KEY2 = "qp2"; | |||
private System2 system2 = System2.INSTANCE; | |||
@Rule | |||
public EsTester tester = new EsTester(new RuleIndexDefinition(new MapSettings())); | |||
@@ -66,8 +69,8 @@ public class ActiveRuleIndexTest { | |||
@Before | |||
public void setUp() { | |||
activeRuleIndexer = new ActiveRuleIndexer(null, tester.client()); | |||
ruleIndexer = new RuleIndexer(null, tester.client()); | |||
activeRuleIndexer = new ActiveRuleIndexer(system2, null, tester.client()); | |||
ruleIndexer = new RuleIndexer(system2, null, tester.client()); | |||
index = new ActiveRuleIndex(tester.client()); | |||
} | |||
@@ -48,12 +48,13 @@ import static org.sonar.server.rule.index.RuleIndexDefinition.TYPE_ACTIVE_RULE; | |||
public class ActiveRuleIndexerTest { | |||
static final RuleKey RULE_KEY_1 = RuleTesting.XOO_X1; | |||
static final RuleKey RULE_KEY_2 = RuleTesting.XOO_X2; | |||
static final RuleKey RULE_KEY_3 = RuleTesting.XOO_X3; | |||
private static final RuleKey RULE_KEY_1 = RuleTesting.XOO_X1; | |||
private static final RuleKey RULE_KEY_2 = RuleTesting.XOO_X2; | |||
private static final RuleKey RULE_KEY_3 = RuleTesting.XOO_X3; | |||
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"; | |||
private System2 system2 = System2.INSTANCE; | |||
@Rule | |||
public EsTester esTester = new EsTester(new RuleIndexDefinition(new MapSettings())); | |||
@@ -61,7 +62,7 @@ public class ActiveRuleIndexerTest { | |||
@Rule | |||
public DbTester dbTester = DbTester.create(System2.INSTANCE); | |||
private ActiveRuleIndexer indexer = new ActiveRuleIndexer(dbTester.getDbClient(), esTester.client()); | |||
private ActiveRuleIndexer indexer = new ActiveRuleIndexer(system2, dbTester.getDbClient(), esTester.client()); | |||
@Test | |||
public void index_nothing() { |
@@ -55,8 +55,10 @@ public class AddProjectActionTest { | |||
static final String LANGUAGE_1 = "xoo"; | |||
static final String LANGUAGE_2 = "foo"; | |||
private System2 system2 = System2.INSTANCE; | |||
@Rule | |||
public DbTester dbTester = DbTester.create(System2.INSTANCE); | |||
public DbTester dbTester = DbTester.create(system2); | |||
@Rule | |||
public EsTester es = new EsTester(new ProjectMeasuresIndexDefinition(new MapSettings())); | |||
@@ -77,7 +79,7 @@ public class AddProjectActionTest { | |||
WsActionTester ws = new WsActionTester(new AddProjectAction(projectAssociationParameters, | |||
qProfileProjectOperations, new ProjectAssociationFinder(new QProfileLookup(dbClient), | |||
new ComponentService(dbClient, null, userSession, null, new ComponentFinder(dbClient), new ProjectMeasuresIndexer(dbClient, es.client()))), | |||
new ComponentService(dbClient, null, userSession, null, new ComponentFinder(dbClient), new ProjectMeasuresIndexer(system2, dbClient, es.client()))), | |||
userSession)); | |||
@Before |
@@ -69,15 +69,15 @@ import static org.sonarqube.ws.QualityProfiles.CreateWsResponse.parseFrom; | |||
public class CreateActionTest { | |||
static final String XOO_LANGUAGE = "xoo"; | |||
static final RuleDto RULE = RuleTesting.newXooX1().setSeverity("MINOR").setLanguage(XOO_LANGUAGE); | |||
private static final String XOO_LANGUAGE = "xoo"; | |||
private static final RuleDto RULE = RuleTesting.newXooX1().setSeverity("MINOR").setLanguage(XOO_LANGUAGE); | |||
private System2 system2 = System2.INSTANCE; | |||
@Rule | |||
public ExpectedException expectedException = ExpectedException.none(); | |||
@Rule | |||
public DbTester dbTester = DbTester.create(System2.INSTANCE); | |||
public DbTester dbTester = DbTester.create(system2); | |||
@Rule | |||
public EsTester esTester = new EsTester(new RuleIndexDefinition(new MapSettings())); | |||
@@ -89,10 +89,10 @@ public class CreateActionTest { | |||
DbSession dbSession = dbTester.getSession(); | |||
RuleIndex ruleIndex = new RuleIndex(esTester.client()); | |||
RuleIndexer ruleIndexer = new RuleIndexer(dbClient, esTester.client()); | |||
RuleIndexer ruleIndexer = new RuleIndexer(system2, dbClient, esTester.client()); | |||
ActiveRuleIndex activeRuleIndex = new ActiveRuleIndex(esTester.client()); | |||
ActiveRuleIndexer activeRuleIndexer = new ActiveRuleIndexer(dbClient, esTester.client()); | |||
ActiveRuleIndexer activeRuleIndexer = new ActiveRuleIndexer(system2, dbClient, esTester.client()); | |||
ProfileImporter[] profileImporters = createImporters(); | |||
@@ -66,7 +66,7 @@ public class RegisterRulesTest { | |||
private static final RuleKey RULE_KEY2 = RuleKey.of("fake", "rule2"); | |||
private static final RuleKey RULE_KEY3 = RuleKey.of("fake", "rule3"); | |||
private System2 system = mock(System2.class);; | |||
private System2 system = mock(System2.class); | |||
@org.junit.Rule | |||
public DbTester dbTester = DbTester.create(system); | |||
@@ -83,9 +83,9 @@ public class RegisterRulesTest { | |||
@Before | |||
public void before() { | |||
when(system.now()).thenReturn(DATE1.getTime()); | |||
ruleIndexer = new RuleIndexer(dbClient, esTester.client()); | |||
ruleIndexer = new RuleIndexer(system, dbClient, esTester.client()); | |||
ruleIndex = new RuleIndex(esTester.client()); | |||
activeRuleIndexer = new ActiveRuleIndexer(dbClient, esTester.client()); | |||
activeRuleIndexer = new ActiveRuleIndexer(system, dbClient, esTester.client()); | |||
} | |||
@Test |
@@ -32,6 +32,7 @@ import org.sonar.api.config.MapSettings; | |||
import org.sonar.api.rule.RuleKey; | |||
import org.sonar.api.rule.RuleStatus; | |||
import org.sonar.api.rules.RuleType; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.db.qualityprofile.ActiveRuleKey; | |||
import org.sonar.db.rule.RuleTesting; | |||
import org.sonar.server.es.EsTester; | |||
@@ -67,25 +68,26 @@ import static org.sonar.server.rule.index.RuleIndexDefinition.TYPE_ACTIVE_RULE; | |||
public class RuleIndexTest { | |||
static final RuleKey RULE_KEY_1 = RuleTesting.XOO_X1; | |||
static final RuleKey RULE_KEY_2 = RuleTesting.XOO_X2; | |||
static final RuleKey RULE_KEY_3 = RuleTesting.XOO_X3; | |||
static final RuleKey RULE_KEY_4 = RuleKey.of("xoo", "x4"); | |||
private static final RuleKey RULE_KEY_1 = RuleTesting.XOO_X1; | |||
private static final RuleKey RULE_KEY_2 = RuleTesting.XOO_X2; | |||
private static final RuleKey RULE_KEY_3 = RuleTesting.XOO_X3; | |||
private static final RuleKey RULE_KEY_4 = RuleKey.of("xoo", "x4"); | |||
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"; | |||
private System2 system2 = System2.INSTANCE; | |||
@Rule | |||
public EsTester tester = new EsTester(new RuleIndexDefinition(new MapSettings())); | |||
RuleIndex index; | |||
RuleIndexer ruleIndexer; | |||
ActiveRuleIndexer activeRuleIndexer; | |||
private RuleIndex index; | |||
private RuleIndexer ruleIndexer; | |||
private ActiveRuleIndexer activeRuleIndexer; | |||
@Before | |||
public void setUp() { | |||
ruleIndexer = new RuleIndexer(null, tester.client()); | |||
activeRuleIndexer = new ActiveRuleIndexer(null, tester.client()); | |||
ruleIndexer = new RuleIndexer(system2, null, tester.client()); | |||
activeRuleIndexer = new ActiveRuleIndexer(system2, null, tester.client()); | |||
index = new RuleIndex(tester.client()); | |||
} | |||
@@ -36,20 +36,19 @@ import org.sonar.server.es.EsTester; | |||
import static com.google.common.collect.Sets.newHashSet; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
public class RuleIndexerTest { | |||
private System2 system2 = System2.INSTANCE; | |||
@Rule | |||
public EsTester esTester = new EsTester(new RuleIndexDefinition(new MapSettings())); | |||
@Rule | |||
public DbTester dbTester = DbTester.create(System2.INSTANCE); | |||
DbClient dbClient = dbTester.getDbClient(); | |||
DbSession dbSession = dbTester.getSession(); | |||
public DbTester dbTester = DbTester.create(system2); | |||
RuleDto rule = new RuleDto() | |||
private DbClient dbClient = dbTester.getDbClient(); | |||
private DbSession dbSession = dbTester.getSession(); | |||
private RuleDto rule = new RuleDto() | |||
.setRuleKey("S001") | |||
.setRepositoryKey("xoo") | |||
.setConfigKey("S1") | |||
@@ -103,7 +102,7 @@ public class RuleIndexerTest { | |||
} | |||
private RuleIndexer createIndexer() { | |||
return new RuleIndexer(dbTester.getDbClient(), esTester.client()); | |||
return new RuleIndexer(system2, dbTester.getDbClient(), esTester.client()); | |||
} | |||
} |
@@ -48,7 +48,7 @@ public class ClearRulesOverloadedDebtTest { | |||
private static final RuleKey RULE_KEY_2 = RuleTesting.XOO_X2; | |||
private static final RuleKey RULE_KEY_3 = RuleTesting.XOO_X3; | |||
System2 system2 = mock(System2.class); | |||
private System2 system2 = mock(System2.class); | |||
@Rule | |||
public DbTester tester = DbTester.create(system2); | |||
@@ -59,12 +59,12 @@ public class ClearRulesOverloadedDebtTest { | |||
@Rule | |||
public LogTester logTester = new LogTester(); | |||
DbClient dbClient = tester.getDbClient(); | |||
DbSession dbSession = tester.getSession(); | |||
RuleDao ruleDao = new RuleDao(); | |||
RuleIndexer ruleIndexer = new RuleIndexer(dbClient, esTester.client()); | |||
private DbClient dbClient = tester.getDbClient(); | |||
private DbSession dbSession = tester.getSession(); | |||
private RuleDao ruleDao = new RuleDao(); | |||
private RuleIndexer ruleIndexer = new RuleIndexer(system2, dbClient, esTester.client()); | |||
ClearRulesOverloadedDebt underTest = new ClearRulesOverloadedDebt(system2, dbClient, ruleIndexer); | |||
private ClearRulesOverloadedDebt underTest = new ClearRulesOverloadedDebt(system2, dbClient, ruleIndexer); | |||
@Test | |||
public void remove_overridden_debt() throws Exception { |
@@ -57,13 +57,15 @@ import static org.sonar.server.test.index.TestIndexDefinition.TYPE; | |||
public class TestIndexerTest { | |||
private System2 system2 = System2.INSTANCE; | |||
@Rule | |||
public EsTester es = new EsTester(new TestIndexDefinition(new MapSettings())); | |||
@Rule | |||
public DbTester db = DbTester.create(System2.INSTANCE); | |||
public DbTester db = DbTester.create(system2); | |||
private TestIndexer underTest = new TestIndexer(db.getDbClient(), es.client()); | |||
private TestIndexer underTest = new TestIndexer(system2, db.getDbClient(), es.client()); | |||
@Test | |||
public void index_tests() throws Exception { |
@@ -88,7 +88,7 @@ public class UserUpdaterTest { | |||
@Before | |||
public void setUp() { | |||
userIndexer = new UserIndexer(dbClient, es.client()); | |||
userIndexer = new UserIndexer(system2, dbClient, es.client()); | |||
DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db); | |||
underTest = new UserUpdater(newUserNotifier, settings, dbClient, | |||
userIndexer, system2, defaultOrganizationProvider); |
@@ -32,8 +32,10 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
public class UserIndexerTest { | |||
private System2 system2 = System2.INSTANCE; | |||
@Rule | |||
public DbTester dbTester = DbTester.create(System2.INSTANCE); | |||
public DbTester dbTester = DbTester.create(system2); | |||
@Rule | |||
public EsTester esTester = new EsTester(new UserIndexDefinition(new MapSettings())); | |||
@@ -65,6 +67,6 @@ public class UserIndexerTest { | |||
} | |||
private UserIndexer createIndexer() { | |||
return new UserIndexer(new DbClient(dbTester.database(), dbTester.myBatis()), esTester.client()); | |||
return new UserIndexer(system2, new DbClient(dbTester.database(), dbTester.myBatis()), esTester.client()); | |||
} | |||
} |
@@ -57,10 +57,11 @@ import static org.mockito.Mockito.when; | |||
public class ChangePasswordActionTest { | |||
private System2 system2 = System2.INSTANCE; | |||
private Settings settings = new MapSettings(); | |||
@Rule | |||
public DbTester dbTester = DbTester.create(System2.INSTANCE); | |||
public DbTester dbTester = DbTester.create(system2); | |||
@Rule | |||
public EsTester esTester = new EsTester(new UserIndexDefinition(settings)); | |||
@@ -86,7 +87,7 @@ public class ChangePasswordActionTest { | |||
groupDao.insert(session, GroupTesting.newGroupDto().setName("sonar-users")); | |||
session.commit(); | |||
UserIndexer userIndexer = new UserIndexer(dbClient, esTester.client()); | |||
UserIndexer userIndexer = new UserIndexer(system2, dbClient, esTester.client()); | |||
userUpdater = new UserUpdater(mock(NewUserNotifier.class), settings, dbClient, userIndexer, system2, defaultOrganizationProvider); | |||
tester = new WsTester(new UsersWs(new ChangePasswordAction(userUpdater, userSessionRule))); | |||
} |
@@ -58,9 +58,10 @@ public class CreateActionTest { | |||
private static final String DEFAULT_GROUP_NAME = "sonar-users"; | |||
private Settings settings = new MapSettings().setProperty("sonar.defaultGroup", DEFAULT_GROUP_NAME); | |||
private System2 system2 = new AlwaysIncreasingSystem2(); | |||
@Rule | |||
public DbTester db = DbTester.create(new AlwaysIncreasingSystem2()); | |||
public DbTester db = DbTester.create(system2); | |||
@Rule | |||
public EsTester esTester = new EsTester(new UserIndexDefinition(settings)); | |||
@Rule | |||
@@ -76,9 +77,8 @@ public class CreateActionTest { | |||
@Before | |||
public void setUp() { | |||
System2 system2 = new System2(); | |||
defaultGroupInDefaultOrg = db.users().insertGroup(db.getDefaultOrganization(), DEFAULT_GROUP_NAME); | |||
userIndexer = new UserIndexer(db.getDbClient(), esTester.client()); | |||
userIndexer = new UserIndexer(system2, db.getDbClient(), esTester.client()); | |||
index = new UserIndex(esTester.client()); | |||
DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db); | |||
tester = new WsTester(new UsersWs(new CreateAction(db.getDbClient(), |
@@ -55,10 +55,11 @@ import static org.sonar.db.user.UserTokenTesting.newUserToken; | |||
public class DeactivateActionTest { | |||
private System2 system2 = System2.INSTANCE; | |||
private Settings settings = new MapSettings(); | |||
@Rule | |||
public DbTester db = DbTester.create(System2.INSTANCE); | |||
public DbTester db = DbTester.create(system2); | |||
@Rule | |||
public EsTester esTester = new EsTester(new UserIndexDefinition(settings)); | |||
@@ -74,13 +75,12 @@ public class DeactivateActionTest { | |||
@Before | |||
public void setUp() { | |||
System2 system2 = new System2(); | |||
UserDao userDao = new UserDao(db.myBatis(), system2); | |||
dbClient = new DbClient(db.database(), db.myBatis(), userDao, new GroupMembershipDao(), new UserTokenDao()); | |||
dbSession = db.getSession(); | |||
dbSession.commit(); | |||
userIndexer = new UserIndexer(dbClient, esTester.client()); | |||
userIndexer = new UserIndexer(system2, dbClient, esTester.client()); | |||
index = new UserIndex(esTester.client()); | |||
DefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db); | |||
ws = new WsTester(new UsersWs(new DeactivateAction( |
@@ -53,6 +53,8 @@ import static org.sonar.test.JsonAssert.assertJson; | |||
public class SearchActionTest { | |||
private System2 system2 = System2.INSTANCE; | |||
@Rule | |||
public EsTester esTester = new EsTester(new UserIndexDefinition(new MapSettings())); | |||
@@ -60,12 +62,12 @@ public class SearchActionTest { | |||
public UserSessionRule userSession = UserSessionRule.standalone(); | |||
@Rule | |||
public DbTester db = DbTester.create(System2.INSTANCE); | |||
public DbTester db = DbTester.create(system2); | |||
private DbClient dbClient = db.getDbClient(); | |||
private DbSession dbSession = db.getSession(); | |||
private UserIndex index = new UserIndex(esTester.client()); | |||
private UserIndexer userIndexer = new UserIndexer(dbClient, esTester.client()); | |||
private UserIndexer userIndexer = new UserIndexer(system2, dbClient, esTester.client()); | |||
private WsTester ws = new WsTester(new UsersWs(new SearchAction(index, dbClient, new UserJsonWriter(userSession)))); | |||
@Test |
@@ -73,7 +73,7 @@ public class UpdateActionTest { | |||
dbClient.groupDao().insert(session, newGroupDto().setName("sonar-users")); | |||
session.commit(); | |||
userIndexer = new UserIndexer(dbClient, esTester.client()); | |||
userIndexer = new UserIndexer(system2, dbClient, esTester.client()); | |||
tester = new WsTester(new UsersWs(new UpdateAction( | |||
new UserUpdater(mock(NewUserNotifier.class), settings, dbClient, userIndexer, system2, defaultOrganizationProvider), userSessionRule, | |||
new UserJsonWriter(userSessionRule), dbClient))); |
@@ -19,7 +19,6 @@ | |||
*/ | |||
package org.sonar.server.view.index; | |||
import com.google.common.base.Function; | |||
import com.google.common.collect.Maps; | |||
import java.util.List; | |||
import java.util.Map; | |||
@@ -53,8 +52,10 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
public class ViewIndexerTest { | |||
private System2 system2 = System2.INSTANCE; | |||
@Rule | |||
public DbTester dbTester = DbTester.create(System2.INSTANCE); | |||
public DbTester dbTester = DbTester.create(system2); | |||
@Rule | |||
public EsTester esTester = new EsTester(new IssueIndexDefinition(new MapSettings()), new ViewIndexDefinition(new MapSettings())); | |||
@@ -64,7 +65,7 @@ public class ViewIndexerTest { | |||
private DbClient dbClient = dbTester.getDbClient(); | |||
private DbSession dbSession = dbTester.getSession(); | |||
private ViewIndexer indexer = (ViewIndexer) new ViewIndexer(dbClient, esTester.client()); | |||
private ViewIndexer indexer = (ViewIndexer) new ViewIndexer(system2, dbClient, esTester.client()); | |||
@Test | |||
public void index_nothing() { | |||
@@ -81,12 +82,7 @@ public class ViewIndexerTest { | |||
List<ViewDoc> docs = esTester.getDocuments("views", "view", ViewDoc.class); | |||
assertThat(docs).hasSize(4); | |||
Map<String, ViewDoc> viewsByUuid = Maps.uniqueIndex(docs, new Function<ViewDoc, String>() { | |||
@Override | |||
public String apply(ViewDoc doc) { | |||
return doc.uuid(); | |||
} | |||
}); | |||
Map<String, ViewDoc> viewsByUuid = Maps.uniqueIndex(docs, ViewDoc::uuid); | |||
assertThat(viewsByUuid.get("ABCD").projects()).containsOnly("JKLM"); | |||
assertThat(viewsByUuid.get("EFGH").projects()).containsOnly("KLMN", "JKLM"); | |||
@@ -116,12 +112,7 @@ public class ViewIndexerTest { | |||
List<ViewDoc> docs = esTester.getDocuments("views", "view", ViewDoc.class); | |||
assertThat(docs).hasSize(2); | |||
Map<String, ViewDoc> viewsByUuid = Maps.uniqueIndex(docs, new Function<ViewDoc, String>() { | |||
@Override | |||
public String apply(ViewDoc doc) { | |||
return doc.uuid(); | |||
} | |||
}); | |||
Map<String, ViewDoc> viewsByUuid = Maps.uniqueIndex(docs, ViewDoc::uuid); | |||
assertThat(viewsByUuid.get("EFGH").projects()).containsOnly("KLMN", "JKLM"); | |||
assertThat(viewsByUuid.get("FGHI").projects()).containsOnly("JKLM"); | |||
@@ -142,7 +133,7 @@ public class ViewIndexerTest { | |||
@Test | |||
public void clear_views_lookup_cache_on_index_view_uuid() { | |||
IssueIndex issueIndex = new IssueIndex(esTester.client(), System2.INSTANCE, userSessionRule); | |||
IssueIndexer issueIndexer = new IssueIndexer(dbClient, esTester.client()); | |||
IssueIndexer issueIndexer = new IssueIndexer(system2, dbClient, esTester.client()); | |||
PermissionIndexer permissionIndexer = new PermissionIndexer(dbClient, esTester.client()); | |||
String viewUuid = "ABCD"; |