5d784887407ff04492b68d3a1bd8a7ef9a83bb39
[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  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.dmaap.mr.tools;
22
23 import static org.junit.Assert.assertTrue;
24
25 import java.io.FileNotFoundException;
26 import java.io.PrintStream;
27 import java.util.Arrays;
28
29 import org.junit.After;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.junit.runner.RunWith;
33 import org.mockito.InjectMocks;
34 import org.mockito.Mock;
35 import org.mockito.MockitoAnnotations;
36 import org.powermock.api.mockito.PowerMockito;
37 import org.powermock.core.classloader.annotations.PowerMockIgnore;
38 import org.powermock.modules.junit4.PowerMockRunner;
39
40 import com.att.nsa.cmdtool.CommandNotReadyException;
41
42 @RunWith(PowerMockRunner.class)
43 @PowerMockIgnore("jdk.internal.reflect.*")
44 public class ClusterCommandTest {
45         @InjectMocks
46         private ClusterCommand command;
47         @Mock
48         private MRCommandContext context;
49         @Mock
50         private PrintStream printStream;
51
52         @Before
53         public void setUp() throws Exception {
54                 MockitoAnnotations.initMocks(this);
55                 PowerMockito.when(context.getCluster()).thenReturn(Arrays.asList("localhost"));
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(context);
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() throws FileNotFoundException, CommandNotReadyException {
86                 String[] parts = { "create", "testtopic", "1", "1" };
87                 command.execute(parts, context, printStream);
88                 assertTrue(true);
89
90         }
91
92         @Test
93         public void testExecute1() throws FileNotFoundException, CommandNotReadyException {
94                 String[] parts = {};
95                 command.execute(parts, context, printStream);
96                 assertTrue(true);
97
98         }
99
100         @Test
101         public void testDisplayHelp() {
102
103                 command.displayHelp(printStream);
104                 assertTrue(true);
105
106         }
107
108 }