2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2023 Nordix Foundation.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.controlloop.drl.legacy;
24 import static org.junit.jupiter.api.Assertions.assertEquals;
26 import com.openpojo.reflection.impl.PojoClassFactory;
27 import com.openpojo.validation.ValidatorBuilder;
28 import com.openpojo.validation.test.impl.GetterTester;
29 import com.openpojo.validation.test.impl.SetterTester;
30 import org.junit.jupiter.api.BeforeEach;
31 import org.junit.jupiter.api.Test;
34 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 final 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);
55 var controlLoopParams = PojoClassFactory.getPojoClass(ControlLoopParams.class);
56 var validator = ValidatorBuilder.create()
57 .with(new SetterTester(), new GetterTester()).build();
58 validator.validate(controlLoopParams);
62 void getClosedLoopControlName() {
63 assertEquals(CONTROL_LOOP_NAME, clp.getClosedLoopControlName());
67 void getPolicyName() {
68 assertEquals(POLICY_NAME, clp.getPolicyName());
72 void getPolicyScope() {
73 assertEquals(POLICY_SCOPE, clp.getPolicyScope());
77 void getPolicyVersion() {
78 assertEquals(POLICY_VERSION, clp.getPolicyVersion());
82 void setClosedLoopControlName() {
83 clp.setClosedLoopControlName(CONTROL_LOOP_NAME.toUpperCase());
84 assertEquals(CONTROL_LOOP_NAME.toUpperCase(), clp.getClosedLoopControlName());
88 void setPolicyName() {
89 clp.setPolicyName(POLICY_NAME.toUpperCase());
90 assertEquals(POLICY_NAME.toUpperCase(), clp.getPolicyName());
94 void setPolicyScope() {
95 clp.setPolicyScope(POLICY_SCOPE.toUpperCase());
96 assertEquals(POLICY_SCOPE.toUpperCase(), clp.getPolicyScope());
100 void setPolicyVersion() {
101 clp.setPolicyVersion(POLICY_VERSION.toUpperCase());
102 assertEquals(POLICY_VERSION.toUpperCase(), clp.getPolicyVersion());
107 var 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());