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 ValidationUtilsTest {
31 private ValidationUtils createTestSubject() {
32 return new ValidationUtils();
37 public void testValidateArtifactLabel() throws Exception {
42 result = ValidationUtils.validateArtifactLabel(label);
47 public void testValidateArtifactDisplayName() throws Exception {
48 String displayName = "";
52 result = ValidationUtils.validateArtifactDisplayName(displayName);
59 public void testNormalizeCategoryName4Display() throws Exception {
65 result = ValidationUtils.normalizeCategoryName4Display(str);
66 Assert.assertEquals("123", result);
70 result = ValidationUtils.normalizeCategoryName4Display(str);
71 Assert.assertEquals("123#123", result);
76 public void testNormalizeCategoryName4Uniqueness() throws Exception {
81 result = ValidationUtils.normalizeCategoryName4Uniqueness(str);
86 public void testValidateCategoryDisplayNameLength() throws Exception {
91 result = ValidationUtils.validateCategoryDisplayNameLength(label);
96 public void testValidateProductFullNameLength() throws Exception {
101 result = ValidationUtils.validateProductFullNameLength(fullName);
106 public void testValidateArtifactLabelLength() throws Exception {
111 result = ValidationUtils.validateArtifactLabelLength(label);
116 public void testValidateResourceInstanceNameLength() throws Exception {
117 String resourceInstanceName = "";
121 result = ValidationUtils.validateResourceInstanceNameLength(resourceInstanceName);
126 public void testValidateResourceInstanceName() throws Exception {
127 String resourceInstanceName = "";
131 result = ValidationUtils.validateResourceInstanceName(resourceInstanceName);
136 public void testValidateUrlLength() throws Exception {
141 result = ValidationUtils.validateUrlLength(url);
146 public void testValidateArtifactNameLength() throws Exception {
147 String artifactName = "";
151 result = ValidationUtils.validateArtifactNameLength(artifactName);
156 public void testValidateComponentNamePattern() throws Exception {
157 String componentName = "";
161 result = ValidationUtils.validateComponentNamePattern(componentName);
166 public void testValidateComponentNameLength() throws Exception {
167 String componentName = "";
171 result = ValidationUtils.validateComponentNameLength(componentName);
176 public void testValidateIcon() throws Exception {
181 result = ValidationUtils.validateIcon(icon);
186 public void testValidateIconLength() throws Exception {
191 result = ValidationUtils.validateIconLength(icon);
196 public void testValidateProjectCode() throws Exception {
197 String projectCode = "";
201 result = ValidationUtils.validateProjectCode(projectCode);
206 public void testValidateProjectCodeLegth() throws Exception {
207 String projectCode = "";
211 result = ValidationUtils.validateProjectCodeLegth(projectCode);
216 public void testValidateContactId() throws Exception {
217 String contactId = "";
221 result = ValidationUtils.validateContactId(contactId);
226 public void testValidateCost() throws Exception {
231 result = ValidationUtils.validateCost(cost);
236 public void testRemoveHtmlTags() throws Exception {
241 result = ValidationUtils.removeHtmlTags(str);
246 public void testRemoveAllTags() throws Exception {
247 String htmlText = "";
251 result = ValidationUtils.removeAllTags(htmlText);
256 public void testNormaliseWhitespace() throws Exception {
261 result = ValidationUtils.normaliseWhitespace(str);
266 public void testStripOctets() throws Exception {
271 result = ValidationUtils.stripOctets(str);
276 public void testRemoveNoneUtf8Chars() throws Exception {
281 result = ValidationUtils.removeNoneUtf8Chars(input);
286 public void testValidateIsEnglish() throws Exception {
291 result = ValidationUtils.validateIsEnglish(input);
296 public void testValidateIsAscii() throws Exception {
301 result = ValidationUtils.validateIsAscii(input);
306 public void testConvertHtmlTagsToEntities() throws Exception {
311 result = ValidationUtils.convertHtmlTagsToEntities(input);
322 public void testValidateTagListLength() throws Exception {
323 int tagListLength = 0;
327 result = ValidationUtils.validateTagListLength(tagListLength);
332 public void testValidateDescriptionLength() throws Exception {
333 String description = "";
337 result = ValidationUtils.validateDescriptionLength(description);
342 public void testValidateStringNotEmpty() throws Exception {
348 result = ValidationUtils.validateStringNotEmpty(value);
349 Assert.assertEquals(false, result);
353 result = ValidationUtils.validateStringNotEmpty(value);
354 Assert.assertEquals(false, result);
359 public void testValidateListNotEmpty() throws Exception {
365 result = ValidationUtils.validateListNotEmpty(list);
366 Assert.assertEquals(false, result);
371 public void testValidateVendorName() throws Exception {
372 String vendorName = "";
376 result = ValidationUtils.validateVendorName(vendorName);
381 public void testValidateVendorNameLength() throws Exception {
382 String vendorName = "";
386 result = ValidationUtils.validateVendorNameLength(vendorName);
391 public void testValidateResourceVendorModelNumberLength() throws Exception {
392 String resourceVendorModelNumber = "";
396 result = ValidationUtils.validateResourceVendorModelNumberLength(resourceVendorModelNumber);
401 public void testValidateVendorRelease() throws Exception {
402 String vendorRelease = "";
406 result = ValidationUtils.validateVendorRelease(vendorRelease);
411 public void testValidateVendorReleaseLength() throws Exception {
412 String vendorRelease = "";
416 result = ValidationUtils.validateVendorReleaseLength(vendorRelease);
421 public void testValidateServiceTypeLength() throws Exception {
422 String serviceType = "";
426 result = ValidationUtils.validateServiceTypeLength(serviceType);
431 public void testValidateServiceRoleLength() throws Exception {
432 String serviceRole = "";
436 result = ValidationUtils.validateServiceRoleLength(serviceRole);
441 public void testHasBeenCertified() throws Exception {
446 result = ValidationUtils.hasBeenCertified(version);
451 public void testNormaliseComponentName() throws Exception {
456 result = ValidationUtils.normaliseComponentName(name);
461 public void testNormalizeComponentInstanceName() throws Exception {
466 result = ValidationUtils.normalizeComponentInstanceName(name);
474 public void testConvertToSystemName() throws Exception {
479 result = ValidationUtils.convertToSystemName(name);
484 public void testNormalizeFileName() throws Exception {
485 String filename = "";
489 result = ValidationUtils.normalizeFileName(filename);
497 public void testValidateUrl() throws Exception {
502 result = ValidationUtils.validateUrl(url);
507 public void testCleanArtifactDisplayName() throws Exception {
512 result = ValidationUtils.cleanArtifactDisplayName(strIn);
517 public void testNormalizeArtifactLabel() throws Exception {
522 result = ValidationUtils.normalizeArtifactLabel(strIn);
527 public void testValidateAdditionalInformationKeyName() throws Exception {
532 result = ValidationUtils.validateAdditionalInformationKeyName(str);
543 public void testValidateConsumerName() throws Exception {
544 String consumerName = "";
548 result = ValidationUtils.validateConsumerName(consumerName);
553 public void testIsUTF8Str() throws Exception {
558 result = ValidationUtils.isUTF8Str(str);
563 public void testValidateConsumerPassSalt() throws Exception {
564 String consumerSalt = "";
568 result = ValidationUtils.validateConsumerPassSalt(consumerSalt);
573 public void testIsFloatNumber() throws Exception {
578 result = ValidationUtils.isFloatNumber(number);
583 public void testValidateCertifiedVersion() throws Exception {
588 result = ValidationUtils.validateCertifiedVersion(version);
593 public void testValidateMinorVersion() throws Exception {
598 result = ValidationUtils.validateMinorVersion(version);
603 public void testNormaliseProductName() throws Exception {
608 result = ValidationUtils.normaliseProductName(name);
616 public void testRemoveHtmlTagsOnly() throws Exception {
617 String htmlText = "";
621 result = ValidationUtils.removeHtmlTagsOnly(htmlText);