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
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.main.parameters;
23 import java.util.ArrayList;
24 import java.util.HashMap;
25 import java.util.List;
28 import org.onap.policy.distribution.forwarding.parameters.ArtifactForwarderParameters;
29 import org.onap.policy.distribution.main.testclasses.DummyArtifactForwarderParameterGroup;
30 import org.onap.policy.distribution.main.testclasses.DummyArtifactForwarderParameterGroup.DummyArtifactForwarderParameterGroupBuilder;
31 import org.onap.policy.distribution.main.testclasses.DummyReceptionHandlerParameterGroup;
32 import org.onap.policy.distribution.main.testclasses.DummyReceptionHandlerParameterGroup.DummyReceptionHandlerParameterGroupBuilder;
33 import org.onap.policy.distribution.reception.parameters.PluginHandlerParameters;
34 import org.onap.policy.distribution.reception.parameters.ReceptionHandlerConfigurationParameterGroup;
35 import org.onap.policy.distribution.reception.parameters.ReceptionHandlerParameters;
38 * Class to hold/create all parameters for test cases.
40 * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
42 public class CommonTestData {
44 private static final String REST_SERVER_PASSWORD = "zb!XztG34";
45 private static final String REST_SERVER_USER = "healthcheck";
46 private static final int REST_SERVER_PORT = 6969;
47 private static final String REST_SERVER_HOST = "0.0.0.0";
48 private static final boolean REST_SERVER_HTTPS = false;
49 public static final String DISTRIBUTION_GROUP_NAME = "SDCDistributionGroup";
50 public static final String FORWARDER_TYPE = "DummyForwarder";
51 public static final String FORWARDER_CLASS_NAME =
52 "org.onap.policy.distribution.main.testclasses.DummyArtifactForwarder";
53 public static final String FORWARDER_CONFIGURATION_PARAMETERS = "dummyConfiguration";
54 public static final String FORWARDER_HOST = "192.168.99.100";
55 public static final String RECEPTION_HANDLER_TYPE = "DummyReceptionHandler";
56 public static final String RECEPTION_HANDLER_CLASS_NAME =
57 "org.onap.policy.distribution.main.testclasses.DummyReceptionHandler";
58 public static final String RECEPTION_CONFIGURATION_PARAMETERS = "dummyReceptionHandlerConfiguration";
59 public static final String MY_STRING_PARAMETER_VALUE = "aStringValue";
60 public static final Boolean MY_BOOLEAN_PARAMETER_VALUE = true;
61 public static final int MY_INTEGER_PARAMETER_VALUE = 1234;
63 public static final String DUMMY_RECEPTION_HANDLER_KEY = "DummyReceptionHandler";
64 public static final String DUMMY_ENGINE_FORWARDER_KEY = "DummyForwarder";
66 public static final String POLICY_TYPE = "DUMMY";
67 public static final String POLICY_NAME = "SamplePolicy";
70 * Returns an instance of ReceptionHandlerParameters for test cases.
72 * @param isEmpty boolean value to represent that object created should be empty or not
73 * @return the restServerParameters object
75 public RestServerParameters getRestServerParameters(final boolean isEmpty) {
76 final RestServerParameters restServerParameters;
78 restServerParameters = new RestServerParameters(REST_SERVER_HOST, REST_SERVER_PORT, REST_SERVER_USER,
79 REST_SERVER_PASSWORD, REST_SERVER_HTTPS);
81 restServerParameters = new RestServerParameters(null, 0, null, null, REST_SERVER_HTTPS);
83 return restServerParameters;
87 * Returns an instance of ReceptionHandlerParameters for test cases.
89 * @param isEmpty boolean value to represent that object created should be empty or not
90 * @return the receptionHandlerParameters object
92 public Map<String, ReceptionHandlerParameters> getReceptionHandlerParameters(final boolean isEmpty) {
93 final Map<String, ReceptionHandlerParameters> receptionHandlerParameters =
94 new HashMap<String, ReceptionHandlerParameters>();
96 final Map<String, ArtifactForwarderParameters> policyForwarders = getArtifactForwarders(isEmpty);
97 final PluginHandlerParameters pHParameters = new PluginHandlerParameters(policyForwarders);
98 final ReceptionHandlerParameters rhParameters = new ReceptionHandlerParameters(RECEPTION_HANDLER_TYPE,
99 RECEPTION_HANDLER_CLASS_NAME, RECEPTION_CONFIGURATION_PARAMETERS, pHParameters);
100 receptionHandlerParameters.put(DUMMY_RECEPTION_HANDLER_KEY, rhParameters);
102 return receptionHandlerParameters;
106 * Returns ReceptionHandlerConfigurationParameterGroups for test cases.
108 * @param isEmpty boolean value to represent that object created should be empty or not
109 * @return the ReceptionHandlerConfigurationParameterGroups
111 public Map<String, ReceptionHandlerConfigurationParameterGroup> getReceptionHandlerConfigurationParameters(
112 final boolean isEmpty) {
113 final Map<String, ReceptionHandlerConfigurationParameterGroup> receptionHandlerConfigurationParameters =
114 new HashMap<String, ReceptionHandlerConfigurationParameterGroup>();
116 final List<String> messageBusAddress = new ArrayList<>();
117 messageBusAddress.add("localhost");
118 final List<String> artifactTypes = new ArrayList<>();
119 artifactTypes.add("TOSCA_CSAR");
120 final DummyReceptionHandlerParameterGroup dummyReceptionHandlerParameterGroup =
121 new DummyReceptionHandlerParameterGroupBuilder().setMyStringParameter(MY_STRING_PARAMETER_VALUE)
122 .setMyIntegerParameter(MY_INTEGER_PARAMETER_VALUE)
123 .setMyBooleanParameter(MY_BOOLEAN_PARAMETER_VALUE).build();
124 receptionHandlerConfigurationParameters.put(RECEPTION_CONFIGURATION_PARAMETERS,
125 dummyReceptionHandlerParameterGroup);
127 return receptionHandlerConfigurationParameters;
131 * Returns an instance of PluginHandlerParameters for test cases.
133 * @param isEmpty boolean value to represent that object created should be empty or not
134 * @return the pluginHandlerParameters object
136 public PluginHandlerParameters getPluginHandlerParameters(final boolean isEmpty) {
137 final Map<String, ArtifactForwarderParameters> policyForwarders = getArtifactForwarders(isEmpty);
138 final PluginHandlerParameters pluginHandlerParameters =
139 new PluginHandlerParameters(policyForwarders);
140 return pluginHandlerParameters;
144 * Returns an instance of ArtifactForwarderParameters for test cases.
146 * @param isEmpty boolean value to represent that object created should be empty or not
147 * @return the policyForwarders object
149 public Map<String, ArtifactForwarderParameters> getArtifactForwarders(final boolean isEmpty) {
150 final Map<String, ArtifactForwarderParameters> policyForwarders =
151 new HashMap<String, ArtifactForwarderParameters>();
153 final ArtifactForwarderParameters pFParameters = new ArtifactForwarderParameters(FORWARDER_TYPE,
154 FORWARDER_CLASS_NAME, FORWARDER_CONFIGURATION_PARAMETERS);
155 policyForwarders.put(DUMMY_ENGINE_FORWARDER_KEY, pFParameters);
157 return policyForwarders;
161 * Returns ArtifactForwarderConfigurationParameterGroups for test cases.
163 * @param isEmpty boolean value to represent that object created should be empty or not
164 * @return the ArtifactForwarderConfigurationParameterGroups
166 public Map<String, ArtifactForwarderConfigurationParameterGroup> getArtifactForwarderConfigurationParameters(
167 final boolean isEmpty) {
168 final Map<String, ArtifactForwarderConfigurationParameterGroup> policyForwarderConfigurationParameters =
169 new HashMap<String, ArtifactForwarderConfigurationParameterGroup>();
171 final DummyArtifactForwarderParameterGroup dummyArtifactForwarderParameterGroup =
172 new DummyArtifactForwarderParameterGroupBuilder().setUseHttps(true).setHostname(FORWARDER_HOST)
173 .setPort(1234).setUserName("myUser").setPassword("myPassword").setIsManaged(true).build();
174 policyForwarderConfigurationParameters.put(FORWARDER_CONFIGURATION_PARAMETERS,
175 dummyArtifactForwarderParameterGroup);
177 return policyForwarderConfigurationParameters;