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