2 * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.
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
8 package org.opendaylight.nemo.renderer.cli.physicalnetwork;
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;
15 import static org.mockito.Mockito.*;
18 * Created by zhangmeng on 2015/11/30.
20 public class UtilsTest extends Utils {
23 public void testGetNodeType() throws Exception {
24 String strType = "switch";
25 Assert.assertTrue(Utils.getNodeType(strType) == PhysicalNodeInstance.NodeType.Switch);
27 Assert.assertTrue(Utils.getNodeType(strType) == PhysicalNodeInstance.NodeType.Router);
29 Assert.assertTrue(Utils.getNodeType(strType) == PhysicalNodeInstance.NodeType.Firewall);
30 strType = "loadbalancer";
31 Assert.assertTrue(Utils.getNodeType(strType) == PhysicalNodeInstance.NodeType.Loadbalancer);
33 Assert.assertTrue(Utils.getNodeType(strType) == null);
37 public void testGetPortType() throws Exception {
38 String strType = "external";
39 Assert.assertTrue(Utils.getPortType(strType) == PhysicalPortInstance.PortType.External);
41 Assert.assertTrue(Utils.getPortType(strType) == PhysicalPortInstance.PortType.Internal);
45 public void testReadFile() throws Exception {
46 String Path = new String(".");
47 Assert.assertNotNull(Utils.readFile(Path));
49 Assert.assertNotNull(Utils.readFile(Path));
50 Assert.assertTrue(Utils.readFile(Path) == "");