e503e212e45dae45358923c83e732839e7f8694a
[dmaap/messagerouter/dmaapclient.git] / src / test / java / org / onap / dmaap / mr / tools / ClusterCommandTest.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.api.mockito.PowerMockito;
34 import org.powermock.core.classloader.annotations.PowerMockIgnore;
35 import org.powermock.modules.junit4.PowerMockRunner;
36
37 import java.io.FileNotFoundException;
38 import java.io.PrintStream;
39 import java.util.Arrays;
40
41 import static org.junit.Assert.assertTrue;
42
43 @RunWith(PowerMockRunner.class)
44 @PowerMockIgnore("jdk.internal.reflect.*")
45 public class ClusterCommandTest {
46     @InjectMocks
47     private ClusterCommand command;
48     @Mock
49     private MRCommandContext context;
50     @Mock
51     private PrintStream printStream;
52
53     @Before
54     public void setUp() throws Exception {
55         MockitoAnnotations.initMocks(this);
56         PowerMockito.when(context.getCluster()).thenReturn(Arrays.asList("localhost"));
57     }
58
59     @After
60     public void tearDown() throws Exception {
61
62     }
63
64     @Test
65     public void testGetMatches() {
66
67         command.getMatches();
68         assertTrue(true);
69
70     }
71
72     @Test
73     public void testCheckReady() {
74
75         try {
76             command.checkReady(context);
77         } catch (CommandNotReadyException e) {
78             // TODO Auto-generated catch block
79             e.printStackTrace();
80         }
81         assertTrue(true);
82
83     }
84
85     @Test
86     public void testExecute() throws FileNotFoundException, CommandNotReadyException {
87         String[] parts = {"create", "testtopic", "1", "1"};
88         command.execute(parts, context, printStream);
89         assertTrue(true);
90
91     }
92
93     @Test
94     public void testExecute1() throws FileNotFoundException, CommandNotReadyException {
95         String[] parts = {};
96         command.execute(parts, context, printStream);
97         assertTrue(true);
98
99     }
100
101     @Test
102     public void testDisplayHelp() {
103
104         command.displayHelp(printStream);
105         assertTrue(true);
106
107     }
108
109 }