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