2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Samsung. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
20 package org.onap.policy.apex.plugins.event.carrier.restserver;
22 import static org.junit.Assert.assertFalse;
23 import static org.junit.Assert.assertNotNull;
24 import static org.junit.Assert.assertTrue;
25 import java.lang.reflect.Field;
26 import org.junit.Before;
27 import org.junit.Test;
28 import org.onap.policy.common.parameters.GroupValidationResult;
30 public class RestServerCarrierTechnologyParametersTest {
32 RestServerCarrierTechnologyParameters restServerCarrierTechnologyParameters = null;
33 GroupValidationResult result = null;
38 * @throws Exception on test set up errors.
41 public void setUp() throws Exception {
42 restServerCarrierTechnologyParameters = new RestServerCarrierTechnologyParameters();
46 public void testRestServerCarrierTechnologyParameters() {
47 assertNotNull(restServerCarrierTechnologyParameters);
48 assertFalse(restServerCarrierTechnologyParameters.isStandalone());
52 public void testValidate() {
53 result = restServerCarrierTechnologyParameters.validate();
54 assertNotNull(result);
55 assertTrue(result.isValid());
59 public void testValidateWithNonDefaultValues() throws NoSuchFieldException, SecurityException,
60 IllegalArgumentException, IllegalAccessException {
62 Field field = RestServerCarrierTechnologyParameters.class.getDeclaredField("standalone");
63 field.setAccessible(true);
64 field.set(restServerCarrierTechnologyParameters, true);
65 field = RestServerCarrierTechnologyParameters.class.getDeclaredField("host");
66 field.setAccessible(true);
67 field.set(restServerCarrierTechnologyParameters, "");
68 field = RestServerCarrierTechnologyParameters.class.getDeclaredField("port");
69 field.setAccessible(true);
70 field.set(restServerCarrierTechnologyParameters, 1023);
71 result = restServerCarrierTechnologyParameters.validate();
72 assertNotNull(result);
73 assertFalse(result.isValid());
75 field = RestServerCarrierTechnologyParameters.class.getDeclaredField("host");
76 field.setAccessible(true);
77 field.set(restServerCarrierTechnologyParameters, "");
78 field = RestServerCarrierTechnologyParameters.class.getDeclaredField("port");
79 field.setAccessible(true);
80 field.set(restServerCarrierTechnologyParameters, 1023);
81 result = restServerCarrierTechnologyParameters.validate();
82 assertNotNull(result);
83 assertFalse(result.isValid());