960dec0e989d12439969b630ea43cd72b621a314
[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"))
27                 .hasValue(new Uuid("f81d4fae-7dec-11d0-a765-00a0c91e6bf6"));
28     }
29
30     @Test
31     public void invalid() {
32         assertThat(uuidUtil.newUuidIfValidPattern("tap61d7aec1-2c")).isAbsent();
33     }
34
35     @Test
36     public void empty() {
37         assertThat(uuidUtil.newUuidIfValidPattern("")).isAbsent();
38     }
39
40     @Test(expected = NullPointerException.class)
41     public void isNull() {
42         assertThat(uuidUtil.newUuidIfValidPattern(null));
43     }
44
45 }