2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.aai.introspection.tools;
23 import static org.junit.Assert.assertFalse;
24 import static org.junit.Assert.assertTrue;
26 import org.junit.Before;
27 import org.junit.Test;
28 import org.onap.aai.AAISetup;
29 import org.onap.aai.introspection.*;
30 import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
31 import org.springframework.test.annotation.DirtiesContext;
33 @DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
34 public class CreateUUIDTest extends AAISetup {
36 private CreateUUID createUUID;
38 private Loader loader;
43 createUUID = new CreateUUID();
44 loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion());
48 * Tests to check if the issue is not resolvable since
49 * the property that is being tested doesn't have the auto generated uuid
50 * metadata set to true in the oxm xml for the version specified
52 * @throws AAIUnknownObjectException - if the object type specified is unable to be found in the oxm
55 public void testNonResolvableIssueIfMissingPropNameThatIsRequired() throws AAIUnknownObjectException {
57 Introspector introspector = loader.introspectorFromName("pserver");
60 issue.setDetail("Some message");
61 issue.setType(IssueType.MISSING_KEY_PROP);
62 issue.setPropName("hostname");
63 issue.setIntrospector(introspector);
65 boolean isIssue = createUUID.resolveIssue(issue);
71 * Tests when there is a resolvable issue when the property
72 * looking for, model-element-uuid, has the auto generated uuid
73 * metadata attribute associated to it if the data is missing
75 * @throws AAIUnknownObjectException - if the object type specified is unable to be found in the oxm
78 public void testResolvableIssueWhenMissingPropNameAllowsToUseGeneratedUUID() throws AAIUnknownObjectException {
80 Introspector introspector = loader.introspectorFromName("model-element");
83 issue.setDetail("Some message");
84 issue.setType(IssueType.MISSING_KEY_PROP);
85 issue.setPropName("model-element-uuid");
86 issue.setIntrospector(introspector);
88 boolean isIssue = createUUID.resolveIssue(issue);