[AAI-2531] | Update springboot to 2.1.12.RELEASE
[aai/sparky-be.git] / sparkybe-onap-service / src / test / java / org / onap / aai / sparky / util / EncryptConvertorTest.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017-2018 Amdocs
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *       http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21 package org.onap.aai.sparky.util;
22
23 import org.junit.Test;
24
25 import java.util.Arrays;
26
27 import static org.junit.Assert.assertEquals;
28 /**
29  * The Class EncryptConvertor.
30  */
31 public class EncryptConvertorTest {
32
33   @Test
34   public void toHexStringTestString() {
35     assertEquals(EncryptConvertor.toHexString("abcd"),"61626364");
36   }
37
38   @Test
39   public void toHexStringTestByteArray() {
40     assertEquals(EncryptConvertor.toHexString("abcd".getBytes()),"61626364");
41   }
42
43   @Test
44   public void stringFromHexTestString() throws Exception {
45     assertEquals(EncryptConvertor.stringFromHex("61626364"),"abcd");
46   }
47
48   @Test
49   public void stringFromHexTestCharArray() throws Exception {
50     assertEquals(EncryptConvertor.stringFromHex("61626364".toCharArray()),"abcd");
51   }
52
53   @Test
54   public void bytesFromHexTestCharArray() throws Exception {
55     byte[] buf = {97, 98, 99, 100};
56     assertEquals(Arrays.toString(EncryptConvertor.bytesFromHex("61626364")), Arrays.toString(buf));
57   }
58
59   @Test
60   public void bytesFromHex() throws Exception {
61     byte[] buf = {97, 98, 99, 100};
62     assertEquals(Arrays.toString(EncryptConvertor.bytesFromHex("61626364".toCharArray())), Arrays.toString(buf));
63   }
64
65   @Test
66   public void fromHexDigit() throws Exception {
67     assertEquals(EncryptConvertor.fromHexDigit('a',2), 10);
68   }
69
70 }