b4058a7ba868c93b67282e3069b8105c2c841f9b
[so.git] / common / src / test / java / org / onap / so / utils / UUIDCheckerTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.utils;
22
23 import static org.junit.Assert.*;
24
25 import org.junit.Test;
26 import org.onap.so.logger.MsoLogger;
27
28 public class UUIDCheckerTest {
29         private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL, UUIDCheckerTest.class);
30         
31         @Test
32         public void isValidUUIDTest(){
33                 String nullID = null;
34                 String badID = "This is not a UUID";
35                 String id = UUIDChecker.getUUID();
36                 assertFalse(UUIDChecker.isValidUUID(nullID));
37                 assertFalse(UUIDChecker.isValidUUID(badID));
38                 assertTrue(UUIDChecker.isValidUUID(id));
39         }
40
41         @Test
42         public void verifyOldUUIDTest(){
43                 String oldID = UUIDChecker.getUUID();
44                 String invalidID = "This is not a UUID";
45                 assertEquals(UUIDChecker.verifyOldUUID(oldID,LOGGER),oldID);
46                 assertNotEquals(UUIDChecker.verifyOldUUID(invalidID,LOGGER),invalidID);
47         }
48         
49         @Test
50         public void generateTest(){
51                 String id = UUIDChecker.generateUUID(LOGGER);
52                 assertNotNull(id);
53                 assertTrue(UUIDChecker.isValidUUID(id));
54                 
55                 id = UUIDChecker.generateServiceInstanceID(LOGGER);
56                 assertNotNull(id);
57                 assertTrue(UUIDChecker.isValidUUID(id));
58                 
59         }
60 }