2 * ============LICENSE_START=======================================================
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
23 package org.onap.dmaap.mr.tools;
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;
37 import java.io.FileNotFoundException;
38 import java.io.PrintStream;
39 import java.util.Arrays;
41 import static org.junit.Assert.assertTrue;
43 @RunWith(PowerMockRunner.class)
44 @PowerMockIgnore("jdk.internal.reflect.*")
45 public class ClusterCommandTest {
47 private ClusterCommand command;
49 private MRCommandContext context;
51 private PrintStream printStream;
54 public void setUp() throws Exception {
55 MockitoAnnotations.initMocks(this);
56 PowerMockito.when(context.getCluster()).thenReturn(Arrays.asList("localhost"));
60 public void tearDown() throws Exception {
65 public void testGetMatches() {
73 public void testCheckReady() {
76 command.checkReady(context);
77 } catch (CommandNotReadyException e) {
78 // TODO Auto-generated catch block
86 public void testExecute() throws FileNotFoundException, CommandNotReadyException {
87 String[] parts = {"create", "testtopic", "1", "1"};
88 command.execute(parts, context, printStream);
94 public void testExecute1() throws FileNotFoundException, CommandNotReadyException {
96 command.execute(parts, context, printStream);
102 public void testDisplayHelp() {
104 command.displayHelp(printStream);