2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 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 * ============LICENSE_END=========================================================
24 package org.onap.appc.design.validator;
26 import java.io.InputStream;
27 import java.util.Enumeration;
28 import java.util.HashMap;
29 import java.util.Properties;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.onap.appc.design.services.util.DesignServiceConstants;
33 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
34 import org.slf4j.Logger;
35 import org.slf4j.LoggerFactory;
36 import junit.framework.Assert;
38 public class TestValidatorService {
42 private final Logger logger = LoggerFactory.getLogger(TestValidatorService.class);
44 public void testValidXMLValidation(){
45 String response = null;
46 String xmlString = "<xml><configure>" + "<operation>create</operation>" + "<base>" + "<request-information>"
47 + "<source>SDN-GP</source>" + "</request-information>" + "</base>" + "</configure>" + "</xml>";
49 ValidatorService vs = new ValidatorService();
51 response = vs.execute("", xmlString, "XML");
52 } catch (Exception e) {
54 Assert.assertEquals("success", response);
58 public void testInvalidXMLValidation() {
59 String response = null;
60 String xmlString = "<xml><configure>" + "<operation>create</operation>" + "<base>" + "<request-information>"
61 + "<source>SDN-GP</source>" + "</request-information>" + "</configure>" + "</xml>";
63 ValidatorService vs = new ValidatorService();
65 response = vs.execute("", xmlString, "XML");
66 } catch (Exception e) {
68 Assert.assertEquals(null, response);
71 public void testYAMLValidation() {
72 String response = null;
73 String YAMLString = "en:";
74 ValidatorService vs = new ValidatorService();
76 response = vs.execute("", YAMLString, "YAML");
77 } catch (Exception e) {
79 Assert.assertEquals("success", response);
82 public void testInvalidYAMLValidation() {
83 String response = null;
84 String YAMLString = "Test \n A:";
85 ValidatorService vs = new ValidatorService();
87 response = vs.execute("", YAMLString, "YAML");
88 } catch (Exception e) {
91 Assert.assertEquals(null, response);
95 public void testJSONValidation(){
96 String response = null;
97 String YAMLString = "{\"Test\": \"Test1\" }";
99 ValidatorService vs = new ValidatorService();
101 response = vs.execute("", YAMLString, "JSON");
102 } catch (Exception e) {
104 Assert.assertEquals("success", response);
107 public void testInvalidJSONValidation(){
108 String response = null;
109 String YAMLString = "{\"Test\" \"Test1\" }";
110 ValidatorService vs = new ValidatorService();
112 response = vs.execute("", YAMLString, "JSON");
113 } catch (Exception e) {
115 Assert.assertEquals(null, response);
119 public void testInvalidvalidateVelocity(){
120 String response = null;
121 String validateVelocity = "{\"Test\" \"Test1\" }";
122 ValidatorService vs = new ValidatorService();
124 response = vs.execute("", validateVelocity, "Velocity");
125 } catch (Exception e) {
127 Assert.assertEquals(null, response);