7bb2c5c965e680b44e3a5cfc1c67f5f4d6a3cb91
[policy/drools-applications.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP
4  * ================================================================================
5  * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.controlloop.drl.legacy;
22
23 import static org.junit.Assert.assertEquals;
24
25 import org.junit.Before;
26 import org.junit.Test;
27
28 public class ControlLoopParamsTest {
29     private static final String CONTROL_LOOP_NAME = "c";
30     private static final String POLICY_NAME = "m";
31     private static final String POLICY_SCOPE = "s";
32     private static final String POLICY_VERSION = "v";
33     private static final String CONTROL_LOOP_YAML = "y";
34
35     private ControlLoopParams  clp = new ControlLoopParams();
36
37     /**
38      * Prepare tests.
39      */
40     @Before
41     public void setUp() {
42         clp.setClosedLoopControlName(CONTROL_LOOP_NAME);
43         clp.setPolicyName(POLICY_NAME);
44         clp.setPolicyScope(POLICY_SCOPE);
45         clp.setPolicyVersion(POLICY_VERSION);
46         clp.setControlLoopYaml(CONTROL_LOOP_YAML);
47     }
48
49     @Test
50     public void getClosedLoopControlName() {
51         assertEquals(CONTROL_LOOP_NAME, clp.getClosedLoopControlName());
52     }
53
54     @Test
55     public void getControlLoopYaml() {
56         assertEquals(CONTROL_LOOP_YAML, clp.getControlLoopYaml());
57     }
58
59     @Test
60     public void getPolicyName() {
61         assertEquals(POLICY_NAME, clp.getPolicyName());
62     }
63
64     @Test
65     public void getPolicyScope() {
66         assertEquals(POLICY_SCOPE, clp.getPolicyScope());
67     }
68
69     @Test
70     public void getPolicyVersion() {
71         assertEquals(POLICY_VERSION, clp.getPolicyVersion());
72     }
73
74     @Test
75     public void setClosedLoopControlName() {
76         clp.setClosedLoopControlName(CONTROL_LOOP_NAME.toUpperCase());
77         assertEquals(CONTROL_LOOP_NAME.toUpperCase(), clp.getClosedLoopControlName());
78     }
79
80     @Test
81     public void setControlLoopYaml() {
82         clp.setControlLoopYaml(CONTROL_LOOP_YAML.toUpperCase());
83         assertEquals(CONTROL_LOOP_YAML.toUpperCase(), clp.getControlLoopYaml());
84     }
85
86     @Test
87     public void setPolicyName() {
88         clp.setPolicyName(POLICY_NAME.toUpperCase());
89         assertEquals(POLICY_NAME.toUpperCase(), clp.getPolicyName());
90     }
91
92     @Test
93     public void setPolicyScope() {
94         clp.setPolicyScope(POLICY_SCOPE.toUpperCase());
95         assertEquals(POLICY_SCOPE.toUpperCase(), clp.getPolicyScope());
96     }
97
98     @Test
99     public void setPolicyVersion() {
100         clp.setPolicyVersion(POLICY_VERSION.toUpperCase());
101         assertEquals(POLICY_VERSION.toUpperCase(), clp.getPolicyVersion());
102     }
103
104     @Test
105     public void testTwo() {
106         ControlLoopParams other = new ControlLoopParams();
107         other.setClosedLoopControlName(CONTROL_LOOP_NAME);
108         other.setPolicyName(POLICY_NAME);
109         other.setPolicyScope(POLICY_SCOPE);
110         other.setPolicyVersion(POLICY_VERSION);
111         other.setControlLoopYaml(CONTROL_LOOP_YAML);
112
113         assertEquals(clp, other);
114         assertEquals(clp.hashCode(), other.hashCode());
115         assertEquals(clp.toString(), other.toString());
116     }
117 }