Improved the UT coverage
[holmes/common.git] / holmes-actions / src / test / java / org / onap / holmes / common / api / entity / CorrelationRuleTest.java
1 /**
2  * Copyright 2017 ZTE Corporation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.onap.holmes.common.api.entity;
18
19 import static org.hamcrest.core.IsEqual.equalTo;
20 import static org.junit.Assert.assertThat;
21
22 import java.util.Date;
23 import java.util.Properties;
24 import org.junit.After;
25 import org.junit.Before;
26 import org.junit.Test;
27
28 public class CorrelationRuleTest {
29
30     private CorrelationRule correlationRule;
31
32     @Before
33     public void before() throws Exception {
34         correlationRule = new CorrelationRule();
35     }
36
37     @After
38     public void after() throws Exception {
39
40     }
41
42     @Test
43     public void getterAndSetter4Rid() throws Exception {
44         final String rid = "rid";
45         correlationRule.setRid(rid);
46         assertThat(correlationRule.getRid(), equalTo(rid));
47     }
48
49     @Test
50     public void getterAndSetter4Name() throws Exception {
51         final String name = "name";
52         correlationRule.setName(name);
53         assertThat(correlationRule.getName(), equalTo(name));
54     }
55
56     @Test
57     public void getterAndSetter4Description() throws Exception {
58         final String description = "description";
59         correlationRule.setDescription(description);
60         assertThat(correlationRule.getDescription(), equalTo(description));
61     }
62
63     @Test
64     public void getterAndSetter4Enabled() throws Exception {
65         final int enabled = 1;
66         correlationRule.setEnabled(enabled);
67         assertThat(correlationRule.getEnabled(), equalTo(enabled));
68     }
69
70     @Test
71     public void getterAndSetter4TemplateID() throws Exception {
72         final long templateId = 1L;
73         correlationRule.setTemplateID(templateId);
74         assertThat(correlationRule.getTemplateID(), equalTo(templateId));
75     }
76
77     @Test
78     public void getterAndSetter4EngineId() throws Exception {
79         final String engineId = "engineId";
80         correlationRule.setEngineID(engineId);
81         assertThat(correlationRule.getEngineID(), equalTo(engineId));
82     }
83
84     @Test
85     public void getterAndSetter4EngineType() throws Exception {
86         final String engineType = "engineType";
87         correlationRule.setEngineType(engineType);
88         assertThat(correlationRule.getEngineType(), equalTo(engineType));
89     }
90
91     @Test
92     public void getterAndSetter4Creator() throws Exception {
93         final String creator = "creator";
94         correlationRule.setCreator(creator);
95         assertThat(correlationRule.getCreator(), equalTo(creator));
96     }
97
98     @Test
99     public void getterAndSetter4Modifier() throws Exception {
100         final String modifier = "modifier";
101         correlationRule.setModifier(modifier);
102         assertThat(correlationRule.getModifier(), equalTo(modifier));
103     }
104
105     @Test
106     public void getterAndSetter4Params() throws Exception {
107         final Properties params = new Properties();
108         correlationRule.setParams(params);
109         assertThat(correlationRule.getParams(), equalTo(params));
110     }
111
112     @Test
113     public void getterAndSetter4Content() throws Exception {
114         final String content = "content";
115         correlationRule.setContent(content);
116         assertThat(correlationRule.getContent(), equalTo(content));
117     }
118
119     @Test
120     public void getterAndSetter4Vendor() throws Exception {
121         final String vendor = "vendor";
122         correlationRule.setVendor(vendor);
123         assertThat(correlationRule.getVendor(), equalTo(vendor));
124     }
125
126     @Test
127     public void getterAndSetter4CreateTime() throws Exception {
128         Date createTime = new Date();
129         correlationRule.setCreateTime(createTime);
130         assertThat(correlationRule.getCreateTime(), equalTo(createTime));
131     }
132
133     @Test
134     public void getterAndSetter4UpdateTime() throws Exception {
135         final Date updateTime = new Date();
136         correlationRule.setUpdateTime(updateTime);
137         assertThat(correlationRule.getUpdateTime(), equalTo(updateTime));
138     }
139
140     @Test
141     public void getterAndSetter4PackageName() throws Exception {
142         final String packageName = "packageName";
143         correlationRule.setPackageName(packageName);
144         assertThat(correlationRule.getPackageName(), equalTo(packageName));
145     }
146
147     @Test
148     public void getterAndSetter4EngineInstance(){
149         final String engineInstance = "engineInstance";
150         correlationRule.setEngineInstance(engineInstance);
151         assertThat(correlationRule.getEngineInstance(), equalTo(engineInstance));
152     }
153
154     @Test
155     public void getterAndSetter4ClosedControlLoopName(){
156         final String closedControlLoopName = "closedControlLoopName";
157         correlationRule.setClosedControlLoopName(closedControlLoopName);
158         assertThat(correlationRule.getClosedControlLoopName(), equalTo(closedControlLoopName));
159     }
160
161     @Test
162     public void testClone() {
163         final String rid = "rid";
164         correlationRule.setRid(rid);
165         CorrelationRule rule = (CorrelationRule) correlationRule.clone();
166         assertThat(rule.getRid(), equalTo(rid));
167     }
168