fixed JUnits in 2 test classes
[appc.git] / appc-config / appc-flow-controller / provider / src / test / java / org / onap / appc / flow / controller / utils / EncryptionToolTest.java
1 /*
2  * ============LICENSE_START=============================================================================================================
3  * Copyright (c) 2018 AT&T Intellectual Property.  All rights reserved.
4  * ===================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License"); 
6  * you may not use this file except in compliance with the License. 
7  * You may obtain a copy of the License at
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software 
12  * distributed under the License is distributed on an "AS IS" BASIS, 
13  * WITHOUT WARRANTIES OR CONDITIONS
14  * OF ANY KIND, either express or implied. 
15  * See the License for the specific language governing permissions and 
16  * limitations under the License.
17  * ============LICENSE_END===============================================================================================================
18  * 
19  */
20 package org.onap.appc.flow.controller.utils;
21
22 import static org.junit.Assert.*;
23
24 import org.junit.Test;
25
26 public class EncryptionToolTest {
27
28     @Test
29     public final void testGetInstance() {
30         String encrypted = EncryptionTool.getInstance().encrypt("AbCdEf");
31         assertNotNull(encrypted);
32     }
33
34     @Test
35     public final void testGetInstanceTwice() {
36         String encrypted = EncryptionTool.getInstance().encrypt("GhIjKl");
37         assertNotNull(encrypted);
38         assertEquals(encrypted, "enc:BDczBmon");
39         String encrypted2 = EncryptionTool.getInstance().encrypt("MNOPQR");
40         assertNotNull(encrypted2);
41         assertEquals(encrypted2, "enc:DhE1PHAZ");
42     }
43
44     @Test
45     public void testAll() {
46         String plainText = "AnyString123";
47         String encrypted = EncryptionTool.getInstance().encrypt(plainText);
48         assertNotEquals(plainText, encrypted);
49         String dec = EncryptionTool.getInstance().decrypt(encrypted);
50         assertNotEquals(encrypted, dec);
51         assertEquals(plainText, dec);
52         System.out.println(String.format("%s = [%s]", plainText, encrypted));
53     }
54
55     @Test
56     public final void testDecrypt() {
57         String decrypted = EncryptionTool.getInstance().decrypt("enc:BBczJmoH");
58         assertNotNull(decrypted);
59         assertEquals(decrypted, "GHIJKL");
60
61         String decrypted2 = EncryptionTool.getInstance().decrypt("BBczJmoH");
62         assertEquals(decrypted2, "BBczJmoH");
63     }
64
65     @Test
66     public final void testEncrypt() {
67         String encrypted = EncryptionTool.getInstance().encrypt("GHIJKL");
68         assertEquals(encrypted, "enc:BBczJmoH");
69     }
70
71     @Test
72     public final void testIsEncrytpedWithNull() {
73
74         String encrypted = EncryptionTool.getInstance().encrypt(null);
75         assertNull(encrypted);
76     }
77 }