import org.sonar.server.qualityprofile.QProfileOperations;
import org.sonar.server.qualityprofile.QProfileSearch;
import org.sonar.server.qualityprofile.QProfiles;
+import org.sonar.server.rule.ProfileRules;
import org.sonar.server.rule.RubyRuleService;
import org.sonar.server.rule.RuleRegistry;
import org.sonar.server.rules.ProfilesConsole;
servicesContainer.addSingleton(Periods.class);
// quality profiles
+ servicesContainer.addSingleton(ProfileRules.class);
servicesContainer.addSingleton(QProfiles.class);
servicesContainer.addSingleton(QProfileSearch.class);
servicesContainer.addSingleton(QProfileOperations.class);
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.collect.Maps;
-import org.sonar.api.rules.RulePriority;
+import org.joda.time.format.ISODateTimeFormat;
+import org.sonar.api.rules.ActiveRule;
+import org.sonar.check.Cardinality;
+import java.util.Date;
import java.util.List;
import java.util.Map;
private final Map<String, Object> ruleSource;
private final Map<String, Object> activeRuleSource;
+ private final Integer id;
private final String key;
+ private final String repositoryKey;
private final String name;
private final String description;
private final String status;
-
- private final RulePriority severity;
+ private final String cardinality;
+ private final String parentKey;
+ private final Date createdAt;
+ private final Date updatedAt;
+
+ private final int activeRuleId;
+ private final String severity;
+ private final String inheritance;
private final List<Param> params;
public QProfileRule(Map<String, Object> ruleSource, Map<String, Object> activeRuleSource) {
this.ruleSource = ruleSource;
this.activeRuleSource = activeRuleSource;
+ id = (Integer) ruleSource.get("id");
key = (String) ruleSource.get("key");
+ repositoryKey = (String) ruleSource.get("repositoryKey");
name = (String) ruleSource.get("name");
description = (String) ruleSource.get("description");
status = (String) ruleSource.get("status");
-
- severity = RulePriority.valueOf((String) activeRuleSource.get("severity"));
+ cardinality = (String) ruleSource.get("cardinality");
+ parentKey = (String) ruleSource.get("parentKey");
+ createdAt = parseOptionalDate("createdAt", ruleSource);
+ updatedAt = parseOptionalDate("updatedAt", ruleSource);
+
+ activeRuleId = (Integer) activeRuleSource.get("id");
+ severity = (String) activeRuleSource.get("severity");
+ inheritance = (String) activeRuleSource.get("inheritance");
params = Lists.newArrayList();
if (ruleSource.containsKey("params")) {
Map<String, Map<String, Object>> ruleParams = Maps.newHashMap();
ruleParams.put((String) ruleParam.get("key"), ruleParam);
}
Map<String, Map<String, Object>> activeRuleParams = Maps.newHashMap();
- for (Map<String, Object> activeRuleParam: (List<Map<String, Object>>) activeRuleSource.get("params")) {
- activeRuleParams.put((String) activeRuleParam.get("key"), activeRuleParam);
+ if (activeRuleSource.containsKey("params")) {
+ for (Map<String, Object> activeRuleParam: (List<Map<String, Object>>) activeRuleSource.get("params")) {
+ activeRuleParams.put((String) activeRuleParam.get("key"), activeRuleParam);
+ }
}
for(Map.Entry<String, Map<String, Object>> ruleParam: ruleParams.entrySet()) {
params.add(new Param(
}
}
+ protected Date parseOptionalDate(String field, Map<String, Object> ruleSource) {
+ String dateValue = (String) ruleSource.get(field);
+ if (dateValue == null) {
+ return null;
+ } else {
+ return ISODateTimeFormat.dateOptionalTimeParser().parseDateTime(dateValue).toDate();
+ }
+ }
+
public Map<String, Object> ruleSource() {
return ruleSource;
}
return activeRuleSource;
}
+ public int id() {
+ return id;
+ }
+
+ public int activeRuleId() {
+ return activeRuleId;
+ }
+
public String key() {
return key;
}
+ public String repositoryKey() {
+ return repositoryKey;
+ }
+
public String name() {
return name;
}
return status;
}
- public RulePriority severity() {
+ public Date createdAt() {
+ return createdAt;
+ }
+
+ public Date updatedAt() {
+ return updatedAt;
+ }
+
+ public String severity() {
return severity;
}
+ public String inheritance() {
+ return inheritance;
+ }
+
+ public boolean isInherited() {
+ return ActiveRule.INHERITED.equals(inheritance);
+ }
+
+ public boolean isOverrides() {
+ return ActiveRule.OVERRIDES.equals(inheritance);
+ }
+
+ public boolean isTemplate() {
+ return Cardinality.MULTIPLE.toString().equals(cardinality);
+ }
+
+ public boolean isEditable() {
+ return parentKey != null;
+ }
+
public List<Param> params() {
return params;
}
+ public String note() {
+ return null;
+ }
+
class Param {
private final String key;
private final String value;
return rules.searchActiveRules(query, paging);
}
- public void searchInactiveRules(Integer profileId) {
+ public long countActiveRules(ProfileRuleQuery query) {
+ return rules.countActiveRules(query);
+ }
+
+ public void searchInactiveRules(ProfileRuleQuery query, Paging paging) {
throw new UnsupportedOperationException();
}
+ public long countInactiveRules(ProfileRuleQuery query) {
+ return rules.countInactiveRules(query);
+ }
+
public void activeRule(Integer profileId, RuleKey ruleKey) {
throw new UnsupportedOperationException();
}
import com.google.common.collect.Lists;
import org.apache.commons.lang.StringUtils;
import org.sonar.server.exceptions.BadRequestException;
+import org.sonar.server.util.RubyUtils;
import javax.annotation.CheckForNull;
ProfileRuleQuery result = new ProfileRuleQuery();
try {
- result.profileId = Integer.parseInt((String) params.get("profileId"));
+ result.profileId = RubyUtils.toInteger(params.get("profileId"));
} catch (Exception badProfileId) {
validationException.addError("profileId could not be parsed");
}
+
+ if (params.containsKey("nameOrKey")) {
+ result.setNameOrKey((String) params.get("nameOrKey"));
+ }
+ if (params.get("repositoryKeys") != null) {
+ for (Object param: (Object[]) params.get("repositoryKeys")) {
+ if (! "".equals(param)) {
+ result.addRepositoryKeys((String) param);
+ }
+ }
+ }
+ if (params.get("severities") != null) {
+ for (Object param: (Object[]) params.get("severities")) {
+ if (! "".equals(param)) {
+ result.addSeverities((String) param);
+ }
+ }
+ }
+ if (params.get("statuses") != null) {
+ for (Object param: (Object[]) params.get("statuses")) {
+ if (! "".equals(param)) {
+ result.addStatuses((String) param);
+ }
+ }
+ }
+
validationException.checkMessages();
return result;
return !(
StringUtils.isEmpty(nameOrKey)
&& repositoryKeys.isEmpty()
- && severities.isEmpty()
&& statuses.isEmpty()
);
}
import org.elasticsearch.action.get.MultiGetItemResponse;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.common.collect.Lists;
-import org.elasticsearch.index.query.BoolFilterBuilder;
-import org.elasticsearch.index.query.FilterBuilder;
-import org.elasticsearch.index.query.FilterBuilders;
+import org.elasticsearch.index.query.*;
import org.elasticsearch.index.query.MatchQueryBuilder.Operator;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
+import org.sonar.api.ServerExtension;
import org.sonar.server.qualityprofile.Paging;
import org.sonar.server.qualityprofile.PagingResult;
import org.sonar.server.qualityprofile.QProfileRule;
import static org.sonar.server.rule.RuleRegistry.TYPE_ACTIVE_RULE;
import static org.sonar.server.rule.RuleRegistry.TYPE_RULE;
-public class ProfileRules {
+public class ProfileRules implements ServerExtension {
private static final String FIELD_PARENT = "_parent";
private static final String FIELD_SOURCE = "_source";
}
public QProfileRuleResult searchActiveRules(ProfileRuleQuery query, Paging paging) {
- BoolFilterBuilder filter = boolFilter().must(
- termFilter("profileId", query.profileId()),
- hasParentFilter(TYPE_RULE, parentRuleFilter(query))
- );
- addMustTermOrTerms(filter, "severity", query.severities());
+ BoolFilterBuilder filter = activeRuleFilter(query);
SearchRequestBuilder builder = index.client().prepareSearch(INDEX_RULES).setTypes(TYPE_ACTIVE_RULE)
.setFilter(filter)
return new QProfileRuleResult(result, PagingResult.create(paging.pageSize(), paging.pageIndex(), hits.getTotalHits()));
}
+ protected BoolFilterBuilder activeRuleFilter(ProfileRuleQuery query) {
+ BoolFilterBuilder filter = boolFilter().must(
+ termFilter("profileId", query.profileId()),
+ hasParentFilter(TYPE_RULE, parentRuleFilter(query))
+ );
+ addMustTermOrTerms(filter, "severity", query.severities());
+ return filter;
+ }
+
+ public long countActiveRules(ProfileRuleQuery query) {
+ return index.executeCount(index.client().prepareCount(INDEX_RULES).setTypes(TYPE_ACTIVE_RULE)
+ .setQuery(QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(), activeRuleFilter(query))));
+ }
+
+ public long countInactiveRules(ProfileRuleQuery query) {
+ return index.executeCount(index.client().prepareCount(INDEX_RULES).setTypes(TYPE_RULE)
+ .setQuery(QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(),
+ boolFilter()
+ .must(parentRuleFilter(query))
+ .mustNot(hasChildFilter(TYPE_ACTIVE_RULE, termFilter("profileId", query.profileId()))))));
+ }
+
private FilterBuilder parentRuleFilter(ProfileRuleQuery query) {
if (! query.hasParentRuleCriteria()) {
return FilterBuilders.matchAllFilter();
import org.elasticsearch.action.bulk.BulkItemResponse;
import org.elasticsearch.action.bulk.BulkRequestBuilder;
import org.elasticsearch.action.bulk.BulkResponse;
+import org.elasticsearch.action.count.CountRequestBuilder;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
}
}
+ public long executeCount(CountRequestBuilder builder) {
+ StopWatch watch = createWatch();
+ try {
+ return builder.execute().actionGet().getCount();
+ } finally {
+ watch.stop("Request executed: %s", builder.toString());
+ }
+ }
+
private String builderToString(SearchRequestBuilder builder) {
try {
return builder.internalBuilder().toXContent(XContentFactory.jsonBuilder(), ToXContent.EMPTY_PARAMS)
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
require 'cgi'
+require 'java'
class NewRulesConfigurationController < ApplicationController
@select_repositories = ANY_SELECTION + java_facade.getRuleRepositoriesByLanguage(@profile.language).collect { |repo| [repo.getName(true), repo.getKey()] }.sort
@select_priority = ANY_SELECTION + RULE_PRIORITIES
- @select_activation = [[message('any'), 'any'], [message('active'), STATUS_ACTIVE], [message('inactive'), STATUS_INACTIVE]]
+ @select_activation = [[message('active'), STATUS_ACTIVE], [message('inactive'), STATUS_INACTIVE]]
@select_inheritance = [[message('any'), 'any'], [message('rules_configuration.not_inherited'), 'NOT'], [message('rules_configuration.inherited'), 'INHERITED'],
[message('rules_configuration.overrides'), 'OVERRIDES']]
@select_status = ANY_SELECTION + [[message('rules.status.beta'), Rule::STATUS_BETA],
stop_watch = Internal.profiling.start("rules", "BASIC")
criteria = {
- :profile => @profile, :activation => @activation, :priorities => @priorities, :inheritance => @inheritance, :status => @status,
- :repositories => @repositories, :searchtext => @searchtext, :include_parameters_and_notes => true, :language => @profile.language, :sort_by => @sort_by}
- @rules = Rule.search(java_facade, criteria)
+ "profileId" => @profile.id.to_i, "activation" => @activation, "severities" => @priorities.to_java, "inheritance" => @inheritance, "statuses" => @status.to_java,
+ "repositoryKeys" => @repositories.to_java, "nameOrKey" => @searchtext, "include_parameters_and_notes" => true, "language" => @profile.language, "sort_by" => @sort_by}
+
+ @rules = []
+ @pagination = Api::Pagination.new(params)
+
+ call_java do
+ query = Java::OrgSonarServerRule::ProfileRuleQuery::parse(criteria.to_java)
+ paging = Java::OrgSonarServerQualityprofile::Paging.create(@pagination.per_page.to_i, @pagination.page.to_i)
- unless @searchtext.blank?
if @activation==STATUS_ACTIVE
- @hidden_inactives = Rule.search(java_facade, {
- :profile => @profile, :activation => STATUS_INACTIVE, :priorities => @priorities, :status => @status,
- :repositories => @repositories, :language => @profile.language, :searchtext => @searchtext, :include_parameters_and_notes => false}).size
-
- elsif @activation==STATUS_INACTIVE
- @hidden_actives = Rule.search(java_facade, {
- :profile => @profile, :activation => STATUS_ACTIVE, :priorities => @priorities, :status => @status,
- :repositories => @repositories, :language => @profile.language, :searchtext => @searchtext, :include_parameters_and_notes => false}).size
+ result = Internal.qprofiles.searchActiveRules(query, paging)
+ else
+ result = Internal.qprofiles.searchInactiveRules(query, paging)
+ end
+
+ @rules = result.rules
+ @pagination.count = result.paging.total
+
+ unless @searchtext.blank?
+ if @activation==STATUS_ACTIVE
+ @hidden_inactives = Internal.qprofiles.countInactiveRules(query)
+ else
+ @hidden_actives = Internal.qprofiles.countInactiveRules(query)
+ end
end
end
rescue
@rules = []
end
- @pagination = Api::Pagination.new(params)
- @pagination.count = @rules.size
- @current_rules = @rules[@pagination.offset, @pagination.limit]
+
+ @current_rules = @rules
end
<% #locals = active_rule, profile
- note = active_rule.note
- active_note_detail_div_id = "and_" + active_rule.id.to_s
- add_active_note_button_id = "aanb_" + active_rule.id.to_s
- edit_active_note_link_id = "eanl_" + active_rule.id.to_s
- delete_active_note_link_id = "danl_" + active_rule.id.to_s
- active_note_form_div_id = "anf_" + active_rule.id.to_s
- active_note_textarea_id = "ant_" + active_rule.id.to_s
- submit_active_note_update_button_id = "sanub_" + active_rule.id.to_s
+ note = rule.note
+ active_note_detail_div_id = "and_" + rule.activeRuleId.to_s
+ add_active_note_button_id = "aanb_" + rule.activeRuleId.to_s
+ edit_active_note_link_id = "eanl_" + rule.activeRuleId.to_s
+ delete_active_note_link_id = "danl_" + rule.activeRuleId.to_s
+ active_note_form_div_id = "anf_" + rule.activeRuleId.to_s
+ active_note_textarea_id = "ant_" + rule.activeRuleId.to_s
+ submit_active_note_update_button_id = "sanub_" + rule.activeRuleId.to_s
%>
<div id="<%= active_note_detail_div_id -%>">
<a class="link-action"
onclick="if(confirm('<%= escape_javascript(message('rules_configuration.confirm_delete_note')) -%>')){
$j.ajax({
- url: '<%=ApplicationController.root_context-%>/new_rules_configuration/delete_active_rule_note?active_rule_id=<%=active_rule.id-%>',
+ url: '<%=ApplicationController.root_context-%>/new_rules_configuration/delete_active_rule_note?active_rule_id=<%=rule.activeRuleId-%>',
type: 'post',
- success:function(response){$j('#active_rule_note_<%= active_rule.id -%>').html(response);}
+ success:function(response){$j('#active_rule_note_<%= rule.activeRuleId -%>').html(response);}
});};return false;"
href="#!"><%=message('delete')-%></a>
<% end %>
<% if profiles_administrator? %>
<form onsubmit="$j.ajax({
- url:'<%= ApplicationController.root_context -%>/new_rules_configuration/update_active_rule_note?active_rule_id=<%=active_rule.id-%>',
+ url:'<%= ApplicationController.root_context -%>/new_rules_configuration/update_active_rule_note?active_rule_id=<%=rule.activeRuleId-%>',
data: $j(this).serialize(),
type:'post',
- success:function(response){$j('#active_rule_note_<%= active_rule.id -%>').html(response);}
+ success:function(response){$j('#active_rule_note_<%= rule.activeRuleId -%>').html(response);}
});
return false;"
method="post"
- action="<%= ApplicationController.root_context -%>/new_rules_configuration//update_active_rule_note?active_rule_id=<%=active_rule.id-%>">
+ action="<%= ApplicationController.root_context -%>/new_rules_configuration//update_active_rule_note?active_rule_id=<%=rule.activeRuleId-%>">
<table id="<%= active_note_form_div_id -%>" style="display: none" class="admin table width100">
<tbody>
<tr>
-<td nowrap valign="top" class="left" x="<%= active_rule.failure_level if active_rule -%>" width="1%">
+<td nowrap valign="top" class="left" x="<%= rule.severity -%>" width="1%">
<form id="levels_<%= rule.id -%>" action="" class="rule-levels-form">
<% enable_modification = profiles_administrator?
select_box_id = "levels_select_#{rule.id}"
data:'level='+$j('#levels_select_#{rule.id} :selected').val()})}"
%>
- <%= check_box_tag(check_box_id, 'yes', (!active_rule.nil?), :onclick => activate_rule, :disabled => !enable_modification || (active_rule && (active_rule.inherited? || active_rule.overrides?))) %>
- <%= select_tag(select_box_id, options_for_select(RulesConfigurationController::RULE_PRIORITIES, (active_rule.nil? ? rule.priority_text : active_rule.priority_text)),
- {:onchange => changel_level, :disabled => (!(enable_modification) || active_rule.nil?)}) %>
+ <%= check_box_tag(check_box_id, 'yes', true, :onclick => activate_rule, :disabled => !enable_modification || rule.inherited? || rule.overrides?) %>
+ <%= select_tag(select_box_id, options_for_select(RulesConfigurationController::RULE_PRIORITIES, rule.severity),
+ {:onchange => changel_level, :disabled => (!(enable_modification))}) %>
- <% if active_rule %>
- <% if active_rule.inherited? %>
- <img src="<%= ApplicationController.root_context -%>/images/inherited.png" alt="Inherited from parent" title="<%= message('rules_configuration.inherited_from_parent') -%>"/>
- <% elsif active_rule.overrides? %>
- <img src="<%= ApplicationController.root_context -%>/images/overrides.png" alt="Overrides parent definition" title="<%= message('rules_configuration.overrides_parent_definition') -%>"/>
- <% end %>
+ <% if rule.inherited? %>
+ <img src="<%= ApplicationController.root_context -%>/images/inherited.png" alt="Inherited from parent" title="<%= message('rules_configuration.inherited_from_parent') -%>"/>
+ <% elsif rule.overrides? %>
+ <img src="<%= ApplicationController.root_context -%>/images/overrides.png" alt="Overrides parent definition" title="<%= message('rules_configuration.overrides_parent_definition') -%>"/>
<% end %>
</form>
</td>
<td class="left" colspan="2">
- <% unless rule.ready? %>
+ <% unless rule.status != "READY" %>
<div class="rule-status">
- <% if rule.beta? %>
+ <% if rule.status == "BETA" %>
<span><%= message('rules.status.beta') %></span>
- <% elsif rule.deprecated? %>
+ <% elsif rule.status == "DEPRECATED" %>
<span><%= message('rules.status.deprecated') %></span>
<% end %>
</div>
<%
ancestor_profile = profile.parent
- ancestor_active_rule = ancestor_profile.active_by_rule_id(rule.id) if ancestor_profile && active_rule && (active_rule.inherited? || active_rule.overrides?)
- if ancestor_active_rule || !rule.parameters.empty?
+ ancestor_active_rule = ancestor_profile.active_by_rule_id(rule.id) if ancestor_profile && (rule.inherited? || rule.overrides?)
+ if ancestor_active_rule || !rule.params.empty?
%>
<table width="100%" class="table spacer-bottom bordered background-gray">
<%
%>
<tr>
<td colspan="2">
- <%= message(active_rule.inherited? ? 'rules_configuration.rule_inherited_from_profile_x' : 'rules_configuration.rule_overriding_from_profile_x',
+ <%= message(rule.inherited? ? 'rules_configuration.rule_inherited_from_profile_x' : 'rules_configuration.rule_overriding_from_profile_x',
:params => ancestor_active_rule_link) -%>
- <% if ancestor_active_rule.priority != active_rule.priority %>
+ <% if ancestor_active_rule.priority != rule.severity %>
<img src="<%= ApplicationController.root_context -%>/images/overrides.png" alt="Overrides parent definition" title="<%= message('rules_configuration.overrides_parent_definition') -%>" style="vertical-align: middle"/>
<span class="form-val-note" style="font-weight: bold"> <%= message('rules_configuration.original_severity') -%>
: <%= ancestor_active_rule.priority_text -%></span>
<% end %>
- <% if profiles_administrator? && active_rule.overrides? %>
- <form action="<%= url_for :overwrite_params => {:action => 'revert_rule', :id => profile.id, :active_rule_id => active_rule.id} -%>" method="post" style="display: inline">
+ <% if profiles_administrator? && rule.overrides? %>
+ <form action="<%= url_for :overwrite_params => {:action => 'revert_rule', :id => profile.id, :active_rule_id => rule.activeRuleId} -%>" method="post" style="display: inline">
<input type="submit" value="<%= message('rules_configuration.revert_to_parent_definition') -%>">
</form>
<% end %>
</td>
</tr>
<% end %>
- <% rule.parameters.sort.each do |parameter|
- active_parameter = active_rule.active_param_by_param_id(parameter.id) if active_rule
- %>
+ <% rule.params.each do |parameter| %>
+ <%
+=begin %>
<tr id="param_<%= parameter.id -%>">
<%= render :partial => 'rule_param', :object => nil,
- :locals => {:parameter => parameter, :active_parameter => active_parameter, :profile => profile, :rule => rule,
- :active_rule => active_rule, :ancestor_active_rule => ancestor_active_rule} %>
+ :locals => {:parameter => parameter, :profile => profile, :rule => rule, :ancestor_active_rule => ancestor_active_rule} %>
</tr>
+ <%
+=end %>
<%
end
%>
</table>
<% end %>
- <% if active_rule %>
- <div id="active_rule_note_<%= active_rule.id -%>">
- <%= render :partial => 'active_rule_note', :locals => {:active_rule => active_rule, :profile => profile} %>
- </div>
- <% end %>
+ <div id="active_rule_note_<%= rule.activeRuleId -%>">
+ <%= render :partial => 'active_rule_note', :locals => {:rule => rule, :profile => profile} %>
+ </div>
<% if profiles_administrator? %>
<% if rule.template? %>
<% end %>
<div class="note">
- <span id="rule_repository_<%= rule.id -%>"><%= message('rules_configuration.repository') %>: <%= rule.repository_key %></span>
+ <span id="rule_repository_<%= rule.id -%>"><%= message('rules_configuration.repository') %>: <%= rule.repositoryKey %></span>
<%= image_tag 'sep12.png' -%>
- <span id="rule_key_<%= rule.id -%>"><%= message('key') %>: <%= rule.plugin_rule_key %></span>
+ <span id="rule_key_<%= rule.id -%>"><%= message('key') %>: <%= rule.key %></span>
<%= image_tag 'sep12.png' -%>
- <% if rule.removed? %>
- <span id="rule_available_since_<%= rule.id -%>"><%= message('rules_configuration.removed_since') %>: <%= human_short_date(rule.updated_at) %></span>
+ <% if rule.status == "REMOVED" %>
+ <span id="rule_available_since_<%= rule.id -%>"><%= message('rules_configuration.removed_since') %>: <%= human_short_date(Time.at(rule.updatedAt.getTime/1000)) %></span>
<% else %>
- <span id="rule_available_since_<%= rule.id -%>"><%= message('rules_configuration.available_since') %> <%= human_short_date(rule.created_at) %></span>
+ <span id="rule_available_since_<%= rule.id -%>"><%= message('rules_configuration.available_since') %> <%= human_short_date(Time.at(rule.createdAt.getTime/1000)) %></span>
<% end %>
</div>
</div>
<% end %>
<%
@current_rules.each do |rule|
- active_rule = @profile.active_by_rule_id(rule.id)
%>
<tr id="rule_<%= rule.id -%>">
- <%= render :partial => 'rule', :object => rule, :locals => {:profile => @profile, :rule => rule, :active_rule => active_rule} %>
+ <%= render :partial => 'rule', :object => rule, :locals => {:profile => @profile, :rule => rule} %>
</tr>
<% end %>
</tbody>
@Test(expected = UnsupportedOperationException.class)
public void testSearchInactiveRules() throws Exception {
- qProfiles.searchInactiveRules(null);
+ final int profileId = 42;
+ ProfileRuleQuery query = ProfileRuleQuery.create(profileId );
+ Paging paging = Paging.create(20, 1);
+ qProfiles.searchInactiveRules(query, paging);
}
@Test(expected = UnsupportedOperationException.class)
List<QProfileRule> rules1 = profileRules.searchActiveRules(ProfileRuleQuery.create(1), paging).rules();
assertThat(rules1).hasSize(3);
assertThat(rules1.get(0).key()).isEqualTo("DM_CONVERT_CASE");
- assertThat(rules1.get(0).severity()).isEqualTo(RulePriority.MINOR);
+ assertThat(rules1.get(0).severity()).isEqualTo(RulePriority.MINOR.toString());
// All rules for profile 2
List<QProfileRule> rules2 = profileRules.searchActiveRules(ProfileRuleQuery.create(2), paging).rules();