private final ProfileImporter[] importers;
private final UserSession userSession;
+ private final ActiveRuleIndexer activeRuleIndexer;
+
public CreateAction(DbClient dbClient, QProfileFactory profileFactory, QProfileExporters exporters,
- Languages languages, ProfileImporter[] importers, UserSession userSession) {
+ Languages languages, ProfileImporter[] importers, UserSession userSession, ActiveRuleIndexer activeRuleIndexer) {
this.dbClient = dbClient;
this.profileFactory = profileFactory;
this.exporters = exporters;
this.languages = languages;
this.importers = importers;
this.userSession = userSession;
+ this.activeRuleIndexer = activeRuleIndexer;
}
- public CreateAction(DbClient dbClient, QProfileFactory profileFactory, QProfileExporters exporters, Languages languages, UserSession userSession) {
- this(dbClient, profileFactory, exporters, languages, new ProfileImporter[0], userSession);
+ public CreateAction(DbClient dbClient, QProfileFactory profileFactory, QProfileExporters exporters, Languages languages, UserSession userSession,
+ ActiveRuleIndexer activeRuleIndexer) {
+ this(dbClient, profileFactory, exporters, languages, new ProfileImporter[0], userSession, activeRuleIndexer);
}
@Override
}
}
dbSession.commit();
+ activeRuleIndexer.index(result.getChanges());
return buildResponse(result);
}
import org.sonar.server.rule.index.RuleIndex;
import org.sonar.server.rule.index.RuleIndexDefinition;
import org.sonar.server.rule.index.RuleIndexer;
+import org.sonar.server.rule.index.RuleQuery;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.TestResponse;
new RuleActivator(mock(System2.class), dbClient, ruleIndex, new RuleActivatorContextFactory(dbClient), null, activeRuleIndexer, userSession),
profileImporters);
- CreateAction underTest = new CreateAction(dbClient, new QProfileFactory(dbClient), qProfileExporters, newLanguages(XOO_LANGUAGE), profileImporters, userSession);
+ CreateAction underTest = new CreateAction(dbClient, new QProfileFactory(dbClient), qProfileExporters, newLanguages(XOO_LANGUAGE), profileImporters, userSession, activeRuleIndexer);
WsActionTester wsTester = new WsActionTester(underTest);
@Test
QualityProfileDto dto = dbClient.qualityProfileDao().selectByNameAndLanguage("New Profile", XOO_LANGUAGE, dbSession);
assertThat(dto.getKey()).isNotNull();
assertThat(dbClient.activeRuleDao().selectByProfileKey(dbSession, dto.getKey())).hasSize(1);
- // FIXME
- // assertThat(ruleIndex.searchAll(new RuleQuery().setQProfileKey(profile.getKey()).setActivation(true))).hasSize(1);
+ assertThat(ruleIndex.searchAll(new RuleQuery().setQProfileKey(dto.getKey()).setActivation(true))).hasSize(1);
}
@Test
new BulkRuleActivationActions(profileService, null, i18n, userSessionRule),
new AddProjectAction(projectAssociationParameters, null, null, null),
new RemoveProjectAction(projectAssociationParameters, null, null, null),
- new CreateAction(null, null, null, languages, importers, userSessionRule),
+ new CreateAction(null, null, null, languages, importers, userSessionRule, null),
new ImportersAction(importers),
new RestoreBuiltInAction(null, languages),
new SearchAction(null, languages),