NETVIRT-1630 migrate to md-sal APIs
[netvirt.git] / qosservice / impl / src / test / java / org / opendaylight / netvirt / qosservice / UuidUtilTest.java
1 /*
2  * Copyright (c) 2017 Red Hat, 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.netvirt.qosservice;
9
10 import static com.google.common.truth.Truth.assertThat;
11
12 import org.junit.Test;
13 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
14
15 /**
16  * Unit test for UuidUtil.
17  *
18  * @author Michael Vorburger.ch
19  */
20 public class UuidUtilTest {
21
22     private final UuidUtil uuidUtil = new UuidUtil();
23
24     @Test
25     public void valid() {
26         assertThat(uuidUtil.newUuidIfValidPattern("f81d4fae-7dec-11d0-a765-00a0c91e6bf6").get())
27                 .isEqualTo(new Uuid("f81d4fae-7dec-11d0-a765-00a0c91e6bf6"));
28     }
29
30     @Test
31     public void invalid() {
32         assertThat(uuidUtil.newUuidIfValidPattern("tap61d7aec1-2c"))
33                 .isNotEqualTo("tap61d7aec1-11");
34     }
35
36     @Test
37     public void empty() {
38         assertThat(uuidUtil.newUuidIfValidPattern("")).isNotNull();
39     }
40
41     @Test(expected = NullPointerException.class)
42     public void isNull() {
43         assertThat(uuidUtil.newUuidIfValidPattern(null));
44     }
45
46 }