public Rule(Map<String, Object> ruleSource) {
id = (Integer) ruleSource.get(RuleDocument.FIELD_ID);
key = (String) ruleSource.get(RuleDocument.FIELD_KEY);
+ language = (String) ruleSource.get(RuleDocument.FIELD_LANGUAGE);
repositoryKey = (String) ruleSource.get(RuleDocument.FIELD_REPOSITORY_KEY);
+ severity = (String) ruleSource.get(RuleDocument.FIELD_SEVERITY);
name = (String) ruleSource.get(RuleDocument.FIELD_NAME);
description = (String) ruleSource.get(RuleDocument.FIELD_DESCRIPTION);
status = (String) ruleSource.get(RuleDocument.FIELD_STATUS);
public void setUp() throws Exception {
when(myBatis.openSession()).thenReturn(session);
- esSetup = new EsSetup(ImmutableSettings.builder().loadFromUrl(ESNode.class.getResource("config/elasticsearch.json")).build());
+ esSetup = new EsSetup(ImmutableSettings.builder().loadFromUrl(ESNode.class.getResource("config/elasticsearch.json"))
+ .put("http.port", "9200")
+ .build());
esSetup.execute(EsSetup.deleteAll());
ESNode node = mock(ESNode.class);
EsSetup.index("rules", "rule", "2").withSource(testFileAsString("shared/rule2.json")),
EsSetup.index("rules", "rule", "3").withSource(testFileAsString("shared/rule3.json"))
);
+ esSetup.client().admin().cluster().prepareHealth(RuleRegistry.INDEX_RULES).setWaitForGreenStatus().execute().actionGet();
}
@After
@Test
public void should_find_rule_by_key() {
- assertThat(registry.findByKey(RuleKey.of("unknown", "OneIssuePerLine"))).isNull();
+ assertThat(registry.findByKey(RuleKey.of("unknown", "RuleWithParameters"))).isNull();
assertThat(registry.findByKey(RuleKey.of("xoo", "unknown"))).isNull();
- final Rule rule = registry.findByKey(RuleKey.of("xoo", "OneIssuePerLine"));
+ final Rule rule = registry.findByKey(RuleKey.of("xoo", "RuleWithParameters"));
assertThat(rule).isNotNull();
assertThat(rule.repositoryKey()).isEqualTo("xoo");
- assertThat(rule.key()).isEqualTo("OneIssuePerLine");
+ assertThat(rule.key()).isEqualTo("RuleWithParameters");
+ assertThat(rule.params()).hasSize(5);
+ assertThat(rule.adminTags()).hasSize(1);
+ assertThat(rule.systemTags()).hasSize(2);
}
"status": "READY",
"createdAt": "2013-10-28T13:07:26.329Z",
"updatedAt": "2013-11-08T10:52:53.473Z",
+ "note": {
+ "data": "<p>This rule should be kept to test params.</p>",
+ "author": "freddy.mallet",
+ "createdAt": "2013-11-14T13:07:26.329Z",
+ "updatedAt": "2013-11-14T13:10:26.329Z"
+ },
+ "systemTags": [ "has-params", "integration-tests" ],
+ "adminTags": [ "keep-enabled" ],
"params": [
{
"key": "string",