diff options
Diffstat (limited to 'src')
30 files changed, 255 insertions, 658 deletions
diff --git a/src/main/java/org/onap/aai/validation/ValidationServiceApplication.java b/src/main/java/org/onap/aai/validation/ValidationServiceApplication.java index 409e375..103c6cb 100644 --- a/src/main/java/org/onap/aai/validation/ValidationServiceApplication.java +++ b/src/main/java/org/onap/aai/validation/ValidationServiceApplication.java @@ -19,31 +19,61 @@ package org.onap.aai.validation; import java.util.HashMap; import java.util.Map; +import javax.annotation.PostConstruct; +import org.apache.commons.lang.StringUtils; import org.eclipse.jetty.util.security.Password; -import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.onap.aai.validation.config.TopicPropertiesConfig; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.support.SpringBootServletInitializer; -import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; import org.springframework.context.annotation.ImportResource; +import org.springframework.core.env.Environment; /** * Validation Service Spring Boot Application. */ -@SpringBootApplication -@ComponentScan(basePackages = "org.onap.aai.validation.config") +@Configuration +@EnableAutoConfiguration +@Import(TopicPropertiesConfig.class) @ImportResource("classpath:validation-service-beans.xml") public class ValidationServiceApplication extends SpringBootServletInitializer { + @Autowired + private Environment env; + public static void main(String[] args) { Map<String, Object> props = new HashMap<>(); String keyStorePassword = System.getProperty("KEY_STORE_PASSWORD"); - if (keyStorePassword != null && !keyStorePassword.isEmpty()) { - props.put("server.ssl.key-store-password", Password.deobfuscate(keyStorePassword)); + if (StringUtils.isEmpty(keyStorePassword)) { + throw new IllegalArgumentException("System Property KEY_STORE_PASSWORD not set"); } + String deobfuscated = Password.deobfuscate(keyStorePassword); + props.put("server.ssl.key-store-password", deobfuscated); + props.put("schema.service.ssl.key-store-password", deobfuscated); + props.put("schema.service.ssl.trust-store-password", deobfuscated); new ValidationServiceApplication() .configure(new SpringApplicationBuilder(ValidationServiceApplication.class).properties(props)) .run(args); } + /** + * Set the trust store system properties using default values from the application properties. + */ + @PostConstruct + public void setSystemProperties() { + String trustStorePath = env.getProperty("server.ssl.key-store"); + if (trustStorePath != null) { + String trustStorePassword = env.getProperty("server.ssl.key-store-password"); + if (trustStorePassword != null) { + System.setProperty("javax.net.ssl.trustStore", trustStorePath); + System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword); + } else { + throw new IllegalArgumentException("Env property server.ssl.key-store-password not set"); + } + } + } } diff --git a/src/main/java/org/onap/aai/validation/config/TopicConfig.java b/src/main/java/org/onap/aai/validation/config/TopicConfig.java index 327db5e..a167672 100644 --- a/src/main/java/org/onap/aai/validation/config/TopicConfig.java +++ b/src/main/java/org/onap/aai/validation/config/TopicConfig.java @@ -26,13 +26,11 @@ import javax.annotation.Resource; import org.apache.commons.lang3.builder.EqualsBuilder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; /** * Gets the configuration of the topics. The topics are configured using Spring in topic-config-beans.xml. */ -@Component("TopicConfig") public class TopicConfig { private List<String> consumerTopicNames; diff --git a/src/main/java/org/onap/aai/validation/reader/OxmConfigTranslator.java b/src/main/java/org/onap/aai/validation/reader/OxmConfigTranslator.java deleted file mode 100644 index 53be6dd..0000000 --- a/src/main/java/org/onap/aai/validation/reader/OxmConfigTranslator.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs - * ============================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END===================================================== - */ -package org.onap.aai.validation.reader; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.PathMatcher; -import java.nio.file.Paths; -import java.util.List; -import java.util.Map; -import java.util.ServiceConfigurationError; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import org.onap.aai.setup.ConfigTranslator; -import org.onap.aai.setup.SchemaLocationsBean; -import org.onap.aai.setup.Version; - -/** - * Determine which OXM and edge rules files to return based on the latest Version - * - */ -public class OxmConfigTranslator extends ConfigTranslator { - - public OxmConfigTranslator(SchemaLocationsBean bean) { - super(bean); - } - - @Override - public Map<Version, List<String>> getNodeFiles() { - String nodeDirectory = bean.getNodeDirectory(); - if (nodeDirectory == null) { - throw new ServiceConfigurationError( - "Node(s) directory is empty in the schema location bean (" + bean.getSchemaConfigLocation() + ")"); - } - try { - return getVersionMap(Paths.get(nodeDirectory), "*_v*.xml"); - } catch (IOException e) { - throw new ServiceConfigurationError("Failed to read node(s) directory " + getPath(nodeDirectory), e); - } - } - - @Override - public Map<Version, List<String>> getEdgeFiles() { - String edgeDirectory = bean.getEdgeDirectory(); - if (edgeDirectory == null) { - throw new ServiceConfigurationError( - "Edge(s) directory is empty in the schema location bean (" + bean.getSchemaConfigLocation() + ")"); - } - try { - return getVersionMap(Paths.get(edgeDirectory), "*_v*.json"); - } catch (IOException e) { - throw new ServiceConfigurationError("Failed to read edge(s) directory " + getPath(edgeDirectory), e); - } - } - - private String getPath(String nodeDirectory) { - return Paths.get(nodeDirectory).toAbsolutePath().toString(); - } - - /** - * Creates a map containing each OXM Version and the matching OXM file path(s) - * - * @param folderPath the folder/directory containing the OXM files - * @param fileSuffix - * @return a new Map object (may be empty) - * @throws IOException if there is a problem reading the specified directory path - */ - private Map<Version, List<String>> getVersionMap(Path folderPath, String globPattern) throws IOException { - final PathMatcher filter = folderPath.getFileSystem().getPathMatcher("glob:**/" + globPattern); - try (final Stream<Path> stream = Files.list(folderPath)) { - return stream.filter(filter::matches).map(Path::toString).filter(p -> getVersionFromPath(p) != null) - .collect(Collectors.groupingBy(this::getVersionFromPath)); - } - } - - private Version getVersionFromPath(String pathName) { - String version = "V" + pathName.replaceAll("\\D+", ""); - try { - return Version.valueOf(version); - } catch (IllegalArgumentException e) { - return null; - } - } -} diff --git a/src/main/java/org/onap/aai/validation/reader/OxmReader.java b/src/main/java/org/onap/aai/validation/reader/OxmReader.java index b8343f1..a62e7db 100644 --- a/src/main/java/org/onap/aai/validation/reader/OxmReader.java +++ b/src/main/java/org/onap/aai/validation/reader/OxmReader.java @@ -1,4 +1,4 @@ -/* +/** * ============LICENSE_START=================================================== * Copyright (c) 2018 Amdocs * ============================================================================ @@ -6,7 +6,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -25,7 +25,7 @@ import java.util.ServiceConfigurationError; import org.eclipse.persistence.internal.oxm.mappings.Descriptor; import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext; import org.onap.aai.nodes.NodeIngestor; -import org.onap.aai.setup.Version; +import org.onap.aai.setup.SchemaVersion; import org.onap.aai.validation.exception.ValidationServiceError; import org.onap.aai.validation.exception.ValidationServiceException; import org.onap.aai.validation.util.StringUtils; @@ -36,18 +36,14 @@ import org.onap.aai.validation.util.StringUtils; public class OxmReader { private NodeIngestor nodeIngestor; - private Version version; + private SchemaVersion version; private Map<String, List<String>> primaryKeysMap = new HashMap<>(); - public OxmReader(NodeIngestor nodeIngestor, Version version) { + public OxmReader(NodeIngestor nodeIngestor, SchemaVersion version) { this.nodeIngestor = nodeIngestor; this.version = version; } - public OxmReader(NodeIngestor nodeIngestor) { - this(nodeIngestor, Version.getLatest()); - } - /** * Get the primary keys for a given entity type. * diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 44df999..38b3d34 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,5 +1,5 @@ # ============LICENSE_START=================================================== -# Copyright (c) 2018 Amdocs +# Copyright (c) 2018-2019 Amdocs # ============================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,7 +22,6 @@ com.att.eelf.logging.path=src/main/resources com.att.eelf.logging.file=logback.xml logback.configurationFile=${com.att.eelf.logging.path}/${com.att.eelf.logging.file} -schemaIngestPropLoc=${CONFIG_HOME}/schemaIngest.properties server.port=9501 server.ssl.client-auth=want @@ -42,3 +41,5 @@ publisher.topic.names=poa-audit-result topics.properties.location=${CONFIG_HOME}/topics/ +schema.translator.list=schema-service +spring.application.name=aai-validation
\ No newline at end of file diff --git a/src/main/resources/validation-service-beans.xml b/src/main/resources/validation-service-beans.xml index 862fd13..d0baca2 100644 --- a/src/main/resources/validation-service-beans.xml +++ b/src/main/resources/validation-service-beans.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- ============LICENSE_START=================================================== -Copyright (c) 2018 Amdocs +Copyright (c) 2018-2019 Amdocs ============================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -16,8 +16,8 @@ See the License for the specific language governing permissions and limitations under the License. ============LICENSE_END===================================================== --> -<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:util="http://www.springframework.org/schema/util" +<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd @@ -28,22 +28,34 @@ limitations under the License. <!-- ////////////////////////////////////////////////////////////////// --> <!-- PROPERTY AND CONFIGURATION FILES --> <!-- ////////////////////////////////////////////////////////////////// --> - <context:property-placeholder location="classpath:event-reader.properties" ignore-unresolvable="true" /> - <context:property-placeholder location="file:${CONFIG_HOME}/aai-environment.properties" ignore-unresolvable="true" /> - <context:property-placeholder location="file:${CONFIG_HOME}/validation-service.properties" ignore-unresolvable="true" /> - <context:property-placeholder location="file:${CONFIG_HOME}/validation-service-auth.properties" ignore-unresolvable="true" /> - <context:property-placeholder location="file:${CONFIG_HOME}/rule-indexing.properties" ignore-unresolvable="true" ignore-resource-not-found="true" /> - <context:property-placeholder location="file:${schemaIngestPropLoc}" ignore-unresolvable="true" /> + <context:property-placeholder location="file:${CONFIG_HOME}/rule-indexing.properties" + ignore-unresolvable="true" ignore-resource-not-found="true" /> + <context:property-placeholder + location=" + classpath:event-reader.properties, + file:${CONFIG_HOME}/aai-environment.properties, + file:${CONFIG_HOME}/validation-service.properties, + file:${CONFIG_HOME}/validation-service-auth.properties, + file:${CONFIG_HOME}/schemaIngest.properties" + ignore-unresolvable="true" /> <bean id="mappingFile" class="org.apache.commons.io.IOUtils" factory-method="toString"> - <constructor-arg value="file:${APP_HOME}/bundleconfig/etc/appprops/model-instance-mapping.json_conf" type="java.io.InputStream" /> + <constructor-arg value="file:${APP_HOME}/bundleconfig/etc/appprops/model-instance-mapping.json_conf" + type="java.io.InputStream" /> </bean> - <util:properties id="dataDictionaryProperties" location="file:${CONFIG_HOME}/rule-data-dictionary.properties" /> + <util:properties id="dataDictionaryProperties" location="file:${CONFIG_HOME}/rule-data-dictionary.properties" /> <!-- ////////////////////////////////////////////////////////////////// --> <!-- CONFIG BEANS --> <!-- ////////////////////////////////////////////////////////////////// --> + + <!-- Component scan for schema service components --> + <context:component-scan base-package="org.onap.aai.config,org.onap.aai.setup"> + <!-- Exclude EdgesConfiguration since edge rules are not required --> + <context:exclude-filter type="assignable" expression="org.onap.aai.config.EdgesConfiguration" /> + </context:component-scan> + <bean id="eventReaderConfig" class="org.onap.aai.validation.config.EventReaderConfig"> <property name="eventDomainPath" value="${event.domain.path}" /> <property name="eventActionPath" value="${event.action.path}" /> @@ -77,6 +89,7 @@ limitations under the License. <property name="connectionTimeout" value="${connectionTimeout}" /> <property name="readTimeout" value="${readTimeout}" /> </bean> + <bean id="topicConfig" class="org.onap.aai.validation.config.TopicConfig" /> <bean id="topicAdminConfig" class="org.onap.aai.validation.config.TopicAdminConfig"> <property name="publishEnable" value="${topic.publish.enable}" /> @@ -91,7 +104,7 @@ limitations under the License. <property name="eventTypeRule" value="#{'${event.type.rule}'.split(',')}" /> <property name="eventTypeModel" value="#{'${event.type.model}'.split(',')}" /> </bean> - + <bean id="ruleIndexingConfig" class="org.onap.aai.validation.config.RuleIndexingConfig"> <property name="indexedEvents" value="#{'${rule.indexing.events}'.split(',')}" /> <property name="excludedOxmValidationEvents" value="#{'${rule.indexing.exclude.oxm.validation}'.split(',')}" /> @@ -112,26 +125,18 @@ limitations under the License. </list> </property> </bean> - <!-- ////////////////////////////////////////////////////////////////// --> <!-- READER BEANS --> <!-- ////////////////////////////////////////////////////////////////// --> - <bean id="schemaLocationsBean" class="org.onap.aai.setup.SchemaLocationsBean"> - <property name="nodeDirectory" value="${nodeDir}" /> - <property name="edgeDirectory" value="${edgeDir}" /> - </bean> - - <bean id="configTranslator" class="org.onap.aai.validation.reader.OxmConfigTranslator"> - <constructor-arg ref="schemaLocationsBean" /> - </bean> + <bean id="configTranslator" class="org.onap.aai.setup.AAIConfigTranslator" /> - <bean id="nodeIngestor" class="org.onap.aai.nodes.NodeIngestor"> - <constructor-arg ref="configTranslator" /> + <bean id="schemaVersionBean" class="org.onap.aai.setup.SchemaVersion"> + <constructor-arg value="${schema.version.api.default}" /> </bean> <bean id="oxmReader" class="org.onap.aai.validation.reader.OxmReader" init-method="init"> <constructor-arg ref="nodeIngestor" /> - <constructor-arg value="V${aai.oxm.version}" /> + <constructor-arg ref="schemaVersionBean" /> </bean> <bean id="jsonReader" class="org.onap.aai.validation.reader.JsonReader" /> @@ -177,10 +182,10 @@ limitations under the License. <constructor-arg ref="rulesConfigurationPath" /> <constructor-arg ref="oxmReader" /> <constructor-arg ref="eventReader" /> - <constructor-arg ref="ruleIndexingConfig"/> + <constructor-arg ref="ruleIndexingConfig" /> </bean> - <bean id="restClient" class="org.onap.aai.validation.data.client.RestClient"> + <bean id="aaiRestClient" class="org.onap.aai.validation.data.client.RestClient"> <constructor-arg ref="restConfig" /> </bean> diff --git a/src/main/resources/validation-service-logging-resources.properties b/src/main/resources/validation-service-logging-resources.properties index 21cbff1..c5d1c11 100644 --- a/src/main/resources/validation-service-logging-resources.properties +++ b/src/main/resources/validation-service-logging-resources.properties @@ -86,21 +86,24 @@ MESSAGE_AUDIT=\ LOG0012I|\ {0}|\ |\ - + MESSAGE_METRIC=\ LOG0013I|\ {0}|\ |\ - + MISSING_REQUEST_ID=\ LOG0014I|\ Missing request ID. Assigned {0}|\ + INVALID_EVENT_TYPE=\ LOG0015I|\ Event has not been validated. Invalid event type. Event:{0}|\ + MISSING_EVENT_TYPE=\ LOG0016I|\ Event has not been validated. Missing event type. Event:{0}|\ + FILTERED_EVENT=\ LOG0017I|\ Event has been filtered.Event:{0}|\ @@ -178,13 +181,14 @@ CANNOT_VALIDATE_ERROR=\ CANNOT_VALIDATE_HANDLE_EXCEPTION_ERROR=\ LOG0902E|\ Error during handling the exception for an event that could not be validated: {0}|\ - |\ - + |\ + MALFORMED_REQUEST_ERROR=\ LOG1000E|\ Malformed request.|\ - + PROCESS_REQUEST_ERROR=\ LOG1001E|\ Error while processing request.|\ + diff --git a/src/test/java/org/onap/aai/validation/modeldriven/validator/TestInstanceReader.java b/src/test/java/org/onap/aai/validation/modeldriven/validator/TestInstanceReader.java index 60588bb..38c790b 100644 --- a/src/test/java/org/onap/aai/validation/modeldriven/validator/TestInstanceReader.java +++ b/src/test/java/org/onap/aai/validation/modeldriven/validator/TestInstanceReader.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs + * Copyright (c) 2018-2019 Amdocs * ============================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,6 @@ import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.onap.aai.validation.exception.ValidationServiceException; import org.onap.aai.validation.modeldriven.configuration.mapping.ModelInstanceMapper; -import org.onap.aai.validation.modeldriven.validator.InstanceReader; import org.onap.aai.validation.test.util.TestUtil; import org.onap.aai.validation.util.JsonUtil; import org.springframework.test.context.ContextConfiguration; @@ -43,7 +42,7 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@TestPropertySource(properties = {"schemaIngestPropLoc = src/test/resources/oxm-reader/schemaIngest.properties"}) +@TestPropertySource(locations = { "classpath:oxm-reader/schemaIngest.properties" }) @ContextConfiguration(locations = {"classpath:model-validation/instance-reader/test-validation-service-beans.xml"}) public class TestInstanceReader { @@ -84,22 +83,26 @@ public class TestInstanceReader { enum TestData { // @formatter:off - MAPPING ("model-validation/instance-reader/model-instance-mapping.json_conf"), - MAPPING_ROOT_UNKNOWN ("model-validation/instance-reader/model-instance-mapping-root-unknown.json_conf"), - MAPPING_ROOT_MISSING ("model-validation/instance-reader/model-instance-mapping-root-missing.json_conf"), - CONNECTOR ("model-validation/instance-reader/connector.json"), - CONNECTOR_MODEL_NAME ("model-validation/instance-reader/connector-model-name.json"), - CONNECTOR_SIBLING ("model-validation/instance-reader/connector-sibling-inventory-items.json"), - EXPECTED_VDC ("model-validation/instance-reader/expected-virtual-data-center.json"), - EXPECTED_VDC_MODEL_NAME ("model-validation/instance-reader/expected-virtual-data-center-model-name.json"), - EXPECTED_LOGICAL_LINK ("model-validation/instance-reader/expected-logical-link.json"), - EXPECTED_GENERIC_VNF ("model-validation/instance-reader/expected-generic-vnf.json"), - EXPECTED_PSERVER ("model-validation/instance-reader/expected-pserver.json"); + MAPPING ("model-validation/instance-reader/model-instance-mapping.json_conf"), + MAPPING_ROOT_UNKNOWN ("model-validation/instance-reader/model-instance-mapping-root-unknown.json_conf"), + MAPPING_ROOT_MISSING ("model-validation/instance-reader/model-instance-mapping-root-missing.json_conf"), + CONNECTOR ("model-validation/instance-reader/connector.json"), + CONNECTOR_MODEL_NAME ("model-validation/instance-reader/connector-model-name.json"), + CONNECTOR_SIBLING ("model-validation/instance-reader/connector-sibling-inventory-items.json"), + EXPECTED_VDC ("model-validation/instance-reader/expected-virtual-data-center.json"), + EXPECTED_VDC_MODEL_NAME ("model-validation/instance-reader/expected-virtual-data-center-model-name.json"), + EXPECTED_LOGICAL_LINK ("model-validation/instance-reader/expected-logical-link.json"), + EXPECTED_GENERIC_VNF ("model-validation/instance-reader/expected-generic-vnf.json"), + EXPECTED_PSERVER ("model-validation/instance-reader/expected-pserver.json"); + // @formatter:on private String filename; - TestData(String filename) {this.filename = filename;} - public String getFilename() {return this.filename;} - // @formatter:on + TestData(String filename) { + this.filename = filename; + } + public String getFilename() { + return this.filename; + } } @Rule @@ -161,8 +164,6 @@ public class TestInstanceReader { JsonElement genericVnfJsonElement = jsonParser.parse(expectedGenericVnf); String expectedGenericVnf = genericVnfJsonElement.toString(); - JsonElement pserverJsonElement = jsonParser.parse(expectedPserver); - String expectedPserver = pserverJsonElement.toString(); // Method under test Multimap<String, String> values = instanceReader.getValues(connectorSibling, mapping); @@ -178,7 +179,7 @@ public class TestInstanceReader { values = instanceReader.getValues(logicalLinkInstance, mapping); assertThat(values.get("generic-vnf").iterator().next(), is(equalTo(expectedGenericVnf))); - assertThat(values.get("pserver").iterator().next(), is(equalTo(expectedPserver))); + assertThat(values.get("pserver").iterator().next(), is(equalTo(jsonParser.parse(expectedPserver).toString()))); } @Test diff --git a/src/test/java/org/onap/aai/validation/modeldriven/validator/TestModelDrivenValidator.java b/src/test/java/org/onap/aai/validation/modeldriven/validator/TestModelDrivenValidator.java index cb9de43..de06357 100644 --- a/src/test/java/org/onap/aai/validation/modeldriven/validator/TestModelDrivenValidator.java +++ b/src/test/java/org/onap/aai/validation/modeldriven/validator/TestModelDrivenValidator.java @@ -1,12 +1,12 @@ -/* +/** * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs + * Copyright (c) 2018-2019 Amdocs * ============================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -43,7 +43,6 @@ import org.onap.aai.validation.controller.ValidationController; import org.onap.aai.validation.modeldriven.ModelCacheManager; import org.onap.aai.validation.modeldriven.ModelId; import org.onap.aai.validation.modeldriven.parser.XMLModelParser; -import org.onap.aai.validation.modeldriven.validator.ModelDrivenValidator; import org.onap.aai.validation.result.ValidationResult; import org.onap.aai.validation.result.Violation; import org.onap.aai.validation.test.util.TestUtil; @@ -52,7 +51,7 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@TestPropertySource(properties = {"schemaIngestPropLoc = src/test/resources/oxm-reader/schemaIngest.properties"}) +@TestPropertySource(locations = {"classpath:oxm-reader/schemaIngest.properties"}) @ContextConfiguration(locations = {"classpath:model-validation/instance-validator/test-validation-service-beans.xml"}) public class TestModelDrivenValidator { @@ -74,21 +73,21 @@ public class TestModelDrivenValidator { private String objectInstance; private String connectorModel; - enum INSTANCE_VALIDATION_FILE { + static enum InstanceValidationFile { // @formatter:off - CONNECTOR_MODEL ("model-validation/instance-validator/connector-widget-id.xml"), - NO_MODEL_ID ("model-validation/instance-validator/connector-instance-no-model-id.json"), - UNKNOWN_MODEL_ID ("model-validation/instance-validator/connector-instance-unknown-model-id.json"), - ERRORS ("model-validation/instance-validator/connector-instance-errors.json"), - MULTIPLE_MISSING_ATTRS ("model-validation/instance-validator/connector-instance-multiple-missing-attrs.json"), - MULTIPLE_UNEXPECTED_ATTRS ("model-validation/instance-validator/connector-instance-multiple-unexpected-attrs.json"), - SUCCESS ("model-validation/instance-validator/connector-instance-success.json"); - // @formatter:on + CONNECTOR_MODEL ("connector-widget-id.xml"), + NO_MODEL_ID ("connector-instance-no-model-id.json"), + UNKNOWN_MODEL_ID ("connector-instance-unknown-model-id.json"), + ERRORS ("connector-instance-errors.json"), + MULTIPLE_MISSING_ATTRS ("connector-instance-multiple-missing-attrs.json"), + MULTIPLE_UNEXPECTED_ATTRS ("connector-instance-multiple-unexpected-attrs.json"), + SUCCESS ("connector-instance-success.json"); + // @formatter:on private String filename; - INSTANCE_VALIDATION_FILE(String filename) { - this.filename = filename; + InstanceValidationFile(String filename) { + this.filename = "model-validation/instance-validator/" + filename; } public String getFilename() { @@ -103,12 +102,12 @@ public class TestModelDrivenValidator { @Before public void setUp() throws Exception { - connectorModel = TestUtil.getFileAsString(INSTANCE_VALIDATION_FILE.CONNECTOR_MODEL.getFilename()); + connectorModel = TestUtil.getFileAsString(InstanceValidationFile.CONNECTOR_MODEL.getFilename()); } @Test public void testValidateInstanceWithoutModelId() throws Exception { - objectInstance = TestUtil.getFileAsString(INSTANCE_VALIDATION_FILE.NO_MODEL_ID.getFilename()); + objectInstance = TestUtil.getFileAsString(InstanceValidationFile.NO_MODEL_ID.getFilename()); ValidationResult validationResult = modelDrivenValidator.validate(objectInstance).get(0); assertThatValidationResultIsValid(validationResult, "c7611ebe-c324-48f1-8085-94aef0c12fd", "connector", @@ -123,7 +122,7 @@ public class TestModelDrivenValidator { @Test public void testValidateInstanceWithUnknownModelId() throws Exception { - objectInstance = TestUtil.getFileAsString(INSTANCE_VALIDATION_FILE.UNKNOWN_MODEL_ID.getFilename()); + objectInstance = TestUtil.getFileAsString(InstanceValidationFile.UNKNOWN_MODEL_ID.getFilename()); Mockito.when(mockModelCacheManager.get(new ModelId(MODEL_ID_ATTRIBUTE_MID, "UNKNOWN-MODEL"))).thenReturn(null); @@ -140,7 +139,7 @@ public class TestModelDrivenValidator { @Test public void testValidate() throws Exception { - objectInstance = TestUtil.getFileAsString(INSTANCE_VALIDATION_FILE.ERRORS.getFilename()); + objectInstance = TestUtil.getFileAsString(InstanceValidationFile.ERRORS.getFilename()); Element modelElement = XMLModelParser.parse(connectorModel, true); @@ -186,7 +185,7 @@ public class TestModelDrivenValidator { @Test public void testValidateMultipleMissingAttrs() throws Exception { - objectInstance = TestUtil.getFileAsString(INSTANCE_VALIDATION_FILE.MULTIPLE_MISSING_ATTRS.getFilename()); + objectInstance = TestUtil.getFileAsString(InstanceValidationFile.MULTIPLE_MISSING_ATTRS.getFilename()); Element modelElement = XMLModelParser.parse(connectorModel, true); @@ -209,7 +208,7 @@ public class TestModelDrivenValidator { @Test public void testValidateMultipleUnexpectedAttrs() throws Exception { - objectInstance = TestUtil.getFileAsString(INSTANCE_VALIDATION_FILE.MULTIPLE_UNEXPECTED_ATTRS.getFilename()); + objectInstance = TestUtil.getFileAsString(InstanceValidationFile.MULTIPLE_UNEXPECTED_ATTRS.getFilename()); Element modelElement = XMLModelParser.parse(connectorModel, true); @@ -232,7 +231,7 @@ public class TestModelDrivenValidator { @Test public void testValidateSuccess() throws Exception { - objectInstance = TestUtil.getFileAsString(INSTANCE_VALIDATION_FILE.SUCCESS.getFilename()); + objectInstance = TestUtil.getFileAsString(InstanceValidationFile.SUCCESS.getFilename()); Element modelElement = XMLModelParser.parse(connectorModel, true); diff --git a/src/test/java/org/onap/aai/validation/reader/TestEventReader.java b/src/test/java/org/onap/aai/validation/reader/TestEventReader.java index a41eb76..b7aba5e 100644 --- a/src/test/java/org/onap/aai/validation/reader/TestEventReader.java +++ b/src/test/java/org/onap/aai/validation/reader/TestEventReader.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs + * Copyright (c) 2018-2019 Amdocs * ============================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,6 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.aai.validation.exception.ValidationServiceException; -import org.onap.aai.validation.reader.EventReader; import org.onap.aai.validation.reader.data.Entity; import org.onap.aai.validation.reader.data.EntityId; import org.onap.aai.validation.test.util.TestUtil; @@ -43,7 +42,7 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@TestPropertySource(properties = {"schemaIngestPropLoc = src/test/resources/oxm-reader/schemaIngest.properties"}) +@TestPropertySource(locations = { "classpath:oxm-reader/schemaIngest.properties" }) @ContextConfiguration(locations = {"classpath:event-reader/test-validation-service-beans.xml"}) public class TestEventReader { @@ -77,16 +76,20 @@ public class TestEventReader { // @formatter:off VSERVER ("event-reader/vserver-create-event.json"), GENERIC_VNF ("event-reader/generic-vnf-create-event.json"), - INVALID_1 ("event-reader/invalid-event-1.json"), - INVALID_2 ("event-reader/invalid-event-2.json"), - INVALID_3 ("event-reader/invalid-event-3.json"), - INVALID_4 ("event-reader/invalid-event-4.json"), - INVALID_5 ("event-reader/invalid-event-5.json"); + INVALID_1 ("event-reader/invalid-event-1.json"), + INVALID_2 ("event-reader/invalid-event-2.json"), + INVALID_3 ("event-reader/invalid-event-3.json"), + INVALID_4 ("event-reader/invalid-event-4.json"), + INVALID_5 ("event-reader/invalid-event-5.json"); + // @formatter:on private String filename; - TestData(String filename) {this.filename = filename;} - public String getFilename() {return this.filename;} - // @formatter:on + TestData(String filename) { + this.filename = filename; + } + public String getFilename() { + return this.filename; + } } @Test diff --git a/src/test/java/org/onap/aai/validation/reader/TestJsonReader.java b/src/test/java/org/onap/aai/validation/reader/TestJsonReader.java index e7a906a..116534b 100644 --- a/src/test/java/org/onap/aai/validation/reader/TestJsonReader.java +++ b/src/test/java/org/onap/aai/validation/reader/TestJsonReader.java @@ -1,12 +1,12 @@ -/* +/** * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs + * Copyright (c) 2018-2019 Amdocs * ============================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -24,7 +24,6 @@ import static org.junit.Assert.assertThat; import java.util.Arrays; import java.util.List; import org.junit.Test; -import org.onap.aai.validation.reader.JsonReader; import org.onap.aai.validation.test.util.TestUtil; public class TestJsonReader { @@ -34,13 +33,19 @@ public class TestJsonReader { } enum TestData { - // @formatter:off - SAMPLE_JSON ("json-reader/sample.json"); + SAMPLE_JSON( + "json-reader/sample.json" + ); - private String filename; - TestData(String filename) {this.filename = filename;} - public String getFilename() {return this.filename;} - // @formatter:on + private String filename; + + TestData(String filename) { + this.filename = filename; + } + + public String getFilename() { + return this.filename; + } } @Test diff --git a/src/test/java/org/onap/aai/validation/reader/TestOxmConfigTranslator.java b/src/test/java/org/onap/aai/validation/reader/TestOxmConfigTranslator.java deleted file mode 100644 index 73e76db..0000000 --- a/src/test/java/org/onap/aai/validation/reader/TestOxmConfigTranslator.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs - * ============================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END===================================================== - */ -package org.onap.aai.validation.reader; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.Matchers.isEmptyString; -import static org.hamcrest.Matchers.not; -import static org.junit.Assert.assertThat; - -import java.nio.file.InvalidPathException; -import java.util.List; -import java.util.Map; -import java.util.ServiceConfigurationError; -import org.junit.Test; -import org.onap.aai.setup.SchemaLocationsBean; -import org.onap.aai.setup.Version; -import org.onap.aai.validation.reader.OxmConfigTranslator; -import org.springframework.test.util.ReflectionTestUtils; - -public class TestOxmConfigTranslator { - - static { - System.setProperty("APP_HOME", "."); - } - - @Test - public void testOxmFiles() { - OxmConfigTranslator translator = buildConfigTranslator("src/test/resources/oxm-reader/single/"); - Map<Version, List<String>> latestVersion = translator.getNodeFiles(); - assertThat(latestVersion.size(), is(3)); - assertThat(latestVersion.values().iterator().next().size(), is(1)); - assertThat(latestVersion.values().iterator().next().get(0), not(isEmptyString())); - Map<Version, List<String>> latestVersion1 = translator.getEdgeFiles(); - assertThat(latestVersion1.size(), is(1)); - assertThat(latestVersion1.values().iterator().next().size(), is(1)); - assertThat(latestVersion1.values().iterator().next().get(0), not(isEmptyString())); - } - - @Test - public void testMultipleOxmFilesPerVersion() { - OxmConfigTranslator translator = buildConfigTranslator("src/test/resources/oxm-reader/multiple"); - Map<Version, List<String>> latestVersion = translator.getNodeFiles(); - assertThat(latestVersion.size(), is(2)); - assertThat(latestVersion.values().iterator().next().size(), is(2)); - assertThat(latestVersion.values().iterator().next().get(0), not(isEmptyString())); - Map<Version, List<String>> latestVersion1 = translator.getEdgeFiles(); - assertThat(latestVersion1.size(), is(0)); - } - - @Test - public void testZeroMatchingFiles() { - OxmConfigTranslator translator = buildConfigTranslator("src/test/resources/oxm-reader/"); - Map<Version, List<String>> versionsMap = translator.getNodeFiles(); - assertThat(versionsMap.size(), is(0)); - } - - @Test(expected = ServiceConfigurationError.class) - public void testNullNodesPath() { - buildConfigTranslator(null).getNodeFiles(); - } - - @Test(expected = ServiceConfigurationError.class) - public void testNullEdgesPath() { - buildConfigTranslator(null).getEdgeFiles(); - } - - @Test(expected = ServiceConfigurationError.class) - public void testNonExistentNodesPath() { - buildConfigTranslator("no-such-folder-exists/").getNodeFiles(); - } - - @Test(expected = ServiceConfigurationError.class) - public void testNonExistentEdgesPath() { - SchemaLocationsBean bean = new SchemaLocationsBean(); - ReflectionTestUtils.setField(bean, "nodeDirectory", "src/test/resources/oxm-reader/"); - ReflectionTestUtils.setField(bean, "edgeDirectory", "no-such-folder-exists/"); - new OxmConfigTranslator(bean).getEdgeFiles(); - } - - @Test(expected = InvalidPathException.class) - public void testInvalidPath() { - buildConfigTranslator("\0").getEdgeFiles(); - } - - private OxmConfigTranslator buildConfigTranslator(String path) { - return new OxmConfigTranslator(createSchemaLocationsBean(path)); - } - - private SchemaLocationsBean createSchemaLocationsBean(String path) { - SchemaLocationsBean bean = new SchemaLocationsBean(); - ReflectionTestUtils.setField(bean, "nodeDirectory", path); - ReflectionTestUtils.setField(bean, "edgeDirectory", path); - return bean; - } - -} diff --git a/src/test/java/org/onap/aai/validation/reader/TestOxmReader.java b/src/test/java/org/onap/aai/validation/reader/TestOxmReader.java index f7f2643..bbceae5 100644 --- a/src/test/java/org/onap/aai/validation/reader/TestOxmReader.java +++ b/src/test/java/org/onap/aai/validation/reader/TestOxmReader.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs + * Copyright (c) 2018-2019 Amdocs * ============================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,13 +26,12 @@ import java.util.List; import javax.inject.Inject; import org.junit.Test; import org.junit.runner.RunWith; -import org.onap.aai.validation.reader.OxmReader; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@TestPropertySource(properties = {"schemaIngestPropLoc = src/test/resources/oxm-reader/schemaIngest.properties"}) +@TestPropertySource(locations = {"classpath:oxm-reader/schemaIngest.properties"}) @ContextConfiguration(locations = {"classpath:oxm-reader/oxm-reader-beans.xml"}) public class TestOxmReader { diff --git a/src/test/java/org/onap/aai/validation/result/TestValidationResult.java b/src/test/java/org/onap/aai/validation/result/TestValidationResult.java index 5d02101..32f85fe 100644 --- a/src/test/java/org/onap/aai/validation/result/TestValidationResult.java +++ b/src/test/java/org/onap/aai/validation/result/TestValidationResult.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs + * Copyright (c) 2018-2019 Amdocs * ============================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,8 +42,6 @@ import org.junit.runner.RunWith; import org.onap.aai.validation.exception.ValidationServiceException; import org.onap.aai.validation.reader.EventReader; import org.onap.aai.validation.reader.data.Entity; -import org.onap.aai.validation.result.ValidationResult; -import org.onap.aai.validation.result.Violation; import org.onap.aai.validation.result.Violation.Builder; import org.onap.aai.validation.result.Violation.ViolationType; import org.onap.aai.validation.test.util.TestUtil; @@ -53,7 +51,7 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@TestPropertySource(properties = {"schemaIngestPropLoc = src/test/resources/oxm-reader/schemaIngest.properties"}) +@TestPropertySource(locations = { "classpath:oxm-reader/schemaIngest.properties" }) @ContextConfiguration(locations = {"classpath:validation-result/test-validation-service-beans.xml"}) public class TestValidationResult { diff --git a/src/test/java/org/onap/aai/validation/ruledriven/rule/RuleTester.java b/src/test/java/org/onap/aai/validation/ruledriven/rule/RuleTester.java index 8593f93..6545120 100644 --- a/src/test/java/org/onap/aai/validation/ruledriven/rule/RuleTester.java +++ b/src/test/java/org/onap/aai/validation/ruledriven/rule/RuleTester.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs + * Copyright (c) 2018-2019 Amdocs * ============================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ package org.onap.aai.validation.ruledriven.rule; import org.onap.aai.validation.reader.data.AttributeValues; -import org.onap.aai.validation.ruledriven.rule.Rule; /** * Helper class for testing rules diff --git a/src/test/java/org/onap/aai/validation/ruledriven/validator/TestRuleDrivenValidator.java b/src/test/java/org/onap/aai/validation/ruledriven/validator/TestRuleDrivenValidator.java index cf1e874..643e2e3 100644 --- a/src/test/java/org/onap/aai/validation/ruledriven/validator/TestRuleDrivenValidator.java +++ b/src/test/java/org/onap/aai/validation/ruledriven/validator/TestRuleDrivenValidator.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs + * Copyright (c) 2018-2019 Amdocs * ============================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,9 +45,9 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@TestPropertySource(properties = {"schemaIngestPropLoc = src/test/resources/oxm-reader/schemaIngest.properties"}) -@ContextConfiguration( - locations = {"classpath:" + TestRuleDrivenValidator.UNIT_TEST_FOLDER + "/test-rule-driven-validator-beans.xml"}) +@TestPropertySource(locations = { "classpath:oxm-reader/schemaIngest.properties" }) +@ContextConfiguration(locations = { + "classpath:" + TestRuleDrivenValidator.UNIT_TEST_FOLDER + "/test-rule-driven-validator-beans.xml" }) public class TestRuleDrivenValidator { static { diff --git a/src/test/java/org/onap/aai/validation/services/TestInfoService.java b/src/test/java/org/onap/aai/validation/services/TestInfoService.java index 0bfa8ba..ac9591a 100644 --- a/src/test/java/org/onap/aai/validation/services/TestInfoService.java +++ b/src/test/java/org/onap/aai/validation/services/TestInfoService.java @@ -1,12 +1,12 @@ -/* +/** * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs + * Copyright (c) 2018-2019 Amdocs * ============================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -35,7 +35,6 @@ import org.junit.runner.RunWith; import org.onap.aai.validation.controller.ValidationController; import org.onap.aai.validation.exception.ValidationServiceException; import org.onap.aai.validation.publisher.MockEventPublisher; -import org.onap.aai.validation.services.InfoService; import org.onap.aai.validation.test.util.TestEntity; import org.onap.aai.validation.test.util.TestUtil; import org.springframework.test.context.ContextConfiguration; @@ -43,7 +42,7 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@TestPropertySource(properties = {"schemaIngestPropLoc = src/test/resources/oxm-reader/schemaIngest.properties"}) +@TestPropertySource(locations = {"classpath:oxm-reader/schemaIngest.properties", "classpath:application.properties"}) @ContextConfiguration(locations = {"classpath:/info-service/test-validation-service-beans.xml"}) public class TestInfoService { @@ -53,12 +52,18 @@ public class TestInfoService { enum TestData { // @formatter:off - VSERVER ("rule-driven-validator/test_events/vserver-create-event.json"); + VSERVER("rule-driven-validator/test_events/vserver-create-event.json"); + // @formatter:on private String filename; - TestData(String filename) {this.filename = filename;} - public String getFilename() {return this.filename;} - // @formatter:on + + TestData(String filename) { + this.filename = filename; + } + + public String getFilename() { + return this.filename; + } } private InfoService infoService; @@ -107,13 +112,9 @@ public class TestInfoService { assertThat(info, containsString("errored=1")); } - /** - * @throws ValidationServiceException - * @throws IOException - * @throws URISyntaxException - */ + @Test - public void testVserverEventRecorded() throws ValidationServiceException, URISyntaxException, IOException { + public void testVserverEventRecorded() throws URISyntaxException, IOException { Path vserverTestFile = Paths.get(ClassLoader.getSystemResource(TestData.VSERVER.getFilename()).toURI()); Path root = vserverTestFile.getParent(); assertThat(root, is(not(nullValue()))); @@ -128,7 +129,7 @@ public class TestInfoService { /** * Assert that the info service status string contains the expected standard results and formatting. - * + * * @param info */ private void assertResultsStringFormatted(String info) { diff --git a/src/test/resources/model-validation/instance-validator/schemaIngest.properties b/src/test/resources/model-validation/instance-validator/schemaIngest.properties index 3e295d0..8df810a 100644 --- a/src/test/resources/model-validation/instance-validator/schemaIngest.properties +++ b/src/test/resources/model-validation/instance-validator/schemaIngest.properties @@ -14,7 +14,35 @@ # limitations under the License. # ============LICENSE_END===================================================== -# Test properties for the org.onap.aai.setup.SchemaLocationsBean -schemaConfig=NA -nodeDir=src/test/resources/oxm-reader/single/ -edgeDir=src/test/resources/oxm-reader/single/
\ No newline at end of file +# Properties for the org.onap.aai.setup.SchemaLocationsBean +# Schema related attributes for the oxm and edges +# Any additional schema related attributes should start with prefix schema +schema.configuration.location=N/A +schema.nodes.location=src/test/resources/oxm-reader/single/oxm +schema.edges.location=src/test/resources/oxm-reader/single/dbedgerules + +# Schema Version Related Attributes + +# Lists all of the versions in the schema +schema.version.list=v8,v9,v10 +# Specifies from which version should the depth parameter to default to zero +schema.version.depth.start=v9 +# Specifies from which version should the related link be displayed in response payload +schema.version.related.link.start=v10 +# Specifies from which version should the client see only the uri excluding host info +# Before this version server base will also be included +schema.version.app.root.start=v10 +# Specifies from which version should the namespace be changed +schema.version.namespace.change.start=v10 +# Specifies from which version should the client start seeing the edge label in payload +schema.version.edge.label.start=v10 +# Specifies the version that the application should default to +schema.version.api.default=v9 + +schema.service.base.url=https://localhost:8452/aai/schema-service/v1/ +schema.service.nodes.endpoint=nodes?version= +schema.service.edges.endpoint=edgerules?version= +schema.service.versions.endpoint=versions + +schema.service.ssl.key-store=src/integration-test/resources/authentication/aai-client-cert.p12 +schema.service.ssl.trust-store=src/integration-test/resources/authentication/tomcat_keystore diff --git a/src/test/resources/oxm-reader/multiple/test_business_v10.xml b/src/test/resources/oxm-reader/multiple/test_business_v10.xml deleted file mode 100644 index f0dc93f..0000000 --- a/src/test/resources/oxm-reader/multiple/test_business_v10.xml +++ /dev/null @@ -1,47 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- -============LICENSE_START=================================================== -Copyright (c) 2018 Amdocs -============================================================================ -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -============LICENSE_END===================================================== ---> -<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" package-name="inventory.aai.onap.org.business.v12" xml-mapping-metadata-complete="true"> - <xml-schema element-form-default="QUALIFIED"> - <xml-ns namespace-uri="http://org.onap.aai.inventory/v12" /> - </xml-schema> - <java-types> - - <java-type name="Bar"> - <xml-root-element name="bar" /> - <java-attributes> - <xml-element java-attribute="barId" name="bar-id" required="true" type="java.lang.String" xml-key="true"> - <xml-properties> - <xml-property name="description" value="Unique id of Bar This is unique across the graph." /> - </xml-properties> - </xml-element> - <xml-element java-attribute="quantity" name="quantity" required="false" type="java.lang.Integer"> - <xml-properties> - <xml-property name="description" value="How many." /> - </xml-properties> - </xml-element> - - </java-attributes> - <xml-properties> - <xml-property name="description" value="General purpose metasyntactic variable" /> - <xml-property name="uniqueProps" value="bar-id" /> - </xml-properties> - </java-type> - - </java-types> -</xml-bindings>
\ No newline at end of file diff --git a/src/test/resources/oxm-reader/multiple/test_business_v13.xml b/src/test/resources/oxm-reader/multiple/test_business_v13.xml deleted file mode 100644 index 2529c6d..0000000 --- a/src/test/resources/oxm-reader/multiple/test_business_v13.xml +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- -============LICENSE_START=================================================== -Copyright (c) 2018 Amdocs -============================================================================ -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -============LICENSE_END===================================================== ---> -<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" package-name="inventory.aai.onap.org.business.v13" xml-mapping-metadata-complete="true"> - <xml-schema element-form-default="QUALIFIED"> - <xml-ns namespace-uri="http://org.onap.aai.inventory/v13" /> - </xml-schema> - <java-types> - - <java-type name="Bar"> - <xml-root-element name="bar" /> - <java-attributes> - <xml-element java-attribute="barId" name="bar-id" required="true" type="java.lang.String" xml-key="true"> - <xml-properties> - <xml-property name="description" value="Unique id of Bar This is unique across the graph." /> - </xml-properties> - </xml-element> - - </java-attributes> - <xml-properties> - <xml-property name="description" value="General purpose metasyntactic variable" /> - <xml-property name="uniqueProps" value="bar-id" /> - </xml-properties> - </java-type> - - </java-types> -</xml-bindings>
\ No newline at end of file diff --git a/src/test/resources/oxm-reader/multiple/test_network_v10.xml b/src/test/resources/oxm-reader/multiple/test_network_v10.xml deleted file mode 100644 index 9767de6..0000000 --- a/src/test/resources/oxm-reader/multiple/test_network_v10.xml +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- -============LICENSE_START=================================================== -Copyright (c) 2018 Amdocs -============================================================================ -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -============LICENSE_END===================================================== ---> -<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" package-name="inventory.aai.onap.org.network.v10" xml-mapping-metadata-complete="true"> - <xml-schema element-form-default="QUALIFIED"> - <xml-ns namespace-uri="http://org.onap.aai.inventory/v12" /> - </xml-schema> - <java-types> - - <java-type name="Foo"> - <xml-root-element name="foo" /> - <java-attributes> - <xml-element java-attribute="fooId" name="foo-id" required="true" type="java.lang.String" xml-key="true"> - <xml-properties> - <xml-property name="description" value="Unique id of Foo. This is unique across the graph." /> - </xml-properties> - </xml-element> - <xml-element java-attribute="fooName" name="foo-name" required="true" type="java.lang.String"> - <xml-properties> - <xml-property name="description" value="Name of Foo." /> - </xml-properties> - </xml-element> - - </java-attributes> - <xml-properties> - <xml-property name="description" value="General purpose metasyntactic variable" /> - <xml-property name="nameProps" value="foo-name" /> - <xml-property name="uniqueProps" value="foo-id" /> - </xml-properties> - </java-type> - - </java-types> -</xml-bindings>
\ No newline at end of file diff --git a/src/test/resources/oxm-reader/multiple/test_network_v13.xml b/src/test/resources/oxm-reader/multiple/test_network_v13.xml deleted file mode 100644 index 892f626..0000000 --- a/src/test/resources/oxm-reader/multiple/test_network_v13.xml +++ /dev/null @@ -1,73 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- -============LICENSE_START=================================================== -Copyright (c) 2018 Amdocs -============================================================================ -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -============LICENSE_END===================================================== ---> -<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" package-name="inventory.aai.onap.org.network.v13" xml-mapping-metadata-complete="true"> - <xml-schema element-form-default="QUALIFIED"> - <xml-ns namespace-uri="http://org.onap.aai.inventory/v13" /> - </xml-schema> - <java-types> - - <java-type name="Foo"> - <xml-root-element name="foo" /> - <java-attributes> - <xml-element java-attribute="fooId" name="foo-id" required="true" type="java.lang.String" xml-key="true"> - <xml-properties> - <xml-property name="description" value="Unique id of Foo. This is unique across the graph." /> - </xml-properties> - </xml-element> - <xml-element java-attribute="fooName" name="foo-name" required="true" type="java.lang.String"> - <xml-properties> - <xml-property name="description" value="Name of Foo." /> - </xml-properties> - </xml-element> - <xml-element java-attribute="quantity" name="quantity" required="false" type="java.lang.String"> - <xml-properties> - <xml-property name="description" value="How many." /> - </xml-properties> - </xml-element> - - </java-attributes> - <xml-properties> - <xml-property name="description" value="General purpose metasyntactic variable" /> - <xml-property name="nameProps" value="foo-name" /> - <xml-property name="uniqueProps" value="foo-id" /> - </xml-properties> - </java-type> - - <java-type name="Quux"> - <xml-root-element name="quux" /> - <java-attributes> - <xml-element java-attribute="qManagerName" name="q-manager-name" required="true" type="java.lang.String" xml-key="true"> - <xml-properties> - <xml-property name="description" value="Unique id of Quux owner. This is unique across the graph." /> - </xml-properties> - </xml-element> - <xml-element java-attribute="color" name="color" required="false" type="java.lang.String"> - <xml-properties> - <xml-property name="description" value="color" /> - </xml-properties> - </xml-element> - - </java-attributes> - <xml-properties> - <xml-property name="description" value="General purpose metasyntactic variable" /> - </xml-properties> - </java-type> - - </java-types> -</xml-bindings>
\ No newline at end of file diff --git a/src/test/resources/oxm-reader/oxm-reader-beans.xml b/src/test/resources/oxm-reader/oxm-reader-beans.xml index c9f064a..93a2ff7 100644 --- a/src/test/resources/oxm-reader/oxm-reader-beans.xml +++ b/src/test/resources/oxm-reader/oxm-reader-beans.xml @@ -1,40 +1,25 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- -============LICENSE_START=================================================== -Copyright (c) 2018 Amdocs -============================================================================ -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -============LICENSE_END===================================================== ---> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> - <bean id="schemaLocationsBean" class="org.onap.aai.setup.SchemaLocationsBean" /> + <bean id="schemaLocationsBean" class="org.onap.aai.setup.SchemaLocationsBean" /> - <bean id="configTranslator" class="org.onap.aai.validation.reader.OxmConfigTranslator"> - <constructor-arg ref="schemaLocationsBean" /> - </bean> + <bean id="schemaVersionsBean" class="org.onap.aai.setup.SchemaVersions" /> - <bean id="nodeIngestor" class="org.onap.aai.nodes.NodeIngestor"> - <constructor-arg ref="configTranslator" /> - </bean> + <bean id="configTranslator" class="org.onap.aai.setup.AAIConfigTranslator" /> + + <bean id="nodeIngestor" class="org.onap.aai.nodes.NodeIngestor" /> + <bean id="schemaVersionBean" class="org.onap.aai.setup.SchemaVersion"> + <constructor-arg value="${schema.version.api.default}" /> + </bean> + <bean id="oxmReader" class="org.onap.aai.validation.reader.OxmReader" init-method="init"> <constructor-arg ref="nodeIngestor" /> - <constructor-arg value="V9" /> + <constructor-arg ref="schemaVersionBean" /> </bean> </beans> diff --git a/src/test/resources/oxm-reader/schemaIngest.properties b/src/test/resources/oxm-reader/schemaIngest.properties index bb1027e..43e755b 100644 --- a/src/test/resources/oxm-reader/schemaIngest.properties +++ b/src/test/resources/oxm-reader/schemaIngest.properties @@ -1,20 +1,32 @@ -# ============LICENSE_START=================================================== -# Copyright (c) 2018 Amdocs -# ============================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END===================================================== +# Properties for the org.onap.aai.setup.SchemaLocationsBean +# Schema related attributes for the oxm and edges +# Any additional schema related attributes should start with prefix schema +schema.configuration.location=N/A +schema.nodes.location=src/test/resources/oxm-reader/single/oxm +schema.edges.location=src/test/resources/oxm-reader/single/dbedgerules -# Test properties for the org.onap.aai.setup.SchemaLocationsBean -schemaConfig=NA -nodeDir=src/test/resources/oxm-reader/single/ -edgeDir=src/test/resources/oxm-reader/single/
\ No newline at end of file +# Schema Version Related Attributes + +# Lists all of the versions in the schema +schema.version.list=v8,v9,v10 +# Specifies from which version should the depth parameter to default to zero +schema.version.depth.start=v9 +# Specifies from which version should the related link be displayed in response payload +schema.version.related.link.start=v10 +# Specifies from which version should the client see only the uri excluding host info +# Before this version server base will also be included +schema.version.app.root.start=v10 +# Specifies from which version should the namespace be changed +schema.version.namespace.change.start=v10 +# Specifies from which version should the client start seeing the edge label in payload +schema.version.edge.label.start=v10 +# Specifies the version that the application should default to +schema.version.api.default=v9 + +schema.service.base.url=https://localhost:8452/aai/schema-service/v1/ +schema.service.nodes.endpoint=nodes?version= +schema.service.edges.endpoint=edgerules?version= +schema.service.versions.endpoint=versions + +schema.service.ssl.key-store=appconfig-local/auth/aai-client-cert.p12 +schema.service.ssl.trust-store=appconfig-local/auth/tomcat_keystore
\ No newline at end of file diff --git a/src/test/resources/oxm-reader/single/aai_oxm_v0.xml b/src/test/resources/oxm-reader/single/aai_oxm_v0.xml deleted file mode 100644 index ffab598..0000000 --- a/src/test/resources/oxm-reader/single/aai_oxm_v0.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- -============LICENSE_START=================================================== -Copyright (c) 2018 Amdocs -============================================================================ -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -============LICENSE_END===================================================== ---> -<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" package-name="inventory.aai.onap.org.v9" xml-mapping-metadata-complete="true"> - <xml-schema element-form-default="QUALIFIED"> - <xml-ns namespace-uri="http://org.openecomp.aai.inventory/v9" /> - </xml-schema> -</xml-bindings>
\ No newline at end of file diff --git a/src/test/resources/oxm-reader/single/aai_oxm_vnonDigit.xml b/src/test/resources/oxm-reader/single/aai_oxm_vnonDigit.xml deleted file mode 100644 index ffab598..0000000 --- a/src/test/resources/oxm-reader/single/aai_oxm_vnonDigit.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<!-- -============LICENSE_START=================================================== -Copyright (c) 2018 Amdocs -============================================================================ -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -============LICENSE_END===================================================== ---> -<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" package-name="inventory.aai.onap.org.v9" xml-mapping-metadata-complete="true"> - <xml-schema element-form-default="QUALIFIED"> - <xml-ns namespace-uri="http://org.openecomp.aai.inventory/v9" /> - </xml-schema> -</xml-bindings>
\ No newline at end of file diff --git a/src/test/resources/oxm-reader/single/test_v10_edges.json b/src/test/resources/oxm-reader/single/dbedgerules/v10/DbEdgeRules_test_v10_edges.json index e69de29..e69de29 100644 --- a/src/test/resources/oxm-reader/single/test_v10_edges.json +++ b/src/test/resources/oxm-reader/single/dbedgerules/v10/DbEdgeRules_test_v10_edges.json diff --git a/src/test/resources/oxm-reader/single/aai_oxm_v10.xml b/src/test/resources/oxm-reader/single/oxm/v10/aai_oxm_v10.xml index b4c880a..b4c880a 100644 --- a/src/test/resources/oxm-reader/single/aai_oxm_v10.xml +++ b/src/test/resources/oxm-reader/single/oxm/v10/aai_oxm_v10.xml diff --git a/src/test/resources/oxm-reader/single/aai_oxm_v8.xml b/src/test/resources/oxm-reader/single/oxm/v8/aai_oxm_v8.xml index 40939a4..40939a4 100644 --- a/src/test/resources/oxm-reader/single/aai_oxm_v8.xml +++ b/src/test/resources/oxm-reader/single/oxm/v8/aai_oxm_v8.xml diff --git a/src/test/resources/oxm-reader/single/aai_oxm_v9.xml b/src/test/resources/oxm-reader/single/oxm/v9/aai_oxm_v9.xml index 6fe7379..6fe7379 100644 --- a/src/test/resources/oxm-reader/single/aai_oxm_v9.xml +++ b/src/test/resources/oxm-reader/single/oxm/v9/aai_oxm_v9.xml |