remove mac validation 57/55857/1
authorTufman, Shay (st198j) <st198j@intl.att.com>
Wed, 4 Jul 2018 13:44:47 +0000 (16:44 +0300)
committerTufman, Shay (st198j) <st198j@intl.att.com>
Wed, 4 Jul 2018 14:27:40 +0000 (17:27 +0300)
remove max conformance level validation

Change-Id: I09672789d6819b52010bc6f1383e0eca25e664e1
Issue-ID: SDC-1465
Signed-off-by: Tufman, Shay (st198j) <st198j@intl.att.com>
src/main/java/org/onap/sdc/tosca/parser/impl/SdcToscaParserFactory.java
src/main/resources/config/configuration.yaml
src/main/resources/config/error-configuration.yaml
src/test/java/org/onap/sdc/impl/ToscaParserErrorHandlingTest.java
src/test/resources/config/error-configuration-test.yaml
src/test/resources/config/error-configuration.yaml
src/test/resources/csars/service-max-conformence-level.csar [new file with mode: 0644]

index bc8d1b1..3293a58 100644 (file)
@@ -10,7 +10,6 @@ import org.onap.sdc.tosca.parser.config.JToscaValidationIssueInfo;
 import org.onap.sdc.tosca.parser.config.SdcToscaParserErrors;
 import org.onap.sdc.tosca.parser.utils.GeneralUtility;
 import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
-import org.onap.sdc.tosca.parser.config.*;
 import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
 import org.onap.sdc.toscaparser.api.ToscaTemplate;
 import org.onap.sdc.toscaparser.api.common.JToscaValidationIssue;
