2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.policy.controlloop.drl.legacy;
23 import static org.junit.Assert.assertEquals;
25 import com.openpojo.reflection.PojoClass;
26 import com.openpojo.reflection.impl.PojoClassFactory;
27 import com.openpojo.validation.Validator;
28 import com.openpojo.validation.ValidatorBuilder;
29 import com.openpojo.validation.test.impl.GetterTester;
30 import com.openpojo.validation.test.impl.SetterTester;
31 import org.junit.Before;
32 import org.junit.Test;
34 public class ControlLoopParamsTest {
35 private static final String CONTROL_LOOP_NAME = "c";
36 private static final String POLICY_NAME = "m";
37 private static final String POLICY_SCOPE = "s";
38 private static final String POLICY_VERSION = "v";
40 private ControlLoopParams clp = new ControlLoopParams();
47 clp.setClosedLoopControlName(CONTROL_LOOP_NAME);
48 clp.setPolicyName(POLICY_NAME);
49 clp.setPolicyScope(POLICY_SCOPE);
50 clp.setPolicyVersion(POLICY_VERSION);
54 public void testPojo() {
55 PojoClass controlLoopParams = PojoClassFactory.getPojoClass(ControlLoopParams.class);
56 Validator validator = ValidatorBuilder.create()
57 .with(new SetterTester(), new GetterTester()).build();
58 validator.validate(controlLoopParams);
62 public void getClosedLoopControlName() {
63 assertEquals(CONTROL_LOOP_NAME, clp.getClosedLoopControlName());
67 public void getPolicyName() {
68 assertEquals(POLICY_NAME, clp.getPolicyName());
72 public void getPolicyScope() {
73 assertEquals(POLICY_SCOPE, clp.getPolicyScope());
77 public void getPolicyVersion() {
78 assertEquals(POLICY_VERSION, clp.getPolicyVersion());
82 public void setClosedLoopControlName() {
83 clp.setClosedLoopControlName(CONTROL_LOOP_NAME.toUpperCase());
84 assertEquals(CONTROL_LOOP_NAME.toUpperCase(), clp.getClosedLoopControlName());
88 public void setPolicyName() {
89 clp.setPolicyName(POLICY_NAME.toUpperCase());
90 assertEquals(POLICY_NAME.toUpperCase(), clp.getPolicyName());
94 public void setPolicyScope() {
95 clp.setPolicyScope(POLICY_SCOPE.toUpperCase());
96 assertEquals(POLICY_SCOPE.toUpperCase(), clp.getPolicyScope());
100 public void setPolicyVersion() {
101 clp.setPolicyVersion(POLICY_VERSION.toUpperCase());
102 assertEquals(POLICY_VERSION.toUpperCase(), clp.getPolicyVersion());
106 public void testTwo() {
107 ControlLoopParams other = new ControlLoopParams();
108 other.setClosedLoopControlName(CONTROL_LOOP_NAME);
109 other.setPolicyName(POLICY_NAME);
110 other.setPolicyScope(POLICY_SCOPE);
111 other.setPolicyVersion(POLICY_VERSION);
113 assertEquals(clp, other);
114 assertEquals(clp.hashCode(), other.hashCode());
115 assertEquals(clp.toString(), other.toString());