2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdc.common.util;
23 import java.util.List;
25 import org.junit.Assert;
26 import org.junit.Test;
29 public class GeneralUtilityTest {
31 private GeneralUtility createTestSubject() {
32 return new GeneralUtility();
37 public void testGenerateTextFile() throws Exception {
43 result = GeneralUtility.generateTextFile(fileName, fileData);
48 public void testIsBase64Encoded() throws Exception {
49 byte[] data = new byte[] { ' ' };
53 result = GeneralUtility.isBase64Encoded(data);
58 public void testIsBase64Encoded_1() throws Exception {
63 result = GeneralUtility.isBase64Encoded(str);
68 public void testIsExceedingLimit() throws Exception {
75 result = GeneralUtility.isExceedingLimit(str, limit);
76 Assert.assertEquals(false, result);
80 result = GeneralUtility.isExceedingLimit(str, limit);
81 Assert.assertEquals(false, result);
86 public void testIsExceedingLimit_1() throws Exception {
87 List<String> strList = null;
89 int delimiterLength = 0;
94 result = GeneralUtility.isExceedingLimit(strList, limit, delimiterLength);
95 Assert.assertEquals(false, result);
100 public void testGetFilenameExtension() throws Exception {
101 String fileName = "";
106 result = GeneralUtility.getFilenameExtension(fileName);
107 Assert.assertEquals("", result);
111 result = GeneralUtility.getFilenameExtension(fileName);
112 Assert.assertEquals("", result);
117 public void testCalculateMD5Base64EncodedByByteArray() throws Exception {
118 byte[] payload = new byte[] { ' ' };
122 result = GeneralUtility.calculateMD5Base64EncodedByByteArray(payload);
127 public void testCalculateMD5Base64EncodedByString() throws Exception {
132 result = GeneralUtility.calculateMD5Base64EncodedByString(data);
137 public void testIsEmptyString() throws Exception {
142 result = GeneralUtility.isEmptyString(str);