@@ -170,13 +169,12 @@ public class SdcToscaParserFactory {
        private void validateCsarVersion(String cSarVersion) throws SdcToscaParserException {
         ConformanceLevel level = configurationManager.getConfiguration().getConformanceLevel();
         String minVersion = level.getMinVersion();
-        String maxVersion = level.getMaxVersion();
         if (cSarVersion != null) {
-            if ((GeneralUtility.conformanceLevelCompare(cSarVersion, minVersion) < 0) || (GeneralUtility.conformanceLevelCompare(cSarVersion, maxVersion) > 0)) {
-                throwConformanceLevelException(minVersion, maxVersion);
+            if (GeneralUtility.conformanceLevelCompare(cSarVersion, minVersion) < 0) {
+                throwConformanceLevelException(minVersion);
             }
         } else {
-            throwConformanceLevelException(minVersion, maxVersion);
+            throwConformanceLevelException(minVersion);
         }
     }
 
@@ -188,9 +186,9 @@ public class SdcToscaParserFactory {
         }
         return false;
     }
-    private void throwConformanceLevelException(String minVersion, String maxVersion) throws SdcToscaParserException {
+    private void throwConformanceLevelException(String minVersion) throws SdcToscaParserException {
         ErrorInfo errorInfo = configurationManager.getErrorConfiguration().getErrorInfo(SdcToscaParserErrors.CONFORMANCE_LEVEL_ERROR.toString());
-        throw new SdcToscaParserException(String.format(errorInfo.getMessage(), minVersion, maxVersion), errorInfo.getCode());
+        throw new SdcToscaParserException(String.format(errorInfo.getMessage(), minVersion), errorInfo.getCode());
     }
 
     private void throwSdcToscaParserException(JToscaException e) throws SdcToscaParserException {
index e5e28f2..9872ff0 100644 (file)
@@ -1,3 +1,3 @@
 conformanceLevel:
   minVersion: '3.0'
-  maxVersion: '8.0'
\ No newline at end of file
+  maxVersion: '9.0'
\ No newline at end of file
index 58d1de3..ff9c6ed 100644 (file)
@@ -13,7 +13,7 @@ errors:
     CONFORMANCE_LEVEL_ERROR: {
         code: TP0003,
         failOnError: true,
-        message: "Error: CSAR version is unsupported. Parser supports versions %s to %s." 
+        message: "Error: CSAR version is unsupported. Parser supports versions from %s."
     }
     GENERAL_ERROR: {
         code: TP0004,
index d022a1a..1e0dd0a 100644 (file)
@@ -9,48 +9,6 @@ import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
 import org.onap.sdc.toscaparser.api.utils.JToscaErrorCodes;
 
 
-/*put(JToscaErrorCodes.GENERAL_ERROR, GENERAL_ERROR);
-
-put(JToscaErrorCodes.PATH_NOT_VALID, FILE_NOT_FOUND);
-//CSAR contents problems
-put(JToscaErrorCodes.MISSING_META_FILE, BAD_FORMAT);
-put(JToscaErrorCodes.INVALID_META_YAML_CONTENT, BAD_FORMAT);
-put(JToscaErrorCodes.ENTRY_DEFINITION_NOT_DEFINED, BAD_FORMAT);
-put(JToscaErrorCodes.MISSING_ENTRY_DEFINITION_FILE, BAD_FORMAT);
-put(JToscaErrorCodes.CSAR_TOSCA_VALIDATION_ERROR, BAD_FORMAT);
-
- MISSING_META_FILE("JT1001"),
-/*     INVALID_META_YAML_CONTENT("JT1002"),
-/*     ENTRY_DEFINITION_NOT_DEFINED("JT1003"),
-/*     MISSING_ENTRY_DEFINITION_FILE("JT1004"),
-/*     GENERAL_ERROR("JT1005"),
-/*     PATH_NOT_VALID("JT1006"),
-/*     CSAR_TOSCA_VALIDATION_ERROR("JT1007");
-
-*/
-
-/*
- * 
- * # Errors
-errors:
-    FILE_NOT_FOUND: {
-        code: TP0001,
-        message: "Error: CSAR file not found."
-    }
-    BAD_FORMAT: {
-        code: TP0002,
-        message: "Error: CSAR file bad format. Check the log for details."
-    }
-    CONFORMANCE_LEVEL_ERROR: {
-        code: TP0003,
-        message: "Error: CSAR version is unsupported. Parser supports versions %s to %s." 
-    }
-    GENERAL_ERROR: {
-        code: TP0004,
-        message: "Error: an unexpected internal error occured."
-    }
- * 
- */
 
 public class ToscaParserErrorHandlingTest extends SdcToscaParserBasicTest {
        
@@ -102,13 +60,23 @@ public class ToscaParserErrorHandlingTest extends SdcToscaParserBasicTest {
        }
        
        @Test
-       public void testInValidConformanceLevelError(){
+       public void testInValidMinConformanceLevelError(){
                String csarPath = "csars/service-invalid-conformence-level.csar";
                String fileLocationString = ToscaParserErrorHandlingTest.class.getClassLoader().getResource(csarPath).getFile();
         File file = new File(fileLocationString);
                Throwable captureThrowable = captureThrowable(file.getAbsolutePath());
                testThrowable(captureThrowable, "TP0003");
        }
+
+       @Test
+       public void testIgnoreMaxConformanceLevelNoError(){
+               String csarPath = "csars/service-max-conformence-level.csar";
+               //TODO: Currently, the conformentce level of the csar for this test is 99 (hard coded). Consider to add ability to replace the configuration in run time.
+               String fileLocationString = ToscaParserErrorHandlingTest.class.getClassLoader().getResource(csarPath).getFile();
+               File file = new File(fileLocationString);
+               Throwable captureThrowable = captureThrowable(file.getAbsolutePath());
+               assertNull(captureThrowable);
+       }
        
        @Test
        public void testFileNotFound(){
index f5c20aa..de603c6 100644 (file)
@@ -13,7 +13,7 @@ errors:
     CONFORMANCE_LEVEL_ERROR: {
         code: TP0003,
         failOnError: false,
-        message: "Error: CSAR version is unsupported. Parser supports versions %s to %s." 
+        message: "Error: CSAR version is unsupported. Parser supports versions from %s."
     }
     GENERAL_ERROR: {
         code: TP0004,
index 44173cd..296c681 100644 (file)
@@ -13,7 +13,7 @@ errors:
     CONFORMANCE_LEVEL_ERROR: {
         code: TP0003,
         failOnError: true,
-        message: "Error: CSAR version is unsupported. Parser supports versions %s to %s." 
+        message: "Error: CSAR version is unsupported. Parser supports versions from %s."
     }
     GENERAL_ERROR: {
         code: TP0004,
diff --git a/src/test/resources/csars/service-max-conformence-level.csar b/src/test/resources/csars/service-max-conformence-level.csar
new file mode 100644 (file)
index 0000000..0cbb872
Binary files /dev/null and b/src/test/resources/csars/service-max-conformence-level.csar differ