2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
 
   6  * ================================================================================
 
   7  * Copyright (C) 2017 Amdocs
 
   8  * =============================================================================
 
   9  * Licensed under the Apache License, Version 2.0 (the "License");
 
  10  * you may not use this file except in compliance with the License.
 
  11  * You may obtain a copy of the License at
 
  13  *      http://www.apache.org/licenses/LICENSE-2.0
 
  15  * Unless required by applicable law or agreed to in writing, software
 
  16  * distributed under the License is distributed on an "AS IS" BASIS,
 
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  18  * See the License for the specific language governing permissions and
 
  19  * limitations under the License.
 
  21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
 
  22  * ============LICENSE_END=========================================================
 
  25 package org.onap.appc.design.validator;
 
  27 import java.io.InputStream;
 
  28 import java.util.Enumeration;
 
  29 import java.util.HashMap;
 
  30 import java.util.Properties;
 
  31 import org.junit.Before;
 
  32 import org.junit.Test;
 
  33 import org.onap.appc.design.services.util.DesignServiceConstants;
 
  34 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
 
  35 import org.slf4j.Logger;
 
  36 import org.slf4j.LoggerFactory;
 
  37 import junit.framework.Assert;
 
  39 public class TestValidatorService {
 
  43     private final Logger logger = LoggerFactory.getLogger(TestValidatorService.class);
 
  45     public void testValidXMLValidation(){
 
  46         String response = null;
 
  47         String xmlString = "<xml><configure>" + "<operation>create</operation>" + "<base>" + "<request-information>"
 
  48                 + "<source>SDN-GP</source>" + "</request-information>" + "</base>" + "</configure>" + "</xml>";
 
  50         ValidatorService vs = new ValidatorService();
 
  52             response = vs.execute("", xmlString, "XML");
 
  53         } catch (Exception e) {
 
  55         Assert.assertEquals("success", response);
 
  59     public void testInvalidXMLValidation() {
 
  60         String response = null;
 
  61         String xmlString = "<xml><configure>" + "<operation>create</operation>" + "<base>" + "<request-information>"
 
  62                 + "<source>SDN-GP</source>" + "</request-information>" + "</configure>" + "</xml>";
 
  64         ValidatorService vs = new ValidatorService();
 
  66             response = vs.execute("", xmlString, "XML");
 
  67         } catch (Exception e) {
 
  69         Assert.assertEquals(null, response);
 
  72     public void testYAMLValidation() {
 
  73         String response = null;
 
  74         String YAMLString = "en:";
 
  75         ValidatorService vs = new ValidatorService();
 
  77             response = vs.execute("", YAMLString, "YAML");
 
  78         } catch (Exception e) {
 
  80         Assert.assertEquals("success", response);
 
  83     public void testInvalidYAMLValidation()  {
 
  84         String response = null;
 
  85         String YAMLString = "Test \n A:";
 
  86         ValidatorService vs = new ValidatorService();
 
  88             response = vs.execute("", YAMLString, "YAML");
 
  89         } catch (Exception e) {
 
  92         Assert.assertEquals(null, response);
 
  96     public void testJSONValidation(){
 
  97         String response = null;
 
  98         String YAMLString = "{\"Test\": \"Test1\" }";
 
 100         ValidatorService vs = new ValidatorService();
 
 102             response = vs.execute("", YAMLString, "JSON");
 
 103         } catch (Exception e) {
 
 105         Assert.assertEquals("success", response);
 
 108     public void testInvalidJSONValidation(){
 
 109         String response = null;
 
 110         String YAMLString = "{\"Test\" \"Test1\" }";
 
 111         ValidatorService vs = new ValidatorService();
 
 113             response = vs.execute("", YAMLString, "JSON");
 
 114         } catch (Exception e) {
 
 116         Assert.assertEquals(null, response);
 
 120     public void testInvalidvalidateVelocity(){
 
 121         String response = null;
 
 122         String validateVelocity = "{\"Test\" \"Test1\" }";
 
 123         ValidatorService vs = new ValidatorService();
 
 125             response = vs.execute("", validateVelocity, "Velocity");
 
 126         } catch (Exception e) {
 
 128         Assert.assertEquals(null, response);