diff options
Diffstat (limited to 'rulemgt/src/test/java')
9 files changed, 442 insertions, 0 deletions
diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/RuleActiveAppTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/RuleActiveAppTest.java index 69910c6..b025e01 100644 --- a/rulemgt/src/test/java/org/openo/holmes/rulemgt/RuleActiveAppTest.java +++ b/rulemgt/src/test/java/org/openo/holmes/rulemgt/RuleActiveAppTest.java @@ -16,8 +16,19 @@ 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}); diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/RuleAppConfigTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/RuleAppConfigTest.java new file mode 100644 index 0000000..5724da2 --- /dev/null +++ b/rulemgt/src/test/java/org/openo/holmes/rulemgt/RuleAppConfigTest.java @@ -0,0 +1,60 @@ +/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.holmes.rulemgt;
+
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.junit.Assert.*;
+
+import io.dropwizard.db.DataSourceFactory;
+import org.junit.Before;
+import org.junit.Test;
+
+public class RuleAppConfigTest {
+
+ private RuleAppConfig ruleAppConfig;
+
+ @Before
+ public void setUp(){
+ ruleAppConfig = new RuleAppConfig();
+ }
+
+ @Test
+ public void getDataSourceFactory() throws Exception {
+ assertThat(ruleAppConfig.getDataSourceFactory(), notNullValue());
+ }
+
+ @Test
+ public void setDataSourceFactory() throws Exception {
+ final DataSourceFactory factory = new DataSourceFactory();
+ ruleAppConfig.setDataSourceFactory(factory);
+ assertThat(ruleAppConfig.getDataSourceFactory(), equalTo(factory));
+ }
+
+ @Test
+ public void getApidescription() throws Exception {
+ assertThat(ruleAppConfig.getApidescription(), equalTo("Holmes rule management rest API"));
+ }
+
+ @Test
+ public void setApidescription() throws Exception {
+ final String value = "desc";
+ ruleAppConfig.setApidescription(value);
+ assertThat(ruleAppConfig.getApidescription(), equalTo(value));
+ }
+
+}
\ No newline at end of file diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/CorrelationCheckRule4EngineTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/CorrelationCheckRule4EngineTest.java new file mode 100644 index 0000000..59e020c --- /dev/null +++ b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/CorrelationCheckRule4EngineTest.java @@ -0,0 +1,32 @@ +/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.holmes.rulemgt.bean.request;
+
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class CorrelationCheckRule4EngineTest {
+ @Test
+ public void getterAndSetter4Content(){
+ final String value = "content";
+ CorrelationCheckRule4Engine correlationCheckRule4Engine = new CorrelationCheckRule4Engine();
+ correlationCheckRule4Engine.setContent(value);
+ assertThat(correlationCheckRule4Engine.getContent(), equalTo(value));
+ }
+}
\ No newline at end of file diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/CorrelationDeployRule4EngineTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/CorrelationDeployRule4EngineTest.java new file mode 100644 index 0000000..8a9b8ec --- /dev/null +++ b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/CorrelationDeployRule4EngineTest.java @@ -0,0 +1,40 @@ +/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.holmes.rulemgt.bean.request;
+
+import static org.junit.Assert.*;
+import static org.hamcrest.core.IsEqual.equalTo;
+
+import org.junit.Test;
+
+public class CorrelationDeployRule4EngineTest {
+ @Test
+ public void getterAndSetter4Content(){
+ final String value = "content";
+ CorrelationDeployRule4Engine correlationDeployRule4Engine = new CorrelationDeployRule4Engine();
+ correlationDeployRule4Engine.setContent(value);
+ assertThat(correlationDeployRule4Engine.getContent(), equalTo(value));
+ }
+
+ @Test
+ public void getterAndSetter4EngineId(){
+ final String value = "engineId";
+ CorrelationDeployRule4Engine correlationDeployRule4Engine = new CorrelationDeployRule4Engine();
+ correlationDeployRule4Engine.setEngineId(value);
+ assertThat(correlationDeployRule4Engine.getEngineId(), equalTo(value));
+ }
+}
\ No newline at end of file diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleQueryConditionTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleQueryConditionTest.java new file mode 100644 index 0000000..8bb5b8b --- /dev/null +++ b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleQueryConditionTest.java @@ -0,0 +1,65 @@ +/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.holmes.rulemgt.bean.request;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class RuleQueryConditionTest {
+ @Test
+ public void getterAndSetter4RuleId(){
+ final String value = "ruleId";
+ RuleQueryCondition ruleQueryCondition = new RuleQueryCondition();
+ ruleQueryCondition.setRid(value);
+ assertThat(ruleQueryCondition.getRid(), equalTo(value));
+ }
+
+ @Test
+ public void getterAndSetter4RuleName(){
+ final String value = "ruleName";
+ RuleQueryCondition ruleQueryCondition = new RuleQueryCondition();
+ ruleQueryCondition.setName(value);
+ assertThat(ruleQueryCondition.getName(), equalTo(value));
+ }
+
+ @Test
+ public void getterAndSetter4Creator(){
+ final String value = "admin";
+ RuleQueryCondition ruleQueryCondition = new RuleQueryCondition();
+ ruleQueryCondition.setCreator(value);
+ assertThat(ruleQueryCondition.getCreator(), equalTo(value));
+ }
+
+ @Test
+ public void getterAndSetter4Modifier(){
+ final String value = "admin";
+ RuleQueryCondition ruleQueryCondition = new RuleQueryCondition();
+ ruleQueryCondition.setModifier(value);
+ assertThat(ruleQueryCondition.getModifier(), equalTo(value));
+ }
+
+ @Test
+ public void getterAndSetter4Enabled(){
+ final int value = 0;
+ RuleQueryCondition ruleQueryCondition = new RuleQueryCondition();
+ ruleQueryCondition.setEnabled(value);
+ assertThat(ruleQueryCondition.getEnabled(), is(value));
+ }
+}
\ No newline at end of file diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleUpdateRequestTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleUpdateRequestTest.java new file mode 100644 index 0000000..4cd4744 --- /dev/null +++ b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleUpdateRequestTest.java @@ -0,0 +1,58 @@ +/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.holmes.rulemgt.bean.request;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+
+public class RuleUpdateRequestTest {
+ @Test
+ public void getterAndSetter4RuleId(){
+ final String value = "ruleId";
+ RuleUpdateRequest ruleUpdateRequest = new RuleUpdateRequest();
+ ruleUpdateRequest.setRuleId(value);
+ assertThat(ruleUpdateRequest.getRuleId(), equalTo(value));
+ }
+
+ @Test
+ public void getterAndSetter4Description(){
+ final String value = "desc";
+ RuleUpdateRequest ruleUpdateRequest = new RuleUpdateRequest();
+ ruleUpdateRequest.setDescription(value);
+ assertThat(ruleUpdateRequest.getDescription(), equalTo(value));
+ }
+
+ @Test
+ public void getterAndSetter4Content(){
+ final String value = "content";
+ RuleUpdateRequest ruleUpdateRequest = new RuleUpdateRequest();
+ ruleUpdateRequest.setContent(value);
+ assertThat(ruleUpdateRequest.getContent(), equalTo(value));
+ }
+
+ @Test
+ public void getterAndSetter4Enabled(){
+ final int value = 0;
+ RuleUpdateRequest ruleUpdateRequest = new RuleUpdateRequest();
+ ruleUpdateRequest.setEnabled(value);
+ assertThat(ruleUpdateRequest.getEnabled(), is(value));
+ }
+}
\ No newline at end of file diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/response/RuleAddAndUpdateResponseTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/response/RuleAddAndUpdateResponseTest.java new file mode 100644 index 0000000..82731d6 --- /dev/null +++ b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/response/RuleAddAndUpdateResponseTest.java @@ -0,0 +1,32 @@ +/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.holmes.rulemgt.bean.response;
+
+import static org.junit.Assert.*;
+import static org.hamcrest.core.IsEqual.equalTo;
+
+import org.junit.Test;
+
+public class RuleAddAndUpdateResponseTest {
+ @Test
+ public void getterAndSetter4RuleId(){
+ final String value = "ruleId";
+ RuleAddAndUpdateResponse ruleAddAndUpdateResponse = new RuleAddAndUpdateResponse();
+ ruleAddAndUpdateResponse.setRuleId(value);
+ assertThat(ruleAddAndUpdateResponse.getRuleId(), equalTo(value));
+ }
+}
\ No newline at end of file diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/response/RuleQueryListResponseTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/response/RuleQueryListResponseTest.java new file mode 100644 index 0000000..c6e0a7e --- /dev/null +++ b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/response/RuleQueryListResponseTest.java @@ -0,0 +1,45 @@ +/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.holmes.rulemgt.bean.response;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Test;
+
+public class RuleQueryListResponseTest {
+
+ @Test
+ public void getterAndSetter4CorrelationRules(){
+ final List<RuleResult4API> value = new ArrayList<>();
+ RuleQueryListResponse ruleQueryListResponse = new RuleQueryListResponse();
+ ruleQueryListResponse.setCorrelationRules(value);
+ assertThat(ruleQueryListResponse.getCorrelationRules(), equalTo(value));
+ }
+
+ @Test
+ public void getterAndSetter4TotalCount(){
+ final int value = 0;
+ RuleQueryListResponse ruleQueryListResponse = new RuleQueryListResponse();
+ ruleQueryListResponse.setTotalCount(value);
+ assertThat(ruleQueryListResponse.getTotalCount(), is(value));
+ }
+
+}
\ No newline at end of file diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/response/RuleResult4APITest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/response/RuleResult4APITest.java new file mode 100644 index 0000000..3af245e --- /dev/null +++ b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/response/RuleResult4APITest.java @@ -0,0 +1,99 @@ +/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.holmes.rulemgt.bean.response;
+
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.*;
+
+import java.util.Date;
+import org.junit.Test;
+
+public class RuleResult4APITest {
+
+ @Test
+ public void getterAndSetter4RuleId(){
+ final String value = "ruleId";
+ RuleResult4API ruleResult4API = new RuleResult4API();
+ ruleResult4API.setRuleId(value);
+ assertThat(ruleResult4API.getRuleId(), equalTo(value));
+ }
+
+ @Test
+ public void getterAndSetter4RuleName(){
+ final String value = "ruleName";
+ RuleResult4API ruleResult4API = new RuleResult4API();
+ ruleResult4API.setRuleName(value);
+ assertThat(ruleResult4API.getRuleName(), equalTo(value));
+ }
+
+ @Test
+ public void getterAndSetter4Description(){
+ final String value = "desc";
+ RuleResult4API ruleResult4API = new RuleResult4API();
+ ruleResult4API.setDescription(value);
+ assertThat(ruleResult4API.getDescription(), equalTo(value));
+ }
+
+ @Test
+ public void getterAndSetter4Content(){
+ final String value = "content";
+ RuleResult4API ruleResult4API = new RuleResult4API();
+ ruleResult4API.setContent(value);
+ assertThat(ruleResult4API.getContent(), equalTo(value));
+ }
+
+ @Test
+ public void getterAndSetter4CreateTime(){
+ final Date value = new Date();
+ RuleResult4API ruleResult4API = new RuleResult4API();
+ ruleResult4API.setCreateTime(value);
+ assertThat(ruleResult4API.getCreateTime(), equalTo(value));
+ }
+
+ @Test
+ public void getterAndSetter4Creator(){
+ final String value = "admin";
+ RuleResult4API ruleResult4API = new RuleResult4API();
+ ruleResult4API.setCreator(value);
+ assertThat(ruleResult4API.getCreator(), equalTo(value));
+ }
+
+ @Test
+ public void getterAndSetter4UpdateTime(){
+ final Date value = new Date();
+ RuleResult4API ruleResult4API = new RuleResult4API();
+ ruleResult4API.setUpdateTime(value);
+ assertThat(ruleResult4API.getUpdateTime(), equalTo(value));
+ }
+
+ @Test
+ public void getterAndSetter4Modifier(){
+ final String value = "admin";
+ RuleResult4API ruleResult4API = new RuleResult4API();
+ ruleResult4API.setModifier(value);
+ assertThat(ruleResult4API.getModifier(), equalTo(value));
+ }
+
+ @Test
+ public void getterAndSetter4Enabled(){
+ final int value = 0;
+ RuleResult4API ruleResult4API = new RuleResult4API();
+ ruleResult4API.setEnabled(value);
+ assertThat(ruleResult4API.getEnabled(), is(value));
+ }
+}
\ No newline at end of file |