RESOURCES_SECTION_KEY, HOW_TO_FIX_SECTION_KEY};
private static final String IGNORED_FAKE_SECTION = "fake_section_to_be_ignored";
- public static final String[] CONTEXTS = {"spring", "hibernate", "apache-commons", "vaadin", "mybatis"};
+ public static final String[] CONTEXTS = {"spring", "hibernate", "apache_commons", "vaadin", "mybatis"};
private static final String HTML_LOREM_IPSUM = "<a href=\"https://google.com\">Lorem</a> ipsum dolor sit amet, consectetur adipiscing " +
"elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco " +
*/
public class XooRulesDefinition implements RulesDefinition {
- public static final String[] AVAILABLE_CONTEXTS = {"JavaScript", "JQuery", "Express.js", "React", "Axios"};
+ public static final String[] AVAILABLE_CONTEXTS = {"javascript", "jquery", "express_js", "react", "axios"};
public static final String XOO_REPOSITORY = "xoo";
public static final String XOO2_REPOSITORY = "xoo2";
NewRule hasTag = repo.createRule(HasTagSensor.RULE_KEY).setName("Has Tag")
.setActivatedByDefault(true)
- .addDescriptionSection(howToFixSectionWithContext("singleContext"));
+ .addDescriptionSection(howToFixSectionWithContext("single_context"));
addDescriptionSectionsWithoutContexts(hasTag, "Search for a given tag in Xoo files");
hasTag
.setName("Find security hotspots, how_to_fix with single context")
.setType(RuleType.SECURITY_HOTSPOT)
.setActivatedByDefault(false)
- .addDescriptionSection(howToFixSectionWithContext("singleContext"));
+ .addDescriptionSection(howToFixSectionWithContext("single_context"));
addDescriptionSectionsWithoutContexts(hotspotWithSingleContext, "Search for Security Hotspots with single context in Xoo files");
repo.done();
private static final RuleDescriptionSection SECTION_1 = new RuleDescriptionSectionBuilder().sectionKey(HOW_TO_FIX_SECTION_KEY).htmlContent(HTML_CONTENT).build();
private static final RuleDescriptionSection SECTION_2 = new RuleDescriptionSectionBuilder().sectionKey(ROOT_CAUSE_SECTION_KEY).htmlContent(HTML_CONTENT + "2").build();
- private static final Context CONTEXT_1 = new Context("CTX_1", "ctx 1 display name");
+ private static final Context CONTEXT_1 = new Context("ctx_1", "ctx 1 display name");
private static final RuleDescriptionSection SECTION_3_WITH_CTX_1 = new RuleDescriptionSectionBuilder()
.sectionKey(RESOURCES_SECTION_KEY)
.htmlContent(HTML_CONTENT)
.context(CONTEXT_1)
.build();
- private static final Context CONTEXT_2 = new Context("CTX_2", "ctx 2 display name");
+ private static final Context CONTEXT_2 = new Context("ctx_2", "ctx 2 display name");
private static final RuleDescriptionSection SECTION_3_WITH_CTX_2 = new RuleDescriptionSectionBuilder()
.sectionKey(RESOURCES_SECTION_KEY)
.htmlContent(HTML_CONTENT + "2")
public void update_several_rule_descriptions() {
system.setNow(DATE1.getTime());
- RuleDescriptionSection section1context1 = createRuleDescriptionSection(HOW_TO_FIX_SECTION_KEY, "section1 ctx1 content", "CTX_1");
- RuleDescriptionSection section1context2 = createRuleDescriptionSection(HOW_TO_FIX_SECTION_KEY, "section1 ctx2 content", "CTX_2");
- RuleDescriptionSection section2context1 = createRuleDescriptionSection(RESOURCES_SECTION_KEY, "section2 content", "CTX_1");
- RuleDescriptionSection section2context2 = createRuleDescriptionSection(RESOURCES_SECTION_KEY,"section2 ctx2 content", "CTX_2");
+ RuleDescriptionSection section1context1 = createRuleDescriptionSection(HOW_TO_FIX_SECTION_KEY, "section1 ctx1 content", "ctx_1");
+ RuleDescriptionSection section1context2 = createRuleDescriptionSection(HOW_TO_FIX_SECTION_KEY, "section1 ctx2 content", "ctx_2");
+ RuleDescriptionSection section2context1 = createRuleDescriptionSection(RESOURCES_SECTION_KEY, "section2 content", "ctx_1");
+ RuleDescriptionSection section2context2 = createRuleDescriptionSection(RESOURCES_SECTION_KEY,"section2 ctx2 content", "ctx_2");
RuleDescriptionSection section3noContext = createRuleDescriptionSection(ASSESS_THE_PROBLEM_SECTION_KEY, "section3 content", null);
RuleDescriptionSection section4noContext = createRuleDescriptionSection(ROOT_CAUSE_SECTION_KEY, "section4 content", null);
execute(context -> {
repo.done();
});
- RuleDescriptionSection section1context2updated = createRuleDescriptionSection(HOW_TO_FIX_SECTION_KEY, "section1 ctx2 updated content", "CTX_2");
+ RuleDescriptionSection section1context2updated = createRuleDescriptionSection(HOW_TO_FIX_SECTION_KEY, "section1 ctx2 updated content", "ctx_2");
RuleDescriptionSection section2updatedWithoutContext = createRuleDescriptionSection(RESOURCES_SECTION_KEY, section2context1.getHtmlContent(), null);
- RuleDescriptionSection section4updatedWithContext1 = createRuleDescriptionSection(ROOT_CAUSE_SECTION_KEY, section4noContext.getHtmlContent(), "CTX_1");
- RuleDescriptionSection section4updatedWithContext2 = createRuleDescriptionSection(ROOT_CAUSE_SECTION_KEY, section4noContext.getHtmlContent(), "CTX_2");
+ RuleDescriptionSection section4updatedWithContext1 = createRuleDescriptionSection(ROOT_CAUSE_SECTION_KEY, section4noContext.getHtmlContent(), "ctx_1");
+ RuleDescriptionSection section4updatedWithContext2 = createRuleDescriptionSection(ROOT_CAUSE_SECTION_KEY, section4noContext.getHtmlContent(), "ctx_2");
system.setNow(DATE2.getTime());
execute(context -> {
NewRepository repo = context.createRepository("fake", "java");
@RunWith(Parameterized.class)
public class RuleDescriptionSectionsGeneratorsTest {
- private static final String KEY_1 = "KEY";
- private static final String KEY_2 = "KEY_2";
+ private static final String KEY_1 = "key";
+ private static final String KEY_2 = "key_2";
private static final String UUID_1 = "uuid1";
private static final String UUID_2 = "uuid2";
underTest.execute(properties, context);
})
.isInstanceOf(IllegalArgumentException.class)
- .hasMessage("Entry 'th ag' is invalid. Rule tags accept only the characters: a-z, 0-9, '+', '-', '#', '.'");
+ .hasMessage("Entry 'th ag' is invalid. For Rule tags the entry has to match the regexp ^[a-z0-9\\+#\\-\\.]+$");
}
}
action.execute(properties, context);
})
.isInstanceOf(IllegalArgumentException.class)
- .hasMessage("Entry 'th ag' is invalid. Rule tags accept only the characters: a-z, 0-9, '+', '-', '#', '.'");
+ .hasMessage("Entry 'th ag' is invalid. For Rule tags the entry has to match the regexp ^[a-z0-9\\+#\\-\\.]+$");
}
}
assertThatThrownBy(() -> call(issueDto.getKey(), "pol op"))
.isInstanceOf(IllegalArgumentException.class)
- .hasMessage("Entries 'pol op' are invalid. Rule tags accept only the characters: a-z, 0-9, '+', '-', '#', '.'");
+ .hasMessage("Entries 'pol op' are invalid. For Rule tags the entry has to match the regexp ^[a-z0-9\\+#\\-\\.]+$");
}
@Test