[AAI] Fix doc config files
[aai/aai-common.git] / aai-core / src / test / java / org / onap / aai / introspection / validation / IntrospectorValidationTest.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *    http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.aai.introspection.validation;
22
23 import static org.junit.Assert.assertEquals;
24
25 import java.util.List;
26
27 import org.junit.Before;
28 import org.junit.Ignore;
29 import org.junit.Test;
30 import org.onap.aai.AAISetup;
31 import org.onap.aai.exceptions.AAIException;
32 import org.onap.aai.introspection.*;
33 import org.onap.aai.introspection.tools.IntrospectorValidator;
34 import org.onap.aai.introspection.tools.Issue;
35 import org.onap.aai.introspection.tools.IssueType;
36 import org.onap.aai.serialization.queryformats.QueryFormatTestHelper;
37 import org.onap.aai.util.AAIConstants;
38 import org.springframework.beans.factory.annotation.Autowired;
39
40 public class IntrospectorValidationTest extends AAISetup {
41
42     private final static ModelType introspectorFactoryType = ModelType.MOXY;
43     private Loader loader;
44     private IntrospectorValidator validator;
45     @Autowired
46     private LoaderFactory loaderFactory;
47
48     @Before
49     public void createValidator() throws Exception {
50         System.setProperty("AJSC_HOME", ".");
51         System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
52         loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getRelatedLinkVersion());
53         validator = new IntrospectorValidator.Builder().validateRequired(false).restrictDepth(10000).build();
54     }
55
56     @Ignore
57     @Test
58     public void verifySuccessWhenEmpty() throws AAIException {
59         Introspector obj = loader.introspectorFromName("generic-vnf");
60         obj.setValue("vnf-id", "key1");
61         validator.validate(obj);
62         List<Issue> issues = validator.getIssues();
63         assertEquals("no issues found", true, issues.isEmpty());
64     }
65
66     @Ignore
67     @Test
68     public void verifyRequiresSingleFieldFailure() throws AAIException {
69         Introspector obj = loader.introspectorFromName("generic-vnf");
70         obj.setValue("vnf-id", "key1");
71         obj.setValue("model-invariant-id", "id1");
72         validator.validate(obj);
73         List<Issue> issues = validator.getIssues();
74         assertEquals("issues found", true, issues.size() == 1);
75         Issue issue = issues.get(0);
76         assertEquals("found expected issue", IssueType.DEPENDENT_PROP_NOT_FOUND, issue.getType());
77     }
78
79     @Ignore
80     @Test
81     public void verifyRequiresSuccess() throws AAIException {
82         Introspector obj = loader.introspectorFromName("generic-vnf");
83         obj.setValue("vnf-id", "key1");
84         obj.setValue("model-invariant-id", "id1");
85         obj.setValue("model-version-id", "version-id1");
86         validator.validate(obj);
87         List<Issue> issues = validator.getIssues();
88         assertEquals("no issues found", true, issues.isEmpty());
89     }
90 }