0dc2f649b28675e6b4389d00fffaa9af941cf89f
[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.modules.junit4.PowerMockRunner;
38
39 import com.att.nsa.cmdtool.CommandNotReadyException;
40
41 @RunWith(PowerMockRunner.class)
42 public class ClusterCommandTest {
43         @InjectMocks
44         private ClusterCommand command;
45         @Mock
46         private MRCommandContext context;
47         @Mock
48         private PrintStream printStream;
49
50         @Before
51         public void setUp() throws Exception {
52                 MockitoAnnotations.initMocks(this);
53                 PowerMockito.when(context.getCluster()).thenReturn(Arrays.asList("localhost"));
54         }
55
56         @After
57         public void tearDown() throws Exception {
58
59         }
60
61         @Test
62         public void testGetMatches() {
63
64                 command.getMatches();
65                 assertTrue(true);
66
67         }
68
69         @Test
70         public void testCheckReady() {
71
72                 try {
73                         command.checkReady(context);
74                 } catch (CommandNotReadyException e) {
75                         // TODO Auto-generated catch block
76                         e.printStackTrace();
77                 }
78                 assertTrue(true);
79
80         }
81
82         @Test
83         public void testExecute() throws FileNotFoundException, CommandNotReadyException {
84                 String[] parts = { "create", "testtopic", "1", "1" };
85                 command.execute(parts, context, printStream);
86                 assertTrue(true);
87
88         }
89
90         @Test
91         public void testExecute1() throws FileNotFoundException, CommandNotReadyException {
92                 String[] parts = {};
93                 command.execute(parts, context, printStream);
94                 assertTrue(true);
95
96         }
97
98         @Test
99         public void testDisplayHelp() {
100
101                 command.displayHelp(printStream);
102                 assertTrue(true);
103
104         }
105
106 }