@Override public boolean isChanged() { return details.isActiveByDefault() != activated; }
public boolean getDefaultActivation() { return details.isActiveByDefault(); }
private void getIncludedAndExcluded(Set<String> included, Set<String> excluded) { for (RuleDetails r : engine.getAllRuleDetails()) { boolean valueSet = currentActivationByRuleKey.get(r.getKey()); if (r.isActiveByDefault() && !valueSet) { excluded.add(r.getKey()); } else if (!r.isActiveByDefault() && valueSet) { included.add(r.getKey()); } } }
private static boolean loadRuleActivation(SonarLintGlobalSettings settings, RuleDetails ruleDetails) { if (settings.getIncludedRules().contains(ruleDetails.getKey())) { return true; } else if (settings.getExcludedRules().contains(ruleDetails.getKey())) { return false; } else { return ruleDetails.isActiveByDefault(); } }
@Before public void setUp() { when(ruleDetails.getType()).thenReturn("BUG"); when(ruleDetails.getSeverity()).thenReturn("MAJOR"); when(ruleDetails.getKey()).thenReturn("key"); when(ruleDetails.isActiveByDefault()).thenReturn(false); root.add(lang); lang.add(rule); // just to not give NPE when firing changes TreeTableTree treeTableTree = mock(TreeTableTree.class); TreeTable treeTable = mock(TreeTable.class); when(treeTableTree.getTreeTable()).thenReturn(treeTable); when(treeTable.getModel()).thenReturn(tableModel); model.setTree(treeTableTree); }
@Test public void getters_rule() { RuleDetails details = mock(RuleDetails.class); when(details.getName()).thenReturn("name"); when(details.getKey()).thenReturn("key"); when(details.getHtmlDescription()).thenReturn("html"); when(details.isActiveByDefault()).thenReturn(true); when(details.getSeverity()).thenReturn("severity"); when(details.getType()).thenReturn("type"); when(details.getLanguage()).thenReturn("lang"); RulesTreeNode.Rule node = new RulesTreeNode.Rule(details, false); assertThat(node.getKey()).isEqualTo("key"); assertThat(node.getName()).isEqualTo("name"); assertThat(node.toString()).isEqualTo("name"); assertThat(node.getHtmlDescription()).isEqualTo("html"); assertThat(node.getDefaultActivation()).isTrue(); assertThat(node.isChanged()).isTrue(); assertThat(node.severity()).isEqualTo("severity"); assertThat(node.type()).isEqualTo("type"); assertThat(node.language()).isEqualTo("lang"); }