From 7b2af8900a4b1de780a4c78ab6b9ff5b621ff7d6 Mon Sep 17 00:00:00 2001 From: GuangrongFu Date: Fri, 17 Feb 2017 17:23:57 +0800 Subject: Add new unit tests for java beans Change-Id: I2b10b32f98f066a553446f2e4d4deb274eb3e981 Issue-ID: HOLMES-12 Signed-off-by: GuangrongFu --- .../bean/request/RuleCreateRequestTest.java | 58 ++++++++++++++++++++++ .../bean/request/RuleDeleteRequestTest.java | 33 ++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleCreateRequestTest.java create mode 100644 rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleDeleteRequestTest.java (limited to 'rulemgt/src/test/java') diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleCreateRequestTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleCreateRequestTest.java new file mode 100644 index 0000000..3f5469d --- /dev/null +++ b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleCreateRequestTest.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 RuleCreateRequestTest { + + @Test + public void getterAndSetter4RuleName(){ + final String rulename = "rulename"; + RuleCreateRequest ruleCreateRequest = new RuleCreateRequest(); + ruleCreateRequest.setRuleName(rulename); + assertThat(ruleCreateRequest.getRuleName(), equalTo(rulename)); + } + + @Test + public void getterAndSetter4Description(){ + final String description = "desc"; + RuleCreateRequest ruleCreateRequest = new RuleCreateRequest(); + ruleCreateRequest.setDescription(description); + assertThat(ruleCreateRequest.getDescription(), equalTo(description)); + } + + @Test + public void getterAndSetter4Content(){ + final String contents = "contents"; + RuleCreateRequest ruleCreateRequest = new RuleCreateRequest(); + ruleCreateRequest.setContent(contents); + assertThat(ruleCreateRequest.getContent(), equalTo(contents)); + } + + @Test + public void getterAndSetter4Enabled(){ + final int enabled = 0; + RuleCreateRequest ruleCreateRequest = new RuleCreateRequest(); + ruleCreateRequest.setEnabled(enabled); + assertThat(ruleCreateRequest.getEnabled(), is(enabled)); + } +} \ No newline at end of file diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleDeleteRequestTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleDeleteRequestTest.java new file mode 100644 index 0000000..f9a09ff --- /dev/null +++ b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleDeleteRequestTest.java @@ -0,0 +1,33 @@ +/** + * 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 RuleDeleteRequestTest { + @Test + public void getterAndSetter4RuleId(){ + final String ruleId = "ruleId"; + RuleDeleteRequest ruleDeleteRequest = new RuleDeleteRequest(); + ruleDeleteRequest.setRuleId(ruleId); + assertThat(ruleDeleteRequest.getRuleId(), equalTo(ruleId)); + } +} \ No newline at end of file -- cgit 1.2.3-korg