2ad522fbe25211510226f75d7e96a75545afe279
[policy/distribution.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2022 Nordix Foundation.
4  *  Modifications Copyright (C) 2022 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.lifecycle.api;
23
24 import static org.assertj.core.api.Assertions.assertThat;
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertFalse;
27 import static org.junit.Assert.assertTrue;
28
29 import org.junit.Test;
30 import org.onap.policy.common.parameters.ValidationStatus;
31 import org.onap.policy.distribution.forwarding.testclasses.CommonTestData;
32
33 /**
34  * Class to perform unit test of {@link LifecycleApiAutomationCompositionForwarderParameters}.
35  *
36  * @author Sirisha Manchikanti (sirisha.manchikanti@est.tech)
37  */
38 public class LifecycleApiAutomationCompositionForwarderParametersTest {
39
40     private static final String AUTOMATION_COMPOSITION_RUNTIME_HOST_NAME = "0.0.0.0";
41     private static final int AUTOMATION_COMPOSITION_RUNTIME_PORT = 6969;
42     private static final String AUTOMATION_COMPOSITION_RUNTIME_USER = "policyadmin";
43     private static final String AUTOMATION_COMPOSITION_RUNTIME_PASSWORD = "zb!XztG34";
44
45
46     @Test
47     public void testValidParameters() {
48         final LifecycleApiAutomationCompositionForwarderParameters configurationParameters =
49                 CommonTestData.getPolicyForwarderParameters(
50                         "src/test/resources/parameters/LifecycleApiAutomationCompositionForwarderParameters.json",
51                         LifecycleApiAutomationCompositionForwarderParameters.class);
52
53         assertEquals(LifecycleApiAutomationCompositionForwarderParameters.class.getSimpleName(),
54                 configurationParameters.getName());
55
56         assertEquals(AUTOMATION_COMPOSITION_RUNTIME_HOST_NAME,
57                 configurationParameters.getAutomationCompositionRuntimeParameters().getHostname());
58         assertEquals(AUTOMATION_COMPOSITION_RUNTIME_PORT,
59                 configurationParameters.getAutomationCompositionRuntimeParameters().getPort());
60         assertFalse(configurationParameters.getAutomationCompositionRuntimeParameters().isUseHttps());
61         assertEquals(AUTOMATION_COMPOSITION_RUNTIME_USER,
62                 configurationParameters.getAutomationCompositionRuntimeParameters().getUserName());
63         assertEquals(AUTOMATION_COMPOSITION_RUNTIME_PASSWORD,
64                 configurationParameters.getAutomationCompositionRuntimeParameters().getPassword());
65
66         assertThat(configurationParameters.validate().getResult()).isNull();
67         assertEquals(ValidationStatus.CLEAN, configurationParameters.validate().getStatus());
68     }
69
70     @Test
71     public void testInvalidParameters() {
72         final LifecycleApiForwarderParameters configurationParameters =
73                 CommonTestData.getPolicyForwarderParameters(
74                         "src/test/resources/parameters/LifecycleApiPolicyForwarderParametersInvalid.json",
75                         LifecycleApiForwarderParameters.class);
76
77         assertEquals(ValidationStatus.INVALID, configurationParameters.validate().getStatus());
78     }
79
80     @Test
81     public void testEmptyParameters() {
82         final LifecycleApiForwarderParameters configurationParameters =
83                 CommonTestData.getPolicyForwarderParameters("src/test/resources/parameters/EmptyParameters.json",
84                         LifecycleApiForwarderParameters.class);
85
86         assertEquals(ValidationStatus.INVALID, configurationParameters.validate().getStatus());
87     }
88 }