2 * ============LICENSE_START=======================================================
3 * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property.
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.sim.dmaap.startstop;
23 import static org.assertj.core.api.Assertions.assertThatCode;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertNull;
26 import static org.junit.Assert.assertTrue;
28 import org.junit.After;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
32 import org.onap.policy.models.sim.dmaap.DmaapSimException;
33 import org.onap.policy.models.sim.dmaap.startstop.Main;
34 import org.onap.policy.sim.dmaap.parameters.CommonTestData;
37 * Class to perform unit test of {@link Main}}.
39 * @author Ram Krishna Verma (ram.krishna.verma@est.tech)
41 public class MainTest {
50 HttpServletServerFactoryInstance.getServerFactory().destroy();
56 * @throws Exception if an error occurs
59 public void tearDown() throws Exception {
66 public void testMain() throws DmaapSimException {
67 final String[] NormalParameters = {"-c", "parameters/NormalParameters.json"};
68 main = new Main(NormalParameters);
69 assertTrue(main.getParameters().isValid());
70 assertEquals(CommonTestData.SIM_GROUP_NAME, main.getParameters().getName());
76 public void testMain_NoArguments() {
77 final String[] NormalParameters = {};
78 main = new Main(NormalParameters);
79 assertNull(main.getParameters());
83 public void testMain_InvalidArguments() {
84 // note: this is missing the "-c" argument, thus the ARGUMENTS are invalid
85 final String[] NormalParameters = {"parameters/NormalParameters.json"};
86 main = new Main(NormalParameters);
87 assertNull(main.getParameters());
91 public void testMain_Help() {
92 final String[] NormalParameters = {"-h"};
93 assertThatCode(() -> Main.main(NormalParameters)).doesNotThrowAnyException();
97 public void testMain_InvalidParameters() {
98 final String[] NormalParameters = {"-c", "parameters/InvalidParameters.json"};
99 main = new Main(NormalParameters);
100 assertNull(main.getParameters());