2faf1a52b4d984bd233c6287a98617eb3541aca2
[nemo.git] / nemo-tools / sandbox / src / test / java / org / opendaylight / nemo / tool / sandbox / models / LinkTest.java
1 /*\r
2  * Copyright (c) 2016 Huawei, Inc. and others. All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 \r
9 package org.opendaylight.nemo.tool.sandbox.models;\r
10 import junit.framework.TestCase;\r
11 import org.junit.Assert;\r
12 import org.junit.Before;\r
13 import org.junit.Test;\r
14 import static org.mockito.Mockito.*;\r
15 import static org.junit.Assert.*;\r
16 \r
17 import org.opendaylight.nemo.tool.sandbox.CmdExecutor;\r
18 import org.opendaylight.nemo.tool.sandbox.models.Connector;\r
19 \r
20 import org.junit.runner.RunWith;\r
21 import org.powermock.api.mockito.PowerMockito;\r
22 import org.powermock.api.support.membermodification.MemberMatcher;\r
23 import org.powermock.api.support.membermodification.MemberModifier;\r
24 import org.powermock.core.classloader.annotations.PrepareForTest;\r
25 import org.powermock.modules.junit4.PowerMockRunner;\r
26 \r
27 /**\r
28  * Created by Thomas Liu on 2016/1/14.\r
29  */\r
30 @RunWith(PowerMockRunner.class)\r
31 @PrepareForTest({CmdExecutor.class})\r
32 public class LinkTest extends TestCase {\r
33 \r
34     private Connector srcInterface;\r
35     private Connector dstInterface;\r
36     private Link likeTest;\r
37 \r
38     @Before\r
39     public void setUp() throws Exception {\r
40         srcInterface = new Connector("src",1);\r
41         dstInterface = new Connector("dst",2);\r
42         likeTest = new Link(srcInterface,dstInterface);\r
43 \r
44     }\r
45 \r
46     @Test\r
47     public void testGetSrcConnector() throws Exception {\r
48         Assert.assertNotNull(likeTest.getSrcConnector());\r
49     }\r
50 \r
51     @Test\r
52     public void testGetDstConnector() throws Exception {\r
53         Assert.assertNotNull(likeTest.getDstConnector());\r
54     }\r
55 \r
56     @Test\r
57     public void testInstall() throws Exception {\r
58         PowerMockito.mockStatic(CmdExecutor.class);\r
59         PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
60         likeTest.install();\r
61     }\r
62 \r
63     @Test\r
64     public void testUninstall() throws Exception {\r
65         PowerMockito.mockStatic(CmdExecutor.class);\r
66         PowerMockito.when(CmdExecutor.sshExecute(any(String.class))).thenReturn("null");\r
67         likeTest.uninstall();\r
68     }\r
69 \r
70     @Test\r
71     public void testEquals() throws Exception {\r
72         Assert.assertNotNull(likeTest.equals(this));\r
73     }\r
74 \r
75     @Test\r
76     public void testHashCode() throws Exception {\r
77         Assert.assertNotNull(likeTest.hashCode());\r
78     }\r
79 \r
80     @Test\r
81     public void testToString() throws Exception {\r
82         Assert.assertNotNull(likeTest.toString());\r
83     }\r
84 }