aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTal Gitelman <tal.gitelman@att.com>2018-11-25 11:49:39 +0200
committerMichael Lando <michael.lando@intl.att.com>2018-11-26 17:17:39 +0000
commit6535675526d608c835f4702b2ee57799da250fbe (patch)
tree222d55438b2ee56938d50b593c04f455b4d7ffe9
parent2bcd93a5879b9bfd8613061e5aba0656519d37a6 (diff)
SDC can not handle complex string in tosca yaml
Issue-ID: SDC-1918 Change-Id: I86957b5d4bf0dab5ca749623efbccd6f4b535f10 Signed-off-by: Tal Gitelman <tal.gitelman@att.com>
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java2
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java30
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/test/CommonUtilsTest.java2
-rw-r--r--test-apis-ci/pom.xml2
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarToscaTester.java2
5 files changed, 33 insertions, 5 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java
index e8169006d2..d128d5349f 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java
@@ -198,7 +198,7 @@ public class PropertyConvertor {
}
private boolean valueStartsWithNonJsonChar(String value) {
- return value.startsWith("/") || value.startsWith(":");
+ return value.startsWith("/") || value.startsWith(":") || value.startsWith("#");
}
public void convertAndAddValue(Map<String, DataTypeDefinition> dataTypes,
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java
index 0ee097b979..adfa457166 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/ValidationUtils.java
@@ -259,7 +259,35 @@ public class ValidationUtils {
}
public static String normaliseWhitespace(String str) {
- return StringUtil.normaliseWhitespace(str);
+ StringBuilder sb = new StringBuilder(str.length());
+ appendNormalisedWhitespace(sb, str, false);
+ return sb.toString();
+ }
+
+ private static void appendNormalisedWhitespace(StringBuilder accum, String string, boolean stripLeading) {
+ boolean lastWasWhite = false;
+ boolean reachedNonWhite = false;
+
+ int len = string.length();
+ int c;
+ for (int i = 0; i < len; i+= Character.charCount(c)) {
+ c = string.codePointAt(i);
+ if (isWhitespace(c)) {
+ if ((stripLeading && !reachedNonWhite) || lastWasWhite)
+ continue;
+ accum.append(' ');
+ lastWasWhite = true;
+ }
+ else {
+ accum.appendCodePoint(c);
+ lastWasWhite = false;
+ reachedNonWhite = true;
+ }
+ }
+ }
+
+ private static boolean isWhitespace(int c){
+ return c == ' ';
}
public static String stripOctets(String str) {
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 e59f6a061f..9806bffc5e 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
@@ -146,7 +146,7 @@ public class CommonUtilsTest {
public void testnormaliseWhitespace() {
assertEquals("goo boo", ValidationUtils.normaliseWhitespace("goo boo"));
- assertEquals("goo boo ", ValidationUtils.normaliseWhitespace("goo boo "));
+ assertEquals("goo boo ", ValidationUtils.normaliseWhitespace("goo boo "));
assertEquals("goo boo", ValidationUtils.normaliseWhitespace("goo boo"));
}
diff --git a/test-apis-ci/pom.xml b/test-apis-ci/pom.xml
index c66f98a48e..156e8ccc15 100644
--- a/test-apis-ci/pom.xml
+++ b/test-apis-ci/pom.xml
@@ -302,7 +302,7 @@
<dependency>
<groupId>org.onap.sdc.sdc-tosca</groupId>
<artifactId>sdc-tosca</artifactId>
- <version>1.4.1</version>
+ <version>1.4.6</version>
<scope>compile</scope>
</dependency>
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarToscaTester.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarToscaTester.java
index 0b62f4a2d0..7ea59ab486 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarToscaTester.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/CsarToscaTester.java
@@ -1,9 +1,9 @@
package org.openecomp.sdc.ci.tests.utils;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.tosca.parser.enums.SdcTypes;
import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
-import org.onap.sdc.tosca.parser.impl.SdcTypes;
import org.onap.sdc.toscaparser.api.Group;
import org.onap.sdc.toscaparser.api.NodeTemplate;
import org.onap.sdc.toscaparser.api.elements.Metadata;