2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2022 Nordix Foundation.
4 * Modifications Copyright (C) 2022-2023 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.distribution.forwarding.lifecycle.api;
24 import static org.assertj.core.api.Assertions.assertThat;
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertFalse;
28 import org.junit.Test;
29 import org.onap.policy.common.parameters.ValidationStatus;
30 import org.onap.policy.distribution.forwarding.testclasses.CommonTestData;
33 * Class to perform unit test of {@link LifecycleApiAutomationCompositionForwarderParameters}.
35 * @author Sirisha Manchikanti (sirisha.manchikanti@est.tech)
37 public class LifecycleApiAutomationCompositionForwarderParametersTest {
39 private static final String AUTOMATION_COMPOSITION_RUNTIME_HOST_NAME = "localhost";
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";
46 public void testValidParameters() {
47 final LifecycleApiAutomationCompositionForwarderParameters configurationParameters =
48 CommonTestData.getPolicyForwarderParameters(
49 "src/test/resources/parameters/LifecycleApiAutomationCompositionForwarderParameters.json",
50 LifecycleApiAutomationCompositionForwarderParameters.class);
52 assertEquals(LifecycleApiAutomationCompositionForwarderParameters.class.getSimpleName(),
53 configurationParameters.getName());
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());
65 assertThat(configurationParameters.validate().getResult()).isNull();
66 assertEquals(ValidationStatus.CLEAN, configurationParameters.validate().getStatus());
70 public void testInvalidParameters() {
71 final LifecycleApiForwarderParameters configurationParameters =
72 CommonTestData.getPolicyForwarderParameters(
73 "src/test/resources/parameters/LifecycleApiPolicyForwarderParametersInvalid.json",
74 LifecycleApiForwarderParameters.class);
76 assertEquals(ValidationStatus.INVALID, configurationParameters.validate().getStatus());
80 public void testEmptyParameters() {
81 final LifecycleApiForwarderParameters configurationParameters =
82 CommonTestData.getPolicyForwarderParameters("src/test/resources/parameters/EmptyParameters.json",
83 LifecycleApiForwarderParameters.class);
85 assertEquals(ValidationStatus.INVALID, configurationParameters.validate().getStatus());