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.testclasses;
24 import org.onap.policy.common.endpoints.http.server.RestServer;
25 import org.onap.policy.common.endpoints.parameters.RestServerParameters;
26 import org.onap.policy.common.utils.coder.CoderException;
27 import org.onap.policy.common.utils.coder.StandardCoder;
28 import org.onap.policy.common.utils.resources.ResourceUtils;
29 import org.onap.policy.distribution.forwarding.PolicyForwardingException;
30 import org.onap.policy.distribution.forwarding.lifecycle.api.LifecycleApiAutomationCompositionForwarder;
31 import org.onap.policy.distribution.main.rest.aaf.AafDistributionFilter;
34 * The class for starting/stopping simulator for testing {@link LifecycleApiAutomationCompositionForwarder} .
36 * @author Sirisha Manchikanti (sirisha.manchikanti@est.tech)
38 public class LifecycleApiAutomationCompositionSimulatorMain {
39 private RestServer restServer;
42 * Starts the simulator.
44 * @throws PolicyForwardingException if error occurs
45 * @throws CoderException if error occurs
47 public void startLifecycycleApiSimulator() throws PolicyForwardingException, CoderException {
48 final StandardCoder standardCoder = new StandardCoder();
49 final RestServerParameters restServerParameters = standardCoder.decode(
50 ResourceUtils.getResourceAsString("src/test/resources/parameters/RestServerParameters.json"),
51 RestServerParameters.class);
52 restServer = new RestServer(restServerParameters, AafDistributionFilter.class,
53 LifecycleApiAutomationCompositionSimulatorEndpoint.class);
54 if (!restServer.start()) {
55 throw new PolicyForwardingException("Failed to start rest simulator. Check log for more details...");
60 * Shut down Execution.
62 public void stopLifecycycleApiSimulator() {
63 if (restServer != null) {