daeb0c94d29077e4c9f7d8ca1d304942594d0ce5
[sdc.git] / common-app-api / src / test / java / org / openecomp / sdc / common / util / GeneralUtilityTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 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.openecomp.sdc.common.util;
22
23 import java.util.List;
24
25 import org.junit.Assert;
26 import org.junit.Test;
27
28
29 public class GeneralUtilityTest {
30
31         private GeneralUtility createTestSubject() {
32                 return new GeneralUtility();
33         }
34
35         
36         @Test
37         public void testGenerateTextFile() throws Exception {
38                 String fileName = "";
39                 String fileData = "";
40                 boolean result;
41
42                 // default test
43                 result = GeneralUtility.generateTextFile(fileName, fileData);
44         }
45
46         
47         @Test
48         public void testIsBase64Encoded() throws Exception {
49                 byte[] data = new byte[] { ' ' };
50                 boolean result;
51
52                 // default test
53                 result = GeneralUtility.isBase64Encoded(data);
54         }
55
56         
57         @Test
58         public void testIsBase64Encoded_1() throws Exception {
59                 String str = "";
60                 boolean result;
61
62                 // default test
63                 result = GeneralUtility.isBase64Encoded(str);
64         }
65
66         
67         @Test
68         public void testIsExceedingLimit() throws Exception {
69                 String str = "";
70                 int limit = 0;
71                 boolean result;
72
73                 // test 1
74                 str = null;
75                 result = GeneralUtility.isExceedingLimit(str, limit);
76                 Assert.assertEquals(false, result);
77
78                 // test 2
79                 str = "";
80                 result = GeneralUtility.isExceedingLimit(str, limit);
81                 Assert.assertEquals(false, result);
82         }
83
84         
85         @Test
86         public void testIsExceedingLimit_1() throws Exception {
87                 List<String> strList = null;
88                 int limit = 0;
89                 int delimiterLength = 0;
90                 boolean result;
91
92                 // test 1
93                 strList = null;
94                 result = GeneralUtility.isExceedingLimit(strList, limit, delimiterLength);
95                 Assert.assertEquals(false, result);
96         }
97
98         
99         @Test
100         public void testGetFilenameExtension() throws Exception {
101                 String fileName = "";
102                 String result;
103
104                 // test 1
105                 fileName = null;
106                 result = GeneralUtility.getFilenameExtension(fileName);
107                 Assert.assertEquals("", result);
108
109                 // test 2
110                 fileName = "";
111                 result = GeneralUtility.getFilenameExtension(fileName);
112                 Assert.assertEquals("", result);
113         }
114
115         
116         @Test
117         public void testCalculateMD5Base64EncodedByByteArray() throws Exception {
118                 byte[] payload = new byte[] { ' ' };
119                 String result;
120
121                 // default test
122                 result = GeneralUtility.calculateMD5Base64EncodedByByteArray(payload);
123         }
124
125         
126         @Test
127         public void testCalculateMD5Base64EncodedByString() throws Exception {
128                 String data = "";
129                 String result;
130
131                 // default test
132                 result = GeneralUtility.calculateMD5Base64EncodedByString(data);
133         }
134
135         
136         @Test
137         public void testIsEmptyString() throws Exception {
138                 String str = "";
139                 boolean result;
140
141                 // default test
142                 result = GeneralUtility.isEmptyString(str);
143         }
144 }