assertThat(db.activeRuleDao().findByProfileKey(session, profile.getKey())).isEmpty();
}
@Test
public void bulk_deactivate_rule() throws Exception {
QualityProfileDto profile = createProfile("java");
RuleDto rule0 = createRule(profile.getLanguage(), "toto1");
RuleDto rule1 = createRule(profile.getLanguage(), "toto2");
RuleDto rule2 = createRule(profile.getLanguage(), "toto3");
RuleDto rule3 = createRule(profile.getLanguage(), "toto4");
createActiveRule(rule0, profile);
createActiveRule(rule2, profile);
createActiveRule(rule3, profile);
createActiveRule(rule1, profile);
session.commit();
// 0. Assert No Active Rule for profile
assertThat(db.activeRuleDao().findByProfileKey(session, profile.getKey())).hasSize(4);
// 1. Deactivate Rule
WsTester.TestRequest request = wsTester.newGetRequest(QProfilesWs.API_ENDPOINT, BulkRuleActivationActions.BULK_DEACTIVATE_ACTION);
request.setParam(RuleActivationActions.PROFILE_KEY, profile.getKey().toString());
WsTester.Result result = request.execute();
session.clearCache();
// 2. Assert ActiveRule in DAO
assertThat(db.activeRuleDao().findByProfileKey(session, profile.getKey())).isEmpty();
}