31142551d5135599b3c2e7ac1ebad9d079da24f0
[unimgr.git] / cli / src / test / java / org / opendaylight / unimgr / cli / UniRemoveShellCommandTest.java
1 /*
2  * Copyright (c) 2016 CableLabs and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.unimgr.cli;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.mockito.Mockito.mock;
12
13 import org.junit.Before;
14 import org.junit.Test;
15 import org.mockito.Mock;
16 import org.mockito.Mockito;
17 import org.powermock.api.support.membermodification.MemberModifier;
18 import org.powermock.reflect.Whitebox;
19
20 public class UniRemoveShellCommandTest {
21     private final String ipAddress = "192.168.1.1";
22     private final UnimgrConsoleProviderTest provider = new UnimgrConsoleProviderTest();
23
24     @Mock UniRemoveShellCommand uniRemoveShellCommand;
25
26     @Before
27     public void setUp() throws IllegalArgumentException, IllegalAccessException{
28         uniRemoveShellCommand = mock(UniRemoveShellCommand.class, Mockito.CALLS_REAL_METHODS);
29         MemberModifier.field(UniRemoveShellCommand.class, "provider").set(uniRemoveShellCommand, provider);
30         MemberModifier.field(UniRemoveShellCommand.class, "ipAddress").set(uniRemoveShellCommand, ipAddress);
31     }
32
33     /**
34      * Test method for {@link org.opendaylight.unimgr.cli.UniRemoveShellCommand#doExecute()}.
35      * @throws Exception
36      */
37     @Test
38     public void testDoExecute() throws Exception {
39         final String success = "Uni successfully removed";
40         final String error = "Error removing Uni";
41         Object answer = Whitebox.invokeMethod(uniRemoveShellCommand, "doExecute");
42         assertEquals(success, answer);
43         answer = Whitebox.invokeMethod(uniRemoveShellCommand, "doExecute");
44         assertEquals(error, answer);
45     }
46
47 }