2  * ============LICENSE_START=======================================================
 
   3  *  Copyright (C) 2021 Nordix Foundation.
 
   4  * ================================================================================
 
   5  * Licensed under the Apache License, Version 2.0 (the "License");
 
   6  * you may not use this file except in compliance with the License.
 
   7  * You may obtain a copy of the License at
 
   9  *      http://www.apache.org/licenses/LICENSE-2.0
 
  11  * Unless required by applicable law or agreed to in writing, software
 
  12  * distributed under the License is distributed on an "AS IS" BASIS,
 
  13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  14  * See the License for the specific language governing permissions and
 
  15  * limitations under the License.
 
  17  * SPDX-License-Identifier: Apache-2.0
 
  18  * ============LICENSE_END=========================================================
 
  21 package org.onap.policy.distribution.reception.parameters;
 
  23 import static org.assertj.core.api.Assertions.assertThat;
 
  25 import java.util.HashMap;
 
  27 import org.junit.Test;
 
  28 import org.onap.policy.common.parameters.GroupValidationResult;
 
  29 import org.onap.policy.distribution.forwarding.parameters.PolicyForwarderParameters;
 
  32  * Class for unit testing PluginHandlerParameters class.
 
  34  * @author Adheli Tavares (adheli.tavares@est.tech)
 
  37 public class TestPluginHandlerParameters {
 
  40     public void testValidate_PolicyDecodersEmpty() {
 
  41         PluginHandlerParameters emptyDecoder = new PluginHandlerParameters(new HashMap<>(), getPolicyForwarders());
 
  43         GroupValidationResult result = emptyDecoder.validate();
 
  45         assertThat(result.getResult())
 
  46                 .contains("parameter group map \"policyDecoders\" INVALID, must have at least one policy decoder");
 
  47         assertThat(result.getResult()).doesNotContain(
 
  48                 "parameter group map \"policyForwarders\" INVALID, must have at least one policy forwarder");
 
  52     public void testValidate_PolicyForwardersNullEmpty() {
 
  53         PluginHandlerParameters emptyDecoder = new PluginHandlerParameters(getPolicyDecoders(), new HashMap<>());
 
  55         GroupValidationResult result = emptyDecoder.validate();
 
  57         assertThat(result.getResult())
 
  58                 .contains("parameter group map \"policyForwarders\" INVALID, must have at least one policy forwarder");
 
  59         assertThat(result.getResult()).doesNotContain(
 
  60                 "parameter group map \"policyDecoders\" INVALID, must have at least one policy decoder");
 
  63     private Map<String, PolicyDecoderParameters> getPolicyDecoders() {
 
  64         final Map<String, PolicyDecoderParameters> policyDecoders = new HashMap<>();
 
  65         final PolicyDecoderParameters pDParameters =
 
  66                 new PolicyDecoderParameters("DummyDecoder", "DummyDecoder", "dummyDecoderConfiguration");
 
  67         policyDecoders.put("DummyDecoder", pDParameters);
 
  69         return policyDecoders;
 
  72     private Map<String, PolicyForwarderParameters> getPolicyForwarders() {
 
  73         final Map<String, PolicyForwarderParameters> policyForwarders = new HashMap<>();
 
  74         final PolicyForwarderParameters pFParameters =
 
  75                 new PolicyForwarderParameters("DummyForwarder", "DummyForwarder", "dummyForwarderConfiguration");
 
  76         policyForwarders.put("DummyForwarder", pFParameters);
 
  78         return policyForwarders;