add testcase to improve test coverage
[multicloud/framework.git] / artifactbroker / main / src / test / java / org / onap / policy / distribution / main / parameters / TestPluginHandlerParameters.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2018 Ericsson. All rights reserved.
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
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.distribution.main.parameters;
22
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertFalse;
25 import static org.junit.Assert.assertTrue;
26 import static org.junit.Assert.fail;
27
28 import java.util.Map;
29 import org.junit.Test;
30 import org.onap.policy.common.parameters.GroupValidationResult;
31 import org.onap.policy.distribution.forwarding.parameters.ArtifactForwarderParameters;
32 import org.onap.policy.distribution.reception.parameters.PluginHandlerParameters;
33
34 /**
35  * Class to perform unit test of PluginHandlerParameters.
36  *
37  * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
38  */
39 public class TestPluginHandlerParameters {
40     CommonTestData commonTestData = new CommonTestData();
41
42     @Test
43     public void testPluginHandlerParameters() {
44         final Map<String, ArtifactForwarderParameters> policyForwarders = commonTestData.getArtifactForwarders(false);
45         final PluginHandlerParameters pHParameters = new PluginHandlerParameters(policyForwarders);
46         final GroupValidationResult validationResult = pHParameters.validate();
47         assertEquals(policyForwarders.get(CommonTestData.DUMMY_ENGINE_FORWARDER_KEY),
48                         pHParameters.getArtifactForwarders().get(CommonTestData.DUMMY_ENGINE_FORWARDER_KEY));
49         assertTrue(validationResult.isValid());
50     }
51
52     @Test
53     public void testPluginHandlerParameters_EmptyArtifactForwarders() {
54         final Map<String, ArtifactForwarderParameters> policyForwarders = commonTestData.getArtifactForwarders(true);
55         final PluginHandlerParameters pHParameters = new PluginHandlerParameters(policyForwarders);
56         GroupValidationResult result = pHParameters.validate();
57         assertFalse(result.isValid());
58         assertTrue(result.getResult().endsWith("must have at least one policy forwarder\n"));
59     }
60 }