fc0fe3db5d455c00e356b9adf061b5ed239094f1
[policy/distribution.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2018 Ericsson. 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
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  * SPDX-License-Identifier: Apache-2.0
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.distribution.forwarding.apex.pdp;
23
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertFalse;
26 import static org.junit.Assert.assertTrue;
27
28 import org.junit.Test;
29 import org.onap.policy.common.parameters.ValidationStatus;
30 import org.onap.policy.distribution.forwarding.xacml.pdp.testclasses.CommonTestData;
31
32 /**
33  * Class to perform unit test of {@link ApexPdpPolicyForwarderParameterGroup}.
34  *
35  * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
36  */
37 public class ApexPdpPolicyForwarderParameterGroupTest {
38
39     @Test
40     public void testValidParameters() {
41         final ApexPdpPolicyForwarderParameterGroup configurationParameters = CommonTestData
42                 .getPolicyForwarderParameters("src/test/resources/parameters/ApexPdpPolicyForwarderParameters.json",
43                         ApexPdpPolicyForwarderParameterGroup.class);
44         assertEquals(ApexPdpPolicyForwarderParameterGroup.class.getSimpleName(), configurationParameters.getName());
45         assertTrue(configurationParameters.isForceUpdate());
46         assertEquals("10.10.10.10", configurationParameters.getHostname());
47         assertEquals(1234, configurationParameters.getPort());
48         assertFalse(configurationParameters.isIgnoreConflicts());
49         assertEquals(ValidationStatus.CLEAN, configurationParameters.validate().getStatus());
50     }
51
52     @Test
53     public void testInvalidParameters() {
54         final ApexPdpPolicyForwarderParameterGroup configurationParameters =
55                 CommonTestData.getPolicyForwarderParameters(
56                         "src/test/resources/parameters/ApexPdpPolicyForwarderParametersInvalid.json",
57                         ApexPdpPolicyForwarderParameterGroup.class);
58
59         assertEquals(ValidationStatus.INVALID, configurationParameters.validate().getStatus());
60     }
61
62     @Test
63     public void testEmptyParameters() {
64         final ApexPdpPolicyForwarderParameterGroup configurationParameters =
65                 CommonTestData.getPolicyForwarderParameters("src/test/resources/parameters/EmptyParameters.json",
66                         ApexPdpPolicyForwarderParameterGroup.class);
67
68         assertEquals(ValidationStatus.INVALID, configurationParameters.validate().getStatus());
69     }
70 }