Merge "[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.springframework.beans.factory.annotation.Autowired;
37
38 public class IntrospectorValidationTest extends AAISetup {
39
40     private final static ModelType introspectorFactoryType = ModelType.MOXY;
41     private Loader loader;
42     private IntrospectorValidator validator;
43     @Autowired
44     private LoaderFactory loaderFactory;
45
46     @Before
47     public void createValidator() throws Exception {
48         System.setProperty("AJSC_HOME", ".");
49         System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local");
50         loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getRelatedLinkVersion());
51         validator = new IntrospectorValidator.Builder().validateRequired(false).restrictDepth(10000).build();
52     }
53
54     @Ignore
55     @Test
56     public void verifySuccessWhenEmpty() throws AAIException {
57         Introspector obj = loader.introspectorFromName("generic-vnf");
58         obj.setValue("vnf-id", "key1");
59         validator.validate(obj);
60         List<Issue> issues = validator.getIssues();
61         assertEquals("no issues found", true, issues.isEmpty());
62     }
63
64     @Ignore
65     @Test
66     public void verifyRequiresSingleFieldFailure() throws AAIException {
67         Introspector obj = loader.introspectorFromName("generic-vnf");
68         obj.setValue("vnf-id", "key1");
69         obj.setValue("model-invariant-id", "id1");
70         validator.validate(obj);
71         List<Issue> issues = validator.getIssues();
72         assertEquals("issues found", true, issues.size() == 1);
73         Issue issue = issues.get(0);
74         assertEquals("found expected issue", IssueType.DEPENDENT_PROP_NOT_FOUND, issue.getType());
75     }
76
77     @Ignore
78     @Test
79     public void verifyRequiresSuccess() throws AAIException {
80         Introspector obj = loader.introspectorFromName("generic-vnf");
81         obj.setValue("vnf-id", "key1");
82         obj.setValue("model-invariant-id", "id1");
83         obj.setValue("model-version-id", "version-id1");
84         validator.validate(obj);
85         List<Issue> issues = validator.getIssues();
86         assertEquals("no issues found", true, issues.isEmpty());
87     }
88 }