[DMAAP-CLIENT] First sonar issues review part2
[dmaap/messagerouter/dmaapclient.git] / src / test / java / org / onap / dmaap / mr / tools / TraceCommandTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP Policy Engine
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Modifications Copyright © 2021 Orange.
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.dmaap.mr.tools;
24
25 import com.att.nsa.cmdtool.CommandNotReadyException;
26 import org.junit.After;
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.junit.runner.RunWith;
30 import org.mockito.InjectMocks;
31 import org.mockito.Mock;
32 import org.mockito.MockitoAnnotations;
33 import org.powermock.core.classloader.annotations.PowerMockIgnore;
34 import org.powermock.modules.junit4.PowerMockRunner;
35
36 import java.io.PrintStream;
37
38 import static org.junit.Assert.assertTrue;
39
40 @RunWith(PowerMockRunner.class)
41 @PowerMockIgnore("jdk.internal.reflect.*")
42 public class TraceCommandTest {
43     @InjectMocks
44     private TraceCommand command;
45     private String[] parts = new String[5];
46     @Mock
47     private PrintStream printStream;
48
49     @Before
50     public void setUp() throws Exception {
51         MockitoAnnotations.initMocks(this);
52         for (int i = 0; i < parts.length; i++) {
53             parts[i] = "String" + (i + 1);
54         }
55
56     }
57
58     @After
59     public void tearDown() throws Exception {
60
61     }
62
63     @Test
64     public void testGetMatches() {
65
66         command.getMatches();
67         assertTrue(true);
68
69     }
70
71     @Test
72     public void testCheckReady() {
73
74         try {
75             command.checkReady(new MRCommandContext());
76         } catch (CommandNotReadyException e) {
77             // TODO Auto-generated catch block
78             e.printStackTrace();
79         }
80         assertTrue(true);
81
82     }
83
84     @Test
85     public void testExecute() {
86
87         try {
88             command.execute(parts, new MRCommandContext(), printStream);
89         } catch (CommandNotReadyException e) {
90             // TODO Auto-generated catch block
91             e.printStackTrace();
92         }
93         assertTrue(true);
94
95     }
96
97     @Test
98     public void testDisplayHelp() {
99
100         command.displayHelp(printStream);
101         assertTrue(true);
102
103     }
104
105 }