Add nemo-impl partical test files
[nemo.git] / nemo-renderers / cli-renderer / src / test / java / org / opendaylight / nemo / renderer / cli / physicalnetwork / UtilsTest.java
1 /*
2  * Copyright (c) 2015 Huawei, Inc. 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.nemo.renderer.cli.physicalnetwork;
9
10 import org.junit.Assert;
11 import org.junit.Test;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.PhysicalNodeInstance;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.generic.physical.network.rev151010.PhysicalPortInstance;
14
15 import static org.mockito.Mockito.*;
16
17 /**
18  * Created by zhangmeng on 2015/11/30.
19  */
20 public class UtilsTest extends Utils {
21
22     @Test
23     public void testGetNodeType() throws Exception {
24         String strType = "switch";
25         Assert.assertTrue(Utils.getNodeType(strType) == PhysicalNodeInstance.NodeType.Switch);
26         strType = "router";
27         Assert.assertTrue(Utils.getNodeType(strType) == PhysicalNodeInstance.NodeType.Router);
28         strType = "firewall";
29         Assert.assertTrue(Utils.getNodeType(strType) == PhysicalNodeInstance.NodeType.Firewall);
30         strType = "loadbalancer";
31         Assert.assertTrue(Utils.getNodeType(strType) == PhysicalNodeInstance.NodeType.Loadbalancer);
32         strType = "test";
33         Assert.assertTrue(Utils.getNodeType(strType) == null);
34     }
35
36     @Test
37     public void testGetPortType() throws Exception {
38         String strType = "external";
39         Assert.assertTrue(Utils.getPortType(strType) == PhysicalPortInstance.PortType.External);
40         strType = "test";
41         Assert.assertTrue(Utils.getPortType(strType) == PhysicalPortInstance.PortType.Internal);
42     }
43
44     @Test
45     public void testReadFile() throws Exception {
46         String Path = new String(".");
47         Assert.assertNotNull(Utils.readFile(Path));
48         Path = "./test";
49         Assert.assertNotNull(Utils.readFile(Path));
50         Assert.assertTrue(Utils.readFile(Path) == "");
51     }
52 }