.getJdbiDaoByOnDemand(CorrelationRuleDao.class)\r
.getRuleByRid(ruleDeleteRequest.getRuleId());\r
} catch (Exception e) {\r
- throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_DB_ERROR);\r
+ throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_DB_ERROR, e);\r
}\r
if (correlationRule == null) {\r
log.warn("the rule:rule id=" + ruleDeleteRequest.getRuleId()\r
package org.openo.holmes.rulemgt;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.IsEqual.equalTo;
+
+import org.junit.Test;
+
public class RuleActiveAppTest {
+ @Test
+ public void getName() throws Exception {
+ RuleActiveApp app = new RuleActiveApp();
+ assertThat(app.getName(), equalTo("Holmes Rule Management ActiveApp APP "));
+ }
+
public static void main(String[] args) throws Exception {
String filePath = "E:\\code\\OES_Analytics_FM_Relation\\correlation-mgt\\rulemgt-standalone\\src\\assembly\\resource\\conf\\correlation-rule.yml";
new RuleActiveApp().run(new String[]{"server", filePath});
--- /dev/null
+/**\r
+ * Copyright 2017 ZTE Corporation.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.openo.holmes.rulemgt;\r
+\r
+import static org.hamcrest.core.IsEqual.equalTo;\r
+import static org.hamcrest.core.IsNull.notNullValue;\r
+import static org.junit.Assert.*;\r
+\r
+import io.dropwizard.db.DataSourceFactory;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+public class RuleAppConfigTest {\r
+\r
+ private RuleAppConfig ruleAppConfig;\r
+\r
+ @Before\r
+ public void setUp(){\r
+ ruleAppConfig = new RuleAppConfig();\r
+ }\r
+\r
+ @Test\r
+ public void getDataSourceFactory() throws Exception {\r
+ assertThat(ruleAppConfig.getDataSourceFactory(), notNullValue());\r
+ }\r
+\r
+ @Test\r
+ public void setDataSourceFactory() throws Exception {\r
+ final DataSourceFactory factory = new DataSourceFactory();\r
+ ruleAppConfig.setDataSourceFactory(factory);\r
+ assertThat(ruleAppConfig.getDataSourceFactory(), equalTo(factory));\r
+ }\r
+\r
+ @Test\r
+ public void getApidescription() throws Exception {\r
+ assertThat(ruleAppConfig.getApidescription(), equalTo("Holmes rule management rest API"));\r
+ }\r
+\r
+ @Test\r
+ public void setApidescription() throws Exception {\r
+ final String value = "desc";\r
+ ruleAppConfig.setApidescription(value);\r
+ assertThat(ruleAppConfig.getApidescription(), equalTo(value));\r
+ }\r
+\r
+}
\ No newline at end of file
--- /dev/null
+/**\r
+ * Copyright 2017 ZTE Corporation.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.openo.holmes.rulemgt.bean.request;\r
+\r
+import static org.hamcrest.core.IsEqual.equalTo;\r
+import static org.junit.Assert.*;\r
+\r
+import org.junit.Test;\r
+\r
+public class CorrelationCheckRule4EngineTest {\r
+ @Test\r
+ public void getterAndSetter4Content(){\r
+ final String value = "content";\r
+ CorrelationCheckRule4Engine correlationCheckRule4Engine = new CorrelationCheckRule4Engine();\r
+ correlationCheckRule4Engine.setContent(value);\r
+ assertThat(correlationCheckRule4Engine.getContent(), equalTo(value));\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/**\r
+ * Copyright 2017 ZTE Corporation.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.openo.holmes.rulemgt.bean.request;\r
+\r
+import static org.junit.Assert.*;\r
+import static org.hamcrest.core.IsEqual.equalTo;\r
+\r
+import org.junit.Test;\r
+\r
+public class CorrelationDeployRule4EngineTest {\r
+ @Test\r
+ public void getterAndSetter4Content(){\r
+ final String value = "content";\r
+ CorrelationDeployRule4Engine correlationDeployRule4Engine = new CorrelationDeployRule4Engine();\r
+ correlationDeployRule4Engine.setContent(value);\r
+ assertThat(correlationDeployRule4Engine.getContent(), equalTo(value));\r
+ }\r
+\r
+ @Test\r
+ public void getterAndSetter4EngineId(){\r
+ final String value = "engineId";\r
+ CorrelationDeployRule4Engine correlationDeployRule4Engine = new CorrelationDeployRule4Engine();\r
+ correlationDeployRule4Engine.setEngineId(value);\r
+ assertThat(correlationDeployRule4Engine.getEngineId(), equalTo(value));\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/**\r
+ * Copyright 2017 ZTE Corporation.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.openo.holmes.rulemgt.bean.request;\r
+\r
+import static org.hamcrest.core.Is.is;\r
+import static org.hamcrest.core.IsEqual.equalTo;\r
+import static org.junit.Assert.*;\r
+\r
+import org.junit.Test;\r
+\r
+public class RuleQueryConditionTest {\r
+ @Test\r
+ public void getterAndSetter4RuleId(){\r
+ final String value = "ruleId";\r
+ RuleQueryCondition ruleQueryCondition = new RuleQueryCondition();\r
+ ruleQueryCondition.setRid(value);\r
+ assertThat(ruleQueryCondition.getRid(), equalTo(value));\r
+ }\r
+\r
+ @Test\r
+ public void getterAndSetter4RuleName(){\r
+ final String value = "ruleName";\r
+ RuleQueryCondition ruleQueryCondition = new RuleQueryCondition();\r
+ ruleQueryCondition.setName(value);\r
+ assertThat(ruleQueryCondition.getName(), equalTo(value));\r
+ }\r
+\r
+ @Test\r
+ public void getterAndSetter4Creator(){\r
+ final String value = "admin";\r
+ RuleQueryCondition ruleQueryCondition = new RuleQueryCondition();\r
+ ruleQueryCondition.setCreator(value);\r
+ assertThat(ruleQueryCondition.getCreator(), equalTo(value));\r
+ }\r
+\r
+ @Test\r
+ public void getterAndSetter4Modifier(){\r
+ final String value = "admin";\r
+ RuleQueryCondition ruleQueryCondition = new RuleQueryCondition();\r
+ ruleQueryCondition.setModifier(value);\r
+ assertThat(ruleQueryCondition.getModifier(), equalTo(value));\r
+ }\r
+\r
+ @Test\r
+ public void getterAndSetter4Enabled(){\r
+ final int value = 0;\r
+ RuleQueryCondition ruleQueryCondition = new RuleQueryCondition();\r
+ ruleQueryCondition.setEnabled(value);\r
+ assertThat(ruleQueryCondition.getEnabled(), is(value));\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/**\r
+ * Copyright 2017 ZTE Corporation.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.openo.holmes.rulemgt.bean.request;\r
+\r
+import static org.hamcrest.core.Is.is;\r
+import static org.hamcrest.core.IsEqual.equalTo;\r
+import static org.junit.Assert.*;\r
+\r
+import org.junit.Test;\r
+\r
+\r
+public class RuleUpdateRequestTest {\r
+ @Test\r
+ public void getterAndSetter4RuleId(){\r
+ final String value = "ruleId";\r
+ RuleUpdateRequest ruleUpdateRequest = new RuleUpdateRequest();\r
+ ruleUpdateRequest.setRuleId(value);\r
+ assertThat(ruleUpdateRequest.getRuleId(), equalTo(value));\r
+ }\r
+\r
+ @Test\r
+ public void getterAndSetter4Description(){\r
+ final String value = "desc";\r
+ RuleUpdateRequest ruleUpdateRequest = new RuleUpdateRequest();\r
+ ruleUpdateRequest.setDescription(value);\r
+ assertThat(ruleUpdateRequest.getDescription(), equalTo(value));\r
+ }\r
+\r
+ @Test\r
+ public void getterAndSetter4Content(){\r
+ final String value = "content";\r
+ RuleUpdateRequest ruleUpdateRequest = new RuleUpdateRequest();\r
+ ruleUpdateRequest.setContent(value);\r
+ assertThat(ruleUpdateRequest.getContent(), equalTo(value));\r
+ }\r
+\r
+ @Test\r
+ public void getterAndSetter4Enabled(){\r
+ final int value = 0;\r
+ RuleUpdateRequest ruleUpdateRequest = new RuleUpdateRequest();\r
+ ruleUpdateRequest.setEnabled(value);\r
+ assertThat(ruleUpdateRequest.getEnabled(), is(value));\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/**\r
+ * Copyright 2017 ZTE Corporation.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.openo.holmes.rulemgt.bean.response;\r
+\r
+import static org.junit.Assert.*;\r
+import static org.hamcrest.core.IsEqual.equalTo;\r
+\r
+import org.junit.Test;\r
+\r
+public class RuleAddAndUpdateResponseTest {\r
+ @Test\r
+ public void getterAndSetter4RuleId(){\r
+ final String value = "ruleId";\r
+ RuleAddAndUpdateResponse ruleAddAndUpdateResponse = new RuleAddAndUpdateResponse();\r
+ ruleAddAndUpdateResponse.setRuleId(value);\r
+ assertThat(ruleAddAndUpdateResponse.getRuleId(), equalTo(value));\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/**\r
+ * Copyright 2017 ZTE Corporation.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.openo.holmes.rulemgt.bean.response;\r
+\r
+import static org.hamcrest.core.Is.is;\r
+import static org.hamcrest.core.IsEqual.equalTo;\r
+import static org.junit.Assert.assertThat;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import org.junit.Test;\r
+\r
+public class RuleQueryListResponseTest {\r
+\r
+ @Test\r
+ public void getterAndSetter4CorrelationRules(){\r
+ final List<RuleResult4API> value = new ArrayList<>();\r
+ RuleQueryListResponse ruleQueryListResponse = new RuleQueryListResponse();\r
+ ruleQueryListResponse.setCorrelationRules(value);\r
+ assertThat(ruleQueryListResponse.getCorrelationRules(), equalTo(value));\r
+ }\r
+\r
+ @Test\r
+ public void getterAndSetter4TotalCount(){\r
+ final int value = 0;\r
+ RuleQueryListResponse ruleQueryListResponse = new RuleQueryListResponse();\r
+ ruleQueryListResponse.setTotalCount(value);\r
+ assertThat(ruleQueryListResponse.getTotalCount(), is(value));\r
+ }\r
+\r
+}
\ No newline at end of file
--- /dev/null
+/**\r
+ * Copyright 2017 ZTE Corporation.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.openo.holmes.rulemgt.bean.response;\r
+\r
+import static org.hamcrest.core.Is.is;\r
+import static org.hamcrest.core.IsEqual.equalTo;\r
+import static org.junit.Assert.*;\r
+\r
+import java.util.Date;\r
+import org.junit.Test;\r
+\r
+public class RuleResult4APITest {\r
+\r
+ @Test\r
+ public void getterAndSetter4RuleId(){\r
+ final String value = "ruleId";\r
+ RuleResult4API ruleResult4API = new RuleResult4API();\r
+ ruleResult4API.setRuleId(value);\r
+ assertThat(ruleResult4API.getRuleId(), equalTo(value));\r
+ }\r
+\r
+ @Test\r
+ public void getterAndSetter4RuleName(){\r
+ final String value = "ruleName";\r
+ RuleResult4API ruleResult4API = new RuleResult4API();\r
+ ruleResult4API.setRuleName(value);\r
+ assertThat(ruleResult4API.getRuleName(), equalTo(value));\r
+ }\r
+\r
+ @Test\r
+ public void getterAndSetter4Description(){\r
+ final String value = "desc";\r
+ RuleResult4API ruleResult4API = new RuleResult4API();\r
+ ruleResult4API.setDescription(value);\r
+ assertThat(ruleResult4API.getDescription(), equalTo(value));\r
+ }\r
+\r
+ @Test\r
+ public void getterAndSetter4Content(){\r
+ final String value = "content";\r
+ RuleResult4API ruleResult4API = new RuleResult4API();\r
+ ruleResult4API.setContent(value);\r
+ assertThat(ruleResult4API.getContent(), equalTo(value));\r
+ }\r
+\r
+ @Test\r
+ public void getterAndSetter4CreateTime(){\r
+ final Date value = new Date();\r
+ RuleResult4API ruleResult4API = new RuleResult4API();\r
+ ruleResult4API.setCreateTime(value);\r
+ assertThat(ruleResult4API.getCreateTime(), equalTo(value));\r
+ }\r
+\r
+ @Test\r
+ public void getterAndSetter4Creator(){\r
+ final String value = "admin";\r
+ RuleResult4API ruleResult4API = new RuleResult4API();\r
+ ruleResult4API.setCreator(value);\r
+ assertThat(ruleResult4API.getCreator(), equalTo(value));\r
+ }\r
+\r
+ @Test\r
+ public void getterAndSetter4UpdateTime(){\r
+ final Date value = new Date();\r
+ RuleResult4API ruleResult4API = new RuleResult4API();\r
+ ruleResult4API.setUpdateTime(value);\r
+ assertThat(ruleResult4API.getUpdateTime(), equalTo(value));\r
+ }\r
+\r
+ @Test\r
+ public void getterAndSetter4Modifier(){\r
+ final String value = "admin";\r
+ RuleResult4API ruleResult4API = new RuleResult4API();\r
+ ruleResult4API.setModifier(value);\r
+ assertThat(ruleResult4API.getModifier(), equalTo(value));\r
+ }\r
+\r
+ @Test\r
+ public void getterAndSetter4Enabled(){\r
+ final int value = 0;\r
+ RuleResult4API ruleResult4API = new RuleResult4API();\r
+ ruleResult4API.setEnabled(value);\r
+ assertThat(ruleResult4API.getEnabled(), is(value));\r
+ }\r
+}
\ No newline at end of file