From ed64b5edff15e702493df21aa3230b81593e6133 Mon Sep 17 00:00:00 2001 From: Michael Lando Date: Fri, 9 Jun 2017 03:19:04 +0300 Subject: [SDC-29] catalog 1707 rebase commit. Change-Id: I43c3dc5cf44abf5da817649bc738938a3e8388c1 Signed-off-by: Michael Lando --- .../openecomp/sdc/common/test/CommonUtilsTest.java | 69 +++++++++--------- .../sdc/common/test/TestExternalConfiguration.java | 83 ++++++++++++---------- .../org/openecomp/sdc/common/test/YamlTest.java | 4 +- 3 files changed, 80 insertions(+), 76 deletions(-) (limited to 'common-app-api/src/test') diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java index 1a062576dc..50c2b79d63 100644 --- a/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java +++ b/common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java @@ -29,9 +29,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.commons.lang3.StringEscapeUtils; -import org.jsoup.Jsoup; -import org.jsoup.safety.Whitelist; +import org.junit.Ignore; import org.junit.Test; import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.util.GeneralUtility; @@ -40,7 +38,6 @@ import org.openecomp.sdc.common.util.ValidationUtils; import org.openecomp.sdc.common.util.YamlToObjectConverter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.w3c.dom.html.HTMLStyleElement; import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.Yaml; @@ -62,7 +59,9 @@ public class CommonUtilsTest { assertTrue(ValidationUtils.validateComponentNamePattern("1111222")); assertFalse(ValidationUtils.validateComponentNamePattern("11!11222")); assertFalse(ValidationUtils.validateComponentNamePattern("111|`1222")); - + assertFalse(ValidationUtils.validateComponentNamePattern(".")); + assertFalse(ValidationUtils.validateComponentNamePattern("")); + assertTrue(ValidationUtils.validateComponentNamePattern("s")); } @Test @@ -104,38 +103,38 @@ public class CommonUtilsTest { assertFalse(ValidationUtils.validateIconLength("ddddddddddddddddddddddsdfsddddddddddddddddddddddsdfs")); } - // 1610OS Support - Because of changes in the validation in the ui this test needs to be fixed -// @Test -// public void testValidateProjectCode() { -// -// assertTrue(ValidationUtils.validateProjectCode("15555")); -// assertTrue(ValidationUtils.validateProjectCode("12434501")); -// assertTrue(ValidationUtils.validateProjectCode("00000")); -// assertFalse(ValidationUtils.validateProjectCode("something")); -// assertFalse(ValidationUtils.validateProjectCode("som ething")); -// assertFalse(ValidationUtils.validateProjectCode("3255 656")); -// assertFalse(ValidationUtils.validateProjectCode("43535t636")); -// assertFalse(ValidationUtils.validateProjectCode("098&656")); -// } + @Test + public void testValidateProjectCode() { + + assertTrue(ValidationUtils.validateProjectCode("15555")); + assertTrue(ValidationUtils.validateProjectCode("12434501")); + assertTrue(ValidationUtils.validateProjectCode("00000")); + assertTrue(ValidationUtils.validateProjectCode("something")); + assertTrue(ValidationUtils.validateProjectCode("som ething")); + assertTrue(ValidationUtils.validateProjectCode("3255 656")); + assertTrue(ValidationUtils.validateProjectCode("43535t636")); + assertFalse(ValidationUtils.validateProjectCode("098&656")); + } @Test public void testValidateProjectCodeLength() { + assertTrue(ValidationUtils.validateProjectCodeLegth("00000")); assertFalse(ValidationUtils.validateProjectCodeLegth("ddddddddddddddddddddddsdfsddddddddddddddddddddddsdfs")); + } - // 1610OS Support - Because of changes in the validation in the ui this test needs to be fixed -// @Test -// public void testValidateContactId() { -// -// assertTrue(ValidationUtils.validateContactId("ml7889")); -// assertTrue(ValidationUtils.validateContactId("Ml7889")); -// assertTrue(ValidationUtils.validateContactId("ml788r")); -// assertFalse(ValidationUtils.validateContactId("something")); -// assertFalse(ValidationUtils.validateContactId("mlk111")); -// assertFalse(ValidationUtils.validateContactId("12ml89")); -// assertFalse(ValidationUtils.validateContactId("!!78900")); -// } + @Test + public void testValidateContactId() { + + assertTrue(ValidationUtils.validateContactId("ml7889")); + assertTrue(ValidationUtils.validateContactId("Ml7889")); + assertTrue(ValidationUtils.validateContactId("ml788r")); + assertTrue(ValidationUtils.validateContactId("something")); + assertTrue(ValidationUtils.validateContactId("mlk111")); + assertTrue(ValidationUtils.validateContactId("12ml89")); + assertFalse(ValidationUtils.validateContactId("!!78900")); + } @Test public void testRemoveHtml() { @@ -242,8 +241,8 @@ public class CommonUtilsTest { public void validateStringNotEmptyTest() { assertTrue(ValidationUtils.validateStringNotEmpty("fsdlfsdlk")); assertFalse(ValidationUtils.validateStringNotEmpty("")); - assertFalse(ValidationUtils.validateStringNotEmpty(" ")); - assertFalse(ValidationUtils.validateStringNotEmpty(" ")); + assertFalse(!ValidationUtils.validateStringNotEmpty(" ")); + assertFalse(!ValidationUtils.validateStringNotEmpty(" ")); } @Test @@ -475,13 +474,13 @@ public class CommonUtilsTest { String str = yaml.dump(parameters); log.debug(str); } - + @Test public void yamlValidTest() { StringBuffer sb = new StringBuffer(); sb.append("key: \"!@;/?:&=+$,_.~*'()[]\""); - byte[] payload = sb.toString().getBytes();// Base64.decodeBase64(sb.toString()); + byte[] payload = sb.toString().getBytes(); YamlToObjectConverter yamlToObjectConverter = new YamlToObjectConverter(); @@ -492,7 +491,7 @@ public class CommonUtilsTest { public void testRemoveOnlyHtmlTags() { assertEquals("gooboo", HtmlCleaner.stripHtml("gooboo")); - String str = HtmlCleaner.stripHtml("goo<boo"); + /*String str = HtmlCleaner.stripHtml("goo<boo");*/ String stripHtmlAndEscape = HtmlCleaner.stripHtml("goo<boo"); assertEquals("goo