Unit test for ovsdb.southbound.ovsdb.transact
[netvirt.git] / utils / mdsal-node / src / test / java / org / opendaylight / ovsdb / utils / mdsal / node / NodeUtilsTest.java
1 /*
2  *  Copyright (C) 2015 Red Hat, Inc.
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  *  Authors : Sam Hague
9  */
10 package org.opendaylight.ovsdb.utils.mdsal.node;
11
12 import static org.junit.Assert.assertEquals;
13 import static org.junit.Assert.assertNotNull;
14
15 import org.junit.Test;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
17
18 public class NodeUtilsTest {
19     private static final String OVS = "OVS";
20     private static final String IDENTIFIER = "192.168.120.31:45001";
21     private static final String OVS_IDENTIFIER = OVS + "|" + IDENTIFIER;
22     private static final String BAD_IDENTIFIER = "BAD" + "|" + IDENTIFIER;
23
24     @Test
25     public void testGetId () {
26         String identifier = NodeUtils.getId(OVS_IDENTIFIER);
27         assertEquals("getId(" + OVS_IDENTIFIER + ") should return " + IDENTIFIER,
28                 identifier, IDENTIFIER);
29
30         identifier = NodeUtils.getId(OVS);
31         assertEquals("getId(" + OVS + ") should return " + OVS,
32                 identifier, OVS);
33
34         identifier = NodeUtils.getId(BAD_IDENTIFIER);
35         assertEquals("getId(" + BAD_IDENTIFIER + ") should return " + BAD_IDENTIFIER,
36                 identifier, BAD_IDENTIFIER);
37     }
38
39     @Test
40     public void testGetOpenFlowNode () {
41         Node node = NodeUtils.getOpenFlowNode(OVS_IDENTIFIER);
42         assertNotNull("node should not be null", node);
43         assertEquals("id should be " + OVS_IDENTIFIER,
44                 node.getId().getValue(), OVS_IDENTIFIER);
45     }
46 }
47