Merge "UT for southbound/transactions/md - set 2"
[ovsdb.git] / openstack / net-virt / src / test / java / org / opendaylight / ovsdb / openstack / netvirt / api / UuidUtilsTest.java
1 /*
2  * Copyright (C) 2014 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 : Dave Tucker
9  */
10
11 package org.opendaylight.ovsdb.openstack.netvirt.api;
12
13 import org.junit.Assert;
14 import org.junit.Test;
15
16 public class UuidUtilsTest {
17
18     static final String NEUTRON_ID = "f1bf546b-79e8-4c42-93c1-147009c85c1d";
19     static final String NEUTRON_KEY = "f1bf546b79e8c4293c1147009c85c1d";
20     static final String INVALID_NEUTRON_ID = "f1bf546b-79e8-4c42-93c1-147009c85c1d-invalid";
21     static final String KEYSTONE_ID = "879704f8cd7d4e60a41177fc99254b5e";
22     static final String KEYSTONE_KEY = "879704f8cd7de60a41177fc99254b5e";
23     static final String GARBAGE = "foobar12345";
24
25     @Test
26     public void testConvertNeutronIDToKey() throws Exception {
27         Assert.assertNull(UuidUtils.convertNeutronIDToKey(null));
28         Assert.assertNull(UuidUtils.convertNeutronIDToKey(INVALID_NEUTRON_ID));
29         Assert.assertEquals(KEYSTONE_KEY,UuidUtils.convertNeutronIDToKey(KEYSTONE_ID));
30         Assert.assertEquals(NEUTRON_KEY, UuidUtils.convertNeutronIDToKey(NEUTRON_ID));
31         /* ToDo: Validation check in this method should be stricter
32         This assertion should ideally fail, but it passes today
33         */
34         Assert.assertEquals(UuidUtils.convertNeutronIDToKey(GARBAGE), GARBAGE);
35     }
36
37     @Test
38     public void testIsValidNeutronID() throws Exception {
39         Assert.assertTrue(UuidUtils.isValidNeutronID(NEUTRON_ID));
40         Assert.assertTrue(UuidUtils.isValidNeutronID(KEYSTONE_ID));
41         Assert.assertFalse(UuidUtils.isValidNeutronID(INVALID_NEUTRON_ID));
42         /* ToDo: Validation check in this method should be stricter
43         This assertion should ideally fail, but it passes today
44         */
45         Assert.assertTrue(UuidUtils.isValidNeutronID(GARBAGE));
46     }
47 }