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