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
 
  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;
 
  27 import static org.junit.Assert.assertTrue;
 
  29 import org.junit.Test;
 
  30 import org.onap.policy.common.parameters.ValidationStatus;
 
  31 import org.onap.policy.distribution.forwarding.testclasses.CommonTestData;
 
  34  * Class to perform unit test of {@link LifecycleApiAutomationCompositionForwarderParameters}.
 
  36  * @author Sirisha Manchikanti (sirisha.manchikanti@est.tech)
 
  38 public class LifecycleApiAutomationCompositionForwarderParametersTest {
 
  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";
 
  47     public void testValidParameters() {
 
  48         final LifecycleApiAutomationCompositionForwarderParameters configurationParameters =
 
  49                 CommonTestData.getPolicyForwarderParameters(
 
  50                         "src/test/resources/parameters/LifecycleApiAutomationCompositionForwarderParameters.json",
 
  51                         LifecycleApiAutomationCompositionForwarderParameters.class);
 
  53         assertEquals(LifecycleApiAutomationCompositionForwarderParameters.class.getSimpleName(),
 
  54                 configurationParameters.getName());
 
  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());
 
  66         assertThat(configurationParameters.validate().getResult()).isNull();
 
  67         assertEquals(ValidationStatus.CLEAN, configurationParameters.validate().getStatus());
 
  71     public void testInvalidParameters() {
 
  72         final LifecycleApiForwarderParameters configurationParameters =
 
  73                 CommonTestData.getPolicyForwarderParameters(
 
  74                         "src/test/resources/parameters/LifecycleApiPolicyForwarderParametersInvalid.json",
 
  75                         LifecycleApiForwarderParameters.class);
 
  77         assertEquals(ValidationStatus.INVALID, configurationParameters.validate().getStatus());
 
  81     public void testEmptyParameters() {
 
  82         final LifecycleApiForwarderParameters configurationParameters =
 
  83                 CommonTestData.getPolicyForwarderParameters("src/test/resources/parameters/EmptyParameters.json",
 
  84                         LifecycleApiForwarderParameters.class);
 
  86         assertEquals(ValidationStatus.INVALID, configurationParameters.validate().getStatus());