From c604f64b971491f8c9b953adce54b847d7946e26 Mon Sep 17 00:00:00 2001 From: Prudence Au Date: Mon, 13 Aug 2018 17:06:59 -0400 Subject: Initial submission for validation service Change-Id: I9372430f1ae347373d5a9a0c7a427d7bd393d61e Issue-ID: LOG-427 Signed-off-by: Prudence Au (prudence.au@amdocs.com) Signed-off-by: Geora Barsky Signed-off-by: Pierre Rioux --- .../aai/validation/auth/MicroServiceAuthTest.java | 227 + .../onap/aai/validation/config/TestRestConfig.java | 79 + .../validation/config/TestTopicAdminConfig.java | 60 + .../aai/validation/config/TestTopicConfig.java | 107 + .../config/TestValidationControllerConfig.java | 69 + .../controller/TestValidationController.java | 391 ++ .../aai/validation/data/client/TestRestClient.java | 74 + .../org/onap/aai/validation/logging/LogReader.java | 101 + .../validation/logging/TestApplicationLogger.java | 245 + .../aai/validation/modeldriven/TestModelId.java | 95 + .../configuration/mapping/TestFilter.java | 55 + .../mapping/TestModelInstanceMapper.java | 71 + .../mapping/TestValueConfiguration.java | 70 + .../modeldriven/parser/TestXMLModelParser.java | 96 + .../modeldriven/validator/TestInstanceReader.java | 236 + .../validator/TestModelDrivenValidator.java | 291 + .../modeldriven/validator/TestModelReader.java | 261 + .../validation/publisher/MockEventPublisher.java | 72 + .../publisher/TestValidationEventPublisher.java | 102 + .../aai/validation/reader/TestEventReader.java | 270 + .../onap/aai/validation/reader/TestJsonReader.java | 95 + .../validation/reader/TestOxmConfigTranslator.java | 111 + .../onap/aai/validation/reader/TestOxmReader.java | 63 + .../aai/validation/request/TestRequestHeaders.java | 143 + .../validation/result/TestValidationResult.java | 444 ++ .../configuration/ConfigFileBuilder.java | 104 + .../ConfigurationExceptionMatcher.java | 73 + .../configuration/TestConfigFileBuilder.java | 59 + .../TestRulesConfigurationReader.java | 448 ++ .../ruledriven/mock/TestDefaultRules.java | 148 + .../aai/validation/ruledriven/rule/RuleHelper.java | 36 + .../aai/validation/ruledriven/rule/RuleTester.java | 47 + .../ruledriven/rule/TestConfigurationLoader.java | 190 + .../ruledriven/rule/TestRuleExecution.java | 494 ++ .../ruledriven/rule/TestRuleValidation.java | 229 + .../validator/TestRuleDrivenValidator.java | 125 + .../aai/validation/services/TestInfoService.java | 140 + .../services/TestValidateServiceImpl.java | 115 + .../aai/validation/test/util/RandomString.java | 40 + .../onap/aai/validation/test/util/TestEntity.java | 88 + .../onap/aai/validation/test/util/TestUtil.java | 52 + .../test/util/ValidationResultIsEqual.java | 58 + .../onap/aai/validation/util/TestStringUtils.java | 170 + src/test/resources/aai-environment.properties | 31 + src/test/resources/auth/auth_policy.json | 55 + .../event-reader/generic-vnf-create-event.json | 75 + .../resources/event-reader/invalid-event-1.json | 165 + .../resources/event-reader/invalid-event-2.json | 165 + .../resources/event-reader/invalid-event-3.json | 75 + .../resources/event-reader/invalid-event-4.json | 150 + .../resources/event-reader/invalid-event-5.json | 165 + .../event-reader/test-validation-service-beans.xml | 38 + .../event-reader/vserver-create-event.json | 165 + .../info-service/test-validation-service-beans.xml | 120 + src/test/resources/json-reader/sample.json | 13 + src/test/resources/logback.xml | 180 + .../resources/model-instance-mapping.json_conf | 28 + .../instance-reader/connector-attributes.json | 399 ++ .../instance-reader/connector-model-name.json | 84 + .../connector-sibling-inventory-items.json | 118 + .../instance-reader/connector.json | 82 + .../instance-reader/expected-generic-vnf.json | 36 + .../instance-reader/expected-logical-link.json | 51 + .../instance-reader/expected-pserver.json | 28 + .../expected-virtual-data-center-model-name.json | 66 + .../expected-virtual-data-center.json | 65 + .../model-instance-mapping-attributes.json_conf | 12 + .../model-instance-mapping-root-missing.json_conf | 16 + .../model-instance-mapping-root-unknown.json_conf | 17 + .../model-instance-mapping.json_conf | 17 + .../test-validation-service-beans.xml | 35 + .../instance-validator/aai-environment.properties | 31 + .../instance-validator/all-models.xml | 1370 ++++ .../connector-instance-errors.json | 113 + .../connector-instance-multiple-missing-attrs.json | 50 + ...nnector-instance-multiple-unexpected-attrs.json | 72 + .../connector-instance-no-model-id.json | 111 + .../connector-instance-success.json | 62 + .../connector-instance-unknown-model-id.json | 113 + .../instance-validator/connector-instance.json | 113 + .../instance-validator/connector-widget-id.xml | 79 + .../model-instance-mapping.json_conf | 28 + .../test-validation-service-beans.xml | 116 + .../validation-service.properties | 29 + .../model-validation/model-parser/all-models.xml | 1370 ++++ .../model-reader/aai-environment.properties | 30 + .../model-validation/model-reader/all-models.xml | 1370 ++++ .../connector-widget-id-no-children-1.xml | 51 + .../connector-widget-id-no-children-2.xml | 79 + .../model-reader/connector-widget-id.xml | 107 + .../model-reader/logical-link-widget-id.xml | 181 + .../model-instance-mapping-attributes-1.json | 11 + .../model-instance-mapping-attributes-2.json | 11 + ...el-instance-mapping-relationships-filter-1.json | 18 + ...el-instance-mapping-relationships-filter-2.json | 18 + ...el-instance-mapping-relationships-filter-3.json | 17 + ...el-instance-mapping-relationships-filter-4.json | 18 + ...el-instance-mapping-relationships-filter-5.json | 17 + ...el-instance-mapping-relationships-filter-6.json | 14 + ...odel-instance-mapping-relationships-root-1.json | 18 + ...odel-instance-mapping-relationships-root-2.json | 17 + ...del-instance-mapping-relationships-with-id.json | 18 + .../model-instance-mapping-relationships.json | 18 + .../model-reader/test-validation-service-beans.xml | 52 + .../model-reader/validation-service.properties | 29 + .../model-reader/virtual-data-center-widget-id.xml | 72 + .../oxm-reader/multiple/test_business_v10.xml | 47 + .../oxm-reader/multiple/test_business_v13.xml | 42 + .../oxm-reader/multiple/test_network_v10.xml | 48 + .../oxm-reader/multiple/test_network_v13.xml | 73 + src/test/resources/oxm-reader/oxm-reader-beans.xml | 40 + .../resources/oxm-reader/schemaIngest.properties | 20 + .../resources/oxm-reader/single/aai_oxm_v0.xml | 23 + .../resources/oxm-reader/single/aai_oxm_v10.xml | 6569 ++++++++++++++++++++ .../resources/oxm-reader/single/aai_oxm_v8.xml | 4362 +++++++++++++ .../resources/oxm-reader/single/aai_oxm_v9.xml | 4772 ++++++++++++++ .../oxm-reader/single/aai_oxm_vnonDigit.xml | 23 + .../oxm-reader/single/test_v10_edges.json | 0 .../rest-config/aai-environment.properties | 29 + .../rest-config/test-validation-service-beans.xml | 29 + .../expected/generic-vnf-create-event.exp.json | 35 + ...pserver-create-event-invalid-ipaddress.exp.json | 24 + .../expected/gizmo-pserver-create-event.exp.json | 13 + ...AAI-EVENT-devINT1-TRINITY-VNF-NAME-BAD.exp.json | 128 + ...AI-EVENT-devINT1-TRINITY-VNF-NAME-GOOD.exp.json | 23 + .../results/expected/vserver-create-event.exp.json | 208 + .../vserver-update-AAI-EVENT-devINT1.exp.json | 38 + .../rules/aai-event/common_rules.groovy | 69 + .../rules/aai-event/entity-complex.groovy | 146 + .../rules/aai-event/entity-newvce.groovy | 43 + .../rules/aai-event/generic-vnf-rules.groovy | 56 + .../rules/aai-event/rule-vserver-all_others.groovy | 118 + .../rule-vserver-related-generic-vnf.groovy | 42 + .../rules/aai-event/vserver-rules.groovy | 44 + .../rules/gizmo-event/common_rules.groovy | 27 + .../rules/gizmo-event/pserver-rules.groovy | 27 + .../test-rule-driven-validator-beans.xml | 55 + .../test_events/generic-vnf-create-event.json | 46 + ...zmo-pserver-create-event-invalid-ipaddress.json | 33 + .../test_events/gizmo-pserver-create-event.json | 33 + ...ate-AAI-EVENT-devINT1-TRINITY-VNF-NAME-BAD.json | 144 + ...te-AAI-EVENT-devINT1-TRINITY-VNF-NAME-GOOD.json | 144 + .../test_events/vserver-create-event.json | 243 + .../vserver-update-AAI-EVENT-devINT1.json | 108 + .../test-validation-service-beans.xml | 28 + .../validation-service.properties | 20 + .../topic-config/test-topic-config-beans.xml | 49 + .../topic-config/test-validation-service-beans.xml | 25 + .../topic-config/topic-aai-data-export.properties | 23 + .../topic-aai-data-integrity.properties | 22 + .../topic-config/topic-aai-event.properties | 23 + .../test-validation-service-beans.xml | 29 + .../validation-controller-config.properties | 21 + .../test-validation-service-beans.xml | 38 + .../validation-result/vserver-create-event.json | 163 + src/test/resources/validation-service.properties | 27 + 156 files changed, 33110 insertions(+) create mode 100644 src/test/java/org/onap/aai/validation/auth/MicroServiceAuthTest.java create mode 100644 src/test/java/org/onap/aai/validation/config/TestRestConfig.java create mode 100644 src/test/java/org/onap/aai/validation/config/TestTopicAdminConfig.java create mode 100644 src/test/java/org/onap/aai/validation/config/TestTopicConfig.java create mode 100644 src/test/java/org/onap/aai/validation/config/TestValidationControllerConfig.java create mode 100644 src/test/java/org/onap/aai/validation/controller/TestValidationController.java create mode 100644 src/test/java/org/onap/aai/validation/data/client/TestRestClient.java create mode 100644 src/test/java/org/onap/aai/validation/logging/LogReader.java create mode 100644 src/test/java/org/onap/aai/validation/logging/TestApplicationLogger.java create mode 100644 src/test/java/org/onap/aai/validation/modeldriven/TestModelId.java create mode 100644 src/test/java/org/onap/aai/validation/modeldriven/configuration/mapping/TestFilter.java create mode 100644 src/test/java/org/onap/aai/validation/modeldriven/configuration/mapping/TestModelInstanceMapper.java create mode 100644 src/test/java/org/onap/aai/validation/modeldriven/configuration/mapping/TestValueConfiguration.java create mode 100644 src/test/java/org/onap/aai/validation/modeldriven/parser/TestXMLModelParser.java create mode 100644 src/test/java/org/onap/aai/validation/modeldriven/validator/TestInstanceReader.java create mode 100644 src/test/java/org/onap/aai/validation/modeldriven/validator/TestModelDrivenValidator.java create mode 100644 src/test/java/org/onap/aai/validation/modeldriven/validator/TestModelReader.java create mode 100644 src/test/java/org/onap/aai/validation/publisher/MockEventPublisher.java create mode 100644 src/test/java/org/onap/aai/validation/publisher/TestValidationEventPublisher.java create mode 100644 src/test/java/org/onap/aai/validation/reader/TestEventReader.java create mode 100644 src/test/java/org/onap/aai/validation/reader/TestJsonReader.java create mode 100644 src/test/java/org/onap/aai/validation/reader/TestOxmConfigTranslator.java create mode 100644 src/test/java/org/onap/aai/validation/reader/TestOxmReader.java create mode 100644 src/test/java/org/onap/aai/validation/request/TestRequestHeaders.java create mode 100644 src/test/java/org/onap/aai/validation/result/TestValidationResult.java create mode 100644 src/test/java/org/onap/aai/validation/ruledriven/configuration/ConfigFileBuilder.java create mode 100644 src/test/java/org/onap/aai/validation/ruledriven/configuration/ConfigurationExceptionMatcher.java create mode 100644 src/test/java/org/onap/aai/validation/ruledriven/configuration/TestConfigFileBuilder.java create mode 100644 src/test/java/org/onap/aai/validation/ruledriven/configuration/TestRulesConfigurationReader.java create mode 100644 src/test/java/org/onap/aai/validation/ruledriven/mock/TestDefaultRules.java create mode 100644 src/test/java/org/onap/aai/validation/ruledriven/rule/RuleHelper.java create mode 100644 src/test/java/org/onap/aai/validation/ruledriven/rule/RuleTester.java create mode 100644 src/test/java/org/onap/aai/validation/ruledriven/rule/TestConfigurationLoader.java create mode 100644 src/test/java/org/onap/aai/validation/ruledriven/rule/TestRuleExecution.java create mode 100644 src/test/java/org/onap/aai/validation/ruledriven/rule/TestRuleValidation.java create mode 100644 src/test/java/org/onap/aai/validation/ruledriven/validator/TestRuleDrivenValidator.java create mode 100644 src/test/java/org/onap/aai/validation/services/TestInfoService.java create mode 100644 src/test/java/org/onap/aai/validation/services/TestValidateServiceImpl.java create mode 100644 src/test/java/org/onap/aai/validation/test/util/RandomString.java create mode 100644 src/test/java/org/onap/aai/validation/test/util/TestEntity.java create mode 100644 src/test/java/org/onap/aai/validation/test/util/TestUtil.java create mode 100644 src/test/java/org/onap/aai/validation/test/util/ValidationResultIsEqual.java create mode 100644 src/test/java/org/onap/aai/validation/util/TestStringUtils.java create mode 100644 src/test/resources/aai-environment.properties create mode 100644 src/test/resources/auth/auth_policy.json create mode 100644 src/test/resources/event-reader/generic-vnf-create-event.json create mode 100644 src/test/resources/event-reader/invalid-event-1.json create mode 100644 src/test/resources/event-reader/invalid-event-2.json create mode 100644 src/test/resources/event-reader/invalid-event-3.json create mode 100644 src/test/resources/event-reader/invalid-event-4.json create mode 100644 src/test/resources/event-reader/invalid-event-5.json create mode 100644 src/test/resources/event-reader/test-validation-service-beans.xml create mode 100644 src/test/resources/event-reader/vserver-create-event.json create mode 100644 src/test/resources/info-service/test-validation-service-beans.xml create mode 100644 src/test/resources/json-reader/sample.json create mode 100644 src/test/resources/logback.xml create mode 100644 src/test/resources/model-instance-mapping.json_conf create mode 100644 src/test/resources/model-validation/instance-reader/connector-attributes.json create mode 100644 src/test/resources/model-validation/instance-reader/connector-model-name.json create mode 100644 src/test/resources/model-validation/instance-reader/connector-sibling-inventory-items.json create mode 100644 src/test/resources/model-validation/instance-reader/connector.json create mode 100644 src/test/resources/model-validation/instance-reader/expected-generic-vnf.json create mode 100644 src/test/resources/model-validation/instance-reader/expected-logical-link.json create mode 100644 src/test/resources/model-validation/instance-reader/expected-pserver.json create mode 100644 src/test/resources/model-validation/instance-reader/expected-virtual-data-center-model-name.json create mode 100644 src/test/resources/model-validation/instance-reader/expected-virtual-data-center.json create mode 100644 src/test/resources/model-validation/instance-reader/model-instance-mapping-attributes.json_conf create mode 100644 src/test/resources/model-validation/instance-reader/model-instance-mapping-root-missing.json_conf create mode 100644 src/test/resources/model-validation/instance-reader/model-instance-mapping-root-unknown.json_conf create mode 100644 src/test/resources/model-validation/instance-reader/model-instance-mapping.json_conf create mode 100644 src/test/resources/model-validation/instance-reader/test-validation-service-beans.xml create mode 100644 src/test/resources/model-validation/instance-validator/aai-environment.properties create mode 100644 src/test/resources/model-validation/instance-validator/all-models.xml create mode 100644 src/test/resources/model-validation/instance-validator/connector-instance-errors.json create mode 100644 src/test/resources/model-validation/instance-validator/connector-instance-multiple-missing-attrs.json create mode 100644 src/test/resources/model-validation/instance-validator/connector-instance-multiple-unexpected-attrs.json create mode 100644 src/test/resources/model-validation/instance-validator/connector-instance-no-model-id.json create mode 100644 src/test/resources/model-validation/instance-validator/connector-instance-success.json create mode 100644 src/test/resources/model-validation/instance-validator/connector-instance-unknown-model-id.json create mode 100644 src/test/resources/model-validation/instance-validator/connector-instance.json create mode 100644 src/test/resources/model-validation/instance-validator/connector-widget-id.xml create mode 100644 src/test/resources/model-validation/instance-validator/model-instance-mapping.json_conf create mode 100644 src/test/resources/model-validation/instance-validator/test-validation-service-beans.xml create mode 100644 src/test/resources/model-validation/instance-validator/validation-service.properties create mode 100644 src/test/resources/model-validation/model-parser/all-models.xml create mode 100644 src/test/resources/model-validation/model-reader/aai-environment.properties create mode 100644 src/test/resources/model-validation/model-reader/all-models.xml create mode 100644 src/test/resources/model-validation/model-reader/connector-widget-id-no-children-1.xml create mode 100644 src/test/resources/model-validation/model-reader/connector-widget-id-no-children-2.xml create mode 100644 src/test/resources/model-validation/model-reader/connector-widget-id.xml create mode 100644 src/test/resources/model-validation/model-reader/logical-link-widget-id.xml create mode 100644 src/test/resources/model-validation/model-reader/model-instance-mapping-attributes-1.json create mode 100644 src/test/resources/model-validation/model-reader/model-instance-mapping-attributes-2.json create mode 100644 src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-filter-1.json create mode 100644 src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-filter-2.json create mode 100644 src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-filter-3.json create mode 100644 src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-filter-4.json create mode 100644 src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-filter-5.json create mode 100644 src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-filter-6.json create mode 100644 src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-root-1.json create mode 100644 src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-root-2.json create mode 100644 src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-with-id.json create mode 100644 src/test/resources/model-validation/model-reader/model-instance-mapping-relationships.json create mode 100644 src/test/resources/model-validation/model-reader/test-validation-service-beans.xml create mode 100644 src/test/resources/model-validation/model-reader/validation-service.properties create mode 100644 src/test/resources/model-validation/model-reader/virtual-data-center-widget-id.xml create mode 100644 src/test/resources/oxm-reader/multiple/test_business_v10.xml create mode 100644 src/test/resources/oxm-reader/multiple/test_business_v13.xml create mode 100644 src/test/resources/oxm-reader/multiple/test_network_v10.xml create mode 100644 src/test/resources/oxm-reader/multiple/test_network_v13.xml create mode 100644 src/test/resources/oxm-reader/oxm-reader-beans.xml create mode 100644 src/test/resources/oxm-reader/schemaIngest.properties create mode 100644 src/test/resources/oxm-reader/single/aai_oxm_v0.xml create mode 100644 src/test/resources/oxm-reader/single/aai_oxm_v10.xml create mode 100644 src/test/resources/oxm-reader/single/aai_oxm_v8.xml create mode 100644 src/test/resources/oxm-reader/single/aai_oxm_v9.xml create mode 100644 src/test/resources/oxm-reader/single/aai_oxm_vnonDigit.xml create mode 100644 src/test/resources/oxm-reader/single/test_v10_edges.json create mode 100644 src/test/resources/rest-config/aai-environment.properties create mode 100644 src/test/resources/rest-config/test-validation-service-beans.xml create mode 100644 src/test/resources/rule-driven-validator/results/expected/generic-vnf-create-event.exp.json create mode 100644 src/test/resources/rule-driven-validator/results/expected/gizmo-pserver-create-event-invalid-ipaddress.exp.json create mode 100644 src/test/resources/rule-driven-validator/results/expected/gizmo-pserver-create-event.exp.json create mode 100644 src/test/resources/rule-driven-validator/results/expected/vserver-create-AAI-EVENT-devINT1-TRINITY-VNF-NAME-BAD.exp.json create mode 100644 src/test/resources/rule-driven-validator/results/expected/vserver-create-AAI-EVENT-devINT1-TRINITY-VNF-NAME-GOOD.exp.json create mode 100644 src/test/resources/rule-driven-validator/results/expected/vserver-create-event.exp.json create mode 100644 src/test/resources/rule-driven-validator/results/expected/vserver-update-AAI-EVENT-devINT1.exp.json create mode 100644 src/test/resources/rule-driven-validator/rules/aai-event/common_rules.groovy create mode 100644 src/test/resources/rule-driven-validator/rules/aai-event/entity-complex.groovy create mode 100644 src/test/resources/rule-driven-validator/rules/aai-event/entity-newvce.groovy create mode 100644 src/test/resources/rule-driven-validator/rules/aai-event/generic-vnf-rules.groovy create mode 100644 src/test/resources/rule-driven-validator/rules/aai-event/rule-vserver-all_others.groovy create mode 100644 src/test/resources/rule-driven-validator/rules/aai-event/rule-vserver-related-generic-vnf.groovy create mode 100644 src/test/resources/rule-driven-validator/rules/aai-event/vserver-rules.groovy create mode 100644 src/test/resources/rule-driven-validator/rules/gizmo-event/common_rules.groovy create mode 100644 src/test/resources/rule-driven-validator/rules/gizmo-event/pserver-rules.groovy create mode 100644 src/test/resources/rule-driven-validator/test-rule-driven-validator-beans.xml create mode 100644 src/test/resources/rule-driven-validator/test_events/generic-vnf-create-event.json create mode 100644 src/test/resources/rule-driven-validator/test_events/gizmo-pserver-create-event-invalid-ipaddress.json create mode 100644 src/test/resources/rule-driven-validator/test_events/gizmo-pserver-create-event.json create mode 100644 src/test/resources/rule-driven-validator/test_events/vserver-create-AAI-EVENT-devINT1-TRINITY-VNF-NAME-BAD.json create mode 100644 src/test/resources/rule-driven-validator/test_events/vserver-create-AAI-EVENT-devINT1-TRINITY-VNF-NAME-GOOD.json create mode 100644 src/test/resources/rule-driven-validator/test_events/vserver-create-event.json create mode 100644 src/test/resources/rule-driven-validator/test_events/vserver-update-AAI-EVENT-devINT1.json create mode 100644 src/test/resources/topic-admin-config/test-validation-service-beans.xml create mode 100644 src/test/resources/topic-admin-config/validation-service.properties create mode 100644 src/test/resources/topic-config/test-topic-config-beans.xml create mode 100644 src/test/resources/topic-config/test-validation-service-beans.xml create mode 100644 src/test/resources/topic-config/topic-aai-data-export.properties create mode 100644 src/test/resources/topic-config/topic-aai-data-integrity.properties create mode 100644 src/test/resources/topic-config/topic-aai-event.properties create mode 100644 src/test/resources/validation-controller-config/test-validation-service-beans.xml create mode 100644 src/test/resources/validation-controller-config/validation-controller-config.properties create mode 100644 src/test/resources/validation-result/test-validation-service-beans.xml create mode 100644 src/test/resources/validation-result/vserver-create-event.json create mode 100644 src/test/resources/validation-service.properties (limited to 'src/test') diff --git a/src/test/java/org/onap/aai/validation/auth/MicroServiceAuthTest.java b/src/test/java/org/onap/aai/validation/auth/MicroServiceAuthTest.java new file mode 100644 index 0000000..f9bd177 --- /dev/null +++ b/src/test/java/org/onap/aai/validation/auth/MicroServiceAuthTest.java @@ -0,0 +1,227 @@ +/* + * ============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.auth; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.file.Paths; +import java.security.cert.X509Certificate; +import javax.security.auth.x500.X500Principal; +import javax.ws.rs.core.Cookie; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.aai.auth.AAIAuthException; +import org.onap.aai.auth.AAIMicroServiceAuth; +import org.onap.aai.auth.AAIMicroServiceAuthCore; +import org.onap.aai.validation.config.ValidationServiceAuthConfig; +import org.springframework.mock.web.MockHttpServletRequest; + +/** + * Tests @{link AAIMicroServiceAuth} + */ + +public class MicroServiceAuthTest { + + static { + System.setProperty("APP_HOME", "."); + System.setProperty("CONFIG_HOME", Paths.get(System.getProperty("user.dir"), "src/test/resources").toString()); + } + + private static final String VALID_ADMIN_USER = "cn=common-name, ou=org-unit, o=org, l=location, st=state, c=us"; + private static final String authPolicyFile = "auth_policy.json"; + + /** + * Temporarily invalidate the default policy file and then try to initialise the authorisation class using the name + * of a policy file that does not exist. + * + * @throws AAIAuthException + * @throws IOException + */ + @Test(expected = AAIAuthException.class) + public void missingPolicyFile() throws AAIAuthException, IOException { + String defaultFile = AAIMicroServiceAuthCore.getDefaultAuthFileName(); + try { + AAIMicroServiceAuthCore.setDefaultAuthFileName("invalid.default.file"); + ValidationServiceAuthConfig authConfig = new ValidationServiceAuthConfig(); + authConfig.setAuthPolicyFile("invalid.file.name"); + new AAIMicroServiceAuth(authConfig); + } finally { + AAIMicroServiceAuthCore.setDefaultAuthFileName(defaultFile); + } + } + + /** + * Test loading of a temporary file created with the specified roles + * + * @throws AAIAuthException + * @throws IOException + * @throws JSONException + */ + @Test + public void createLocalAuthFile() throws AAIAuthException, IOException, JSONException { + JSONObject roles = createRoleObject("role", createUserObject("user"), createFunctionObject("func")); + AAIMicroServiceAuth auth = createAuthService(roles); + assertThat(auth.authUser("nosuchuser", "method:func"), is(equalTo("AAI_9101"))); + assertThat(auth.authUser("user", "method:func"), is(equalTo("OK"))); + } + + /** + * Test loading of the policy file relative to CONFIG_HOME + * + * @throws AAIAuthException + */ + @Test + public void createAuth() throws AAIAuthException { + AAIMicroServiceAuth auth = createStandardAuth(); + assertAdminUserAuthorisation(auth, VALID_ADMIN_USER); + } + + @Test + public void testAuthUser() throws AAIAuthException { + AAIMicroServiceAuth auth = createStandardAuth(); + assertThat(auth.authUser(VALID_ADMIN_USER, "GET:actions"), is(equalTo("OK"))); + assertThat(auth.authUser(VALID_ADMIN_USER, "WRONG:action"), is(equalTo("AAI_9101"))); + } + + @Test + public void testAuthCookie() throws AAIAuthException { + AAIMicroServiceAuth auth = createStandardAuth(); + Cookie mockCookie = new Cookie("name", null); + StringBuilder user = new StringBuilder(VALID_ADMIN_USER); + + assertThat(auth.authCookie(null, "GET:actions", user), is(false)); + assertThat(auth.authCookie(null, "WRONG:action", user), is(false)); + + assertThat(auth.authCookie(mockCookie, "GET:actions", user), is(true)); + assertThat(auth.authCookie(mockCookie, "WRONG:action", user), is(false)); + } + + @Test + public void testValidateRequests() throws AAIAuthException { + AAIMicroServiceAuth auth = createStandardAuth(); + assertThat(auth.validateRequest(new MockHttpServletRequest(), null, "app/v1/service"), is(false)); + assertThat(auth.validateRequest(createMockRequest(), "POST", "getAndPublish"), is(false)); + assertThat(auth.validateRequest(createMockRequest(), "POST", "validate"), is(true)); + } + + private MockHttpServletRequest createMockRequest() { + MockHttpServletRequest servletRequest = new MockHttpServletRequest(); + servletRequest.setSecure(true); + servletRequest.setScheme("https"); + servletRequest.setServerPort(9501); + servletRequest.setServerName("localhost"); + servletRequest.setRequestURI("/services/validation-service/v1/app/validate"); + + X509Certificate mockCertificate = Mockito.mock(X509Certificate.class); + Mockito.when(mockCertificate.getSubjectX500Principal()) + .thenReturn(new X500Principal("CN=test, OU=qa, O=Test Ltd, L=London, ST=London, C=GB")); + + servletRequest.setAttribute("javax.servlet.request.X509Certificate", new X509Certificate[] {mockCertificate}); + servletRequest.setAttribute("javax.servlet.request.cipher_suite", ""); + return servletRequest; + } + + private AAIMicroServiceAuth createStandardAuth() throws AAIAuthException { + ValidationServiceAuthConfig authConfig = new ValidationServiceAuthConfig(); + authConfig.setAuthPolicyFile(authPolicyFile); + return new AAIMicroServiceAuth(authConfig); + } + + /** + * @param rolesJson + * @return + * @throws IOException + * @throws AAIAuthException + */ + private AAIMicroServiceAuth createAuthService(JSONObject roles) throws IOException, AAIAuthException { + ValidationServiceAuthConfig authConfig = new ValidationServiceAuthConfig(); + File file = File.createTempFile("auth-policy", "json"); + file.deleteOnExit(); + FileWriter fileWriter = new FileWriter(file); + fileWriter.write(roles.toString()); + fileWriter.flush(); + fileWriter.close(); + + authConfig.setAuthPolicyFile(file.getAbsolutePath()); + return new AAIMicroServiceAuth(authConfig); + } + + /** + * Assert authorisation results for an admin user based on the test policy file + * + * @param auth + * @param adminUser + * @throws AAIAuthException + */ + private void assertAdminUserAuthorisation(AAIMicroServiceAuth auth, String adminUser) throws AAIAuthException { + assertThat(auth.authUser(adminUser, "GET:actions"), is(equalTo("OK"))); + assertThat(auth.authUser(adminUser, "POST:actions"), is(equalTo("OK"))); + assertThat(auth.authUser(adminUser, "PUT:actions"), is(equalTo("OK"))); + assertThat(auth.authUser(adminUser, "DELETE:actions"), is(equalTo("OK"))); + } + + private JSONArray createFunctionObject(String functionName) throws JSONException { + JSONArray functionsArray = new JSONArray(); + JSONObject func = new JSONObject(); + func.put("name", functionName); + func.put("methods", createMethodObject("method")); + functionsArray.put(func); + return functionsArray; + } + + private JSONArray createMethodObject(String methodName) throws JSONException { + JSONArray methodsArray = new JSONArray(); + JSONObject method = new JSONObject(); + method.put("name", methodName); + methodsArray.put(method); + return methodsArray; + } + + private JSONArray createUserObject(String username) throws JSONException { + JSONArray usersArray = new JSONArray(); + JSONObject user = new JSONObject(); + user.put("username", username); + usersArray.put(user); + return usersArray; + } + + private JSONObject createRoleObject(String roleName, JSONArray usersArray, JSONArray functionsArray) + throws JSONException { + JSONObject roles = new JSONObject(); + + JSONObject role = new JSONObject(); + role.put("name", roleName); + role.put("functions", functionsArray); + role.put("users", usersArray); + + JSONArray rolesArray = new JSONArray(); + rolesArray.put(role); + roles.put("roles", rolesArray); + + return roles; + } + +} diff --git a/src/test/java/org/onap/aai/validation/config/TestRestConfig.java b/src/test/java/org/onap/aai/validation/config/TestRestConfig.java new file mode 100644 index 0000000..313c847 --- /dev/null +++ b/src/test/java/org/onap/aai/validation/config/TestRestConfig.java @@ -0,0 +1,79 @@ +/* + * ============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.config; + +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +import javax.inject.Inject; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.aai.validation.config.RestConfig; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = {"classpath:/rest-config/test-validation-service-beans.xml"}) +public class TestRestConfig { + + static { + System.setProperty("APP_HOME", "."); + } + + @Inject + private RestConfig restConfig; + + @Test + public void testRestConfigPopulation() throws Exception { + RestConfig expectedRestConfig = new RestConfig(); + + expectedRestConfig.setHost("localhost"); + expectedRestConfig.setPort(8080); + expectedRestConfig.setProtocol("https"); + expectedRestConfig.setBaseModelURI("${baseModelURI}"); + expectedRestConfig.setTrustStorePath("/dir1/dir2/trustStorePath"); + expectedRestConfig.setTrustStorePassword("70c87528c88dcd9f9c2558d30e817868"); + expectedRestConfig.setKeyStorePath("/dir1/dir2/keyStorePath"); + expectedRestConfig.setKeyStorePassword("70c87528c88dcd9f9c2558d30e817868"); + expectedRestConfig.setKeyManagerFactoryAlgorithm("AES"); + expectedRestConfig.setKeyStoreType("jks"); + expectedRestConfig.setSecurityProtocol("TLS"); + expectedRestConfig.setConnectionTimeout(100); + expectedRestConfig.setReadTimeout(200); + + assertThat(expectedRestConfig, is(restConfig)); + assertThat(expectedRestConfig.getBaseModelURI(), is(restConfig.getBaseModelURI())); + assertThat(expectedRestConfig.getConnectionTimeout(), is(restConfig.getConnectionTimeout())); + assertThat(expectedRestConfig.getHost(), is(restConfig.getHost())); + assertThat(expectedRestConfig.getKeyManagerFactoryAlgorithm(), is(restConfig.getKeyManagerFactoryAlgorithm())); + assertThat(expectedRestConfig.getKeyStorePassword(), is(restConfig.getKeyStorePassword())); + assertThat(expectedRestConfig.getKeyStorePath(), is(restConfig.getKeyStorePath())); + assertThat(expectedRestConfig.getKeyStoreType(), is(restConfig.getKeyStoreType())); + assertThat(expectedRestConfig.getPort(), is(restConfig.getPort())); + assertThat(expectedRestConfig.getProtocol(), is(restConfig.getProtocol())); + assertThat(expectedRestConfig.getReadTimeout(), is(restConfig.getReadTimeout())); + assertThat(expectedRestConfig.getSecurityProtocol(), is(restConfig.getSecurityProtocol())); + assertThat(expectedRestConfig.getTrustStorePassword(), is(restConfig.getTrustStorePassword())); + assertThat(expectedRestConfig.getTrustStorePath(), is(restConfig.getTrustStorePath())); + assertThat(expectedRestConfig.hashCode(), is(restConfig.hashCode())); + assertThat(expectedRestConfig.toString(), is(restConfig.toString())); + assertTrue(expectedRestConfig.equals(restConfig)); + + } +} diff --git a/src/test/java/org/onap/aai/validation/config/TestTopicAdminConfig.java b/src/test/java/org/onap/aai/validation/config/TestTopicAdminConfig.java new file mode 100644 index 0000000..f6a6195 --- /dev/null +++ b/src/test/java/org/onap/aai/validation/config/TestTopicAdminConfig.java @@ -0,0 +1,60 @@ +/* + * ============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.config; + +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +import javax.inject.Inject; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.aai.validation.config.TopicAdminConfig; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = {"classpath:/topic-admin-config/test-validation-service-beans.xml"}) +public class TestTopicAdminConfig { + + static { + System.setProperty("APP_HOME", "."); + } + + @Inject + private TopicAdminConfig topicAdminConfig; + + @Test + public void testTopicAdminConfigPopulation() throws Exception { + TopicAdminConfig expectedTopicAdminConfig = new TopicAdminConfig(); + + expectedTopicAdminConfig.setPublishEnable(true); + expectedTopicAdminConfig.setPublishRetries(3l); + expectedTopicAdminConfig.setConsumeEnable(true); + expectedTopicAdminConfig.setConsumePollingIntervalSeconds(3l); + + assertThat(expectedTopicAdminConfig, is(topicAdminConfig)); + assertThat(expectedTopicAdminConfig.hashCode(), is(topicAdminConfig.hashCode())); + assertThat(expectedTopicAdminConfig.toString(), is(topicAdminConfig.toString())); + assertThat(expectedTopicAdminConfig.getConsumePollingIntervalSeconds(), + is(topicAdminConfig.getConsumePollingIntervalSeconds())); + assertThat(expectedTopicAdminConfig.getPublishRetries(), is(topicAdminConfig.getPublishRetries())); + assertTrue(expectedTopicAdminConfig.equals(topicAdminConfig)); + } + +} diff --git a/src/test/java/org/onap/aai/validation/config/TestTopicConfig.java b/src/test/java/org/onap/aai/validation/config/TestTopicConfig.java new file mode 100644 index 0000000..efe82b8 --- /dev/null +++ b/src/test/java/org/onap/aai/validation/config/TestTopicConfig.java @@ -0,0 +1,107 @@ +/* + * ============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.config; + +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +import java.util.List; +import java.util.Properties; +import javax.annotation.Resource; +import javax.inject.Inject; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.aai.validation.config.TopicConfig; +import org.onap.aai.validation.ValidationServiceApplication; +import org.onap.aai.validation.config.TopicConfig.Topic; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = {"classpath:/topic-config/test-validation-service-beans.xml"}) +public class TestTopicConfig { + + static { + System.setProperty("APP_HOME", "."); + } + + @Inject + private TopicConfig topicConfigurations; + + @Resource(name = "topicProperties") + private Properties topicProperties; + + + @Test + public void testGetTopicProperties() throws Exception { + assertThat(topicProperties.getProperty("aai-event.name"), is("aai-event")); + assertThat(topicProperties.getProperty("aai-data-export.name"), is("aai-data-export")); + } + + + + @Test + public void testGetConsumerTopicsFromTopicConfig() throws Exception { + assertThat(topicConfigurations.getConsumerTopicNames(), containsInAnyOrder("aai-event", "aai-data-export")); + } + + + @Test + public void testGetConsumerTopicConfigurationObjects() throws Exception { + Topic eventTopic = new TopicConfig("aai-event","aai-data-integrity").new Topic(); + eventTopic.setName("aai-event"); + eventTopic.setHost("event-dummy-host"); + eventTopic.setUsername("event-dummy-username"); + eventTopic.setPassword("event-dummy-password"); + eventTopic.setConsumerGroup("event-dummy-consumer-group"); + eventTopic.setConsumerId("event-dummy-consumer-id"); + eventTopic.setTransportType("event-dummy-transport-type"); + + Topic exportTopic = new TopicConfig("aai-data-export","aai-data-integrity").new Topic(); + exportTopic.setName("aai-data-export"); + exportTopic.setHost("export-dummy-host"); + exportTopic.setUsername("export-dummy-username"); + exportTopic.setPassword("export-dummy-password"); + exportTopic.setConsumerGroup("export-dummy-consumer-group"); + exportTopic.setConsumerId("export-dummy-consumer-id"); + exportTopic.setTransportType("export-dummy-transport-type"); + + List consumerTopics = topicConfigurations.getConsumerTopics(); + + assertThat(consumerTopics, containsInAnyOrder(eventTopic, exportTopic)); + } + + @Test + public void testGetPublisherTopicConfigurationObjects() throws Exception { + Topic integrityTopic = new TopicConfig("aai-data-export","aai-data-integrity").new Topic(); + integrityTopic.setName("aai-data-integrity"); + integrityTopic.setHost("integrity-dummy-host"); + integrityTopic.setPartition("integrity-dummy-partition"); + integrityTopic.setUsername("integrity-dummy-username"); + integrityTopic.setPassword("integrity-dummy-password"); + integrityTopic.setTransportType("integrity-dummy-transport-type"); + + List publisherTopics = topicConfigurations.getPublisherTopics(); + + assertThat(publisherTopics, containsInAnyOrder(integrityTopic)); + } + + +} diff --git a/src/test/java/org/onap/aai/validation/config/TestValidationControllerConfig.java b/src/test/java/org/onap/aai/validation/config/TestValidationControllerConfig.java new file mode 100644 index 0000000..a8e03eb --- /dev/null +++ b/src/test/java/org/onap/aai/validation/config/TestValidationControllerConfig.java @@ -0,0 +1,69 @@ +/* + * ============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.config; + +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +import java.util.ArrayList; +import java.util.List; +import javax.inject.Inject; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.aai.validation.config.ValidationControllerConfig; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = {"classpath:/validation-controller-config/test-validation-service-beans.xml"}) +public class TestValidationControllerConfig { + + static { + System.setProperty("APP_HOME", "."); + } + + @Inject + private ValidationControllerConfig validationControllerConfig; + + @Test + public void testValidationControllerConfig() { + ValidationControllerConfig expected = new ValidationControllerConfig(); + List excludedEventActionList = new ArrayList(); + excludedEventActionList.add("DELETE"); + + List eventTypeRuleList = new ArrayList(2); + eventTypeRuleList.add("AAI-EVENT"); + eventTypeRuleList.add("AAI-DATA-EXPORT-API"); + + List eventTypeModelList = new ArrayList(); + eventTypeModelList.add("AAI-DATA-EXPORT-NQ"); + + expected.setEventDomain("devINT1"); + expected.setExcludedEventActions(excludedEventActionList); + expected.setEventTypeRule(eventTypeRuleList); + expected.setEventTypeModel(eventTypeModelList); + expected.setEventTypeEnd("END-EVENT"); + + assertThat(expected.getEventDomain(), is(validationControllerConfig.getEventDomain())); + assertThat(expected.getExcludedEventActions(), is(validationControllerConfig.getExcludedEventActions())); + assertThat(expected.getEventTypeRule(), is(validationControllerConfig.getEventTypeRule())); + assertThat(expected.getEventTypeModel(), is(validationControllerConfig.getEventTypeModel())); + assertThat(expected.getEventTypeEnd(), is(validationControllerConfig.getEventTypeEnd())); + } + +} diff --git a/src/test/java/org/onap/aai/validation/controller/TestValidationController.java b/src/test/java/org/onap/aai/validation/controller/TestValidationController.java new file mode 100644 index 0000000..ff67181 --- /dev/null +++ b/src/test/java/org/onap/aai/validation/controller/TestValidationController.java @@ -0,0 +1,391 @@ +/* + * ============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.controller; + +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.onap.aai.validation.Validator; +import org.onap.aai.validation.config.EventReaderConfig; +import org.onap.aai.validation.config.ValidationControllerConfig; +import org.onap.aai.validation.controller.ValidationController; +import org.onap.aai.validation.exception.ValidationServiceError; +import org.onap.aai.validation.exception.ValidationServiceException; +import org.onap.aai.validation.publisher.MessagePublisher; +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.result.ValidationResult; +import org.onap.aai.validation.result.Violation; + +@RunWith(MockitoJUnitRunner.class) +public class TestValidationController { + + private static final String AAI_EVENT = "AAI-EVENT"; + private static final String CREATE = "CREATE"; + private static final String DELETE = "DELETE"; + private static final String DEV_INT_1 = "devINT1"; + private static final String ENTITY_LINK = "entityLink"; + private static final String MODEL = "model"; + private static final String RULE = "rule"; + private static final String TEST = "test"; + private static final String TESTDATA_EVENTTYPE_NAMEDQUERY = "aai named query eventtype"; + private static final String TESTDATA_EVENTTYPE_API = "aai api eventtype"; + private static final String TESTDATA_EVENTTYPE_AAI = "aai event eventype"; + private static final String TESTDATA_EVENTTYPE_UNKNOWN = "unknown eventtype"; + private static final String TESTDATA_EVENTTYPE_NULL = "event with null eventtype"; + private static final String TESTDATA_EVENTTYPE_END_EVENT = "END-EVENT"; + private static final String TESTDATA_DOMAIN_INVALID = "event with invalid domain"; + private static final String TESTDATA_DOMAIN_NULL = "event with null domain"; + private static final String TESTDATA_EVENTACTION_DELETE = "event with delete event action"; + private static final String TESTDATA_EVENTACTION_NULL = "event with null event action"; + private static final String TESTDATA_EXCEPTION_EVENT = "event causing exception"; + private static final String TESTDATA_HANDLE_EXCEPTION_EXCEPTION_EVENT = + "event causing exception during handling of the original exception"; + private static final String TESTDATA_VALIDATION_RESULT_PUBLISH_ERROR = + "event causing exception during publishing of validation result"; + private static final String VSERVER = "vserver"; + + @Mock + private ValidationControllerConfig validationControllerConfig; + + @Mock + private EventReader eventReader; + + @Mock + private Validator ruleDrivenValidator; + + @Mock + private Validator modelDrivenValidator; + + @Mock + private MessagePublisher messagePublisher; + + @InjectMocks + private ValidationController validationController = new ValidationController(validationControllerConfig, + eventReader, ruleDrivenValidator, modelDrivenValidator, messagePublisher); + + @Mock + private Entity entity; + + static { + System.setProperty("APP_HOME", "."); + } + + @Before + public void setupMocks() throws ValidationServiceException { + + Map> validationResultsMap = setupTestData(); + + when(ruleDrivenValidator.validate(TESTDATA_EVENTTYPE_AAI)) + .thenReturn(validationResultsMap.get(TESTDATA_EVENTTYPE_AAI)); + when(ruleDrivenValidator.validate(TESTDATA_EVENTTYPE_API)) + .thenReturn(validationResultsMap.get(TESTDATA_EVENTTYPE_API)); + when(modelDrivenValidator.validate(TESTDATA_EVENTTYPE_NAMEDQUERY)) + .thenReturn(validationResultsMap.get(TESTDATA_EVENTTYPE_NAMEDQUERY)); + when(ruleDrivenValidator.validate(TESTDATA_EXCEPTION_EVENT)) + .thenThrow(new RuntimeException("Failed to validate")); + when(ruleDrivenValidator.validate(TESTDATA_HANDLE_EXCEPTION_EXCEPTION_EVENT)) + .thenThrow(new RuntimeException("Failed to validate")); + when(ruleDrivenValidator.validate(TESTDATA_VALIDATION_RESULT_PUBLISH_ERROR)) + .thenReturn(validationResultsMap.get(TESTDATA_VALIDATION_RESULT_PUBLISH_ERROR)); + when(ruleDrivenValidator.validate(TESTDATA_EVENTACTION_NULL)) + .thenReturn(validationResultsMap.get(TESTDATA_EVENTTYPE_AAI)); + + Map> eventTypeDataMap = setupEventTypeData(); + when(validationControllerConfig.getEventTypeRule()).thenReturn(eventTypeDataMap.get(RULE)); + when(validationControllerConfig.getEventTypeModel()).thenReturn(eventTypeDataMap.get(MODEL)); + when(validationControllerConfig.getEventTypeEnd()).thenReturn("END-EVENT"); + + when(eventReader.getEventType(TESTDATA_EVENTTYPE_AAI)).thenReturn(Optional.of(AAI_EVENT)); + when(eventReader.getEventType(TESTDATA_EVENTTYPE_API)).thenReturn(Optional.of("AAI-DATA-EXPORT-API")); + when(eventReader.getEventType(TESTDATA_EVENTTYPE_NAMEDQUERY)).thenReturn(Optional.of("AAI-DATA-EXPORT-NQ")); + when(eventReader.getEventType(TESTDATA_EVENTTYPE_UNKNOWN)).thenReturn(Optional.of("EVENTTYPE-UNKNOWN")); + when(eventReader.getEventType(TESTDATA_EVENTTYPE_NULL)).thenReturn(Optional.empty()); + when(eventReader.getEventType(TESTDATA_EXCEPTION_EVENT)).thenReturn(Optional.of(AAI_EVENT)); + when(eventReader.getEventType(TESTDATA_HANDLE_EXCEPTION_EXCEPTION_EVENT)).thenReturn(Optional.of(AAI_EVENT)); + when(eventReader.getEventType(TESTDATA_VALIDATION_RESULT_PUBLISH_ERROR)).thenReturn(Optional.of(AAI_EVENT)); + when(eventReader.getEventType(TESTDATA_EVENTACTION_NULL)).thenReturn(Optional.of(AAI_EVENT)); + + when(validationControllerConfig.getEventDomain()).thenReturn(DEV_INT_1); + when(eventReader.getEventDomain(TESTDATA_EVENTTYPE_AAI)).thenReturn(Optional.of(DEV_INT_1)); + when(eventReader.getEventDomain(TESTDATA_EVENTTYPE_API)).thenReturn(Optional.of(DEV_INT_1)); + when(eventReader.getEventDomain(TESTDATA_EVENTTYPE_NAMEDQUERY)).thenReturn(Optional.of(DEV_INT_1)); + when(eventReader.getEventDomain(TESTDATA_EVENTTYPE_UNKNOWN)).thenReturn(Optional.of(DEV_INT_1)); + when(eventReader.getEventDomain(TESTDATA_EVENTTYPE_NULL)).thenReturn(Optional.of(DEV_INT_1)); + when(eventReader.getEventDomain(TESTDATA_DOMAIN_INVALID)).thenReturn(Optional.of("invalidDomain")); + when(eventReader.getEventDomain(TESTDATA_DOMAIN_NULL)).thenReturn(Optional.empty()); + when(eventReader.getEventDomain(TESTDATA_EXCEPTION_EVENT)).thenReturn(Optional.of(DEV_INT_1)); + when(eventReader.getEventDomain(TESTDATA_HANDLE_EXCEPTION_EXCEPTION_EVENT)).thenReturn(Optional.of(DEV_INT_1)); + when(eventReader.getEventDomain(TESTDATA_VALIDATION_RESULT_PUBLISH_ERROR)).thenReturn(Optional.of(DEV_INT_1)); + when(eventReader.getEventDomain(TESTDATA_EVENTACTION_DELETE)).thenReturn(Optional.of(DEV_INT_1)); + when(eventReader.getEventDomain(TESTDATA_EVENTACTION_NULL)).thenReturn(Optional.of(DEV_INT_1)); + + List excludedActions = new ArrayList<>(); + excludedActions.add(DELETE); + when(validationControllerConfig.getExcludedEventActions()).thenReturn(excludedActions); + when(eventReader.getEventAction(TESTDATA_EVENTTYPE_AAI)).thenReturn(Optional.of(CREATE)); + when(eventReader.getEventAction(TESTDATA_EVENTTYPE_API)).thenReturn(Optional.of(CREATE)); + when(eventReader.getEventAction(TESTDATA_EVENTTYPE_NAMEDQUERY)).thenReturn(Optional.of(CREATE)); + when(eventReader.getEventAction(TESTDATA_EVENTTYPE_UNKNOWN)).thenReturn(Optional.of(CREATE)); + when(eventReader.getEventAction(TESTDATA_EVENTTYPE_NULL)).thenReturn(Optional.of(CREATE)); + when(eventReader.getEventAction(TESTDATA_EXCEPTION_EVENT)).thenReturn(Optional.of(CREATE)); + when(eventReader.getEventAction(TESTDATA_HANDLE_EXCEPTION_EXCEPTION_EVENT)).thenReturn(Optional.of(CREATE)); + when(eventReader.getEventAction(TESTDATA_VALIDATION_RESULT_PUBLISH_ERROR)).thenReturn(Optional.of(CREATE)); + when(eventReader.getEventAction(TESTDATA_EVENTACTION_DELETE)).thenReturn(Optional.of(DELETE)); + when(eventReader.getEventAction(TESTDATA_EVENTACTION_NULL)).thenReturn(Optional.empty()); + + when(eventReader.getEntityType(TESTDATA_EXCEPTION_EVENT)).thenReturn(Optional.of(VSERVER)); + when(eventReader.getEntity(TESTDATA_EXCEPTION_EVENT)).thenReturn(entity); + when(eventReader.getEntityType(TESTDATA_HANDLE_EXCEPTION_EXCEPTION_EVENT)).thenThrow( + new RuntimeException("Error during handling the exception for an event that couldn't be validated")); + //@formatter:off + Mockito.doThrow(new ValidationServiceException(ValidationServiceError.EVENT_CLIENT_PUBLISHER_INIT_ERROR)) + .when(messagePublisher) + .publishMessage( + Mockito.contains("\"entityId\":\"[vserver-id=instanceid1]\",\"entityType\":\"entitytype1\",\"resourceVersion\":\"resourceVersion1\"")); + //@formatter:on + } + + private Map> setupEventTypeData() { + Map> eventTypeDataMap = new HashMap<>(); + List eventTypeRule = new ArrayList<>(); + + eventTypeRule.add(AAI_EVENT); + eventTypeRule.add("AAI-DATA-EXPORT-API"); + eventTypeDataMap.put(RULE, eventTypeRule); + + List eventTypeModel = new ArrayList<>(); + eventTypeModel.add("AAI-DATA-EXPORT-NQ"); + eventTypeDataMap.put(MODEL, eventTypeModel); + + return eventTypeDataMap; + } + + private Map> setupTestData() throws ValidationServiceException { + + Map> validationResultsMap = new HashMap<>(); + + List aaiEventValidationResults = new ArrayList<>(); + + setUpEntityMock("20160525162737-61c49d41-5338-4755-af54-06cee9fe4aca", VSERVER, "1464193654"); + + aaiEventValidationResults.add(new ValidationResult(entity)); + aaiEventValidationResults.add(new ValidationResult(entity)); + validationResultsMap.put(TESTDATA_EVENTTYPE_AAI, aaiEventValidationResults); + + List apiEventValidationResults = new ArrayList<>(); + + setUpEntityMock("20160525162737-61c49d41-5338-4755-af54-06cee9fe4acb", VSERVER, "1464193655"); + + apiEventValidationResults.add(new ValidationResult(entity)); + validationResultsMap.put(TESTDATA_EVENTTYPE_API, apiEventValidationResults); + + List namedQueryEventValidationResults = new ArrayList<>(); + + setUpEntityMock("20160525162737-61c49d41-5338-4755-af54-06cee9fe4acc", VSERVER, "1464193656"); + + namedQueryEventValidationResults.add(new ValidationResult(entity)); + validationResultsMap.put(TESTDATA_EVENTTYPE_NAMEDQUERY, namedQueryEventValidationResults); + + List messagePublishExceptionValidationResults = new ArrayList<>(); + + setUpEntityMock("instanceid1", "entitytype1", "resourceVersion1"); + + messagePublishExceptionValidationResults.add(new ValidationResult(entity)); + validationResultsMap.put(TESTDATA_VALIDATION_RESULT_PUBLISH_ERROR, messagePublishExceptionValidationResults); + + return validationResultsMap; + } + + @Test + public void testExecuteForAAIEvent() throws Exception { + // Test for AAI-EVENT + validationController.execute(TESTDATA_EVENTTYPE_AAI, TEST); + verify(ruleDrivenValidator, times(1)).validate(TESTDATA_EVENTTYPE_AAI); + verify(messagePublisher, times(2)).publishMessage(Mockito.contains( + "\"entityId\":{\"vserver-id\":\"20160525162737-61c49d41-5338-4755-af54-06cee9fe4aca\"},\"entityType\":\"vserver\",\"entityLink\":\"entityLink\",\"resourceVersion\":\"1464193654\",\"entity\":{},\"violations\":[]}")); + } + + @Test + public void testExecuteForAPIEvent() throws Exception { + // Test for AAI-DATA-EXPORT-API + validationController.execute(TESTDATA_EVENTTYPE_API, TEST); + verify(ruleDrivenValidator, times(1)).validate(TESTDATA_EVENTTYPE_API); + verify(messagePublisher, times(1)).publishMessage(Mockito.contains( + "\"entityId\":{\"vserver-id\":\"20160525162737-61c49d41-5338-4755-af54-06cee9fe4acb\"},\"entityType\":\"vserver\",\"entityLink\":\"entityLink\",\"resourceVersion\":\"1464193655\",\"entity\":{},\"violations\":[]}")); + } + + @Test + public void testExecuteForNQEvent() throws Exception { + // Test for AAI-DATA-EXPORT-NQ + validationController.execute(TESTDATA_EVENTTYPE_NAMEDQUERY, TEST); + verify(modelDrivenValidator, times(1)).validate(TESTDATA_EVENTTYPE_NAMEDQUERY); + verify(messagePublisher, times(1)).publishMessage(Mockito.contains( + "\"entityId\":{\"vserver-id\":\"20160525162737-61c49d41-5338-4755-af54-06cee9fe4acc\"},\"entityType\":\"vserver\",\"entityLink\":\"entityLink\",\"resourceVersion\":\"1464193656\",\"entity\":{},\"violations\":[]}")); + } + + @Test + public void testExecuteForNullDomain() throws Exception { + doVerifyMockInteractionsTest(TESTDATA_DOMAIN_NULL, TEST); + } + + private void doVerifyMockInteractionsTest(String event, String eventSource) throws Exception { + validationController.execute(event, eventSource); + verify(eventReader, times(1)).getEventType(Mockito.anyString()); + verify(ruleDrivenValidator, times(0)).validate(Mockito.anyString()); + verify(modelDrivenValidator, times(0)).validate(Mockito.anyString()); + verify(messagePublisher, times(0)).publishMessage(Mockito.anyString()); + + } + + @Test + public void testExecuteForInvalidDomain() throws Exception { + doVerifyMockInteractionsTest(TESTDATA_DOMAIN_INVALID, TEST); + } + + @Test + public void testExecuteForExcludedAction() throws Exception { + doVerifyMockInteractionsTest(TESTDATA_EVENTACTION_DELETE, TEST); + } + + @Test + public void testExecuteForNullAction() throws Exception { + validationController.execute(TESTDATA_EVENTACTION_NULL, TEST); + verify(eventReader, times(2)).getEventType(Mockito.anyString()); + verify(ruleDrivenValidator, times(1)).validate(Mockito.anyString()); + verify(modelDrivenValidator, times(0)).validate(Mockito.anyString()); + verify(messagePublisher, times(2)).publishMessage(Mockito.anyString()); + } + + + + private void doEventTypeTest(String event, String eventSource, int numEventReaderInvocations) throws Exception { + validationController.execute(event, eventSource); + verify(eventReader, times(numEventReaderInvocations)).getEventType(event); + verify(ruleDrivenValidator, times(0)).validate(Mockito.anyString()); + verify(modelDrivenValidator, times(0)).validate(Mockito.anyString()); + verify(messagePublisher, times(0)).publishMessage(Mockito.anyString()); + } + + @Test + public void testExecuteForNullEventType() throws Exception { + // The implementation checks whether this is an end event + // Given that it is not, the event is then examined to see if it is a validation candidate + doEventTypeTest(TESTDATA_EVENTTYPE_NULL, TEST, 2); + } + + @Test + public void testExecuteForUnknownEventType() throws Exception { + doEventTypeTest(TESTDATA_EVENTTYPE_UNKNOWN, TEST, 2); + } + + @Test + public void testExecuteForEndEventType() throws Exception { + doVerifyMockInteractionsTest(TESTDATA_EVENTTYPE_END_EVENT, TEST); + } + + @Test + public void testExceptionDuringValidation() throws Exception { + String primaryKey = "vserver-id"; + String value = "example-vserver-id-val-34666"; + String resourceVersion = "123456789"; + + EntityId entityId = new EntityId(primaryKey, value); + + when(entity.getResourceVersion()).thenReturn(Optional.of(resourceVersion)); + when(entity.getIds()).thenReturn(Collections.singletonList(entityId)); + validationController.execute(TESTDATA_EXCEPTION_EVENT, TEST); + verify(ruleDrivenValidator, times(1)).validate(TESTDATA_EXCEPTION_EVENT); + + // @formatter:off + Violation violation = new Violation.Builder(entity) + .category("CANNOT_VALIDATE") + .severity("CRITICAL") + .violationType("NONE") + .errorMessage("Failed to validate") + .build(); + // @formatter:on + + JsonObject violationObject = new JsonParser().parse(violation.toString()).getAsJsonObject(); + violationObject.remove("validationRule"); // Not set + + JsonObject validationResult = new JsonObject(); + JsonObject entityIdObject = new JsonObject(); + JsonElement entity = new JsonObject(); + entityIdObject.addProperty(primaryKey, value); + validationResult.add(Violation.ENTITY_ID_PROPERTY, entityIdObject); + validationResult.addProperty(Violation.ENTITY_TYPE_PROPERTY, "entitytype1"); + validationResult.addProperty(ENTITY_LINK, ENTITY_LINK); + validationResult.addProperty("resourceVersion", resourceVersion); + validationResult.add("entity", entity); + JsonArray violations = new JsonArray(); + violations.add(violationObject); + validationResult.add("violations", violations); + + String json = validationResult.toString(); + String messageContent = json.substring(1, json.length() - 1); // Remove the { } from the JSON string + verify(messagePublisher).publishMessage(Mockito.contains(messageContent)); + } + + @Test + public void testExceptionDuringHandlingValidationException() throws Exception { + // Test for exception during handling of an exception scenario + validationController.execute(TESTDATA_HANDLE_EXCEPTION_EXCEPTION_EVENT, TEST); + verify(ruleDrivenValidator, times(1)).validate(TESTDATA_HANDLE_EXCEPTION_EXCEPTION_EVENT); + verify(messagePublisher, times(0)).publishMessage(Mockito.anyString()); + } + + @Test + public void testExceptionDuringMessagePublish() throws Exception { + // Test for exception during publishing message. + // Cant verify if the static application logger has been called. + // This test is here for code coverage. + validationController.execute(TESTDATA_VALIDATION_RESULT_PUBLISH_ERROR, TEST); + verify(ruleDrivenValidator, times(1)).validate(TESTDATA_VALIDATION_RESULT_PUBLISH_ERROR); + verify(messagePublisher, times(1)).publishMessage(Mockito.contains( + "\"entityId\":{\"vserver-id\":\"instanceid1\"},\"entityType\":\"entitytype1\",\"entityLink\":\"entityLink\",\"resourceVersion\":\"resourceVersion1\",\"entity\":{},\"violations\":[]}")); + } + + private void setUpEntityMock(String id, String type, String resourceVersion) throws ValidationServiceException { + when(eventReader.getEventReaderConfig()).thenReturn(new EventReaderConfig()); + when(entity.getType()).thenReturn(type); + EntityId entityId = new EntityId("vserver-id", id); + when(entity.getIds()).thenReturn(Collections.singletonList(entityId)); + when(entity.getEntityLink()).thenReturn(ENTITY_LINK); + when(entity.getResourceVersion()).thenReturn(Optional.of(resourceVersion)); + } +} diff --git a/src/test/java/org/onap/aai/validation/data/client/TestRestClient.java b/src/test/java/org/onap/aai/validation/data/client/TestRestClient.java new file mode 100644 index 0000000..9f2807b --- /dev/null +++ b/src/test/java/org/onap/aai/validation/data/client/TestRestClient.java @@ -0,0 +1,74 @@ +/* + * ============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.data.client; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; + +import javax.ws.rs.core.MediaType; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.aai.validation.config.RestConfig; +import org.onap.aai.validation.data.client.RestClient; +import org.onap.aai.validation.exception.ValidationServiceException; + +/** + * Simple tests for GET and POST failures so as to increase code coverage. + * + * Note that the REST client is not properly initialised. + * + */ +public class TestRestClient { + + static { + System.setProperty("APP_HOME", "."); + } + + private static final String TEST_URL = "/aai/v11"; + private RestConfig mockRestConfig; + + @Before + public void setUp() { + mockRestConfig = Mockito.mock(RestConfig.class); + Mockito.when(mockRestConfig.getProtocol()).thenReturn("http"); + Mockito.when(mockRestConfig.getHost()).thenReturn("localhost"); + Mockito.when(mockRestConfig.getPort()).thenReturn(8080); + } + + @Test + public void validateConstructor() { + RestClient restClient = new RestClient(mockRestConfig); + assertNotNull(restClient); + assertThat(restClient.toString(), is(notNullValue())); + } + + @Test(expected = ValidationServiceException.class) + public void getOperationFailure() throws ValidationServiceException { + RestClient restClient = new RestClient(mockRestConfig); + restClient.get(TEST_URL, MediaType.TEXT_PLAIN); + } + + @Test(expected = ValidationServiceException.class) + public void postOperationFailure() throws ValidationServiceException { + RestClient restClient = new RestClient(mockRestConfig); + restClient.post(TEST_URL, MediaType.TEXT_PLAIN); + } +} diff --git a/src/test/java/org/onap/aai/validation/logging/LogReader.java b/src/test/java/org/onap/aai/validation/logging/LogReader.java new file mode 100644 index 0000000..096221d --- /dev/null +++ b/src/test/java/org/onap/aai/validation/logging/LogReader.java @@ -0,0 +1,101 @@ +/* + * ============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.logging; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.TimeUnit; +import org.apache.commons.lang.time.StopWatch; +import org.junit.Assert; + +public class LogReader { + + private Map cachedLogMap = new HashMap<>(); + private Map readersMap = new HashMap<>(); + private BufferedReader cachedReader; + + public LogReader(String logDirectory, String logFilePrefix) throws IOException { + cachedReader = getReader(logDirectory, logFilePrefix); + } + + private BufferedReader getReader(String logDirectory, String logFilePrefix) throws IOException { + BufferedReader reader = readersMap.get(logFilePrefix); + if (reader == null) { + reader = new BufferedReader(new FileReader(getLogFile(logDirectory, logFilePrefix))); + while (reader.readLine() != null) { + // Consume all lines + } + readersMap.put(logFilePrefix, reader); + } + return reader; + } + + /** + * @param logDirectory + * @return the most recently created log file. + * @throws IOException + */ + public File getLogFile(String logDirectory, String filenamePrefix) throws IOException { + Path cachedLog = cachedLogMap.get(filenamePrefix); + + if (cachedLog == null) { + Optional latestFilePath = Files.list(Paths.get(logDirectory)) + .filter(f -> Files.isDirectory(f) == false && f.getFileName().toString().startsWith(filenamePrefix)) + .max(Comparator.comparingLong(f -> f.toFile().lastModified())); + if (latestFilePath.isPresent()) { + cachedLog = latestFilePath.get(); + } else { + throw new IOException("No validation log files were found!"); + } + } + + return cachedLog.toFile(); + } + + /** + * @return new lines appended to the log file + * @throws IOException + */ + public String getNewLines() throws IOException { + StopWatch stopwatch = new StopWatch(); + stopwatch.start(); + + while (!cachedReader.ready()) { + if (stopwatch.getTime() > TimeUnit.SECONDS.toMillis(30)) { + Assert.fail("Test took too long"); + } + // else keep waiting + } + + StringBuilder lines = new StringBuilder(); + String line; + while ((line = cachedReader.readLine()) != null) { + lines.append(line).append(System.lineSeparator()); + } + return lines.toString(); + } +} diff --git a/src/test/java/org/onap/aai/validation/logging/TestApplicationLogger.java b/src/test/java/org/onap/aai/validation/logging/TestApplicationLogger.java new file mode 100644 index 0000000..d19d43d --- /dev/null +++ b/src/test/java/org/onap/aai/validation/logging/TestApplicationLogger.java @@ -0,0 +1,245 @@ +/* + * ============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.logging; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.CoreMatchers.startsWith; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.io.IOException; +import java.nio.file.Paths; +import java.util.Arrays; +import org.apache.commons.lang.time.StopWatch; +import org.junit.BeforeClass; +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.aai.cl.api.LogFields; +import org.onap.aai.cl.api.Logger; +import org.onap.aai.cl.mdc.MdcOverride; +import org.onap.aai.validation.logging.ApplicationMsgs; +import org.onap.aai.validation.logging.LogHelper; +import org.onap.aai.validation.logging.LogHelper.TriConsumer; +import org.springframework.http.HttpHeaders; + +/** + * Simple test to log each of the validation messages in turn. + * + * This version tests only the error logger at INFO level. + * + */ +public class TestApplicationLogger { + + @BeforeClass + public static void setupClass() { + System.setProperty("APP_HOME", "."); + } + + /** + * Check that each message can be logged and that (by implication of successful logging) there is a corresponding + * resource (message format). + * + * @throws IOException + */ + @Test + public void logAllMessages() throws IOException { + Logger logger = LogHelper.INSTANCE; + String logDirectory = getLogDirectory(); + LogReader errorReader = new LogReader(logDirectory, "error"); + LogReader debugReader = new LogReader(logDirectory, "debug"); + String[] args = {"1", "2", "3", "4"}; + for (ApplicationMsgs msg : Arrays.asList(ApplicationMsgs.values())) { + if (msg.name().endsWith("ERROR")) { + logger.error(msg, args); + validateLoggedMessage(msg, errorReader, "ERROR"); + + logger.error(msg, new RuntimeException("fred"), args); + validateLoggedMessage(msg, errorReader, "fred"); + } else { + logger.info(msg, args); + validateLoggedMessage(msg, errorReader, "INFO"); + + logger.warn(msg, args); + validateLoggedMessage(msg, errorReader, "WARN"); + } + + logger.debug(msg, args); + validateLoggedMessage(msg, debugReader, "DEBUG"); + + // The trace level is not enabled + logger.trace(msg, args); + } + } + + /** + * Check that each message can be logged and that (by implication of successful logging) there is a corresponding + * resource (message format). + * + * @throws IOException + */ + @Test + public void logDebugMessages() throws IOException { + LogReader reader = new LogReader(getLogDirectory(), "debug"); + LogHelper.INSTANCE.debug("a message"); + String s = reader.getNewLines(); + assertThat(s, is(notNullValue())); + } + + + /** + * Check logAudit with HTTP headers + * + * @throws IOException + */ + @Test + public void logAuditMessage() throws IOException { + LogHelper logger = LogHelper.INSTANCE; + LogReader reader = new LogReader(getLogDirectory(), "audit"); + + HttpHeaders headers = Mockito.mock(HttpHeaders.class); + Mockito.when(headers.getFirst("X-ECOMP-RequestID")).thenReturn("ecomp-request-id"); + Mockito.when(headers.getFirst("X-FromAppId")).thenReturn("app-id"); + + // Call logAudit without first calling startAudit + logger.logAuditSuccess("first call: bob"); + String s = reader.getNewLines(); + assertThat(s, is(notNullValue())); + assertThat("audit message log level", s, containsString("INFO")); + assertThat("audit message content", s, containsString("bob")); + + // This time call the start method + logger.startAudit(headers, null); + logger.logAuditSuccess("second call: foo"); + s = reader.getNewLines(); + assertThat(s, is(notNullValue())); + assertThat("audit message log level", s, containsString("INFO")); + assertThat("audit message content", s, containsString("foo")); + assertThat("audit message content", s, containsString("ecomp-request-id")); + assertThat("audit message content", s, containsString("app-id")); + } + + /** + * Check logAudit with no HTTP headers + * + * @throws IOException + */ + @Test + public void logAuditMessageWithoutHeaders() throws IOException { + LogHelper logger = LogHelper.INSTANCE; + LogReader reader = new LogReader(getLogDirectory(), "audit"); + logger.startAudit(null, null); + logger.logAuditSuccess("foo"); + String s = reader.getNewLines(); + assertThat(s, is(notNullValue())); + assertThat("audit message log level", s, containsString("INFO")); + assertThat("audit message content", s, containsString("foo")); + } + + /** + * Check logMetrics + * + * @throws IOException + */ + @Test + public void logMetricsMessage() throws IOException { + LogReader reader = new LogReader(getLogDirectory(), "metrics"); + LogHelper logger = LogHelper.INSTANCE; + logger.logMetrics("metrics: fred"); + String s = reader.getNewLines(); + assertThat(s, is(notNullValue())); + assertThat("metrics message log level", s, containsString("INFO")); + assertThat("metrics message content", s, containsString("fred")); + } + + @Test + public void logMetricsMessageWithStopwatch() throws IOException { + LogReader reader = new LogReader(getLogDirectory(), "metrics"); + LogHelper logger = LogHelper.INSTANCE; + StopWatch stopWatch = new StopWatch(); + stopWatch.start(); + logger.logMetrics(stopWatch, "joe", "bloggs"); + String logLine = reader.getNewLines(); + assertThat(logLine, is(notNullValue())); + assertThat("metrics message log level", logLine, containsString("INFO")); + assertThat("metrics message content", logLine, containsString("joe")); + } + + @Test + public void callUnsupportedMethods() throws IOException { + LogHelper logger = LogHelper.INSTANCE; + ApplicationMsgs dummyMsg = ApplicationMsgs.LOAD_PROPERTIES; + callUnsupportedOperationMethod(logger::error, dummyMsg); + callUnsupportedOperationMethod(logger::info, dummyMsg); + callUnsupportedOperationMethod(logger::warn, dummyMsg); + callUnsupportedOperationMethod(logger::debug, dummyMsg); + callUnsupportedOperationMethod(logger::trace, dummyMsg); + try { + logger.error(dummyMsg, new LogFields(), new RuntimeException("test"), ""); + } catch (UnsupportedOperationException e) { + // Expected to reach here + } + try { + logger.info(dummyMsg, new LogFields(), new MdcOverride(), ""); + } catch (UnsupportedOperationException e) { + // Expected to reach here + } + try { + logger.formatMsg(dummyMsg, ""); + } catch (UnsupportedOperationException e) { + // Expected to reach here + } + } + + private String getLogDirectory() { + String logDirectory = LogHelper.getLogDirectory(); + assertThat(Paths.get(logDirectory).toAbsolutePath().toString(), + startsWith(Paths.get(System.getProperty("APP_HOME")).toAbsolutePath().toString())); + return logDirectory; + } + + /** + * Call a logger method which is expected to throw an UnsupportedOperationException + * + * @param logMethod + * @param dummyMsg + */ + private void callUnsupportedOperationMethod(TriConsumer, LogFields, String[]> logMethod, + ApplicationMsgs dummyMsg) { + try { + logMethod.accept(dummyMsg, new LogFields(), new String[] {""}); + org.junit.Assert.fail("method should have thrown execption"); // NOSONAR as code not reached + } catch (UnsupportedOperationException e) { + // Expected to reach here + } + } + + /** + * Assert that a log message was logged to the expected log file at the expected severity + * + * @param msg + * @param reader + * @param severity + * @throws IOException + */ + private void validateLoggedMessage(ApplicationMsgs msg, LogReader reader, String severity) throws IOException { + String s = reader.getNewLines(); + assertThat(s, is(notNullValue())); + assertThat(msg.toString() + " log level", s, containsString(severity)); + } +} diff --git a/src/test/java/org/onap/aai/validation/modeldriven/TestModelId.java b/src/test/java/org/onap/aai/validation/modeldriven/TestModelId.java new file mode 100644 index 0000000..7cefede --- /dev/null +++ b/src/test/java/org/onap/aai/validation/modeldriven/TestModelId.java @@ -0,0 +1,95 @@ +/* + * ============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.modeldriven; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; +import static org.junit.Assert.assertThat; + +import org.junit.Test; +import org.onap.aai.validation.modeldriven.ModelId; + +public class TestModelId { + + static { + System.setProperty("APP_HOME", "."); + } + + @Test + public void testGettersAndSetters() { + String attr = null; + String id = null; + ModelId modelId = new ModelId(attr, id); + assertThat(modelId.getModelIdAttribute(), is(equalTo(attr))); + assertThat(modelId.getModelId(), is(equalTo(id))); + assertThat(modelId.isEmpty(), is(true)); + + attr = ""; + modelId.setModelIdAttribute(attr); + assertThat(modelId.getModelIdAttribute(), is(equalTo(attr))); + assertThat(modelId.getModelId(), is(equalTo(id))); + assertThat(modelId.isEmpty(), is(true)); + + attr = "new_attr_value"; + modelId.setModelIdAttribute(attr); + assertThat(modelId.getModelIdAttribute(), is(equalTo(attr))); + assertThat(modelId.getModelId(), is(equalTo(id))); + assertThat(modelId.isEmpty(), is(true)); + + id = "new_id"; + modelId.setModelId(id); + assertThat(modelId.getModelIdAttribute(), is(equalTo(attr))); + assertThat(modelId.getModelId(), is(equalTo(id))); + assertThat(modelId.isEmpty(), is(false)); + + id = ""; + modelId.setModelId(id); + assertThat(modelId.getModelIdAttribute(), is(equalTo(attr))); + assertThat(modelId.getModelId(), is(equalTo(id))); + assertThat(modelId.isEmpty(), is(true)); + + attr = null; + modelId.setModelIdAttribute(attr); + assertThat(modelId.getModelIdAttribute(), is(equalTo(attr))); + assertThat(modelId.getModelId(), is(equalTo(id))); + assertThat(modelId.isEmpty(), is(true)); + } + + @Test + public void testIsEmpty() { + assertThat(new ModelId(null, null).isEmpty(), is(true)); + assertThat(new ModelId("", null).isEmpty(), is(true)); + assertThat(new ModelId(null, "").isEmpty(), is(true)); + assertThat(new ModelId("", "").isEmpty(), is(true)); + assertThat(new ModelId("A", null).isEmpty(), is(true)); + assertThat(new ModelId(null, "B").isEmpty(), is(true)); + assertThat(new ModelId("A", "B").isEmpty(), is(false)); + } + + @Test + public void testEqualsMethod() { + ModelId id1 = new ModelId("a", "b"); + ModelId id2 = new ModelId("a", "b"); + assertThat(id1, is(equalTo(id1))); + assertThat(id1, is(equalTo(id2))); + assertThat(id1, is(not(equalTo(null)))); + assertThat(id1.hashCode(), is(equalTo(id2.hashCode()))); + } + +} diff --git a/src/test/java/org/onap/aai/validation/modeldriven/configuration/mapping/TestFilter.java b/src/test/java/org/onap/aai/validation/modeldriven/configuration/mapping/TestFilter.java new file mode 100644 index 0000000..c9d2688 --- /dev/null +++ b/src/test/java/org/onap/aai/validation/modeldriven/configuration/mapping/TestFilter.java @@ -0,0 +1,55 @@ +/* + * ============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.modeldriven.configuration.mapping; + +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; +import org.onap.aai.validation.modeldriven.configuration.mapping.Filter; + +public class TestFilter { + + static { + System.setProperty("APP_HOME", "."); + } + + @Test + public void testAllMethodsInFilterClassToImproveCodeCoverage() { + Filter filter1 = new Filter(); + List valid = new ArrayList<>(); + valid.add("String 1"); + filter1.setPath("path"); + filter1.setValid(valid); + + Filter filter2 = new Filter(); + filter2.setPath("path"); + filter2.setValid(valid); + + assertThat(filter1, is(filter2)); + assertThat(filter1.hashCode(), is(filter2.hashCode())); + assertThat(filter1.getPath(), is(filter2.getPath())); + assertThat(filter1.getValid(), is(filter2.getValid())); + assertThat(filter1.toString(), is(filter2.toString())); + assertTrue(filter1.equals(filter2)); + } + +} diff --git a/src/test/java/org/onap/aai/validation/modeldriven/configuration/mapping/TestModelInstanceMapper.java b/src/test/java/org/onap/aai/validation/modeldriven/configuration/mapping/TestModelInstanceMapper.java new file mode 100644 index 0000000..7c820bb --- /dev/null +++ b/src/test/java/org/onap/aai/validation/modeldriven/configuration/mapping/TestModelInstanceMapper.java @@ -0,0 +1,71 @@ +/* + * ============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.modeldriven.configuration.mapping; + +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; +import org.onap.aai.validation.modeldriven.configuration.mapping.Filter; +import org.onap.aai.validation.modeldriven.configuration.mapping.ModelInstanceMapper; +import org.onap.aai.validation.modeldriven.configuration.mapping.ValueConfiguration; +import org.onap.aai.validation.modeldriven.configuration.mapping.ModelInstanceMapper.MappingType; + +public class TestModelInstanceMapper { + + static { + System.setProperty("APP_HOME", "."); + } + + @Test + public void testAllMethodsToImproveCodeCoverage() { + List valid = new ArrayList<>(); + valid.add("string1"); + Filter filter = new Filter(); + filter.setPath("testPath"); + filter.setValid(valid); + + ValueConfiguration valueConf1 = new ValueConfiguration(); + valueConf1.setFilter(filter); + valueConf1.setId("id"); + valueConf1.setOrigin("testOrigin"); + valueConf1.setRoot("testRoot"); + valueConf1.setValue("testValue"); + + ModelInstanceMapper mapper1 = new ModelInstanceMapper(); + mapper1.setInstance(valueConf1); + mapper1.setMappingType(MappingType.ATTRIBUTE.toString()); + mapper1.setModel(valueConf1); + + ModelInstanceMapper mapper2 = new ModelInstanceMapper(); + mapper2.setInstance(valueConf1); + mapper2.setMappingType(MappingType.ATTRIBUTE.toString()); + mapper2.setModel(valueConf1); + + assertThat(mapper1.hashCode(), is(mapper2.hashCode())); + assertThat(mapper1.getInstance(), is(mapper2.getInstance())); + assertThat(mapper1.getMappingType(), is(mapper2.getMappingType())); + assertThat(mapper1.getModel(), is(mapper2.getModel())); + assertThat(mapper1.toString(), is(mapper2.toString())); + assertTrue(mapper1.equals(mapper2)); + } + +} diff --git a/src/test/java/org/onap/aai/validation/modeldriven/configuration/mapping/TestValueConfiguration.java b/src/test/java/org/onap/aai/validation/modeldriven/configuration/mapping/TestValueConfiguration.java new file mode 100644 index 0000000..80c1ab8 --- /dev/null +++ b/src/test/java/org/onap/aai/validation/modeldriven/configuration/mapping/TestValueConfiguration.java @@ -0,0 +1,70 @@ +/* + * ============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.modeldriven.configuration.mapping; + +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; +import org.onap.aai.validation.modeldriven.configuration.mapping.Filter; +import org.onap.aai.validation.modeldriven.configuration.mapping.ValueConfiguration; + +public class TestValueConfiguration { + + static { + System.setProperty("APP_HOME", "."); + } + + @Test + public void testAllMethodsToImproveCodeCoverage() { + + List valid = new ArrayList<>(); + valid.add("string1"); + Filter filter = new Filter(); + filter.setPath("testPath"); + filter.setValid(valid); + + ValueConfiguration valueConf1 = new ValueConfiguration(); + valueConf1.setFilter(filter); + valueConf1.setId("id"); + valueConf1.setOrigin("testOrigin"); + valueConf1.setRoot("testRoot"); + valueConf1.setValue("testValue"); + + ValueConfiguration valueConf2 = new ValueConfiguration(); + valueConf2.setFilter(filter); + valueConf2.setId("id"); + valueConf2.setOrigin("testOrigin"); + valueConf2.setRoot("testRoot"); + valueConf2.setValue("testValue"); + + assertThat(valueConf1, is(valueConf2)); + assertThat(valueConf1.hashCode(), is(valueConf2.hashCode())); + assertThat(valueConf1.getFilter(), is(valueConf2.getFilter())); + assertThat(valueConf1.getId(), is(valueConf2.getId())); + assertThat(valueConf1.getOrigin(), is(valueConf2.getOrigin())); + assertThat(valueConf1.getRoot(), is(valueConf2.getRoot())); + assertThat(valueConf1.getValue(), is(valueConf2.getValue())); + assertThat(valueConf1.toString(), is(valueConf2.toString())); + assertTrue(valueConf1.equals(valueConf2)); + } + +} diff --git a/src/test/java/org/onap/aai/validation/modeldriven/parser/TestXMLModelParser.java b/src/test/java/org/onap/aai/validation/modeldriven/parser/TestXMLModelParser.java new file mode 100644 index 0000000..3344193 --- /dev/null +++ b/src/test/java/org/onap/aai/validation/modeldriven/parser/TestXMLModelParser.java @@ -0,0 +1,96 @@ +/* + * ============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.modeldriven.parser; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import org.dom4j.Element; +import org.dom4j.Node; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.onap.aai.validation.modeldriven.parser.XMLModelParser; + +public class TestXMLModelParser { + + static { + System.setProperty("APP_HOME", "."); + } + + private static final String CONNECTOR_MODEL_ID = "460c6de2-a92b-4e3b-9ba3-538ce782b2fa"; + private static final String MODEL_ID_ATTRIBUTE = "model-name-version-id"; + + private Element modelElement; + + @Rule + public ExpectedException exception = ExpectedException.none(); + + @Before + public void setUp() throws Exception { + File modelFile = new File("src/test/resources/model-validation/model-parser/all-models.xml"); + Element modelsElement = XMLModelParser.parse(modelFile, false); + modelElement = XMLModelParser.getModelElementWithId(modelsElement, MODEL_ID_ATTRIBUTE, CONNECTOR_MODEL_ID); + } + + @Test + public void testParseXMLModelFile() throws Exception { + assertEquals("Invalid model element name.", "model", modelElement.getName()); + } + + @Test + public void testGetAttributes() throws Exception { + String attrsXPath = "metadata/metadatum/metaname"; + List attrNodes = XMLModelParser.getObjectsFromXPath(modelElement, attrsXPath); + assertEquals("Unexpected number of attributes.", 2, attrNodes.size()); + + List validAttrs = new ArrayList<>(); + validAttrs.add("a"); + validAttrs.add("b"); + + List actualAttrs = new ArrayList<>(); + for (Node node : attrNodes) { + actualAttrs.add(node.getText()); + } + + assertTrue("Unexpected attribute names.", validAttrs.containsAll(actualAttrs)); + } + + @Test + public void testGetRelatedObjects() throws Exception { + String relObjsXPath = "model-elements/model-element"; + List relatedNodes = XMLModelParser.getObjectsFromXPath(modelElement, relObjsXPath); + assertEquals("Unexpected number of related objects.", 1, relatedNodes.size()); + + Node relatedObjUUIDNode = relatedNodes.get(0).selectSingleNode("model-element-uuid"); + assertEquals("Unexpected related object UUID.", "71b825be-febf-45f7-b86a-ca0e3de19c90", + relatedObjUUIDNode.getText()); + } + + @Test + public void testModelValidationFailure() throws Exception { + File modelFile = new File("src/test/resources/model-validation/model-parser/all-models.xml"); + + assertNull("Validation failure should result in null being returned.", XMLModelParser.parse(modelFile, true)); + } +} 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 new file mode 100644 index 0000000..60588bb --- /dev/null +++ b/src/test/java/org/onap/aai/validation/modeldriven/validator/TestInstanceReader.java @@ -0,0 +1,236 @@ +/* + * ============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.modeldriven.validator; + +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThat; + +import com.google.common.collect.Multimap; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; +import javax.inject.Inject; +import org.json.JSONArray; +import org.json.JSONObject; +import org.junit.BeforeClass; +import org.junit.Rule; +import org.junit.Test; +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; +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:model-validation/instance-reader/test-validation-service-beans.xml"}) +public class TestInstanceReader { + + static { + System.setProperty("APP_HOME", "."); + } + + private static ModelInstanceMapper mapping; + private static ModelInstanceMapper mappingRootUnknown; + private static ModelInstanceMapper mappingRootMissing; + private static String connector; + private static String connectorSibling; + private static String expectedVirtualDataCenter; + private static String expectedVirtualDataCenterModelName; + private static String connectorModelName; + private static String expectedLogicalLink; + private static String expectedGenericVnf; + private static String expectedPserver; + + @Inject + private InstanceReader instanceReader; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + mapping = TestInstanceReader.getMapping(TestData.MAPPING.getFilename()); + mappingRootUnknown = TestInstanceReader.getMapping(TestData.MAPPING_ROOT_UNKNOWN.getFilename()); + mappingRootMissing = TestInstanceReader.getMapping(TestData.MAPPING_ROOT_MISSING.getFilename()); + connector = TestUtil.getFileAsString(TestData.CONNECTOR.getFilename()); + connectorModelName = TestUtil.getFileAsString(TestData.CONNECTOR_MODEL_NAME.getFilename()); + connectorSibling = TestUtil.getFileAsString(TestData.CONNECTOR_SIBLING.getFilename()); + expectedVirtualDataCenter = TestUtil.getFileAsString(TestData.EXPECTED_VDC.getFilename()); + expectedVirtualDataCenterModelName = TestUtil.getFileAsString(TestData.EXPECTED_VDC_MODEL_NAME.getFilename()); + expectedLogicalLink = TestUtil.getFileAsString(TestData.EXPECTED_LOGICAL_LINK.getFilename()); + expectedGenericVnf = TestUtil.getFileAsString(TestData.EXPECTED_GENERIC_VNF.getFilename()); + expectedPserver = TestUtil.getFileAsString(TestData.EXPECTED_PSERVER.getFilename()); + + } + + 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"); + + private String filename; + TestData(String filename) {this.filename = filename;} + public String getFilename() {return this.filename;} + // @formatter:on + } + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Test + public void testGetValuesNoModelName() throws Exception { + // Set expectation + JsonParser jsonParser = new JsonParser(); + JsonElement jsonElement = jsonParser.parse(expectedVirtualDataCenter); + String expectedValue = jsonElement.toString(); + + // Method under test + Multimap values = instanceReader.getValues(connector, mapping); + + assertFalse(values.isEmpty()); + assertThat(values.keys().iterator().next(), is(equalTo("virtual-data-center"))); + assertThat(values.get("virtual-data-center").iterator().next(), is(equalTo(expectedValue))); + } + + @Test + public void testGetValuesWithModelName() throws Exception { + // Set expectation + JsonParser jsonParser = new JsonParser(); + JsonElement jsonElement = jsonParser.parse(expectedVirtualDataCenterModelName); + String expectedValue = jsonElement.toString(); + + // Method under test + Multimap values = instanceReader.getValues(connectorModelName, mapping); + + assertFalse(values.isEmpty()); + assertThat(values.keys().iterator().next(), is(equalTo("Test VC Model Name"))); + assertThat(values.get("Test VC Model Name").iterator().next(), is(equalTo(expectedValue))); + } + + @Test + public void testNavigateInstance() throws Exception { + // Set expectation + JsonParser jsonParser = new JsonParser(); + JsonElement jsonElement = jsonParser.parse(expectedLogicalLink); + String expectedValue = jsonElement.toString(); + + // Method under test + Multimap values = instanceReader.getValues(connector, mapping); + + String virtualDataCenterInstance = values.get("virtual-data-center").iterator().next(); + + // Method under test + values = instanceReader.getValues(virtualDataCenterInstance, mapping); + + assertThat(values.keys().iterator().next(), is(equalTo("Test LL Model Name"))); + assertThat(values.get("Test LL Model Name").iterator().next(), is(equalTo(expectedValue))); + } + + @Test + public void testNavigateInstanceWithSiblingInventoryItems() throws Exception { + // Set expectations + JsonParser jsonParser = new JsonParser(); + JsonElement genericVnfJsonElement = jsonParser.parse(expectedGenericVnf); + String expectedGenericVnf = genericVnfJsonElement.toString(); + + JsonElement pserverJsonElement = jsonParser.parse(expectedPserver); + String expectedPserver = pserverJsonElement.toString(); + + // Method under test + Multimap values = instanceReader.getValues(connectorSibling, mapping); + + String virtualDataCenterInstance = values.get("virtual-data-center").iterator().next(); + + // Method under test + values = instanceReader.getValues(virtualDataCenterInstance, mapping); + + String logicalLinkInstance = values.get("Test LL Model Name").iterator().next(); + + // Method under test + values = instanceReader.getValues(logicalLinkInstance, mapping); + + assertThat(values.get("generic-vnf").iterator().next(), is(equalTo(expectedGenericVnf))); + assertThat(values.get("pserver").iterator().next(), is(equalTo(expectedPserver))); + } + + @Test + public void testGetValuesRootUnknown() throws Exception { + Multimap values = instanceReader.getValues(connector, mappingRootUnknown); + + assertThat(values.isEmpty(), is(true)); + } + + @Test + public void testGetValuesRootMissing() throws Exception { + thrown.expect(ValidationServiceException.class); + thrown.expectMessage("VS-604"); + + instanceReader.getValues(connector, mappingRootMissing); + } + + @Test + public void testGetInstanceTypeNoModelName() throws Exception { + String instanceType = instanceReader.getInstanceType(connector); + assertThat(instanceType, is("connector")); + } + + @Test + public void testGetModelName() throws Exception { + String instanceType = instanceReader.getModelName(connectorModelName); + assertThat(instanceType, is("Test Connector Model Name")); + } + + @Test + public void testGetInstanceIdNoModelName() throws Exception { + String instanceId = instanceReader.getInstanceId(connector); + assertThat(instanceId, is("c7611ebe-c324-48f1-8085-94aef0c12fd")); + } + + @Test + public void testGetInstanceIdModelName() throws Exception { + String instanceId = instanceReader.getInstanceId(connectorModelName); + assertThat(instanceId, is("c7611ebe-c324-48f1-8085-94aef0c12fd")); + } + + @Test + public void testGetResourceVersion() throws Exception { + String resourceVersion = instanceReader.getResourceVersion(connector); + + assertThat(resourceVersion, is("1467975776")); + } + + private static ModelInstanceMapper getMapping(String mappingFileName) throws Exception { + JSONArray jsonArray = new JSONArray(TestUtil.getFileAsString(mappingFileName)); + JSONObject jsonObject = jsonArray.getJSONObject(0); + + return JsonUtil.fromJson(jsonObject.toString(), ModelInstanceMapper.class); + } +} 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 new file mode 100644 index 0000000..cb9de43 --- /dev/null +++ b/src/test/java/org/onap/aai/validation/modeldriven/validator/TestModelDrivenValidator.java @@ -0,0 +1,291 @@ +/* + * ============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.modeldriven.validator; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder; +import static org.junit.Assert.assertThat; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.inject.Inject; +import org.dom4j.Element; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +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; +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"}) +@ContextConfiguration(locations = {"classpath:model-validation/instance-validator/test-validation-service-beans.xml"}) +public class TestModelDrivenValidator { + + static { + System.setProperty("APP_HOME", "."); + } + + private static final String RESOURCE_VERSION = "1467975776"; + private static final String MODEL_ID_ATTRIBUTE_MNV = "model-name-version-id"; + private static final String MODEL_ID_ATTRIBUTE_MID = "model-id"; + + @Mock + private ModelCacheManager mockModelCacheManager; + + @InjectMocks + @Inject + private ModelDrivenValidator modelDrivenValidator; + + private String objectInstance; + private String connectorModel; + + enum INSTANCE_VALIDATION_FILE { + // @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 + + private String filename; + + INSTANCE_VALIDATION_FILE(String filename) { + this.filename = filename; + } + + public String getFilename() { + return this.filename; + } + } + + @Before + public void initMocks() { + MockitoAnnotations.initMocks(this); + } + + @Before + public void setUp() throws Exception { + connectorModel = TestUtil.getFileAsString(INSTANCE_VALIDATION_FILE.CONNECTOR_MODEL.getFilename()); + } + + @Test + public void testValidateInstanceWithoutModelId() throws Exception { + objectInstance = TestUtil.getFileAsString(INSTANCE_VALIDATION_FILE.NO_MODEL_ID.getFilename()); + + ValidationResult validationResult = modelDrivenValidator.validate(objectInstance).get(0); + assertThatValidationResultIsValid(validationResult, "c7611ebe-c324-48f1-8085-94aef0c12fd", "connector", + "1467975776"); + + Violation violation = validationResult.getViolations().get(0); + Map details = new HashMap<>(); + details.put("No model ID", null); + assertThatViolationIsValid(violation, ValidationController.VALIDATION_ERROR_SEVERITY, details, + "The model [null] could not be found", RESOURCE_VERSION); + } + + @Test + public void testValidateInstanceWithUnknownModelId() throws Exception { + objectInstance = TestUtil.getFileAsString(INSTANCE_VALIDATION_FILE.UNKNOWN_MODEL_ID.getFilename()); + + Mockito.when(mockModelCacheManager.get(new ModelId(MODEL_ID_ATTRIBUTE_MID, "UNKNOWN-MODEL"))).thenReturn(null); + + ValidationResult validationResult = modelDrivenValidator.validate(objectInstance).get(0); + assertThatValidationResultIsValid(validationResult, "c7611ebe-c324-48f1-8085-94aef0c12fd", "connector", + "1467975776"); + + Violation violation = validationResult.getViolations().get(0); + Map details = new HashMap<>(); + details.put("No model ID", "UNKNOWN-MODEL"); + assertThatViolationIsValid(violation, ValidationController.VALIDATION_ERROR_SEVERITY, details, + "The model [UNKNOWN-MODEL] could not be found", RESOURCE_VERSION); + } + + @Test + public void testValidate() throws Exception { + objectInstance = TestUtil.getFileAsString(INSTANCE_VALIDATION_FILE.ERRORS.getFilename()); + + Element modelElement = XMLModelParser.parse(connectorModel, true); + + Mockito.when(mockModelCacheManager.get(new ModelId(MODEL_ID_ATTRIBUTE_MID, "connector-widget-id"))) + .thenReturn(modelElement); + Mockito.when(mockModelCacheManager + .get(new ModelId(MODEL_ID_ATTRIBUTE_MNV, "l2-bridge-for-wan-connector-resource-id"))).thenReturn(null); + + ValidationResult validationResult = modelDrivenValidator.validate(objectInstance).get(0); + assertThatValidationResultIsValid(validationResult, "c7611ebe-c324-48f1-8085-94aef0c12fd", "connector", + "1467975776"); + + List violations = validationResult.getViolations(); + + assertThat(violations, hasSize(3)); + assertThat(getCategories(violations), + containsInAnyOrder(Arrays.asList("MISSING_ATTR", "UNEXPECTED_ATTR", "UNEXPECTED_REL").toArray())); + + Violation violation = getValidationByCategory(violations, "MISSING_ATTR").get(0); + Map details = new HashMap<>(); + details.put("MISSING ATTR", "product"); + assertThatViolationIsValid(violation, ValidationController.VALIDATION_ERROR_SEVERITY, details, + "Attribute [product] is missing in the object instance", RESOURCE_VERSION); + + violation = getValidationByCategory(violations, "UNEXPECTED_ATTR").get(0); + details = new HashMap<>(); + details.put("UNEXPECTED ATTR", "unexpected"); + assertThatViolationIsValid(violation, ValidationController.VALIDATION_ERROR_SEVERITY, details, + "Attribute [unexpected] should not be present in the object instance", RESOURCE_VERSION); + + violation = getValidationByCategory(violations, "UNEXPECTED_REL").get(0); + details = new HashMap<>(); + Map entityIdmap = new HashMap<>(); + entityIdmap.put("vdc-id", "vdc-01"); + details.put("entityId", entityIdmap); + details.put("modelName", null); + details.put("entityType", "virtual-data-center"); + details.put("UNEXPECTED REL", "logical-link"); + assertThatViolationIsValid(violation, ValidationController.VALIDATION_ERROR_SEVERITY, details, + "Entity [vdc-id=vdc-01] of type [virtual-data-center] must not be related to [logical-link]", + RESOURCE_VERSION); + } + + @Test + public void testValidateMultipleMissingAttrs() throws Exception { + objectInstance = TestUtil.getFileAsString(INSTANCE_VALIDATION_FILE.MULTIPLE_MISSING_ATTRS.getFilename()); + + Element modelElement = XMLModelParser.parse(connectorModel, true); + + Mockito.when(mockModelCacheManager.get(new ModelId(MODEL_ID_ATTRIBUTE_MID, "connector-widget-id"))) + .thenReturn(modelElement); + Mockito.when(mockModelCacheManager + .get(new ModelId(MODEL_ID_ATTRIBUTE_MNV, "l2-bridge-for-wan-connector-resource-id"))).thenReturn(null); + + List violations = modelDrivenValidator.validate(objectInstance).get(0).getViolations(); + + assertThat(violations, hasSize(2)); + assertThat(getCategories(violations), + containsInAnyOrder(Arrays.asList("MISSING_ATTR", "MISSING_ATTR").toArray())); + + List missingAttrValidations = getValidationByCategory(violations, "MISSING_ATTR"); + String detailsAsString = getDetails(missingAttrValidations).toString(); + assertThat(detailsAsString, containsString("{MISSING ATTR=product}")); + assertThat(detailsAsString, containsString("{MISSING ATTR=vpn-id}")); + } + + @Test + public void testValidateMultipleUnexpectedAttrs() throws Exception { + objectInstance = TestUtil.getFileAsString(INSTANCE_VALIDATION_FILE.MULTIPLE_UNEXPECTED_ATTRS.getFilename()); + + Element modelElement = XMLModelParser.parse(connectorModel, true); + + Mockito.when(mockModelCacheManager.get(new ModelId(MODEL_ID_ATTRIBUTE_MID, "connector-widget-id"))) + .thenReturn(modelElement); + Mockito.when(mockModelCacheManager + .get(new ModelId(MODEL_ID_ATTRIBUTE_MNV, "l2-bridge-for-wan-connector-resource-id"))).thenReturn(null); + + List violations = modelDrivenValidator.validate(objectInstance).get(0).getViolations(); + + assertThat(violations, hasSize(2)); + assertThat(getCategories(violations), + containsInAnyOrder(Arrays.asList("UNEXPECTED_ATTR", "UNEXPECTED_ATTR").toArray())); + + List missingAttrViolations = getValidationByCategory(violations, "UNEXPECTED_ATTR"); + String detailsAsString = getDetails(missingAttrViolations).toString(); + assertThat(detailsAsString, containsString("{UNEXPECTED ATTR=city}")); + assertThat(detailsAsString, containsString("{UNEXPECTED ATTR=state}")); + } + + @Test + public void testValidateSuccess() throws Exception { + objectInstance = TestUtil.getFileAsString(INSTANCE_VALIDATION_FILE.SUCCESS.getFilename()); + + Element modelElement = XMLModelParser.parse(connectorModel, true); + + Mockito.when(mockModelCacheManager.get(new ModelId(MODEL_ID_ATTRIBUTE_MID, "connector-widget-id"))) + .thenReturn(modelElement); + Mockito.when(mockModelCacheManager + .get(new ModelId(MODEL_ID_ATTRIBUTE_MNV, "l2-bridge-for-wan-connector-resource-id"))).thenReturn(null); + + List violations = modelDrivenValidator.validate(objectInstance).get(0).getViolations(); + + assertThat(violations, is(empty())); + } + + private void assertThatValidationResultIsValid(ValidationResult validationResult, String entityInstanceId, + String entityType, String resourceVersion) { + assertThat( + validationResult.getEntityId().getAsJsonObject().entrySet().iterator().next().getValue().getAsString(), + is(equalTo(entityInstanceId))); + assertThat(validationResult.getEntityType(), is(equalTo(entityType))); + assertThat(validationResult.getResourceVersion(), is(equalTo(resourceVersion))); + } + + private void assertThatViolationIsValid(Violation violation, String severity, Map violationDetails, + String errorMessage, String resourceVersion) { + assertThat(violation.getSeverity(), is(equalTo(severity))); + assertThat(violation.getViolationType(), is(equalTo("Model"))); + assertThat(violation.getViolationDetails(), is(equalTo(violationDetails))); + assertThat(violation.getErrorMessage(), is(equalTo(errorMessage))); + } + + private List getCategories(List validations) { + List categories = new ArrayList<>(); + for (Violation validation : validations) { + categories.add(validation.getCategory()); + } + return categories; + } + + private List> getDetails(List validations) { + List> details = new ArrayList<>(); + for (Violation validation : validations) { + details.add(validation.getViolationDetails()); + } + return details; + } + + private List getValidationByCategory(List validations, String category) { + List validationsByCategory = new ArrayList<>(); + for (Violation validation : validations) { + if (category.equals(validation.getCategory())) { + validationsByCategory.add(validation); + } + } + return validationsByCategory; + } +} diff --git a/src/test/java/org/onap/aai/validation/modeldriven/validator/TestModelReader.java b/src/test/java/org/onap/aai/validation/modeldriven/validator/TestModelReader.java new file mode 100644 index 0000000..d974ca2 --- /dev/null +++ b/src/test/java/org/onap/aai/validation/modeldriven/validator/TestModelReader.java @@ -0,0 +1,261 @@ +/* + * ============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.modeldriven.validator; + +import static org.hamcrest.Matchers.arrayContainingInAnyOrder; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +import com.google.common.collect.Multimap; +import java.io.File; +import java.util.Collection; +import java.util.List; +import java.util.Map.Entry; +import javax.inject.Inject; +import org.dom4j.Element; +import org.dom4j.Node; +import org.json.JSONArray; +import org.json.JSONObject; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.aai.validation.exception.ValidationServiceException; +import org.onap.aai.validation.modeldriven.ModelCacheManager; +import org.onap.aai.validation.modeldriven.configuration.mapping.ModelInstanceMapper; +import org.onap.aai.validation.modeldriven.parser.XMLModelParser; +import org.onap.aai.validation.modeldriven.validator.ModelReader; +import org.onap.aai.validation.test.util.TestUtil; +import org.onap.aai.validation.util.JsonUtil; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = {"classpath:model-validation/model-reader/test-validation-service-beans.xml"}) +public class TestModelReader { + + static { + System.setProperty("APP_HOME", "."); + } + + private Element modelElement; + private ModelInstanceMapper mapping; + + @Inject + private ModelCacheManager cache; + + @Test + public void testGetValues() throws Exception { + mapping = getMapping("model-validation/model-reader/model-instance-mapping-attributes-1.json"); + modelElement = XMLModelParser + .parse(new File("src/test/resources/model-validation/model-reader/connector-widget-id.xml"), false); + + Multimap values = ModelReader.getValues(modelElement, mapping, cache); + + assertThat(values.entries().size(), is(2)); + assertThat(values.containsEntry("product", null), is(true)); + assertThat(values.containsEntry("vpn-id", null), is(true)); + } + + /** + * @throws Exception + */ + @Test(expected = ValidationServiceException.class) + public void testGetValuesWithUnknownPath() throws Exception { + mapping = getMapping("model-validation/model-reader/model-instance-mapping-attributes-2.json"); + modelElement = XMLModelParser + .parse(new File("src/test/resources/model-validation/model-reader/connector-widget-id.xml"), false); + + ModelReader.getValues(modelElement, mapping, cache); + } + + @Test + public void testGetValuesSingleModel() throws Exception { + mapping = getMapping("model-validation/model-reader/model-instance-mapping-relationships.json"); + modelElement = XMLModelParser + .parse(new File("src/test/resources/model-validation/model-reader/connector-widget-id.xml"), false); + + List expectedModels = XMLModelParser.getObjectsFromXPath(modelElement, mapping.getModel().getRoot()); + + Multimap values = ModelReader.getValues(modelElement, mapping, cache); + + Collection> entries = values.entries(); + assertThat(entries.size(), is(1)); + assertThat(values.containsEntry("virtual-data-center", expectedModels.get(0)), is(true)); + } + + @Test + public void testGetValuesMultipleModels() throws Exception { + mapping = getMapping("model-validation/model-reader/model-instance-mapping-relationships.json"); + modelElement = XMLModelParser + .parse(new File("src/test/resources/model-validation/model-reader/logical-link-widget-id.xml"), false); + + Multimap values = ModelReader.getValues(modelElement, mapping, cache); + + assertThat(values.keys().toArray(new String[] {}), arrayContainingInAnyOrder(new String[] {"logical-link",})); + + values = ModelReader.getValues(values.values().iterator().next(), mapping, cache); + + assertThat(values.keys().toArray(new String[] {}), + arrayContainingInAnyOrder(new String[] {"pBgf", "vDbe", "ipe", "vSbg",})); + } + + @Test + public void testGetValuesCurrentModelNoChildrenNoValues() throws Exception { + mapping = getMapping("model-validation/model-reader/model-instance-mapping-relationships.json"); + modelElement = XMLModelParser.parse( + new File("src/test/resources/model-validation/model-reader/connector-widget-id-no-children-1.xml"), + false); + + Multimap values = ModelReader.getValues(modelElement, mapping, cache); + + assertThat(values.isEmpty(), is(true)); + } + + @Test + public void testGetValuesCurrentModelNoChildrenWithValues() throws Exception { + mapping = getMapping("model-validation/model-reader/model-instance-mapping-relationships.json"); + modelElement = XMLModelParser.parse( + new File("src/test/resources/model-validation/model-reader/connector-widget-id-no-children-2.xml"), + false); + + Multimap parentValues = ModelReader.getValues(modelElement, mapping, cache); + + Multimap childValues = + ModelReader.getValues(parentValues.entries().iterator().next().getValue(), mapping, cache); + + assertThat(childValues.isEmpty(), is(true)); + } + + @Test + public void testResourceModelType() throws Exception { + mapping = getMapping("model-validation/model-reader/model-instance-mapping-relationships.json"); + modelElement = XMLModelParser.parse( + new File("src/test/resources/model-validation/model-reader/virtual-data-center-widget-id.xml"), false); + + Multimap values = ModelReader.getValues(modelElement, mapping, cache); + + assertThat(values.keys().toArray(new String[] {}), + arrayContainingInAnyOrder(new String[] {"l2-bridge-for-wan-connector",})); + } + + @Test + public void testRootWithInvalidPath() throws Exception { + mapping = getMapping("model-validation/model-reader/model-instance-mapping-relationships-root-1.json"); + modelElement = XMLModelParser.parse( + new File("src/test/resources/model-validation/model-reader/virtual-data-center-widget-id.xml"), false); + + Multimap values = ModelReader.getValues(modelElement, mapping, cache); + + assertThat(values.entries(), is(empty())); + } + + @Test + public void testRootMissing() throws Exception { + mapping = getMapping("model-validation/model-reader/model-instance-mapping-relationships-root-2.json"); + modelElement = XMLModelParser.parse( + new File("src/test/resources/model-validation/model-reader/virtual-data-center-widget-id.xml"), false); + + Multimap values = ModelReader.getValues(modelElement, mapping, cache); + assertThat(values.entries(), is(empty())); + } + + @Test + public void testFilterWithInvalidType() throws Exception { + mapping = getMapping("model-validation/model-reader/model-instance-mapping-relationships-filter-1.json"); + modelElement = XMLModelParser + .parse(new File("src/test/resources/model-validation/model-reader/connector-widget-id.xml"), false); + + Multimap values = ModelReader.getValues(modelElement, mapping, cache); + + assertThat(values.entries(), is(empty())); + } + + @Test + public void testFilterWithEmptyArray() throws Exception { + mapping = getMapping("model-validation/model-reader/model-instance-mapping-relationships-filter-2.json"); + modelElement = XMLModelParser.parse( + new File("src/test/resources/model-validation/model-reader/virtual-data-center-widget-id.xml"), false); + + Multimap values = ModelReader.getValues(modelElement, mapping, cache); + + assertThat(values.entries(), is(empty())); + } + + @Test + public void testFilterWithMissingValidProperty() throws Exception { + mapping = getMapping("model-validation/model-reader/model-instance-mapping-relationships-filter-3.json"); + modelElement = XMLModelParser.parse( + new File("src/test/resources/model-validation/model-reader/virtual-data-center-widget-id.xml"), false); + + Multimap values = ModelReader.getValues(modelElement, mapping, cache); + + assertThat(values.entries(), is(empty())); + } + + @Test + public void testFilterWithInvalidPath() throws Exception { + mapping = getMapping("model-validation/model-reader/model-instance-mapping-relationships-filter-4.json"); + modelElement = XMLModelParser.parse( + new File("src/test/resources/model-validation/model-reader/virtual-data-center-widget-id.xml"), false); + + Multimap values = ModelReader.getValues(modelElement, mapping, cache); + + assertThat(values.entries(), is(empty())); + } + + @Test + public void testFilterWithMissingPath() throws Exception { + mapping = getMapping("model-validation/model-reader/model-instance-mapping-relationships-filter-5.json"); + modelElement = XMLModelParser.parse( + new File("src/test/resources/model-validation/model-reader/virtual-data-center-widget-id.xml"), false); + + Multimap values = ModelReader.getValues(modelElement, mapping, cache); + + assertThat(values.entries(), is(empty())); + } + + @Test + public void testFilterMissing() throws Exception { + mapping = getMapping("model-validation/model-reader/model-instance-mapping-relationships-filter-6.json"); + modelElement = XMLModelParser.parse( + new File("src/test/resources/model-validation/model-reader/virtual-data-center-widget-id.xml"), false); + + Multimap values = ModelReader.getValues(modelElement, mapping, cache); + + assertThat(values.keys().toArray(new String[] {}), + arrayContainingInAnyOrder(new String[] {"l2-bridge-for-wan-connector"})); + } + + @Test + public void testGetValuesWithMultipleModelFetch() throws Exception { + mapping = getMapping("model-validation/model-reader/model-instance-mapping-relationships-with-id.json"); + modelElement = XMLModelParser + .parse(new File("src/test/resources/model-validation/model-reader/connector-widget-id.xml"), false); + + Multimap values = ModelReader.getValues(modelElement, mapping, cache); + + assertThat(values.entries(), is(empty())); + } + + private ModelInstanceMapper getMapping(String mappingFileName) throws Exception { + JSONArray jsonArray = new JSONArray(TestUtil.getFileAsString(mappingFileName)); + JSONObject jsonObject = jsonArray.getJSONObject(0); + + return JsonUtil.fromJson(jsonObject.toString(), ModelInstanceMapper.class); + } +} diff --git a/src/test/java/org/onap/aai/validation/publisher/MockEventPublisher.java b/src/test/java/org/onap/aai/validation/publisher/MockEventPublisher.java new file mode 100644 index 0000000..d1cfae0 --- /dev/null +++ b/src/test/java/org/onap/aai/validation/publisher/MockEventPublisher.java @@ -0,0 +1,72 @@ +/* + * ============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.publisher; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.util.Collection; +import org.onap.aai.validation.exception.ValidationServiceException; +import org.onap.aai.validation.publisher.MessagePublisher; +import org.onap.aai.validation.result.ValidationResult; +import org.onap.aai.validation.test.util.TestEntity; +import org.onap.aai.validation.test.util.ValidationResultIsEqual; + +/** + * Will be injected by Spring + * + */ +public class MockEventPublisher implements MessagePublisher { + + private ValidationResult expectedValidationResult; + private String testDescription; + private boolean publishedMessage; + + public MockEventPublisher() { + // Deliberately empty - no configuration needed + } + + public void setTestEntity(TestEntity entity) throws URISyntaxException, IOException { + this.expectedValidationResult = entity.getExpectedValidationResult(); + this.publishedMessage = false; + } + + public void setTestDescription(String testDescription) { + this.testDescription = testDescription; + } + + @Override + public void publishMessage(String message) throws ValidationServiceException { + ValidationResult validationResult = ValidationResult.fromJson(message); + assertThat(testDescription, validationResult, is(ValidationResultIsEqual.equalTo(expectedValidationResult))); + publishedMessage = true; + } + + @Override + public void publishMessages(Collection messages) throws ValidationServiceException { + for (String message : messages) { + publishMessage(message); + } + } + + public boolean processedSuccessfully() { + return publishedMessage || expectedValidationResult == null; + } +} diff --git a/src/test/java/org/onap/aai/validation/publisher/TestValidationEventPublisher.java b/src/test/java/org/onap/aai/validation/publisher/TestValidationEventPublisher.java new file mode 100644 index 0000000..8950e63 --- /dev/null +++ b/src/test/java/org/onap/aai/validation/publisher/TestValidationEventPublisher.java @@ -0,0 +1,102 @@ +/* + * ============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.publisher; + +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import org.onap.aai.event.client.DMaaPEventPublisher; +import org.onap.aai.validation.config.TopicAdminConfig; +import org.onap.aai.validation.config.TopicConfig; +import org.onap.aai.validation.config.TopicConfig.Topic; +import org.onap.aai.validation.factory.DMaaPEventPublisherFactory; +import org.onap.aai.validation.publisher.ValidationEventPublisher; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class TestValidationEventPublisher { + + static { + System.setProperty("APP_HOME", "."); + System.setProperty("consumer.topic.names", "poa-rule-validation"); + System.setProperty("publisher.topic.names", "poa-audit-result"); + } + + private DMaaPEventPublisher mockEventPublisher; + private ValidationEventPublisher validationEventPublisher; + private List topicList = new ArrayList<>(); + + @Before + public void setUp() throws Exception { + TopicConfig mockTopicConfig = Mockito.mock(TopicConfig.class); + TopicAdminConfig mockTopicAdminConfig = Mockito.mock(TopicAdminConfig.class); + when(mockTopicAdminConfig.isPublishEnable()).thenReturn(true); + + Topic topic1 = new TopicConfig("poa-rule-validation","poa-audit-result").new Topic(); + topic1.setName("aai-data-integrity"); + topic1.setHost("integrity-dummy-host"); + topic1.setPartition("integrity-dummy-partition"); + topic1.setUsername("integrity-dummy-username"); + topic1.setPassword("integrity-dummy-password"); + topic1.setTransportType("integrity-dummy-transport-type"); + topicList.add(topic1); + + when(mockTopicConfig.getPublisherTopics()).thenReturn(topicList); + validationEventPublisher = new ValidationEventPublisher(mockTopicConfig, mockTopicAdminConfig); + + mockEventPublisher = Mockito.mock(DMaaPEventPublisher.class); + when(mockEventPublisher.closeWithUnsent()).thenReturn(new ArrayList<>()); + + DMaaPEventPublisherFactory mockEventPublisherFactory = Mockito.mock(DMaaPEventPublisherFactory.class); + when(mockEventPublisherFactory.createEventPublisher(any(), any(), any(), any(), any())) + .thenReturn(mockEventPublisher); + + validationEventPublisher.setEventPublisherFactory(mockEventPublisherFactory); + } + + @Test + public void testPublishMessages() throws Exception { + Collection messages = new ArrayList<>(); + messages.add("first test message"); + messages.add("second test message"); + when(mockEventPublisher.sendSync(any(String.class), Mockito.>any())).thenReturn(2); + + validationEventPublisher.publishMessages(messages); + verify(mockEventPublisher, times(1)).sendSync(topicList.get(0).getPartition(), messages); + } + + @Test + public void testPublishMessage() throws Exception { + Collection messages = new ArrayList<>(); + messages.add("first test message"); + when(mockEventPublisher.sendSync(any(String.class), Mockito.>any())).thenReturn(1); + + validationEventPublisher.publishMessage(messages.iterator().next()); + verify(mockEventPublisher, times(1)).sendSync(topicList.get(0).getPartition(), messages); + } + +} diff --git a/src/test/java/org/onap/aai/validation/reader/TestEventReader.java b/src/test/java/org/onap/aai/validation/reader/TestEventReader.java new file mode 100644 index 0000000..a41eb76 --- /dev/null +++ b/src/test/java/org/onap/aai/validation/reader/TestEventReader.java @@ -0,0 +1,270 @@ +/* + * ============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.equalTo; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import javax.inject.Inject; +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; +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"}) +@ContextConfiguration(locations = {"classpath:event-reader/test-validation-service-beans.xml"}) +public class TestEventReader { + + static { + System.setProperty("APP_HOME", "."); + } + + @Inject + private EventReader eventReader; + + private static String vserverEvent; + private static String genericVnfEvent; + private static String invalidEvent1; + private static String invalidEvent2; + private static String invalidEvent3; + private static String invalidEvent4; + private static String invalidEvent5; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + vserverEvent = TestUtil.getFileAsString(TestData.VSERVER.getFilename()); + genericVnfEvent = TestUtil.getFileAsString(TestData.GENERIC_VNF.getFilename()); + invalidEvent1 = TestUtil.getFileAsString(TestData.INVALID_1.getFilename()); + invalidEvent2 = TestUtil.getFileAsString(TestData.INVALID_2.getFilename()); + invalidEvent3 = TestUtil.getFileAsString(TestData.INVALID_3.getFilename()); + invalidEvent4 = TestUtil.getFileAsString(TestData.INVALID_4.getFilename()); + invalidEvent5 = TestUtil.getFileAsString(TestData.INVALID_5.getFilename()); + } + + enum TestData { + // @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"); + + private String filename; + TestData(String filename) {this.filename = filename;} + public String getFilename() {return this.filename;} + // @formatter:on + } + + @Test + public void testGetEventDomain() throws Exception { + Optional eventType = eventReader.getEventDomain(vserverEvent); + + assertThat(eventType.get(), is("devINT1")); + } + + @Test + public void testGetEventAction() throws Exception { + Optional action = eventReader.getEventAction(vserverEvent); + + assertThat(action.get(), is("CREATE")); + } + + @Test + public void testGetEventType() throws Exception { + Optional eventType = eventReader.getEventType(vserverEvent); + + assertThat(eventType.isPresent(), is(true)); + assertThat(eventType.get(), is("AAI-EVENT")); + } + + @Test(expected = ValidationServiceException.class) + public void testGetEventTypeMalformedJson() throws Exception { + eventReader.getEventType("this is malformed"); + } + + @Test + public void testGetEventTypeFromUnrecognisableEvent() throws Exception { + Optional eventType = eventReader.getEventType("this-is-not-an-event-but-is-valid-json"); + + assertThat(eventType.isPresent(), is(false)); + } + + @Test + public void testGetEventTypeThatIsMissing() throws Exception { + Optional eventType = eventReader.getEventType(invalidEvent1); + + assertThat(eventType.isPresent(), is(false)); + } + + @Test + public void testGetEntityType() throws Exception { + Optional entityType = eventReader.getEntityType(vserverEvent); + + assertThat(entityType.get(), is("vserver")); + } + + @Test + public void testGetEntity() throws Exception { + Entity entity = eventReader.getEntity(genericVnfEvent); + + assertThat(entity.getType(), is("generic-vnf")); + + // Dig deeper to check we have the object we want + JsonParser parser = new JsonParser(); + JsonElement jsonElement = parser.parse(entity.getJson()); + String id = jsonElement.getAsJsonObject().get("vnf-id").getAsString(); + + assertThat(id, is("VAPP-1581")); + } + + @Test + public void testEntityLink() throws Exception { + Entity entity = eventReader.getEntity(vserverEvent); + + assertThat(entity.getEntityLink(), is( + "cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/tenants/tenant/example-tenant-id-val-88551/vservers/vserver/example-vserver-id-val-34666")); + } + + @Test(expected = ValidationServiceException.class) + public void testGetEntityWithMissingEntityType() throws Exception { + eventReader.getEntity(invalidEvent1); + } + + @Test(expected = ValidationServiceException.class) + public void testGetEntityWithUnknownEntityType() throws Exception { + eventReader.getEntity(invalidEvent2); + } + + @Test + public void testGetNestedEntity() throws Exception { + Entity entity = eventReader.getEntity(vserverEvent); + + assertThat(entity.getType(), is("vserver")); + + // Dig deeper to check we have the object we want + JsonParser parser = new JsonParser(); + JsonElement jsonElement = parser.parse(entity.getJson()); + String id = jsonElement.getAsJsonObject().get("vserver-id").getAsString(); + + assertThat(id, is("example-vserver-id-val-34666")); + } + + @Test(expected = ValidationServiceException.class) + public void testTooManyNestedEntitiesThrowsException() throws Exception { + eventReader.getEntity(invalidEvent4); + } + + @Test + public void testGetEntityIds() throws Exception { + Entity entity = eventReader.getEntity(vserverEvent); + + List ids = entity.getIds(); + + assertThat(ids, hasSize(1)); + EntityId entityId = ids.get(0); + + assertThat(entityId.getPrimaryKey(), is("vserver-id")); + assertThat(entityId.getValue(), is("example-vserver-id-val-34666")); + } + + @Test + public void testCompareEntityIds() throws Exception { + EntityId entityId = new EntityId(); + assertThat(entityId, is(not(equalTo(null)))); + + entityId.setPrimaryKey("key"); + assertThat(entityId, is(not(equalTo(null)))); + entityId.setValue("value"); + assertThat(entityId, is(not(equalTo(null)))); + + EntityId other = new EntityId(); + assertThat(entityId, is(not(equalTo(other)))); + + other.setPrimaryKey("key"); + assertThat(entityId, is(not(equalTo(other)))); + + other.setValue("value"); + assertThat(entityId, is(equalTo(other))); + + // Force call to hashCode() + assertThat(entityId.hashCode(), is(equalTo(other.hashCode()))); + } + + @Test + public void testGetEntityIdsForUnknownEntityType() throws Exception { + Entity entity = eventReader.getEntity(invalidEvent3); + + List ids = entity.getIds(); + + assertThat(ids, is(empty())); + } + + @Test + public void testGetResourceVersion() throws Exception { + Entity entity = eventReader.getEntity(vserverEvent); + + Optional resourceVersion = entity.getResourceVersion(); + + assertThat(resourceVersion.isPresent(), is(true)); + assertThat(resourceVersion.get(), is("1464193654")); + } + + @Test + public void testGetResourceVersionMissing() throws Exception { + Entity entity = eventReader.getEntity(invalidEvent5); + + Optional resourceVersion = entity.getResourceVersion(); + assertThat(resourceVersion.isPresent(), is(false)); + } + + @Test + public void testGetProperty() throws Exception { + Entity entity = eventReader.getEntity(vserverEvent); + + String resourceVersion = (String) entity.getAttributeValues(Arrays.asList("prov-status")).get("prov-status"); + + assertThat(resourceVersion, is("PREPROV")); + } + + @Test + public void testEntityLinkIsStripped() throws Exception { + Entity entity = eventReader.getEntity(vserverEvent); + String entityLink = entity.getEntityLink(); + assertThat(entityLink, is( + "cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/tenants/tenant/example-tenant-id-val-88551/vservers/vserver/example-vserver-id-val-34666")); + } +} diff --git a/src/test/java/org/onap/aai/validation/reader/TestJsonReader.java b/src/test/java/org/onap/aai/validation/reader/TestJsonReader.java new file mode 100644 index 0000000..e7a906a --- /dev/null +++ b/src/test/java/org/onap/aai/validation/reader/TestJsonReader.java @@ -0,0 +1,95 @@ +/* + * ============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.Matchers.empty; +import static org.hamcrest.Matchers.is; +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 { + + static { + System.setProperty("APP_HOME", "."); + } + + enum TestData { + // @formatter:off + SAMPLE_JSON ("json-reader/sample.json"); + + private String filename; + TestData(String filename) {this.filename = filename;} + public String getFilename() {return this.filename;} + // @formatter:on + } + + @Test + public void testGetString() throws Exception { + String json = TestUtil.getFileAsString(TestData.SAMPLE_JSON.getFilename()); + JsonReader jsonReader = new JsonReader(); + List result = jsonReader.get(json, "$.event-header.entity-type"); + assertThat(result.get(0), is("vserver")); + } + + @Test + public void testGetInteger() throws Exception { + String json = TestUtil.getFileAsString(TestData.SAMPLE_JSON.getFilename()); + JsonReader jsonReader = new JsonReader(); + List result = jsonReader.get(json, "$.event-header.sample-integer"); + assertThat(result.get(0), is("1")); + } + + @Test + public void testGetBoolean() throws Exception { + String json = TestUtil.getFileAsString(TestData.SAMPLE_JSON.getFilename()); + JsonReader jsonReader = new JsonReader(); + List result = jsonReader.get(json, "$.event-header.sample-boolean"); + assertThat(result.get(0), is("true")); + } + + @Test + public void testGetObjectAsString() throws Exception { + String json = TestUtil.getFileAsString(TestData.SAMPLE_JSON.getFilename()); + JsonReader jsonReader = new JsonReader(); + List result = jsonReader.get(json, "$.event-header.sample-object"); + + assertThat(result.get(0), is("{\"property\":\"value\"}")); + } + + @Test + public void testGetArrayAsString() throws Exception { + String json = TestUtil.getFileAsString(TestData.SAMPLE_JSON.getFilename()); + JsonReader jsonReader = new JsonReader(); + List result = jsonReader.get(json, "$.event-header.sample-array"); + + assertThat(result, is(Arrays.asList("one"))); + } + + @Test + public void testGetWithInvalidPath() throws Exception { + String json = TestUtil.getFileAsString(TestData.SAMPLE_JSON.getFilename()); + JsonReader jsonReader = new JsonReader(); + List result = jsonReader.get(json, "$.unknown"); + assertThat(result, empty()); + } +} diff --git a/src/test/java/org/onap/aai/validation/reader/TestOxmConfigTranslator.java b/src/test/java/org/onap/aai/validation/reader/TestOxmConfigTranslator.java new file mode 100644 index 0000000..73e76db --- /dev/null +++ b/src/test/java/org/onap/aai/validation/reader/TestOxmConfigTranslator.java @@ -0,0 +1,111 @@ +/* + * ============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> 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> 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> 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> latestVersion1 = translator.getEdgeFiles(); + assertThat(latestVersion1.size(), is(0)); + } + + @Test + public void testZeroMatchingFiles() { + OxmConfigTranslator translator = buildConfigTranslator("src/test/resources/oxm-reader/"); + Map> 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 new file mode 100644 index 0000000..f7f2643 --- /dev/null +++ b/src/test/java/org/onap/aai/validation/reader/TestOxmReader.java @@ -0,0 +1,63 @@ +/* + * ============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.Matchers.contains; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +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"}) +@ContextConfiguration(locations = {"classpath:oxm-reader/oxm-reader-beans.xml"}) +public class TestOxmReader { + + static { + System.setProperty("APP_HOME", "."); + } + + @Inject + private OxmReader oxmReader; + + @Test + public void testGetPrimaryKeysSingleKey() throws Exception { + List primaryKeys = oxmReader.getPrimaryKeys("connector"); + assertThat(primaryKeys.get(0), is("resource-instance-id")); + } + + @Test + public void testGetPrimaryKeysMultipleKeys() throws Exception { + List primaryKeys = oxmReader.getPrimaryKeys("cloud-region"); + assertThat(primaryKeys, contains("cloud-owner", "cloud-region-id")); + } + + @Test + public void testGetPrimaryKeysUnknownObject() throws Exception { + List primaryKeys = oxmReader.getPrimaryKeys("most-surely-does-not-exist"); + assertThat(primaryKeys, empty()); + } +} diff --git a/src/test/java/org/onap/aai/validation/request/TestRequestHeaders.java b/src/test/java/org/onap/aai/validation/request/TestRequestHeaders.java new file mode 100644 index 0000000..b9ff07c --- /dev/null +++ b/src/test/java/org/onap/aai/validation/request/TestRequestHeaders.java @@ -0,0 +1,143 @@ +/* + * ============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.request; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.junit.Assert.assertThat; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map.Entry; +import javax.ws.rs.core.MultivaluedHashMap; +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.aai.validation.services.RequestHeaders; +import org.springframework.http.HttpHeaders; + +/** + * Test the RequestHeaders class. + * + */ +public class TestRequestHeaders { + + static { + System.setProperty("APP_HOME", "."); + } + + @Test + public void testONAPHeaders() { + String transactionId = "transaction-id"; + String serviceInstanceId = "service-instance-id"; + + MultivaluedHashMap headersMap = new MultivaluedHashMap<>(); + headersMap.put(RequestHeaders.HEADER_REQUEST_ID, createSingletonList(transactionId)); + headersMap.put(RequestHeaders.HEADER_SERVICE_INSTANCE_ID, createSingletonList(serviceInstanceId)); + headersMap.put("X-FromAppId", createSingletonList("app-id")); + headersMap.put("Host", createSingletonList("hostname")); + + HttpHeaders headers = createMockedHeaders(headersMap); + RequestHeaders requestHeaders = new RequestHeaders(headers); + assertThat(requestHeaders.getRequestId(), is(equalTo(transactionId))); + assertThat(requestHeaders.getInstanceId(), is(equalTo(serviceInstanceId))); + } + + @Test + public void testMultipleHeaderValues() { + String transactionId = "transaction-id"; + String serviceInstanceId = "service-instance-id"; + + MultivaluedHashMap headersMap = new MultivaluedHashMap<>(); + headersMap.put(RequestHeaders.HEADER_REQUEST_ID, Arrays.asList(transactionId, "fred")); + headersMap.put(RequestHeaders.HEADER_SERVICE_INSTANCE_ID, Arrays.asList(serviceInstanceId, "bob")); + + HttpHeaders headers = createMockedHeaders(headersMap); + RequestHeaders requestHeaders = new RequestHeaders(headers); + assertThat(requestHeaders.getRequestId(), is(equalTo(transactionId))); + assertThat(requestHeaders.getInstanceId(), is(equalTo(serviceInstanceId))); + } + + @Test + public void testStandardHeaders() { + MultivaluedHashMap headersMap = new MultivaluedHashMap<>(); + headersMap.put("X-TransactionId", createSingletonList("transaction-id")); + headersMap.put("X-FromAppId", createSingletonList("app-id")); + headersMap.put("Host", createSingletonList("hostname")); + + HttpHeaders headers = createMockedHeaders(headersMap); + RequestHeaders requestHeaders = new RequestHeaders(headers); + assertThat(requestHeaders.getRequestId(), is(nullValue())); + assertThat(requestHeaders.getInstanceId(), is(nullValue())); + } + + @Test + public void testEmptyHeaders() { + MultivaluedHashMap headersMap = new MultivaluedHashMap<>(); + headersMap.put(RequestHeaders.HEADER_REQUEST_ID, Collections.emptyList()); + headersMap.put(RequestHeaders.HEADER_SERVICE_INSTANCE_ID, Collections.emptyList()); + + HttpHeaders headers = createMockedHeaders(headersMap); + RequestHeaders requestHeaders = new RequestHeaders(headers); + assertThat(requestHeaders.getRequestId(), is(nullValue())); + assertThat(requestHeaders.getInstanceId(), is(nullValue())); + } + + @Test + public void testNullHeaders() { + MultivaluedHashMap headersMap = new MultivaluedHashMap<>(); + headersMap.put(RequestHeaders.HEADER_REQUEST_ID, Collections.emptyList()); + + HttpHeaders headers = createMockedHeaders(headersMap); + Mockito.when(headers.getFirst(RequestHeaders.HEADER_SERVICE_INSTANCE_ID)).thenReturn(null); + + RequestHeaders requestHeaders = new RequestHeaders(headers); + assertThat(requestHeaders.getRequestId(), is(nullValue())); + assertThat(requestHeaders.getInstanceId(), is(nullValue())); + } + + @Test + public void testToString() { + String transactionId = "transaction-id"; + String serviceInstanceId = "service-instance-id"; + + MultivaluedHashMap headersMap = new MultivaluedHashMap<>(); + headersMap.put(RequestHeaders.HEADER_REQUEST_ID, createSingletonList(transactionId)); + headersMap.put(RequestHeaders.HEADER_SERVICE_INSTANCE_ID, createSingletonList(serviceInstanceId)); + + HttpHeaders headers = createMockedHeaders(headersMap); + RequestHeaders requestHeaders = new RequestHeaders(headers); + assertThat(requestHeaders.toString(), + is(equalTo("RequestHeaders [requestId=transaction-id, instanceId=service-instance-id]"))); + } + + private HttpHeaders createMockedHeaders(MultivaluedHashMap headersMap) { + HttpHeaders headers = Mockito.mock(HttpHeaders.class); + for (Entry> entry : headersMap.entrySet()) { + List valuesList = entry.getValue(); + String value = valuesList == null || valuesList.isEmpty() ? null : valuesList.get(0); + Mockito.when(headers.getFirst(entry.getKey())).thenReturn(value); + } + return headers; + } + + private List createSingletonList(String listItem) { + return Collections.singletonList(listItem); + } +} diff --git a/src/test/java/org/onap/aai/validation/result/TestValidationResult.java b/src/test/java/org/onap/aai/validation/result/TestValidationResult.java new file mode 100644 index 0000000..5d02101 --- /dev/null +++ b/src/test/java/org/onap/aai/validation/result/TestValidationResult.java @@ -0,0 +1,444 @@ +/* + * ============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.result; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import java.time.Instant; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import javax.inject.Inject; +import org.junit.Before; +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.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; +import org.onap.aai.validation.util.JsonUtil; +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"}) +@ContextConfiguration(locations = {"classpath:validation-result/test-validation-service-beans.xml"}) +public class TestValidationResult { + + static { + System.setProperty("APP_HOME", "."); + } + + @Inject + private EventReader eventReader; + + private static String vserverEvent; + private static Entity entity; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + vserverEvent = TestUtil.getFileAsString(TestData.VSERVER.getFilename()); + } + + @Before + public void setUp() throws Exception { + entity = eventReader.getEntity(vserverEvent); + } + + enum TestData { + // @formatter:off + VSERVER ("validation-result/vserver-create-event.json"); + + private String filename; + TestData(String filename) {this.filename = filename;} + public String getFilename() {return this.filename;} + // @formatter:on + } + + @Test + public void testValidationResultWithViolationDetailsAsString() throws Exception { + // Violation details + Map violationDetails = new HashMap<>(); + violationDetails.put("attr1", "val1"); + violationDetails.put("attr2", "val2"); + + ValidationResult validationResult = getValidationResult(violationDetails); + ValidationResult transformedVr = toAndFromJson(validationResult); + + assertThatValidationResultIsValid(transformedVr); + Violation v = assertThatViolationIsValid(transformedVr, validationResult.getViolations().get(0)); + assertThat(v.getViolationDetails(), is(violationDetails)); + } + + @Test + public void testValidationResultWithViolationDetailsIncludingNull() throws Exception { + // Violation details + Map violationDetails = new HashMap<>(); + violationDetails.put("attr1", "val1"); + violationDetails.put("attr2", null); + + ValidationResult validationResult = getValidationResult(violationDetails); + ValidationResult transformedVr = toAndFromJson(validationResult); + + // Check + assertThatValidationResultIsValid(transformedVr); + Violation v = assertThatViolationIsValid(transformedVr, validationResult.getViolations().get(0)); + assertThat(v.getViolationDetails(), is(violationDetails)); + } + + @Test + public void testValidationResultWithViolationDetailsAsList() throws Exception { + // Violation details + Map violationDetails = new HashMap<>(); + violationDetails.put("attr1", Arrays.asList("val1", "val2")); + violationDetails.put("attr2", Arrays.asList("val3", "val4")); + + ValidationResult validationResult = getValidationResult(violationDetails); + ValidationResult transformedVr = toAndFromJson(validationResult); + + // Check + assertThatValidationResultIsValid(transformedVr); + Violation v = assertThatViolationIsValid(transformedVr, validationResult.getViolations().get(0)); + assertThat(v.getViolationDetails(), is(violationDetails)); + } + + @Test + public void testValidationResultWithViolationDetailsAsInt() throws Exception { + // Violation details + Map violationDetails = new HashMap<>(); + violationDetails.put("attr1", 1); + violationDetails.put("attr2", 2); + + ValidationResult validationResult = getValidationResult(violationDetails); + ValidationResult vr = toAndFromJson(validationResult); + + // Check + assertThatValidationResultIsValid(vr); + Violation v = assertThatViolationIsValid(vr, validationResult.getViolations().get(0)); + assertThat(v.getViolationDetails().get("attr1"), is(1.0)); + assertThat(v.getViolationDetails().get("attr2"), is(2.0)); + } + + @Test + public void testValidationResultWithViolationDetailsAsObject() throws Exception { + // Violation details + JsonArray jsonArray = new JsonArray(); + jsonArray.add("v1"); + JsonObject jsonObject = new JsonObject(); + jsonObject.add("p1", jsonArray); + jsonObject.add("p2", jsonArray); + Map violationDetails = new HashMap<>(); + violationDetails.put("attr1", jsonObject); + + ValidationResult validationResult = getValidationResult(violationDetails); + ValidationResult transformedVr = toAndFromJson(validationResult); + + // Check + assertThatValidationResultIsValid(transformedVr); + Violation v = assertThatViolationIsValid(transformedVr, validationResult.getViolations().get(0)); + String jsonDetails = v.getViolationDetails().get("attr1").toString(); + JsonParser jsonParser = new JsonParser(); + JsonElement jsonElement = jsonParser.parse(jsonDetails); + assertThat(jsonObject, is(jsonElement)); + } + + @Test + public void testCompareObjects() throws Exception { + ValidationResult validationResult = new ValidationResult(entity); + assertThat(validationResult, is(not(equalTo(null)))); + + validationResult.setEntityId(new JsonObject()); + assertThat(validationResult, is(not(equalTo(null)))); + + ValidationResult other = new ValidationResult(entity); + assertThat(validationResult, is(not(equalTo(other)))); + + validationResult.setEntityType("type"); + assertThat(validationResult, is(not(equalTo(other)))); + + Map violationDetails = new HashMap<>(); + + //@formatter:off + Violation violation = new Violation.Builder(entity) + .category("category") + .severity("severity") + .violationType("violationType") + .violationDetails(violationDetails) + .errorMessage("errorMessage") + .build(); + //@formatter:on + + validationResult.addViolation(violation); + assertThat(validationResult, is(not(equalTo(other)))); + + // Force call to hashCode() + assertThat(validationResult.hashCode(), is(not(equalTo(other.hashCode())))); + + } + + /** + * Tests for comparing two Violation objects. The generated Violation ID must be deterministic. + * + * @throws Exception + */ + @Test + public void testCompareViolationObjects() throws Exception { + // Use the standard vserver event + Builder builder = new Violation.Builder(entity); + + // Force call to toString() for coverage only + assertThat(builder.toString(), is(equalTo(new Violation.Builder(entity).toString()))); + + // Build a blank violation + Violation violation = builder.build(); + + // Identity tests + assertThat(violation, is(not(equalTo(null)))); + assertThat(violation, is(not(equalTo(1)))); + assertThat(violation, is(equalTo(violation))); + + // Ensure that any violations we build are identical + testViolationIdsForEquality(builder, builder, true); + + // Create a copy of the vserver event and vary the resourceVersion + Entity entity2 = eventReader + .getEntity(vserverEvent.replaceFirst("resource-version\": \"1464193654", "resource-version\": \"123")); + + // The violationId produced for identically built violations is the same for each builder (although the vserver + // events differ). + testViolationIdsForEquality(new Violation.Builder(entity), new Violation.Builder(entity2), true); + + // The violationId produced must differ whenever the violation values differ. + testViolationIdsForInequality(new Violation.Builder(entity), new Violation.Builder(entity2)); + + // Make a new variant of the vserver event using a different entity Id + Entity entity3 = eventReader.getEntity( + vserverEvent.replaceFirst("vserver-id\": \"example-vserver-id-val-34666", "vserver-id\": \"123")); + + // The violationId produced for identically built violations is now different for each builder (because the + // entity Ids differ). + testViolationIdsForEquality(new Violation.Builder(entity), new Violation.Builder(entity3), false); + } + + /** + * Generate various violations using the supplied builders and assert the expected equality of the generated + * Violation IDs whenever the values supplied to the builders are the same. + * + * @param b1 a builder + * @param b2 another builder + * @param expectedResult whether or not the two builders should produce identical violations + * @throws ValidationServiceException + */ + private void testViolationIdsForEquality(Builder b1, Builder b2, Boolean expectedResult) + throws ValidationServiceException { + Violation v1 = b1.build(); + Violation v2 = b2.build(); + assertThatViolationsAreEqual(v1, v2, expectedResult); + + // Use the same category + String category = "INVALID OBJ"; + v1 = b1.category(category).build(); + v2 = b2.category(category).build(); + assertThatViolationsAreEqual(v1, v2, expectedResult); + + // Use the same severity + String severity = "CRITICAL"; + v1 = b1.severity(severity).build(); + v2 = b2.severity(severity).build(); + assertThatViolationsAreEqual(v1, v2, expectedResult); + + // Use the same violation type + v1 = b1.violationType(ViolationType.RULE).build(); + v2 = b2.violationType(ViolationType.RULE).build(); + assertThatViolationsAreEqual(v1, v2, expectedResult); + + // Use the same validation rule + String rule = "prov-status"; + v1 = b1.validationRule(rule).build(); + v2 = b2.validationRule(rule).build(); + assertThatViolationsAreEqual(v1, v2, expectedResult); + + // Use the same error message + String errorMessage = "Invalid prov-status value. Must have a value not equal to ACTIVE/active."; + v1 = b1.errorMessage(errorMessage).build(); + v2 = b2.errorMessage(errorMessage).build(); + assertThatViolationsAreEqual(v1, v2, expectedResult); + + // Use the same violation details + Map details = new HashMap<>(); + details.put(rule, "ACTIVE"); + v1 = b1.violationDetails(details).build(); + v2 = b2.violationDetails(details).build(); + assertThatViolationsAreEqual(v1, v2, expectedResult); + } + + /** + * Generate violations using the supplied builders and assert that the generated Violation IDs differ whenever the + * values supplied to the builders differ. + * + * @param builder + * @param builder2 + * @throws ValidationServiceException + */ + private void testViolationIdsForInequality(Builder builder, Builder builder2) throws ValidationServiceException { + Violation violation; + Violation other; + + // Vary the violation type + violation = builder.violationType("").build(); + other = builder2.violationType(ViolationType.RULE).build(); + assertThatViolationIdsDiffer(violation, other); + + violation = builder.violationType(ViolationType.NONE).build(); + other = builder2.violationType(ViolationType.RULE).build(); + assertThatViolationIdsDiffer(violation, other); + + // Vary the validation rule + violation = builder.validationRule(null).build(); + other = builder2.validationRule("rule").build(); + assertThatViolationIdsDiffer(violation, other); + + violation = builder.validationRule("rule1").build(); + other = builder2.validationRule(null).build(); + assertThatViolationIdsDiffer(violation, other); + + violation = builder.validationRule("rule1").build(); + other = builder2.validationRule("rule2").build(); + assertThatViolationIdsDiffer(violation, other); + + // Vary the category + violation = builder.category(null).build(); + other = builder2.category("category").build(); + assertThatViolationIdsDiffer(violation, other); + + violation = builder.category("category").build(); + other = builder2.category(null).build(); + assertThatViolationIdsDiffer(violation, other); + + violation = builder.category("category1").build(); + other = builder2.category("category2").build(); + assertThatViolationIdsDiffer(violation, other); + + // Vary the error message + violation = builder.validationRule("rule").build(); + other = builder2.validationRule("rule").errorMessage("message2").build(); + assertThatViolationIdsDiffer(violation, other); + + violation = builder.validationRule("rule").errorMessage("message1").build(); + other = builder2.validationRule("rule").errorMessage("message2").build(); + assertThatViolationIdsDiffer(violation, other); + + // Vary the severity + violation = builder.errorMessage("msg").build(); + other = builder2.errorMessage("msg").severity("sev2").build(); + assertThatViolationIdsDiffer(violation, other); + + violation = builder.errorMessage("msg").severity("sev1").build(); + other = builder2.errorMessage("msg").severity("sev2").build(); + assertThatViolationIdsDiffer(violation, other); + } + + private ValidationResult getValidationResult(Map violationDetails) + throws ValidationServiceException { + ValidationResult validationResult = new ValidationResult(entity); + + //@formatter:off + Violation violation = new Violation.Builder(entity) + .category("category") + .severity("severity") + .violationType("violationType") + .violationDetails(violationDetails) + .errorMessage("errorMessage") + .build(); + //@formatter:on + + validationResult.addViolation(violation); + + return validationResult; + } + + private ValidationResult toAndFromJson(ValidationResult validationResult) { + return JsonUtil.toAnnotatedClassfromJson(validationResult.toJson(), ValidationResult.class); + } + + private void assertThatValidationResultIsValid(ValidationResult vr) { + assertTrue("Expected valid UUID", isValidEventId(vr.getValidationId())); + assertIsValidTimestamp(vr.getValidationTimestamp()); + JsonObject expectedEntityId = new JsonObject(); + expectedEntityId.addProperty("vserver-id", "example-vserver-id-val-34666"); + assertThat(vr.getEntityId(), is(expectedEntityId)); + assertThat(vr.getEntityType(), is("vserver")); + assertThat(vr.getResourceVersion(), is("1464193654")); + assertThat(vr.getEntityLink(), is( + "cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/tenants/tenant/example-tenant-id-val-88551/vservers/vserver/example-vserver-id-val-34666")); + } + + private Violation assertThatViolationIsValid(ValidationResult vr, Violation expectedViolation) { + Violation v = vr.getViolations().get(0); + assertThat(v.getViolationId(), is(expectedViolation.getViolationId())); + assertThat(v.getCategory(), is("category")); + assertThat(v.getSeverity(), is("severity")); + assertThat(v.getViolationType(), is("violationType")); + assertThat(v.getErrorMessage(), is("errorMessage")); + return v; + } + + private void assertThatViolationsAreEqual(Violation v1, Violation v2, Boolean expectedResult) { + assertThat("Violation equality in error:\n" + v1 + " equals " + v2, v1.equals(v2), is(expectedResult)); + assertThat("Violation ID equality in error:\n" + v1.getViolationId() + " equals " + v2.getViolationId(), + v1.getViolationId().equals(v2.getViolationId()), is(expectedResult)); + // Force a call to toString() for code coverage only + assertThat(v1.toString().equals(v2.toString()), is(equalTo(expectedResult))); + } + + private void assertThatViolationIdsDiffer(Violation violation, Violation other) { + assertThat(violation.getViolationId(), is(not(equalTo(other.getViolationId())))); + assertThat(violation, is(not(equalTo(other)))); + } + + private boolean isValidEventId(String eventId) { + try { + UUID.fromString(eventId); + } catch (IllegalArgumentException exception) { + return false; + } + return true; + } + + private void assertIsValidTimestamp(String date) { + DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyyMMdd'T'HHmmssX").withZone(ZoneOffset.UTC); + Instant.from(f.parse(date)); + } +} diff --git a/src/test/java/org/onap/aai/validation/ruledriven/configuration/ConfigFileBuilder.java b/src/test/java/org/onap/aai/validation/ruledriven/configuration/ConfigFileBuilder.java new file mode 100644 index 0000000..1f87ca0 --- /dev/null +++ b/src/test/java/org/onap/aai/validation/ruledriven/configuration/ConfigFileBuilder.java @@ -0,0 +1,104 @@ +/* + * ============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.ruledriven.configuration; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.List; +import java.util.Properties; +import org.junit.rules.TemporaryFolder; +import org.onap.aai.cl.api.Logger; +import org.onap.aai.validation.logging.LogHelper; +import org.onap.aai.validation.ruledriven.configuration.EntitySection; +import org.onap.aai.validation.ruledriven.configuration.RulesConfigurationLoader; +import org.onap.aai.validation.ruledriven.configuration.build.ContentBuilder; +import org.onap.aai.validation.ruledriven.configuration.build.EntityBuilder; +import org.onap.aai.validation.ruledriven.configuration.build.RuleBuilder; + +public class ConfigFileBuilder extends ContentBuilder { + + private static final Logger logger = LogHelper.INSTANCE; + + private static final String TMP_CONFIG_FILE = "config.txt"; + private TemporaryFolder testFolder; + private File tempFile; + + public ConfigFileBuilder(TemporaryFolder testFolder) { + super(); + this.testFolder = testFolder; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("ConfigBuilder [").append(testFolder.getRoot().getAbsolutePath()).append(System.lineSeparator()); + for (ContentBuilder item : items) { + sb.append(item).append(System.lineSeparator()); + } + sb.append(System.lineSeparator()).append("]"); + return sb.toString(); + } + + public EntityBuilder entity() { + EntityBuilder item = new EntityBuilder(); + addContent(item); + return item; + } + + public RuleBuilder rule() { + RuleBuilder item = new RuleBuilder(); + addContent(item); + return item; + } + + public void entity(Properties props) { + EntityBuilder entity = entity(); + entity.appendProperties(props); + } + + public RuleBuilder rule(String name) { + RuleBuilder rule = rule(); + rule.appendValue("name", name); + return rule; + } + + public List loadConfiguration() throws IOException { + logger.debug("Configuration file: " + build()); + return buildConfiguration(build()); + } + + private List buildConfiguration(String text) throws IOException { + tempFile = createConfigFile(text); + return RulesConfigurationLoader.loadConfiguration(tempFile).getEntities(); + } + + private File createConfigFile(String configText) throws IOException { + tempFile = testFolder.newFile(TMP_CONFIG_FILE); + BufferedWriter bw = new BufferedWriter(new FileWriter(tempFile)); + bw.write(configText); + bw.close(); + return tempFile; + } + + public void freeResources() { + tempFile.delete(); + } + +} diff --git a/src/test/java/org/onap/aai/validation/ruledriven/configuration/ConfigurationExceptionMatcher.java b/src/test/java/org/onap/aai/validation/ruledriven/configuration/ConfigurationExceptionMatcher.java new file mode 100644 index 0000000..f32c5d3 --- /dev/null +++ b/src/test/java/org/onap/aai/validation/ruledriven/configuration/ConfigurationExceptionMatcher.java @@ -0,0 +1,73 @@ +/* + * ============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.ruledriven.configuration; + +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeMatcher; +import org.onap.aai.validation.ruledriven.configuration.GroovyConfigurationException; + +public class ConfigurationExceptionMatcher { + public static Matcher hasInvalidToken(final String expectedToken) { + return new TypeSafeMatcher() { + private String foundToken; + + @Override + public void describeTo(Description description) { + description.appendText("result from getInvalidToken() equals \"").appendText(expectedToken) + .appendText("\""); + } + + @Override + public void describeMismatchSafely(final GroovyConfigurationException exception, + final Description mismatchDescription) { + mismatchDescription.appendText("was ").appendValue(foundToken); + } + + @Override + protected boolean matchesSafely(GroovyConfigurationException exception) { + foundToken = exception.getInvalidToken(); + return foundToken != null && foundToken.equalsIgnoreCase(expectedToken); + } + }; + } + + public static Matcher configTextContains(final String expectedConfigText) { + return new TypeSafeMatcher() { + private String foundConfigText; + + @Override + public void describeTo(Description description) { + description.appendText("result from getConfigText() containing \"").appendText(expectedConfigText) + .appendText("\""); + } + + @Override + public void describeMismatchSafely(final GroovyConfigurationException exception, + final Description mismatchDescription) { + mismatchDescription.appendText("was ").appendValue(foundConfigText); + } + + @Override + protected boolean matchesSafely(GroovyConfigurationException exception) { + foundConfigText = exception.getConfigText(); + return foundConfigText != null && foundConfigText.contains(expectedConfigText); + } + }; + } +} diff --git a/src/test/java/org/onap/aai/validation/ruledriven/configuration/TestConfigFileBuilder.java b/src/test/java/org/onap/aai/validation/ruledriven/configuration/TestConfigFileBuilder.java new file mode 100644 index 0000000..6d56fa8 --- /dev/null +++ b/src/test/java/org/onap/aai/validation/ruledriven/configuration/TestConfigFileBuilder.java @@ -0,0 +1,59 @@ +/* + * ============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.ruledriven.configuration; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.onap.aai.validation.ruledriven.configuration.build.EntityBuilder; + +/** + * These tests are required to ensure code coverage by unit testing + * + */ +public class TestConfigFileBuilder { + + static { + System.setProperty("APP_HOME", "."); + } + + @Rule + public TemporaryFolder testFolder = new TemporaryFolder(); + + /** + * Validate that a content builder accepts a numeric value + * + * @throws Exception + */ + @Test + public void testNumberItem() throws Exception { + ConfigFileBuilder builder = new ConfigFileBuilder(testFolder); + EntityBuilder ab = new EntityBuilder(); + ab.appendValue("dummy", 3); + ab.appendValue("dummy2", 5L); + builder.addContent(ab); + builder.toString(); + } + + @Test + public void testToString() throws Exception { + ConfigFileBuilder builder = new ConfigFileBuilder(testFolder); + builder.addContent(new EntityBuilder()); + builder.toString(); + } +} diff --git a/src/test/java/org/onap/aai/validation/ruledriven/configuration/TestRulesConfigurationReader.java b/src/test/java/org/onap/aai/validation/ruledriven/configuration/TestRulesConfigurationReader.java new file mode 100644 index 0000000..c0f9f48 --- /dev/null +++ b/src/test/java/org/onap/aai/validation/ruledriven/configuration/TestRulesConfigurationReader.java @@ -0,0 +1,448 @@ +/* + * ============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.ruledriven.configuration; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Properties; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.rules.TemporaryFolder; +import org.onap.aai.validation.ruledriven.configuration.EntitySection; +import org.onap.aai.validation.ruledriven.configuration.GroovyConfigurationException; +import org.onap.aai.validation.ruledriven.configuration.RuleSection; +import org.onap.aai.validation.ruledriven.configuration.SettingsSection; +import org.onap.aai.validation.ruledriven.configuration.build.EntityBuilder; +import org.onap.aai.validation.ruledriven.configuration.build.RuleBuilder; +import org.onap.aai.validation.ruledriven.configuration.build.ValidationBuilder; +import org.onap.aai.validation.test.util.RandomString; + +/** + * Tests for the Groovy classes that read and parse the rules configuration + * + */ +public class TestRulesConfigurationReader { + + static { + System.setProperty("APP_HOME", "."); + } + + @Rule + public TemporaryFolder testFolder = new TemporaryFolder(); + + /** + * Exception expected by Junit. This is modified per test. + */ + @Rule + public final ExpectedException exception = ExpectedException.none(); + + private static final String INVALID_TOKEN = "audif"; + + @Test + public void testEmptyConfiguration() throws Exception { + ConfigFileBuilder builder = new ConfigFileBuilder(testFolder); + Collection entitys = builder.loadConfiguration(); + assertThat(entitys.size(), is(0)); + } + + /** + * Test for reporting of an unknown token with various syntax formatting + * + * @throws Exception + */ + @Test + public void testInvalidTopLevelItem() throws Exception { + testInvalidToken(INVALID_TOKEN); + testInvalidToken(INVALID_TOKEN + " { }"); + testInvalidToken("{ " + INVALID_TOKEN + " }"); + testInvalidToken(INVALID_TOKEN + " { "); + testInvalidToken(INVALID_TOKEN + " } "); + testInvalidToken("{} " + INVALID_TOKEN); + testInvalidToken("\"" + INVALID_TOKEN); + } + + @Test + public void testInvalidentityItem1() throws Exception { + testInvalidToken("entity { invalid }", "invalid"); + } + + @Test + public void testInvalidentityItem2() throws Exception { + testInvalidToken("entity { invalid item }", "item"); + } + + @Test + public void testInvalidentityItem3() throws Exception { + testInvalidToken("entity { name name\n fred fred}", "name"); + } + + @Test + public void testInvalidQuery() throws Exception { + testInvalidToken("entity { name 'name'\n joe}", "joe"); + } + + @Test + public void testGenericRuleWithZeroAttributes() throws Exception { + ConfigFileBuilder builder = new ConfigFileBuilder(testFolder); + EntityBuilder entity = builder.entity(); + entity.appendValue("name", "entity"); + ValidationBuilder validation = entity.validation(buildProperties("type")); + validation.useRule("ruleZ"); + builder.rule("ruleZ"); + + exception.expect(GroovyConfigurationException.class); + exception.expectMessage(containsString("attributes")); + builder.loadConfiguration(); + } + + @Test + public void testInvalidUseRule() throws Exception { + testInvalidToken("entity { validation { useRule { foo } } }", "foo"); + } + + @Test + public void testMissingRule() throws Exception { + ConfigFileBuilder builder = new ConfigFileBuilder(testFolder); + builder.entity().validation().useRule("missingRule"); + exception.expect(GroovyConfigurationException.class); + exception.expectMessage(containsString("missingRule")); + builder.loadConfiguration(); + } + + @Test + public void testDuplicateRule() throws Exception { + ConfigFileBuilder builder = new ConfigFileBuilder(testFolder); + builder.rule("duplicateRule"); + builder.rule("duplicateRule"); + exception.expect(GroovyConfigurationException.class); + exception.expectMessage(containsString("duplicateRule")); + builder.loadConfiguration(); + } + + @Test + public void testSimpleentity() throws Exception { + String name = RandomString.generate(); + + ConfigFileBuilder builder = new ConfigFileBuilder(testFolder); + Properties entity = new Properties(); + entity.put("name", name); + builder.entity(entity); + + List entities = builder.loadConfiguration(); + + assertThat(entities.size(), is(1)); + EntitySection entityConf = entities.get(0); + assertThat(entityConf.getName(), is(equalTo(name))); + } + + /** + * The Settings section is not tested elsewhere + * + * @throws Exception + */ + @Test + public void testGlobalSettings() throws Exception { + SettingsSection settings = new SettingsSection(); + settings.toString(); + } + + @Test + public void testentityWithRuleUsingStrings() throws Exception { + String name = RandomString.generate(); + String description = RandomString.generate(); + String severity = RandomString.generate(); + List attributes = Arrays.asList(RandomString.generate()); + String validate = randomValidationExpression(); + + Properties rule = new Properties(); + rule.put("name", name); + rule.put("description", description); + rule.put("severity", severity); + rule.put("attributes", attributes); + rule.put("validate", validate); + + String type = RandomString.generate(); + + Properties validation = new Properties(); + validation.put("type", type); + validation.put("rule", rule); + + ConfigFileBuilder builder = new ConfigFileBuilder(testFolder); + Properties entity = new Properties(); + entity.put("validation", validation); + builder.entity(entity); + + List entities = builder.loadConfiguration(); + + assertThat(entities.size(), is(1)); + EntitySection entityConf = entities.get(0); + Collection rules = entityConf.getRules(); + assertThat(rules.size(), is(1)); + + RuleSection ruleConfig = rules.iterator().next(); + assertThat(ruleConfig.getName(), is(equalTo(name))); + assertThat(ruleConfig.getDescription(), is(equalTo(description))); + assertThat(ruleConfig.getSeverity(), is(equalTo(severity))); + assertThat(ruleConfig.getAttributes(), is(equalTo(attributes))); + assertThat(ruleConfig.getExpression(), is(equalTo(validate))); + assertThat(ruleConfig.getType(), is(equalTo(type))); + } + + @Test + public void testentityWithRuleUsingBuilder() throws Exception { + String name = RandomString.generate(); + String description = RandomString.generate(); + String severity = RandomString.generate(); + List attributes = Arrays.asList(RandomString.generate()); + String validate = randomValidationExpression(); + String type = RandomString.generate(); + + ConfigFileBuilder builder = new ConfigFileBuilder(testFolder); + ValidationBuilder validation = builder.entity().validation(); + validation.appendValue("type", type); + + RuleBuilder rule = validation.rule(name); + rule.appendValue("description", description); + rule.appendValue("severity", severity); + rule.appendValue("attributes", attributes); + rule.appendValue("validate", validate); + + List entitys = builder.loadConfiguration(); + + assertThat(entitys.size(), is(1)); + EntitySection entityConf = entitys.get(0); + Collection rules = entityConf.getRules(); + assertThat(rules.size(), is(1)); + + RuleSection ruleConfig = rules.iterator().next(); + assertThat(ruleConfig.getName(), is(equalTo(name))); + assertThat(ruleConfig.getDescription(), is(equalTo(description))); + assertThat(ruleConfig.getSeverity(), is(equalTo(severity))); + assertThat(ruleConfig.getAttributes(), is(equalTo(attributes))); + assertThat(ruleConfig.getExpression(), is(equalTo(validate))); + assertThat(ruleConfig.getType(), is(equalTo(type))); + } + + @Test + public void testentityWithEmbeddedRule() throws Exception { + Properties rule = buildProperties("name", "description", "severity", "validate"); + rule.put("attributes", Arrays.asList(RandomString.generate())); + + Properties validation = buildProperties("type"); + validation.put("rule", rule); + + ConfigFileBuilder builder = new ConfigFileBuilder(testFolder); + Properties entity = new Properties(); + entity.put("validation", validation); + builder.entity(entity); + + List entitys = builder.loadConfiguration(); + + assertThat(entitys.size(), is(1)); + EntitySection entityConf = entitys.get(0); + Collection rules = entityConf.getRules(); + assertThat(rules.size(), is(1)); + + RuleSection ruleConfig = rules.iterator().next(); + assertThatConfigMatchesProperties(ruleConfig, rule, validation); + } + + @Test + public void testEmbeddedRuleUsingString() throws Exception { + ConfigFileBuilder builder = new ConfigFileBuilder(testFolder); + builder.appendLine("entity {"); + builder.appendLine(" type 'newvce'"); + builder.appendLine(" validation {"); + builder.appendLine(" rule {"); + builder.appendLine(" name 'vnfName'"); + builder.appendLine( + " description 'Validate that the vnf-name attribute matches the expected string format'"); + builder.appendLine(" severity 'MAJOR'"); + builder.appendLine(" attributes 'vnf-name'"); + builder.appendLine(" validate 'vnf-name.matchesPattern(xxxxnnnvbc)'"); + builder.appendLine(" }"); + builder.appendLine(" }"); + builder.appendLine("}"); + List entitys = builder.loadConfiguration(); + + assertThat(entitys.size(), is(1)); + EntitySection entityConf = entitys.get(0); + assertThat(entityConf.getName(), is(equalTo("newvce"))); + + Collection rules = entityConf.getRules(); + assertThat(rules.size(), is(1)); + RuleSection ruleConfig = rules.iterator().next(); + + assertThat(ruleConfig.getType(), is(equalTo("newvce"))); + assertThat(ruleConfig.getName(), is(equalTo("vnfName"))); + assertThat(ruleConfig.getDescription(), + is(equalTo("Validate that the vnf-name attribute matches the expected string format"))); + assertThat(ruleConfig.getSeverity(), is(equalTo("MAJOR"))); + List expectedList = new ArrayList(); + expectedList.add("vnf-name"); + assertThat(ruleConfig.getAttributes(), is(equalTo(expectedList))); + assertThat(ruleConfig.getExpression(), is(equalTo("vnf-name.matchesPattern(xxxxnnnvbc)"))); + } + + @Test + public void testGenericRuleUsingStrings() throws Exception { + ConfigFileBuilder builder = new ConfigFileBuilder(testFolder); + builder.appendLine("entity {"); + builder.appendLine(" type 'newvce'"); + builder.appendLine(" validation {"); + builder.appendLine(" useRule {"); + builder.appendLine(" name 'genericRule'"); + builder.appendLine(" attributes 'clli'"); + builder.appendLine(" }"); + builder.appendLine(" }"); + builder.appendLine("}"); + builder.appendLine("rule {"); + builder.appendLine(" name 'genericRule'"); + builder.appendLine(" description 'The field (attribute) must be less than 50 characters in length'"); + builder.appendLine(" severity 'MINOR'"); + builder.appendLine(" validate 'attribute.size() < 50'"); + builder.appendLine("}"); + + List entitys = builder.loadConfiguration(); + assertThat(entitys.size(), is(1)); + EntitySection entityConf = entitys.get(0); + assertThat(entityConf.getName(), is(equalTo("newvce"))); + + Collection rules = entityConf.getRules(); + assertThat("Number of rules", rules.size(), is(1)); + RuleSection ruleConfig = rules.iterator().next(); + + assertThat(ruleConfig.getType(), is(equalTo("newvce"))); + assertThat(ruleConfig.getName(), is(equalTo("genericRule"))); + assertThat(ruleConfig.getDescription(), + is(equalTo("The field (attribute) must be less than 50 characters in length"))); + assertThat(ruleConfig.getSeverity(), is(equalTo("MINOR"))); + List expectedList = new ArrayList(); + expectedList.add("clli"); + assertThat(ruleConfig.getAttributes(), is(equalTo(expectedList))); + assertThat(ruleConfig.getExpression(), is(equalTo("attribute.size() < 50"))); + } + + @Test + public void testMultipleGenericRules() throws Exception { + ConfigFileBuilder builder = new ConfigFileBuilder(testFolder); + EntityBuilder entity = builder.entity(); + ValidationBuilder validation = entity.validation(buildProperties("type")); + validation.useRule("rule1"); + validation.useRule("rule2").appendValue("attributes", "attr"); + builder.rule("rule1").appendValue("attributes", "field").appendValue("validate", "true"); + builder.rule("rule2").appendValue("validate", "true"); + + List entitys = builder.loadConfiguration(); + + assertThat(entitys.size(), is(1)); + EntitySection entityConf = entitys.get(0); + Collection rules = entityConf.getRules(); + assertThat(rules.size(), is(2)); + + Iterator iterator = rules.iterator(); + RuleSection ruleConfig = iterator.next(); + assertThat(ruleConfig.getName(), is(equalTo("rule1"))); + assertThat(ruleConfig.getAttributes(), is(Collections.singletonList("field"))); + + ruleConfig = iterator.next(); + assertThat(ruleConfig.getName(), is(equalTo("rule2"))); + assertThat(ruleConfig.getAttributes(), is(Collections.singletonList("attr"))); + } + + @Test + public void testGenericRuleWithMultipleAttributes() throws Exception { + ConfigFileBuilder builder = new ConfigFileBuilder(testFolder); + EntityBuilder entity = builder.entity(); + ValidationBuilder validation = entity.validation(buildProperties("type")); + validation.useRule("rule").appendValue("attributes", Arrays.asList("attr1", "attr2")); + builder.rule("rule").appendValue("attributes", Arrays.asList("field1", "field2")).appendValue("validate", + "true"); + + List entities = builder.loadConfiguration(); + + assertThat(entities.size(), is(1)); + EntitySection entityConf = entities.get(0); + Collection rules = entityConf.getRules(); + assertThat(rules.size(), is(1)); + + Iterator iterator = rules.iterator(); + RuleSection ruleConfig = iterator.next(); + assertThat(ruleConfig.getName(), is(equalTo("rule"))); + assertThat(ruleConfig.getAttributes(), is(Arrays.asList("attr1", "attr2"))); + } + + private String randomValidationExpression() { + String validate = RandomString.generate(); + while (validate.matches("^\\d+[a-fA-F]+\\D+.*") || validate.matches("0x\\D+.*")) { + validate = RandomString.generate(); + } + return validate; + } + + private void testInvalidToken(String configText) throws IOException { + testInvalidToken(configText, INVALID_TOKEN); + } + + private void testInvalidToken(String configText, String invalidToken) throws IOException { + ConfigFileBuilder builder = new ConfigFileBuilder(testFolder); + builder.addContent(configText); + assertConfigurationException(invalidToken); + builder.loadConfiguration(); + } + + private void assertConfigurationException(String invalidToken) { + exception.expect(GroovyConfigurationException.class); + exception.expectMessage(containsString(invalidToken)); + exception.expect(ConfigurationExceptionMatcher.hasInvalidToken(invalidToken)); + exception.expect(ConfigurationExceptionMatcher.configTextContains(invalidToken)); + } + + private Properties buildProperties(String... strings) { + Properties props = new Properties(); + for (String str : strings) { + props.put(str, randomValidationExpression()); + } + return props; + } + + private void assertThatConfigMatchesProperties(RuleSection ruleConfig, Properties rule, Properties validation) { + assertMatch(ruleConfig.getName(), rule, "name"); + assertMatch(ruleConfig.getDescription(), rule, "description"); + assertMatch(ruleConfig.getSeverity(), rule, "severity"); + assertThat(ruleConfig.getAttributes(), is(equalTo(rule.get("attributes")))); + assertMatch(ruleConfig.getExpression(), rule, "validate"); + assertMatch(ruleConfig.getType(), validation, "type"); + assertMatch(ruleConfig.getObjectId(), validation, "objectId"); + } + + private void assertMatch(String value, Properties props, String key) { + assertThat(value, is(equalTo(props.getProperty(key)))); + } +} diff --git a/src/test/java/org/onap/aai/validation/ruledriven/mock/TestDefaultRules.java b/src/test/java/org/onap/aai/validation/ruledriven/mock/TestDefaultRules.java new file mode 100644 index 0000000..c3b36ed --- /dev/null +++ b/src/test/java/org/onap/aai/validation/ruledriven/mock/TestDefaultRules.java @@ -0,0 +1,148 @@ +/* + * ============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.ruledriven.mock; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import static org.mockito.Matchers.anyListOf; +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.when; + +import com.google.gson.JsonObject; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.stubbing.Answer; +import org.onap.aai.validation.Validator; +import org.onap.aai.validation.exception.ValidationServiceException; +import org.onap.aai.validation.reader.EventReader; +import org.onap.aai.validation.reader.data.AttributeValues; +import org.onap.aai.validation.reader.data.Entity; +import org.onap.aai.validation.reader.data.EntityId; +import org.onap.aai.validation.result.ValidationResult; +import org.onap.aai.validation.result.Violation; +import org.onap.aai.validation.ruledriven.RuleDrivenValidator; + +/** + * Test that the rules present under bundleconfig/etc/rules/ can be loaded and evaluated (using a mocked event). + * + */ +@RunWith(MockitoJUnitRunner.class) +public class TestDefaultRules { + + static { + System.setProperty("APP_HOME", "."); + } + + enum TestCase { + NULL, + VSERVER; + } + + // Data returned by the mocked EventReader + enum TestData { + // @formatter:off + ENTITTY_DATA ("vserver dummy json data"), + ENTITTY_TYPE ("vserver"), + RESOURCE_VERSION_VALUE("1476735182"), + VSERVER_ID_KEY ("vserver-id"), + VSERVER_ID_VALUE ("13b629a4-87ae-492d-943f-acb8f3d9c3d9"); + // @formatter:on + + private String value; + + TestData(String value) { + this.value = value; + } + } + + @Mock + private EventReader eventReader; + + @Mock + private Entity entity; + + private Validator ruleDrivenValidator; + + @Before + public void createMockEventReader() throws ValidationServiceException { + when(eventReader.getEventType(TestCase.VSERVER.name())).thenReturn(Optional.of("aai-event")); + when(eventReader.getEventType(TestCase.NULL.name())).thenReturn(null); + + when(eventReader.getEntityType(anyString())).thenReturn(Optional.of(TestData.ENTITTY_TYPE.value)); + when(eventReader.getEntity(anyString())).thenReturn(entity); + + // Mocked entity returned by the event reader + when(entity.getType()).thenReturn(TestData.ENTITTY_TYPE.value); + when(entity.getResourceVersion()).thenReturn(Optional.of(TestData.RESOURCE_VERSION_VALUE.value)); + + EntityId entityId = new EntityId(TestData.VSERVER_ID_KEY.value, TestData.VSERVER_ID_VALUE.value); + when(entity.getIds()).thenReturn(new ArrayList<>(Arrays.asList(entityId))); + + // Return dummy values for any requested attributes + when(entity.getAttributeValues(anyListOf(String.class))).thenAnswer(new Answer() { + @SuppressWarnings("unchecked") + @Override + public AttributeValues answer(InvocationOnMock invocation) { + AttributeValues attributeValues = new AttributeValues(); + for (String attribute : (List) invocation.getArguments()[0]) { + if (attribute.contains("[*]")) { + attributeValues.put(attribute, Collections.emptyList()); + } else { + attributeValues.put(attribute, ""); + } + } + return attributeValues; + } + }); + } + + @Before + public void createRuleDrivenValidator() throws ValidationServiceException { + Path configurationPath = Paths.get("bundleconfig/etc/rules"); + ruleDrivenValidator = new RuleDrivenValidator(configurationPath, null, eventReader, null); + } + + @Test + public void testExecuteRulesForVserver() throws Exception { + List results = ruleDrivenValidator.validate(TestCase.VSERVER.name()); + assertThat(results.size(), is(1)); + + ValidationResult validationResult = results.get(0); + assertThat(validationResult.getEntityType(), is(equalTo(TestData.ENTITTY_TYPE.value))); + JsonObject expectedEntityId = new JsonObject(); + expectedEntityId.addProperty(TestData.VSERVER_ID_KEY.value, TestData.VSERVER_ID_VALUE.value); + assertThat(validationResult.getEntityId(), is(equalTo(expectedEntityId))); + assertThat(validationResult.getViolations().size(), is(2)); + + Violation violation = validationResult.getViolations().get(0); + assertThat(violation.getCategory(), is(equalTo("MISSING_REL"))); + } + +} diff --git a/src/test/java/org/onap/aai/validation/ruledriven/rule/RuleHelper.java b/src/test/java/org/onap/aai/validation/ruledriven/rule/RuleHelper.java new file mode 100644 index 0000000..456d011 --- /dev/null +++ b/src/test/java/org/onap/aai/validation/ruledriven/rule/RuleHelper.java @@ -0,0 +1,36 @@ +/* + * ============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.ruledriven.rule; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import org.onap.aai.validation.reader.data.AttributeValues; +import org.onap.aai.validation.ruledriven.rule.Rule; + +public class RuleHelper { + + static void assertRuleResult(Rule rule, AttributeValues values, Boolean expectedResult) { + assertThat(rule + " failed for values [" + values + "]", rule.execute(values), is(equalTo(expectedResult))); + } + + static void assertRuleResult(Rule rule, Object value, Boolean expectedResult) { + assertThat(rule + " failed for value [" + value + "]", rule.execute(value), is(equalTo(expectedResult))); + } +} 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 new file mode 100644 index 0000000..8593f93 --- /dev/null +++ b/src/test/java/org/onap/aai/validation/ruledriven/rule/RuleTester.java @@ -0,0 +1,47 @@ +/* + * ============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.ruledriven.rule; + +import org.onap.aai.validation.reader.data.AttributeValues; +import org.onap.aai.validation.ruledriven.rule.Rule; + +/** + * Helper class for testing rules + * + */ +public class RuleTester { + + private Rule rule; + private AttributeValues attributeValues; + + /** + * @param trinityRule + * @param attributeValues + */ + public RuleTester(Rule trinityRule, AttributeValues attributeValues) { + this.rule = trinityRule; + this.attributeValues = attributeValues; + } + + /** + * @param expectedResult + */ + public void test(boolean expectedResult) { + RuleHelper.assertRuleResult(rule, attributeValues, expectedResult); + } +} diff --git a/src/test/java/org/onap/aai/validation/ruledriven/rule/TestConfigurationLoader.java b/src/test/java/org/onap/aai/validation/ruledriven/rule/TestConfigurationLoader.java new file mode 100644 index 0000000..f226252 --- /dev/null +++ b/src/test/java/org/onap/aai/validation/ruledriven/rule/TestConfigurationLoader.java @@ -0,0 +1,190 @@ +/* + * ============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.ruledriven.rule; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.LinkedHashSet; +import java.util.Set; +import javax.inject.Inject; +import org.junit.Test; +import org.onap.aai.validation.reader.OxmReader; +import org.onap.aai.validation.reader.data.AttributeValues; +import org.onap.aai.validation.ruledriven.RuleDrivenValidator; +import org.onap.aai.validation.ruledriven.rule.Rule; + +public class TestConfigurationLoader { + + static { + System.setProperty("APP_HOME", "."); + } + + private enum AAIRelation { + RELATED_TO("related-to"), + PROPERTY_KEY("property-key"), + PROPERTY_VALUE("property-value"); + + private final String text; + + /** + * @param text + */ + private AAIRelation(final String text) { + this.text = text; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Enum#toString() + */ + @Override + public String toString() { + return text; + } + } + + @Inject + private OxmReader oxmReader; + + /** + * If vserver is related to an image with image-name = 'TRINITY' then generic-vnf.vnf-name must match xxxxnnnnv + */ + @Test + public void testTrinityRule() throws Exception { + Path configurationPath = Paths.get("bundleconfig/etc/rules"); + + RuleDrivenValidator validator = new RuleDrivenValidator(configurationPath, oxmReader, null, null); + validator.initialise(); + + // Find the trinity rule + Rule trinityRule = null; + for (Rule rule : validator.getRulesForEntity("vserver", "aai-event")) { + if (rule.getName().contains("TRINITY") && rule.getName().contains("generic-vnf")) { + trinityRule = rule; + } + } + + // Create a set of relationship objects to be passed to the rule + Set relationships = new LinkedHashSet<>(); + AttributeValues attributeValues = new AttributeValues(); + attributeValues.put("relationship-list.relationship[*]", relationships); + + // Test the rule against the relationships + RuleTester ruleTester = new RuleTester(trinityRule, attributeValues); + ruleTester.test(true); + + JsonObject genericVnfData = createRelationshipData(relationships, "generic-vnf"); + ruleTester.test(true); + + // Add a new object for the image relationship + JsonObject imageData = createRelationshipData(relationships, "image"); + ruleTester.test(true); + + createRelationshipData(relationships, "pserver"); + ruleTester.test(true); + + // Add a new JSON object for the image name + JsonObject imageNameProperty = createRelatedToProperty(imageData); + ruleTester.test(true); + + setPropertyKey(imageNameProperty, "image.image-name"); + ruleTester.test(true); + + setPropertyValue(imageNameProperty, "not TRINITY"); + ruleTester.test(true); + + setPropertyValue(imageNameProperty, "TRINITY"); + ruleTester.test(false); + + JsonObject vnfNameProperty = createRelatedToProperty(genericVnfData); + ruleTester.test(false); + + setPropertyKey(vnfNameProperty, "generic-vnf.vnf-name"); + ruleTester.test(false); + + setPropertyValue(vnfNameProperty, "invalid"); + ruleTester.test(false); + + setPropertyValue(vnfNameProperty, ""); + ruleTester.test(false); + + setPropertyValue(vnfNameProperty, "bmsx0001v"); + ruleTester.test(true); + + // Add another new object for a different image relationship + JsonObject image2Data = createRelationshipData(relationships, "image"); + ruleTester.test(true); + + JsonObject image2NameProperty = createRelatedToProperty(image2Data); + ruleTester.test(true); + + setPropertyKey(image2NameProperty, "image.image-name"); + ruleTester.test(true); + + setPropertyValue(image2NameProperty, "not TRINITY"); + ruleTester.test(true); + + setPropertyValue(vnfNameProperty, "invalid"); + ruleTester.test(false); + + setPropertyValue(imageNameProperty, "not TRINITY"); + ruleTester.test(true); + + setPropertyValue(image2NameProperty, "TRINITY"); + ruleTester.test(false); + + setPropertyValue(image2NameProperty, "also not TRINITY"); + ruleTester.test(true); + } + + /** + * @param relationshipData + * @return + */ + private JsonObject createRelatedToProperty(JsonObject relationshipData) { + JsonObject imageNameProperty = new JsonObject(); + JsonElement jsonArray = new JsonArray(); + jsonArray.getAsJsonArray().add(imageNameProperty); + relationshipData.add("related-to-property", jsonArray); + return imageNameProperty; + } + + /** + * @param relationships + * @param relatedObject + * @return + */ + private JsonObject createRelationshipData(Set relationships, String relatedObject) { + JsonObject relationData = new JsonObject(); + relationData.addProperty(AAIRelation.RELATED_TO.toString(), relatedObject); + relationships.add(relationData); + return relationData; + } + + private void setPropertyKey(JsonObject objectMap, String propertyKeyName) { + objectMap.addProperty(AAIRelation.PROPERTY_KEY.toString(), propertyKeyName); + } + + private void setPropertyValue(JsonObject objectMap, String propertyValue) { + objectMap.addProperty(AAIRelation.PROPERTY_VALUE.toString(), propertyValue); + } +} diff --git a/src/test/java/org/onap/aai/validation/ruledriven/rule/TestRuleExecution.java b/src/test/java/org/onap/aai/validation/ruledriven/rule/TestRuleExecution.java new file mode 100644 index 0000000..15e958d --- /dev/null +++ b/src/test/java/org/onap/aai/validation/ruledriven/rule/TestRuleExecution.java @@ -0,0 +1,494 @@ +/* + * ============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.ruledriven.rule; + +import static org.hamcrest.CoreMatchers.containsString; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.onap.aai.validation.reader.data.AttributeValues; +import org.onap.aai.validation.ruledriven.configuration.GroovyConfigurationException; +import org.onap.aai.validation.ruledriven.configuration.RuleSection; +import org.onap.aai.validation.ruledriven.rule.GroovyRule; + +/** + * Tests for creating an AuditRule object and then executing the rule expression against fixed attribute values + * + * @see GroovyRule + * + */ +public class TestRuleExecution { + + static { + System.setProperty("APP_HOME", "."); + } + + @Rule + public final ExpectedException exception = ExpectedException.none(); + + /** + * Simple example of a rule using a boolean expression, acting on a single attribute + * + * @throws Exception + */ + @Test + public void testRuleCreation() throws Exception { + // This object represents a rule + GroovyRule rule = buildRule("i", "i == 44"); + + // Success + assertRuleResult(rule, 44, true); + + // Failure + assertRuleResult(rule, 5, false); + } + + @Test + public void testRuleWithMultipleAttributes() throws Exception { + GroovyRule rule = buildRule(Arrays.asList("i", "j"), "i == 22 && j == 44"); + + // Success + assertRuleResult(rule, Arrays.asList(22, 44), true); + + // Failure + assertRuleResult(rule, Arrays.asList(5, 5), false); + assertRuleResult(rule, Arrays.asList(22, 5), false); + assertRuleResult(rule, Arrays.asList(5, 44), false); + } + + /** + * vserver is related to vpe and vserver-name contains me6 + */ + @Test + public void testConditionalRegExp() throws Exception { + // !related-to.contains("vpe") || vserver-name =~ "me6" + String expression = "!related-to.contains(\"vpe\") || vserver-name =~ \"me6\""; + List attributes = Arrays.asList("related-to", "vserver-name"); + GroovyRule rule = buildRule(attributes, expression); + + // Create some tests, varying the values for each attribute + Collection> relatedToTests = new ArrayList<>(); + Collection> vserverNameTests = new ArrayList<>(); + + // These are the related-to values to test + relatedToTests.add(Collections.emptyList()); + relatedToTests.add(Arrays.asList("vpe")); + relatedToTests.add(Arrays.asList("vpe", "vces")); + relatedToTests.add(Arrays.asList("vces")); + relatedToTests.add(Arrays.asList("other", "vces")); + + // These are the vserver-name values to test + Collection testNames = new ArrayList<>(); + testNames.add("fred"); + testNames.add("me"); + testNames.add("me7"); + testNames.add("me6"); + testNames.add("123me6"); + testNames.add("me6789"); + testNames.add("123me6789"); + + // Additional test for no vserver-name values present + vserverNameTests.add(Collections.emptyList()); + + for (String name : testNames) { + // Build single element lists containing the test vserver names + vserverNameTests.add(Arrays.asList(name)); + + // Also build multi-element lists containing the test vserver names + vserverNameTests.add(Arrays.asList(name, "6dummy")); + } + + // Now run the tests, computing the expected Boolean result each time + for (Collection relatedToList : relatedToTests) { + // If no vpe is related, then the result will always be true + boolean expectedResult = !relatedToList.contains("vpe"); + + Map map = new HashMap<>(); + map.put("related-to", relatedToList); + + for (Collection vserverNames : vserverNameTests) { + // Assign the strings to the attribute vserver-name + map.put("vserver-name", vserverNames); + + if (expectedResult == false) { + for (String name : vserverNames) { + if (name.contains("me6")) { + expectedResult = true; + break; + } + } + } + + testWithAttributeValue(rule, map, expectedResult); + } + } + } + + /** + * generic-vnf.vnf-type should be "BW NFM" and not "bnfm" + */ + @Test + public void testStringComparison() throws Exception { + String attribute = "generic-vnf.vnf-type"; + String expression = "vnf-type == 'BW NFM'"; + GroovyRule rule = buildRule(attribute, expression); + assertRuleResult(rule, "BW NFM", true); + assertRuleResult(rule, "bnfm", false); + assertRuleResult(rule, null, false); + assertRuleResult(rule, "", false); + assertRuleResult(rule, "fred", false); + assertRuleResult(rule, "bob", false); + assertRuleResult(rule, 5, false); + assertRuleResult(rule, 1000L, false); + } + + @Test + public void testNotEquals() throws Exception { + GroovyRule rule = buildRule("x", "x != 'foo'"); + assertRuleResult(rule, "", true); + assertRuleResult(rule, "bar", true); + assertRuleResult(rule, "foo", false); + assertRuleResult(rule, "foo\n", true); + assertRuleResult(rule, 5, true); + assertRuleResult(rule, 1000L, true); + assertRuleResult(rule, null, true); + } + + @Test + public void testGreaterThan() throws Exception { + Map tests = new HashMap<>(); + tests.put(-1, false); + tests.put(0, false); + tests.put(1, false); + tests.put(4, false); + tests.put(5, true); + tests.put(55, true); + tests.put(null, false); + testRuleExpression("i", "i > 4", tests); + } + + @Test + public void testValidStringLength() throws Exception { + String attribute = "clli"; + String expression = "clli.size() == 8 || clli.size() == 11"; + Map tests = new HashMap<>(); + tests.put("", false); + tests.put("X", false); + tests.put("1", false); + tests.put("1234", false); + tests.put("123456", false); + tests.put("1234567", false); + tests.put("12345678", true); + tests.put("123456789", false); + tests.put("1234567890", false); + tests.put("12345678901", true); + tests.put("1234567890ABC", false); + tests.put("1234567890123456789012345678901234567890", false); + testRuleExpression(attribute, expression, tests); + } + + /** + * location_clli is 8 or 11 characters and must be characters only + */ + @Test + public void testStringLengthAndChars() throws Exception { + String attribute = "location_clli"; + String expression = "location_clli != null && location_clli.matches('[a-zA-Z]{8,11}')"; + Map tests = new HashMap<>(); + tests.put(null, false); + tests.put("", false); + tests.put("X", false); + tests.put("1234567", false); + tests.put("12345678", false); // 8 digits + tests.put("ABCDEFGH", true); // 8 chars + tests.put("1234567890A", false); // 11 mixed + tests.put("abcdefghijk", true); // 11 chars + tests.put("AbCdEfGhIjK", true); // 11 chars + tests.put("AbCdEfGhIj?", false); // special char + testRuleExpression(attribute, expression, tests); + } + + /** + * incorrect naming, e.g. expecting ae0.x (where x is unit/subinterface number), but receiving ae0.353.3303 + */ + @Test + public void testRegularExpression() throws Exception { + String attribute = "unit"; + String expression = "unit.matches('^ae0\\\\.(\\\\d)+')"; + Map tests = new HashMap<>(); + tests.put("", false); + tests.put("X", false); + tests.put("ae0", false); + tests.put("ae0.", false); + tests.put("ae01", false); + tests.put("ae012", false); + tests.put("ae0.1", true); + tests.put("ae0.354", true); + tests.put("ae0.354.", false); + tests.put("ae0.353.3303", false); + tests.put("ae0.353.3303.1", false); + testRuleExpression(attribute, expression, tests); + } + + @Test + public void testNullStringLength() throws Exception { + String attribute = "clli"; + String expression = "clli.size() == 8 || clli.size() == 11"; + exception.expect(IllegalArgumentException.class); + exception.expectMessage(containsString("Argument")); + exception.expectMessage(containsString("null")); + GroovyRule rule = buildRule(attribute, expression); + rule.execute((Object[]) null); + } + + @Test + public void testStringLengthWithNull() throws Exception { + String attribute = "a"; + String expression = "a == null || a.size() > 4"; + Map tests = new HashMap<>(); + tests.put("", false); + tests.put("X", false); + tests.put("1", false); + tests.put("1234", false); + tests.put("123456", true); + tests.put("1234567", true); + tests.put("12345678", true); + tests.put("123456789", true); + tests.put("1234567890", true); + tests.put("12345678901", true); + tests.put("1234567890ABC", true); + tests.put("1234567890123456789012345678901234567890", true); + testRuleExpression(attribute, expression, tests); + } + + /** + * Prov-status cannot be ACTIVE or NULL (empty) + */ + @Test + public void testStringTextWithNull() throws Exception { + String attribute = "prov-status"; + String expression = "prov-status != null && prov-status != 'ACTIVE'"; + Map tests = new HashMap<>(); + tests.put(null, false); + tests.put("ACTIVE", false); + tests.put("", true); + tests.put("X", true); + tests.put("1", true); + tests.put("1234", true); + tests.put("123456", true); + tests.put("1234567", true); + tests.put("12345678", true); + tests.put("123456789", true); + tests.put("1234567890", true); + tests.put("12345678901", true); + tests.put("1234567890ABC", true); + tests.put("1234567890123456789012345678901234567890", true); + testRuleExpression(attribute, expression, tests); + } + + /** + * Prov-status cannot be ACTIVE/active or NULL/null or empty or missing + */ + @Test + public void testCaseInsensitveStringMatch() throws Exception { + String attribute = "prov-status"; + String expression = + "prov-status != null && prov-status.size() > 0 && !prov-status.equalsIgnoreCase('NULL') && !prov-status.equalsIgnoreCase('ACTIVE')"; + Map tests = new HashMap<>(); + tests.put(null, false); + tests.put("", false); + tests.put("active", false); + tests.put("ACTIVE", false); + tests.put("null", false); + tests.put("NULL", false); + tests.put("NVTPROV", true); + tests.put("1", true); + tests.put("1234", true); + testRuleExpression(attribute, expression, tests); + } + + @Test + public void testUsingAttributeValuesObject() throws Exception { + List attributes = Arrays.asList("attr1", "attr2"); + String expression = "attr1.size() == 8 || attr2.size() == 11"; + GroovyRule rule = buildRule(attributes, expression); + AttributeValues attributeValues = new AttributeValues("attr1", "other"); + attributeValues.put("attr2", "other"); + rule.execute(attributeValues); + } + + @Test + public void testMissingMethod() throws Exception { + String attribute = "clli"; + String expression = "clli.size() == 8 || clli.size() == 11"; + exception.expect(IllegalArgumentException.class); + exception.expectMessage(containsString("Integer")); + exception.expectMessage(containsString("size()")); + GroovyRule rule = buildRule(attribute, expression); + rule.execute(1); + } + + @Test + public void testMultipleAttributes() throws Exception { + List attributes = Arrays.asList("clli", "other"); + String expression = "clli.size() == 8 || other.size() == 11"; + exception.expect(IllegalArgumentException.class); + exception.expectMessage(containsString("Integer")); + exception.expectMessage(containsString("size()")); + GroovyRule rule = buildRule(attributes, expression); + rule.execute(new Integer(1), new Integer(2)); + } + + /** + * Compare two attributes (using a sub-string match) + */ + @Test + public void testAttributeComparison() throws Exception { + String attribute1 = "heat-stack-id"; + String attribute2 = "vnf-name"; + + // Alternative forms of the expression + Collection expressionsToTest = new ArrayList<>(); + expressionsToTest.add("heat-stack-id?.size() > 10 && heat-stack-id[0..10] == vnf-name"); + expressionsToTest.add("heat-stack-id?.size() > 10 && heat-stack-id.substring(0,11) == vnf-name"); + expressionsToTest.add("heat-stack-id?.size() > 10 && heat-stack-id.take(11) == vnf-name"); + + // Create some tests, varying the values for each attribute + Collection heatStackIds = new ArrayList<>(); + Collection vnfNames = new ArrayList<>(); + + heatStackIds.add("123me67890abcdef"); + heatStackIds.add("123me67890a"); + heatStackIds.add("fred"); + heatStackIds.add(""); + heatStackIds.add(null); + + vnfNames.add("123me67890abcdef"); + vnfNames.add("123me67890a"); + vnfNames.add("123me6789"); + vnfNames.add("fred"); + vnfNames.add("bob"); + vnfNames.add(""); + vnfNames.add(null); + + // Build a rule per expression + for (String expression : expressionsToTest) { + GroovyRule rule = buildRule(Arrays.asList(attribute1, attribute2), expression); + + // Now run the tests, computing the expected Boolean result each time + for (String heatStackId : heatStackIds) { + Map map = new HashMap<>(); + map.put(attribute1, heatStackId); + for (String vnfName : vnfNames) { + map.put(attribute2, vnfName); + boolean expectedExpressionResult = // Java equivalent of the expression + heatStackId != null && heatStackId.length() > 10 + && heatStackId.substring(0, 11).equals(vnfName); + testWithAttributeValue(rule, map, expectedExpressionResult); + } + } + } + } + + /** + * @param rule + * @param tests + */ + public void assertTestResults(GroovyRule rule, Map tests) { + for (Entry e : tests.entrySet()) { + Object attributeValue = e.getKey(); + Boolean expectedResult = (Boolean) e.getValue(); + RuleHelper.assertRuleResult(rule, attributeValue, expectedResult); + } + } + + private void testWithAttributeValue(GroovyRule rule, Map map, boolean expectedResult) { + AttributeValues attributeValues = new AttributeValues(map); + RuleHelper.assertRuleResult(rule, attributeValues, expectedResult); + } + + private void testRuleExpression(String attributes, String expression, Map tests) + throws InstantiationException, IllegalAccessException, IOException, GroovyConfigurationException { + GroovyRule rule = buildRule("testRule", attributes, expression); + assertTestResults(rule, tests); + } + + /** + * Build a simple rule using a RuleConfiguration object + * + * @param name the rule name + * @param attribute a named variable, referenced in the expression + * @param expression the expression to evaluate (returns a Boolean value) + * @return + * @throws IOException + * @throws InstantiationException + * @throws IllegalAccessException + * @throws GroovyConfigurationException + */ + private GroovyRule buildRule(String name, String attribute, String expression) + throws IOException, InstantiationException, IllegalAccessException, GroovyConfigurationException { + RuleSection ruleConfig = new RuleSection(); + ruleConfig.setName(name); + ruleConfig.setAttributes(Collections.singletonList(attribute)); + ruleConfig.setExpression(expression); + return new GroovyRule(ruleConfig); + } + + private GroovyRule buildRule(String name, List attributes, String expression) + throws InstantiationException, IllegalAccessException, IOException, GroovyConfigurationException { + RuleSection ruleConfig = new RuleSection(); + ruleConfig.setName(name); + ruleConfig.setAttributes(attributes); + ruleConfig.setExpression(expression); + return new GroovyRule(ruleConfig); + } + + /** + * Build a simple rule (with a default name) using a RuleConfiguration object + * + * @see TestRuleExecution#buildRule(String, String, String) + * + * @param attribute a named variable, referenced in the expression + * @param expression the expression to evaluate (returns a Boolean value) + * @throws GroovyConfigurationException + */ + private GroovyRule buildRule(String attribute, String expression) + throws InstantiationException, IllegalAccessException, IOException, GroovyConfigurationException { + return buildRule("testRule", attribute, expression); + } + + private GroovyRule buildRule(List attributes, String expression) + throws InstantiationException, IllegalAccessException, IOException, GroovyConfigurationException { + return buildRule("testRule", attributes, expression); + } + + private void assertRuleResult(GroovyRule rule, Object value, boolean expectedResult) { + RuleHelper.assertRuleResult(rule, value, expectedResult); + } + +} diff --git a/src/test/java/org/onap/aai/validation/ruledriven/rule/TestRuleValidation.java b/src/test/java/org/onap/aai/validation/ruledriven/rule/TestRuleValidation.java new file mode 100644 index 0000000..0650743 --- /dev/null +++ b/src/test/java/org/onap/aai/validation/ruledriven/rule/TestRuleValidation.java @@ -0,0 +1,229 @@ +/* + * ============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.ruledriven.rule; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.onap.aai.validation.ruledriven.configuration.GroovyConfigurationException; +import org.onap.aai.validation.ruledriven.configuration.RuleSection; +import org.onap.aai.validation.ruledriven.rule.GroovyRule; + +/** + * Tests for creating an AuditRule object and then executing the rule expression against fixed attribute values + * + * @see GroovyRule + * + */ +public class TestRuleValidation { + + static { + System.setProperty("APP_HOME", "."); + } + + @Rule + public final ExpectedException exception = ExpectedException.none(); + + /** + * Test multiple sample expressions each with various different attribute names. Each of the attribute names used in + * this test is valid for use within a rule. + * + * @throws GroovyConfigurationException + * @throws IOException + * @throws IllegalAccessException + * @throws InstantiationException + * + * @throws Exception + */ + @Test + public void testValidAttributeNames() + throws InstantiationException, IllegalAccessException, IOException, GroovyConfigurationException { + testValidExpressions("clli"); // Sample name + testValidExpressions("c"); + testValidExpressions("i"); // Short attribute name, part of the size() text + testValidExpressions("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); + testValidExpressions("size"); // Does not interfere with .size() method call + testValidExpressions("s12"); // Digits allowed in the attribute name + testValidExpressions("s12s"); + testValidExpressions("12s"); + testValidExpressions("12-s"); // Hyphens supported + testValidExpressions("12_s"); // Underscores supported + testValidExpressions("if"); // Keyword + testValidExpressions("return"); + testValidExpressions("A.B.C"); // Dots indicate a JSON Path + } + + /** + * Test that the attribute name is sanitised. Each of the following attribute names is invalid for use in the rules + * configuration. + * + * @throws Exception + */ + @Test + public void testInvalidAttributeNames() throws Exception { + testInvalidAttributeName(""); // Zero-length + testInvalidAttributeName("null"); // Reserved keyword + testInvalidAttributeName("8"); // This would cause replacement of the value 8 in the expression + testInvalidAttributeName("size()"); // This would replace the call to size() + testInvalidAttributeName("s?"); // Special character not supported by the implementation + testInvalidAttributeName("\""); + testInvalidAttributeName("s\\"); + testInvalidAttributeName("s/"); + testInvalidAttributeName("s\""); + testInvalidAttributeName("s'"); + testInvalidAttributeName("=="); + } + + /** + * A rule cannot support an attribute that is zero-length. This test ensures that this is detected even when the + * expression itself is valid. + * + * @throws Exception + */ + @Test + public void testZeroLengthAttribute() throws Exception { + String attribute = ""; + String expression = "clli.size() == 8 || clli.size() == 11"; + GroovyRule rule = buildRule("testRule", attribute, expression); + assertThat(rule.toString(), rule.isValid(), is(equalTo(false))); + } + + @Test + public void testInvalidRuleSyntax() throws Exception { + String attribute = "fred"; + String expression = "fred. = 8 || fred.size() == 11"; + exception.expect(GroovyConfigurationException.class); + exception.expectMessage(containsString("unexpected")); + buildRule("testRule", attribute, expression); + } + + @Test + public void testInvalidAttribute() throws Exception { + String attribute = "fred"; + String expression = "size.size() == 8 || size.size() == 11"; + GroovyRule rule = buildRule("testRule", attribute, expression); + + assertThat(rule.toString(), rule.isValid(), is(equalTo(false))); + } + + /** + * Utility to build and test different expressions using the supplied attribute name + * + * @param attribute attribute (field) identifier + * @throws InstantiationException + * @throws IllegalAccessException + * @throws IOException + * @throws GroovyConfigurationException + */ + private void testValidExpressions(String attribute) + throws InstantiationException, IllegalAccessException, IOException, GroovyConfigurationException { + testValidLengthRule(attribute); + } + + /** + * Utility to build and test an expression asserting that the size() of the attribute is 8 or 11 + * + * @param attribute attribute (field) identifier + * @throws InstantiationException + * @throws IllegalAccessException + * @throws IOException + * @throws GroovyConfigurationException + */ + private void testValidLengthRule(String attribute) + throws InstantiationException, IllegalAccessException, IOException, GroovyConfigurationException { + String fieldName = attribute.substring(attribute.lastIndexOf(".") + 1); + String expression = fieldName + ".size() == 8 || " + fieldName + ".size() == 11"; + GroovyRule rule = buildRule("testRule", attribute, expression); + + // Test that the rule is valid + assertThat(rule.toString(), rule.isValid(), is(equalTo(true))); + + // Now test that the rule actually executes successfully + Map tests = new HashMap<>(); + tests.put("", false); + tests.put("X", false); + tests.put("1234567", false); + tests.put("12345678", true); // 8 digits + tests.put("ABCDEFGH", true); // 8 chars + tests.put("12E4567890A", true); // 11 mixed digits/chars + tests.put("abcdefghijk", true); // 11 chars + tests.put("AbCdEfGhIjK", true); // 11 chars mixed case + tests.put("AbCdEfGhIj?", true); // special char + testRuleExpression(attribute, expression, tests); + } + + private void testRuleExpression(String attributes, String expression, Map tests) + throws InstantiationException, IllegalAccessException, IOException, GroovyConfigurationException { + GroovyRule rule = buildRule("testRule", attributes, expression); + assertThat("The rule should be valid", rule.isValid(), is(equalTo(true))); + for (Entry e : tests.entrySet()) { + Object attributeValue = e.getKey(); + Boolean expectedResult = (Boolean) e.getValue(); + RuleHelper.assertRuleResult(rule, attributeValue, expectedResult); + } + } + + /** + * Build a simple rule using a RuleConfiguration object + * + * @param name the rule name + * @param attribute a named variable, referenced in the expression + * @param expression the expression to evaluate (returns a Boolean value) + * @return + * @throws IOException + * @throws InstantiationException + * @throws IllegalAccessException + * @throws GroovyConfigurationException + */ + private GroovyRule buildRule(String name, String attribute, String expression) + throws InstantiationException, IllegalAccessException, IOException, GroovyConfigurationException { + RuleSection ruleConfig = new RuleSection(); + ruleConfig.setName(name); + ruleConfig.setAttributes(Collections.singletonList(attribute)); + ruleConfig.setExpression(expression); + return new GroovyRule(ruleConfig); + } + + /** + * Utility to build a rule and test that the attribute is valid + * + * @param attribute attribute (field) identifier + * @throws InstantiationException + * @throws IllegalAccessException + * @throws IOException + * @throws GroovyConfigurationException + */ + private void testInvalidAttributeName(String attribute) + throws InstantiationException, IllegalAccessException, IOException, GroovyConfigurationException { + String expression = attribute + ".size() == 8 || " + attribute + ".size() == 11"; + GroovyRule rule = buildRule("testRule", attribute, expression); + + // Test that the rule is invalid + assertThat(rule.toString(), rule.isValid(), is(equalTo(false))); + } +} 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 new file mode 100644 index 0000000..cf1e874 --- /dev/null +++ b/src/test/java/org/onap/aai/validation/ruledriven/validator/TestRuleDrivenValidator.java @@ -0,0 +1,125 @@ +/* + * ============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.ruledriven.validator; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.MatcherAssert.assertThat; + +import com.google.gson.JsonSyntaxException; +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.ArrayList; +import java.util.List; +import java.util.function.BiPredicate; +import java.util.stream.Stream; +import javax.inject.Inject; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.aai.validation.exception.ValidationServiceException; +import org.onap.aai.validation.result.ValidationResult; +import org.onap.aai.validation.ruledriven.RuleDrivenValidator; +import org.onap.aai.validation.test.util.TestEntity; +import org.onap.aai.validation.test.util.ValidationResultIsEqual; +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"}) +@ContextConfiguration( + locations = {"classpath:" + TestRuleDrivenValidator.UNIT_TEST_FOLDER + "/test-rule-driven-validator-beans.xml"}) +public class TestRuleDrivenValidator { + + static { + System.setProperty("APP_HOME", "."); + } + + public static final String UNIT_TEST_FOLDER = "rule-driven-validator"; + private static final String TEST_EVENTS_PATH = "/test_events"; + + @Inject + private RuleDrivenValidator validator; + + /** + * @param testEntitiesPath + * @param testEventsPath + * @param resultsPath + * @return all test entities + * @throws URISyntaxException + */ + public static List getEntities(String testEntitiesPath, String testEventsPath, String resultsPath) + throws URISyntaxException { + Path testEvents = Paths.get(ClassLoader.getSystemResource(testEntitiesPath + testEventsPath).toURI()); + + BiPredicate jsonMatcher = + (path, basicFileAttributes) -> path.toFile().getName().matches(".*\\.json"); + + List entitiesList = new ArrayList<>(); + try (Stream paths = Files.find(testEvents, 2, jsonMatcher)) { + paths.forEach((path) -> entitiesList.add(new TestEntity(testEvents, path, testEventsPath, resultsPath))); + } catch (IOException e) { + throw new RuntimeException(e); + } + + return entitiesList; + } + + /** + * @throws ValidationServiceException + * @throws JsonSyntaxException + * @throws URISyntaxException + * @throws IOException + */ + @Test + public void testValidateUnitTestInstances() + throws ValidationServiceException, JsonSyntaxException, URISyntaxException, IOException { + validateEntities(UNIT_TEST_FOLDER, TEST_EVENTS_PATH, "/results/expected"); + } + + /** + * @param inputEventsFolder + * @param testEventsPath + * @param resultsPath + * @throws URISyntaxException + * @throws ValidationServiceException + * @throws IOException + */ + private void validateEntities(String inputEventsFolder, String testEventsPath, String resultsPath) + throws URISyntaxException, ValidationServiceException, IOException { + for (TestEntity entity : getEntities(inputEventsFolder, testEventsPath, resultsPath)) { + List results = validator.validate(entity.getJson()); + assertThat(results.size(), is(1)); + ValidationResult expectedResult = entity.getExpectedValidationResult(); + if (expectedResult == null) { + Path testEvents = Paths.get(ClassLoader.getSystemResource(inputEventsFolder + resultsPath).toURI()); + StringBuilder sb = new StringBuilder(); + Files.walk(testEvents).forEach((path) -> sb.append(path).append("\n")); + assertThat("Expected results missing (" + entity.expectedResultsFile + ")\n" + sb.toString(), + expectedResult, is(notNullValue())); + } + assertThat(entity.inputFile.getAbsolutePath(), results.get(0), + is(ValidationResultIsEqual.equalTo(expectedResult))); + } + } + +} diff --git a/src/test/java/org/onap/aai/validation/services/TestInfoService.java b/src/test/java/org/onap/aai/validation/services/TestInfoService.java new file mode 100644 index 0000000..0bfa8ba --- /dev/null +++ b/src/test/java/org/onap/aai/validation/services/TestInfoService.java @@ -0,0 +1,140 @@ +/* + * ============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.services; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.CoreMatchers.startsWith; +import static org.junit.Assert.assertThat; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Path; +import java.nio.file.Paths; +import javax.inject.Inject; +import org.junit.Before; +import org.junit.Test; +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; +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:/info-service/test-validation-service-beans.xml"}) +public class TestInfoService { + + static { + System.setProperty("APP_HOME", "."); + } + + enum TestData { + // @formatter:off + VSERVER ("rule-driven-validator/test_events/vserver-create-event.json"); + + private String filename; + TestData(String filename) {this.filename = filename;} + public String getFilename() {return this.filename;} + // @formatter:on + } + + private InfoService infoService; + + @Inject + private ValidationController validationController; + + @Inject + MockEventPublisher messagePublisher; + + @Before + public void setUp() throws ValidationServiceException { + infoService = new InfoService(); + infoService.setValidationController(validationController); + } + + /** + * @throws ValidationServiceException + */ + @Test + public void testInitialisedInfoService() throws ValidationServiceException { + assertThat(infoService.getValidationController(), is(validationController)); + String info = infoService.getInfo(); + assertResultsStringFormatted(info); + } + + /** + * @throws ValidationServiceException + */ + @Test + public void testThrowableRecorded() throws ValidationServiceException { + validationController.recordThrowable(new Exception()); + String info = infoService.getInfo(); + assertResultsStringFormatted(info); + assertThat(info, containsString("Exception reported")); + } + + /** + * @throws ValidationServiceException + */ + @Test + public void testInvalidEventRecorded() throws ValidationServiceException { + validationController.execute("", "http"); + String info = infoService.getInfo(); + assertResultsStringFormatted(info); + assertThat(info, containsString("errored=1")); + } + + /** + * @throws ValidationServiceException + * @throws IOException + * @throws URISyntaxException + */ + @Test + public void testVserverEventRecorded() throws ValidationServiceException, URISyntaxException, IOException { + Path vserverTestFile = Paths.get(ClassLoader.getSystemResource(TestData.VSERVER.getFilename()).toURI()); + Path root = vserverTestFile.getParent(); + assertThat(root, is(not(nullValue()))); + TestEntity entity = new TestEntity(root, vserverTestFile, "test_events", "results/expected"); + messagePublisher.setTestEntity(entity); + messagePublisher.setTestDescription(entity.inputFile.getAbsolutePath()); + validationController.execute(TestUtil.getFileAsString(TestData.VSERVER.getFilename()), "http"); + String info = infoService.getInfo(); + assertResultsStringFormatted(info); + assertThat(info, containsString("total=1")); + } + + /** + * Assert that the info service status string contains the expected standard results and formatting. + * + * @param info + */ + private void assertResultsStringFormatted(String info) { + assertThat(info, startsWith("Status: Up\n")); + assertThat(info, containsString("Started at")); + assertThat(info, containsString("total=0")); + } + +} diff --git a/src/test/java/org/onap/aai/validation/services/TestValidateServiceImpl.java b/src/test/java/org/onap/aai/validation/services/TestValidateServiceImpl.java new file mode 100644 index 0000000..e23f7a2 --- /dev/null +++ b/src/test/java/org/onap/aai/validation/services/TestValidateServiceImpl.java @@ -0,0 +1,115 @@ +/* + * ============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.services; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; + +import java.net.URISyntaxException; +import java.security.cert.X509Certificate; +import java.util.Collections; +import java.util.List; +import java.util.Map.Entry; +import javax.security.auth.x500.X500Principal; +import javax.ws.rs.core.MultivaluedHashMap; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.aai.auth.AAIMicroServiceAuth; +import org.onap.aai.validation.controller.ValidationController; +import org.onap.aai.validation.services.ValidateServiceImpl; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.mock.web.MockHttpServletRequest; + +public class TestValidateServiceImpl { + + static { + System.setProperty("APP_HOME", "."); + } + + private ValidationController mockValidationController; + private AAIMicroServiceAuth mockAaiMicroServiceAuth; + + @Before + public void setUp() { + mockValidationController = Mockito.mock(ValidationController.class); + mockAaiMicroServiceAuth = Mockito.mock(AAIMicroServiceAuth.class); + } + + @Test + public void validateConstructor() { + ValidateServiceImpl validateServiceImpl = + new ValidateServiceImpl(mockValidationController, mockAaiMicroServiceAuth); + assertNotNull(validateServiceImpl); + assertThat(validateServiceImpl.toString(), is(notNullValue())); + } + + @Test + public void testValidateEventWithoutHeaderFailure() { + ValidateServiceImpl validateServiceImpl = + new ValidateServiceImpl(mockValidationController, mockAaiMicroServiceAuth); + ResponseEntity response = validateServiceImpl.validate("testEvent"); + assertThat(response.getStatusCode(), is(HttpStatus.INTERNAL_SERVER_ERROR)); + } + + /** + * Create a (mocked) HTTPS request and invoke the Babel generate artifacts API + * + * @param request for the Babel Service + * @return the Response from the HTTP API + * @throws URISyntaxException + */ + @Test + public void testRequestWithHeaders() throws URISyntaxException { + // Create mocked request headers map + MultivaluedHashMap headersMap = new MultivaluedHashMap<>(); + headersMap.put("X-TransactionId", createSingletonList("transaction-id")); + headersMap.put("X-FromAppId", createSingletonList("app-id")); + headersMap.put("Host", createSingletonList("hostname")); + + HttpHeaders headers = Mockito.mock(HttpHeaders.class); + for (Entry> entry : headersMap.entrySet()) { + Mockito.when(headers.get(entry.getKey())).thenReturn(entry.getValue()); + } + + MockHttpServletRequest servletRequest = new MockHttpServletRequest(); + servletRequest.setSecure(true); + servletRequest.setScheme("https"); + servletRequest.setServerPort(9501); + servletRequest.setServerName("localhost"); + servletRequest.setRequestURI("/services/validation-service/v1/app/validate"); + + X509Certificate mockCertificate = Mockito.mock(X509Certificate.class); + Mockito.when(mockCertificate.getSubjectX500Principal()) + .thenReturn(new X500Principal("CN=test, OU=qa, O=Test Ltd, L=London, ST=London, C=GB")); + + servletRequest.setAttribute("javax.servlet.request.X509Certificate", new X509Certificate[] {mockCertificate}); + servletRequest.setAttribute("javax.servlet.request.cipher_suite", ""); + + ValidateServiceImpl service = new ValidateServiceImpl(mockValidationController, mockAaiMicroServiceAuth); + service.validate(headers, servletRequest, "testEvent"); + } + + private List createSingletonList(String listItem) { + return Collections.singletonList(listItem); + } +} diff --git a/src/test/java/org/onap/aai/validation/test/util/RandomString.java b/src/test/java/org/onap/aai/validation/test/util/RandomString.java new file mode 100644 index 0000000..ba2d85e --- /dev/null +++ b/src/test/java/org/onap/aai/validation/test/util/RandomString.java @@ -0,0 +1,40 @@ +/* + * ============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.test.util; + +import java.util.Random; + +public class RandomString { + + private static final String VALID_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + private static final int MAX_STRING_LENGTH = 50; + private static Random rng = new Random(); + + public static String generate() { + return generateString(rng, VALID_CHARS, rng.nextInt(MAX_STRING_LENGTH) + 1); + } + + public static String generateString(Random rng, String characters, int length) { + char[] text = new char[length]; + for (int i = 0; i < length; i++) { + text[i] = characters.charAt(rng.nextInt(characters.length())); + } + return new String(text); + } + +} diff --git a/src/test/java/org/onap/aai/validation/test/util/TestEntity.java b/src/test/java/org/onap/aai/validation/test/util/TestEntity.java new file mode 100644 index 0000000..e42873a --- /dev/null +++ b/src/test/java/org/onap/aai/validation/test/util/TestEntity.java @@ -0,0 +1,88 @@ +/* + * ============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.test.util; + +import com.google.gson.JsonSyntaxException; +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.nio.file.NoSuchFileException; +import java.nio.file.Path; +import org.onap.aai.validation.result.ValidationResult; + +public class TestEntity { + + public File inputFile; + public String expectedResultsFile; + + public TestEntity(Path root, Path inputFilePath, String inputEventsPath, String outputEventsPath) { + String rootUri = root.toUri().toString(); + String resultsRoot = rootUri.replaceAll(inputEventsPath + "/$", outputEventsPath + "/"); + String inputFileUri = inputFilePath.toUri().toString(); + this.inputFile = inputFilePath.toFile(); + this.expectedResultsFile = inputFileUri.replace(rootUri, resultsRoot).replaceAll("\\.json$", ".exp.json"); + } + + public String getJson() throws URISyntaxException, IOException { + return TestUtil.getFileAsString(inputFile.getPath()); + } + + /** + * @return the contents of the file that stores the expected JSON, or an empty string if there is no expected JSON + * @throws URISyntaxException + * @throws IOException + */ + public String getExpectedJson() throws URISyntaxException, IOException { + try { + return TestUtil.getFileAsString(new URI(expectedResultsFile).getPath()); + } catch (NoSuchFileException e) { + return ""; + } + } + + public ValidationResult getExpectedValidationResult() throws JsonSyntaxException, URISyntaxException, IOException { + return ValidationResult.fromJson(getExpectedJson()); + } + + @Override + public String toString() { + return "TestEntity [inputFile=" + inputFile + ", expectedResultsFile=" + expectedResultsFile + "]"; + } + + public boolean expectsError() throws URISyntaxException, IOException { + try { + getErrorFileContents(); + } catch (NoSuchFileException e) { + return false; + } + return true; + } + + public String getExpectedErrorMessage() throws URISyntaxException, IOException { + return getErrorFileContents().trim(); + } + + private String getErrorFileContents() throws URISyntaxException, IOException { + return TestUtil.getFileAsString(new URI(getErrorFileURI()).getPath()); + } + + private String getErrorFileURI() { + return expectedResultsFile.replaceAll("\\.exp\\.json$", ".error"); + } +} diff --git a/src/test/java/org/onap/aai/validation/test/util/TestUtil.java b/src/test/java/org/onap/aai/validation/test/util/TestUtil.java new file mode 100644 index 0000000..39d1246 --- /dev/null +++ b/src/test/java/org/onap/aai/validation/test/util/TestUtil.java @@ -0,0 +1,52 @@ +/* + * ============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.test.util; + +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; + +/** + * Test helper methods. + */ +public class TestUtil { + + /** + * Gets files, such as test data from the classpath. + * + * @param filename the name of the file + * @return a String with the file contents. + * @throws URISyntaxException + * @throws IOException + */ + public static String getFileAsString(String filename) throws URISyntaxException, IOException { + // Try loading the named file directly + URI uri = new File(filename).toURI(); + URL systemResource = ClassLoader.getSystemResource(filename); + if (systemResource != null) { + uri = systemResource.toURI(); + } + byte[] encoded = Files.readAllBytes(Paths.get(uri)); + return new String(encoded, StandardCharsets.UTF_8); + } +} diff --git a/src/test/java/org/onap/aai/validation/test/util/ValidationResultIsEqual.java b/src/test/java/org/onap/aai/validation/test/util/ValidationResultIsEqual.java new file mode 100644 index 0000000..aa6471f --- /dev/null +++ b/src/test/java/org/onap/aai/validation/test/util/ValidationResultIsEqual.java @@ -0,0 +1,58 @@ +/* + * ============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.test.util; + +import org.hamcrest.BaseMatcher; +import org.hamcrest.Description; +import org.hamcrest.Matcher; +import org.onap.aai.validation.result.ValidationResult; + +/** + * Matcher for comparing actual and expected ValidationResults + * + */ +public class ValidationResultIsEqual extends BaseMatcher { + private final ValidationResult expected; + + public static Matcher equalTo(ValidationResult validationResult) { + return new ValidationResultIsEqual(validationResult); + } + + private ValidationResultIsEqual(ValidationResult expected) { + this.expected = expected; + } + + @Override + public boolean matches(Object o) { + if (expected == null) { + return false; + } + ValidationResult actual = (ValidationResult) o; + return actual.getEntityId().equals(expected.getEntityId()) && // + actual.getEntityType().equals(expected.getEntityType()) && // + (actual.getEntityLink() == null ? "" : actual.getEntityLink()).equals(expected.getEntityLink()) && // + actual.getResourceVersion().equals(expected.getResourceVersion()) && // + actual.getViolations().equals(expected.getViolations()); + } + + @Override + public void describeTo(Description description) { + description.appendText(expected == null ? "" : expected.toString()); + } + +} diff --git a/src/test/java/org/onap/aai/validation/util/TestStringUtils.java b/src/test/java/org/onap/aai/validation/util/TestStringUtils.java new file mode 100644 index 0000000..038e10d --- /dev/null +++ b/src/test/java/org/onap/aai/validation/util/TestStringUtils.java @@ -0,0 +1,170 @@ +/* + * ============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.util; + +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; + +import java.util.Arrays; +import java.util.List; +import org.junit.Test; +import org.onap.aai.validation.exception.ValidationServiceException; +import org.onap.aai.validation.util.StringUtils; + +public class TestStringUtils { + + static { + System.setProperty("APP_HOME", "."); + } + + @Test + public void testStripSinglePrefix() throws Exception { + String prefixDelimiter = "."; + String prefix = "prefix"; + String suffix = "suffix"; + String testString = prefix + prefixDelimiter + suffix; + + String result = StringUtils.stripPrefix(testString, prefixDelimiter); + + assertEquals("Prefix incorrectly stripped.", suffix, result); + } + + @Test + public void testStripMultiplePrefix() throws Exception { + String prefixDelimiter = "***"; + String prefix = "prefix"; + String suffix = "suffix"; + String testString = prefix + prefixDelimiter + prefix + prefixDelimiter + suffix; + + String result = StringUtils.stripPrefix(testString, prefixDelimiter); + + assertEquals("Prefix incorrectly stripped.", suffix, result); + } + + @Test + public void testStripSubstr() { + List stringList = Arrays.asList("/text()one", "tw/text()o", "three/text()"); + List stripSubstr = StringUtils.stripSuffix(stringList, "/text()"); + assertThat(stripSubstr, containsInAnyOrder("/text()one", "tw/text()o", "three")); + } + + @Test + public void testStripStringRegex() throws Exception { + String prefixDelimiter = "/aai/v8/"; + String prefix = "prefix"; + String suffix = "suffix"; + String testString = prefix + prefixDelimiter + suffix; + String regex = "\\/aai\\/v[0-9]*\\/"; + + String stripString = StringUtils.stripPrefixRegex(testString, regex); + + assertThat(stripString, is(suffix)); + } + + @Test + public void testStripStringRegexNotFound() throws Exception { + String prefixDelimiter = "delimiter"; + String prefix = "prefix"; + String suffix = "suffix"; + String testString = prefix + prefixDelimiter + suffix; + String regex = "\\/aai\\/v[0-9]*\\/"; + + String stripString = StringUtils.stripPrefixRegex(testString, regex); + + assertThat(stripString, is(testString)); + } + + @Test + public void testStripStringRegexMultiplePrefix() throws Exception { + String prefixDelimiter = "/aai/v8/"; + String prefix = "prefix"; + String suffix = "text" + prefixDelimiter + "text"; + String testString = prefix + prefixDelimiter + suffix; + String regex = "\\/aai\\/v[0-9]*\\/"; + + String stripString = StringUtils.stripPrefixRegex(testString, regex); + + assertThat(stripString, is(suffix)); + } + + @Test + public void testStripStringRegexNullString() throws Exception { + String testString = null; + String regex = "\\/aai\\/v[0-9]*\\/"; + + String stripString = StringUtils.stripPrefixRegex(testString, regex); + + assertThat(stripString, nullValue()); + } + + @Test + public void testStripStringRegexEmptyString() throws Exception { + String testString = ""; + String regex = "\\/aai\\/v[0-9]*\\/"; + + String stripString = StringUtils.stripPrefixRegex(testString, regex); + + assertThat(stripString, is(testString)); + } + + @Test + public void testStripStringRegexNullRegex() throws Exception { + String testString = "test"; + String regex = null; + + String stripString = StringUtils.stripPrefixRegex(testString, regex); + + assertThat(stripString, is(testString)); + } + + @Test + public void testStripStringRegexEmptyRegex() throws Exception { + String testString = "test"; + String regex = ""; + + String stripString = StringUtils.stripPrefixRegex(testString, regex); + + assertThat(stripString, is(testString)); + } + + @Test(expected = ValidationServiceException.class) + public void testStripStringRegexInvalidRegex() throws Exception { + String prefixDelimiter = "/aai/v8/"; + String prefix = "prefix"; + String suffix = "suffix"; + String testString = prefix + prefixDelimiter + suffix; + String regex = "***"; + + StringUtils.stripPrefixRegex(testString, regex); + } + + @Test + public void testStripStringRegexLimitedPrefix() throws Exception { + String prefixDelimiter = "/aai/v8/"; + String suffix = "suffix"; + String testString = prefixDelimiter + suffix; + String regex = "\\/aai\\/v[0-9]*\\/"; + + String stripString = StringUtils.stripPrefixRegex(testString, regex); + + assertThat(stripString, is(suffix)); + } +} diff --git a/src/test/resources/aai-environment.properties b/src/test/resources/aai-environment.properties new file mode 100644 index 0000000..463a2b0 --- /dev/null +++ b/src/test/resources/aai-environment.properties @@ -0,0 +1,31 @@ +# ============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===================================================== + +# This file is used by various tests (src/test and src/integration-test) as it loaded from the classpath +host=localhost +port=8443 +httpProtocol=file +trustStorePath=src/main/resources/authentication/tomcat_keystore +trustStorePassword.x=70c87528c88dcd9f9c2558d30e817868 +keyStorePath=src/main/resources/authentication/aai-client-cert.p12 +keyStorePassword.x=70c87528c88dcd9f9c2558d30e817868 +keyManagerFactoryAlgorithm=SunX509 +keyStoreType=PKCS12 +securityProtocol=TLS +connectionTimeout=5000 +readTimeout=1000 + +baseModelURI=src/test/resources/model-validation/instance-validator/all-models.xml \ No newline at end of file diff --git a/src/test/resources/auth/auth_policy.json b/src/test/resources/auth/auth_policy.json new file mode 100644 index 0000000..2bf63d1 --- /dev/null +++ b/src/test/resources/auth/auth_policy.json @@ -0,0 +1,55 @@ +{"roles": [ + { + "name": "admin", + "functions": [ + { + "name": "actions", + "methods": [ + {"name": "GET"}, + {"name": "DELETE"}, + {"name": "PUT"} + ] + }, + { + "name": "validate", + "methods": [{"name": "POST"}] + } + ], + "users": [ + {"username": "CN=common-name, OU=org-unit, O=org, L=location, ST=state, C=US"}, + {"username": "CN=test, OU=qa, O=Test Ltd, L=London, ST=London, C=GB"} + ] + }, + { + "name": "ops", + "functions": [{ + "name": "actions", + "methods": [{"name": "POST"}] + }], + "users": [ + {"username": "CN=common-name, OU=org-unit, O=org, L=location, ST=state, C=US"}, + {"username": "CN=test, OU=qa, O=Test Ltd, L=London, ST=London, C=GB"} + ] + }, + { + "name": "basicauth", + "functions": [{ + "name": "util", + "methods": [{"name": "GET"}] + }], + "users": [{ + "user": "aai", + "pass": "OBF:1u2a1t2v1vgb1s3g1s3m1vgj1t3b1u30" + }] + }, + { + "name": "nofuncauth", + "functions": [{ + "name": "nofuncutil" + }], + "users": [{ + "user": "aai", + "pass": "OBF:1u2a1t2v1vgb1s3g1s3m1vgj1t3b1u30" + }] + } +]} diff --git a/src/test/resources/event-reader/generic-vnf-create-event.json b/src/test/resources/event-reader/generic-vnf-create-event.json new file mode 100644 index 0000000..94235b7 --- /dev/null +++ b/src/test/resources/event-reader/generic-vnf-create-event.json @@ -0,0 +1,75 @@ +{ + "cambria.partition": "AAI", + "event-header": { + "id": "20160525111931-22f454f0-93ff-4571-bed0-573ca6c85353", + "timestamp": "20160525-11:19:31:421", + "source-name": "RO", + "domain": "devINT1", + "sequence-number": "0", + "severity": "NORMAL", + "event-type": "AAI-EVENT", + "version": "v7", + "action": "CREATE", + "entity-type": "generic-vnf", + "top-entity-type": "generic-vnf", + "entity-link": "https://dummy-host.onap.org:8443/aai/v7/network/generic-vnfs/generic-vnf/VAPP-1581", + "topic-name": "topicName", + "event-id": "7994f700-766b-47ed-a322-194346edd92e" + }, + "entity": { + "vnf-id": "VAPP-1581", + "vnf-name": "example-vnf-name-val-3501", + "vnf-name2": "example-vnf-name2-val-3501", + "vnf-type": "example-vnf-type-val-3501", + "regional-resource-zone": "example-regional-resource-zone-val-3501", + "prov-status": "example-prov-status-val-3501", + "operational-state": "example-operational-state-val-3501", + "license-key": "example-license-key-val-3501", + "equipment-role": "example-equipment-role-val-3501", + "orchestration-status": "example-orchestration-status-val-3501", + "heat-stack-id": "example-heat-stack-id-val-3501", + "mso-catalog-key": "example-mso-catalog-key-val-3501", + "management-option": "example-management-option-val-3501", + "ipv4-oam-address": "example-ipv4-oam-address-val-3501", + "ipv4-loopback0-address": "example-ipv4-loopback0-address-val-3501", + "nm-lan-v6-address": "example-nm-lan-v6-address-val-3501", + "management-v6-address": "example-management-v6-address-val-3501", + "vcpu": 1817, + "vcpu-units": "example-vcpu-units-val-3501", + "vmemory": 6020, + "vmemory-units": "example-vmemory-units-val-3501", + "vdisk": 5281, + "vdisk-units": "example-vdisk-units-val-3501", + "in-maint": false, + "is-closed-loop-disabled": true, + "resource-version": "1464189571", + "relationship-list": { + "relationship": { + "related-to": "logical-link", + "related-link": "https://loopback.onap.org:8443/aai/v7/network/logical-links/logical-link/link-01/", + "relationship-data": { + "relationship-key": "logical-link.link-name", + "relationship-value": "link-01" + } + } + }, + "l-interfaces": { + + }, + "lag-interfaces": { + "lag-interface": { + "interface-name": "example-interface-name-val-3131", + "resource-version": "1464189571", + "relationship-list": { + + }, + "l-interfaces": { + + } + } + }, + "vf-modules": { + + } + } +} \ No newline at end of file diff --git a/src/test/resources/event-reader/invalid-event-1.json b/src/test/resources/event-reader/invalid-event-1.json new file mode 100644 index 0000000..523c9d8 --- /dev/null +++ b/src/test/resources/event-reader/invalid-event-1.json @@ -0,0 +1,165 @@ +{ + "cambria.partition": "AAI", + "event-header": { + "id": "20160525162737-61c49d41-5338-4755-af54-06cee9fe4acf", + "timestamp": "20160525-16:27:37:353", + "source-name": "RO", + "domain": "devINT1", + "sequence-number": "0", + "severity": "NORMAL", + "event-type-MISSING": "AAI-EVENT", + "version": "v7", + "action": "CREATE", + "entity-type-MISSING": "vserver", + "top-entity-type": "cloud-region", + "entity-link": "https://dummy-host.onap.org:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/tenants/tenant/example-tenant-id-val-88551/vservers/vserver/example-vserver-id-val-34666", + "topic-name": "topicName", + "event-id": "7994f700-766b-47ed-a322-194346edd92e" + }, + "entity": { + "cloud-owner": "region1", + "cloud-region-id": "AAIregion1", + "tenants": { + "tenant": [ + { + "tenant-id": "example-tenant-id-val-88551", + "tenant-name": "example-tenant-name-val-88551", + "vservers": { + "vserver": [ + { + "vserver-id": "example-vserver-id-val-34666", + "vserver-name": "example-vserver-name-val-34666", + "vserver-name2": "example-vserver-name2-val-34666", + "prov-status": "PREPROV", + "vserver-selflink": "example-vserver-selflink-val-34666", + "in-maint": true, + "is-closed-loop-disabled": true, + "resource-version": "1464193654", + "volumes": { + "volume": [ + { + "volume-id": "example-volume-id-val-79195", + "volume-selflink": "example-volume-selflink-val-79195", + "resource-version": "1464193654", + "relationship-list": { + + } + } + ] + }, + "relationship-list": { + + }, + "l-interfaces": { + "l-interface": [ + { + "interface-name": "example-interface-name-val-25679", + "interface-role": "example-interface-role-val-25679", + "v6-wan-link-ip": "example-v6-wan-link-ip-val-25679", + "selflink": "example-selflink-val-25679", + "interface-id": "example-interface-id-val-25679", + "macaddr": "example-macaddr-val-25679", + "network-name": "example-network-name-val-25679", + "resource-version": "1464193654", + "vlans": { + "vlan": [ + { + "vlan-interface": "example-vlan-interface-val-28675", + "vlan-id-inner": 22278797, + "vlan-id-outer": 22278797, + "resource-version": "1464193654", + "speed-value": "example-speed-value-val-28675", + "speed-units": "example-speed-units-val-28675", + "vlan-description": "example-vlan-description-val-28675", + "relationship-list": { + + }, + "l3-interface-ipv4-address-list": [ + { + "l3-interface-ipv4-address": "example-l3-interface-ipv4-address-val-39271", + "l3-interface-ipv4-prefix-length": 78868308, + "vlan-id-inner": 78868308, + "vlan-id-outer": 78868308, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ], + "l3-interface-ipv6-address-list": [ + { + "l3-interface-ipv6-address": "example-l3-interface-ipv6-address-val-4005", + "l3-interface-ipv6-prefix-length": 78340763, + "vlan-id-inner": 78340763, + "vlan-id-outer": 78340763, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ] + } + ] + }, + "sriov-vfs": { + "sriov-vf": [ + { + "pci-id": "example-pci-id-val-85354", + "vf-vlan-filter": "example-vf-vlan-filter-val-85354", + "vf-mac-filter": "example-vf-mac-filter-val-85354", + "vf-vlan-strip": true, + "vf-vlan-anti-spoof-check": true, + "vf-mac-anti-spoof-check": true, + "vf-mirrors": "example-vf-mirrors-val-85354", + "vf-broadcast-allow": true, + "vf-unknown-multicast-allow": true, + "vf-unknown-unicast-allow": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ] + }, + "relationship-list": { + + }, + "l3-interface-ipv4-address-list": [ + { + "l3-interface-ipv4-address": "example-l3-interface-ipv4-address-val-21446", + "l3-interface-ipv4-prefix-length": 71127022, + "vlan-id-inner": 71127022, + "vlan-id-outer": 71127022, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ], + "l3-interface-ipv6-address-list": [ + { + "l3-interface-ipv6-address": "example-l3-interface-ipv6-address-val-88071", + "l3-interface-ipv6-prefix-length": 55080281, + "vlan-id-inner": 55080281, + "vlan-id-outer": 55080281, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ] + } + ] + } + } + ] + } + } + ] + } + } +} \ No newline at end of file diff --git a/src/test/resources/event-reader/invalid-event-2.json b/src/test/resources/event-reader/invalid-event-2.json new file mode 100644 index 0000000..5d9def7 --- /dev/null +++ b/src/test/resources/event-reader/invalid-event-2.json @@ -0,0 +1,165 @@ +{ + "cambria.partition": "AAI", + "event-header": { + "id": "20160525162737-61c49d41-5338-4755-af54-06cee9fe4acf", + "timestamp": "20160525-16:27:37:353", + "source-name": "RO", + "domain": "devINT1", + "sequence-number": "0", + "severity": "NORMAL", + "event-type": "AAI-EVENT", + "version": "v7", + "action": "CREATE", + "entity-type": "UNKNOWN-ENTITY-TYPE", + "top-entity-type": "cloud-region", + "entity-link": "https://dummy-host.onap.org:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/tenants/tenant/example-tenant-id-val-88551/vservers/vserver/example-vserver-id-val-34666", + "topic-name": "topicName", + "event-id": "7994f700-766b-47ed-a322-194346edd92e" + }, + "entity": { + "cloud-owner": "region1", + "cloud-region-id": "AAIregion1", + "tenants": { + "tenant": [ + { + "tenant-id": "example-tenant-id-val-88551", + "tenant-name": "example-tenant-name-val-88551", + "vservers": { + "vserver": [ + { + "vserver-id": "example-vserver-id-val-34666", + "vserver-name": "example-vserver-name-val-34666", + "vserver-name2": "example-vserver-name2-val-34666", + "prov-status": "PREPROV", + "vserver-selflink": "example-vserver-selflink-val-34666", + "in-maint": true, + "is-closed-loop-disabled": true, + "resource-version": "1464193654", + "volumes": { + "volume": [ + { + "volume-id": "example-volume-id-val-79195", + "volume-selflink": "example-volume-selflink-val-79195", + "resource-version": "1464193654", + "relationship-list": { + + } + } + ] + }, + "relationship-list": { + + }, + "l-interfaces": { + "l-interface": [ + { + "interface-name": "example-interface-name-val-25679", + "interface-role": "example-interface-role-val-25679", + "v6-wan-link-ip": "example-v6-wan-link-ip-val-25679", + "selflink": "example-selflink-val-25679", + "interface-id": "example-interface-id-val-25679", + "macaddr": "example-macaddr-val-25679", + "network-name": "example-network-name-val-25679", + "resource-version": "1464193654", + "vlans": { + "vlan": [ + { + "vlan-interface": "example-vlan-interface-val-28675", + "vlan-id-inner": 22278797, + "vlan-id-outer": 22278797, + "resource-version": "1464193654", + "speed-value": "example-speed-value-val-28675", + "speed-units": "example-speed-units-val-28675", + "vlan-description": "example-vlan-description-val-28675", + "relationship-list": { + + }, + "l3-interface-ipv4-address-list": [ + { + "l3-interface-ipv4-address": "example-l3-interface-ipv4-address-val-39271", + "l3-interface-ipv4-prefix-length": 78868308, + "vlan-id-inner": 78868308, + "vlan-id-outer": 78868308, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ], + "l3-interface-ipv6-address-list": [ + { + "l3-interface-ipv6-address": "example-l3-interface-ipv6-address-val-4005", + "l3-interface-ipv6-prefix-length": 78340763, + "vlan-id-inner": 78340763, + "vlan-id-outer": 78340763, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ] + } + ] + }, + "sriov-vfs": { + "sriov-vf": [ + { + "pci-id": "example-pci-id-val-85354", + "vf-vlan-filter": "example-vf-vlan-filter-val-85354", + "vf-mac-filter": "example-vf-mac-filter-val-85354", + "vf-vlan-strip": true, + "vf-vlan-anti-spoof-check": true, + "vf-mac-anti-spoof-check": true, + "vf-mirrors": "example-vf-mirrors-val-85354", + "vf-broadcast-allow": true, + "vf-unknown-multicast-allow": true, + "vf-unknown-unicast-allow": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ] + }, + "relationship-list": { + + }, + "l3-interface-ipv4-address-list": [ + { + "l3-interface-ipv4-address": "example-l3-interface-ipv4-address-val-21446", + "l3-interface-ipv4-prefix-length": 71127022, + "vlan-id-inner": 71127022, + "vlan-id-outer": 71127022, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ], + "l3-interface-ipv6-address-list": [ + { + "l3-interface-ipv6-address": "example-l3-interface-ipv6-address-val-88071", + "l3-interface-ipv6-prefix-length": 55080281, + "vlan-id-inner": 55080281, + "vlan-id-outer": 55080281, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ] + } + ] + } + } + ] + } + } + ] + } + } +} \ No newline at end of file diff --git a/src/test/resources/event-reader/invalid-event-3.json b/src/test/resources/event-reader/invalid-event-3.json new file mode 100644 index 0000000..20160a8 --- /dev/null +++ b/src/test/resources/event-reader/invalid-event-3.json @@ -0,0 +1,75 @@ +{ + "cambria.partition": "AAI", + "event-header": { + "id": "20160525111931-22f454f0-93ff-4571-bed0-573ca6c85353", + "timestamp": "20160525-11:19:31:421", + "source-name": "RO", + "domain": "devINT1", + "sequence-number": "0", + "severity": "NORMAL", + "event-type": "AAI-EVENT", + "version": "v7", + "action": "CREATE", + "entity-type": "UNKNOWN-ENTITY-TYPE", + "top-entity-type": "UNKNOWN-ENTITY-TYPE", + "entity-link": "https://dummy-host.onap.org:8443/aai/v7/network/generic-vnfs/generic-vnf/VAPP-1581", + "topic-name": "topicName", + "event-id": "7994f700-766b-47ed-a322-194346edd92e" + }, + "entity": { + "vnf-id": "VAPP-1581", + "vnf-name": "example-vnf-name-val-3501", + "vnf-name2": "example-vnf-name2-val-3501", + "vnf-type": "example-vnf-type-val-3501", + "regional-resource-zone": "example-regional-resource-zone-val-3501", + "prov-status": "example-prov-status-val-3501", + "operational-state": "example-operational-state-val-3501", + "license-key": "example-license-key-val-3501", + "equipment-role": "example-equipment-role-val-3501", + "orchestration-status": "example-orchestration-status-val-3501", + "heat-stack-id": "example-heat-stack-id-val-3501", + "mso-catalog-key": "example-mso-catalog-key-val-3501", + "management-option": "example-management-option-val-3501", + "ipv4-oam-address": "example-ipv4-oam-address-val-3501", + "ipv4-loopback0-address": "example-ipv4-loopback0-address-val-3501", + "nm-lan-v6-address": "example-nm-lan-v6-address-val-3501", + "management-v6-address": "example-management-v6-address-val-3501", + "vcpu": 1817, + "vcpu-units": "example-vcpu-units-val-3501", + "vmemory": 6020, + "vmemory-units": "example-vmemory-units-val-3501", + "vdisk": 5281, + "vdisk-units": "example-vdisk-units-val-3501", + "in-maint": false, + "is-closed-loop-disabled": true, + "resource-version": "1464189571", + "relationship-list": { + "relationship": { + "related-to": "logical-link", + "related-link": "https://loopback.onap.org:8443/aai/v7/network/logical-links/logical-link/link-01/", + "relationship-data": { + "relationship-key": "logical-link.link-name", + "relationship-value": "link-01" + } + } + }, + "l-interfaces": { + + }, + "lag-interfaces": { + "lag-interface": { + "interface-name": "example-interface-name-val-3131", + "resource-version": "1464189571", + "relationship-list": { + + }, + "l-interfaces": { + + } + } + }, + "vf-modules": { + + } + } +} \ No newline at end of file diff --git a/src/test/resources/event-reader/invalid-event-4.json b/src/test/resources/event-reader/invalid-event-4.json new file mode 100644 index 0000000..eb1a489 --- /dev/null +++ b/src/test/resources/event-reader/invalid-event-4.json @@ -0,0 +1,150 @@ +{ + "cambria.partition": "AAI", + "event-header": { + "id": "20160525162737-61c49d41-5338-4755-af54-06cee9fe4acf", + "timestamp": "20160525-16:27:37:353", + "source-name": "RO", + "domain": "devINT1", + "sequence-number": "0", + "severity": "NORMAL", + "event-type": "AAI-EVENT", + "version": "v7", + "action": "CREATE", + "entity-type": "vserver", + "top-entity-type": "cloud-region", + "entity-link": "https://dummy-host.onap.org:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/tenants/tenant/example-tenant-id-val-88551/vservers/vserver/example-vserver-id-val-34666", + "topic-name": "topicName", + "event-id": "7994f700-766b-47ed-a322-194346edd92e" + }, + "entity": { + "cloud-owner": "region1", + "cloud-region-id": "AAIregion1", + "tenants": { + "tenant": [ + { + "tenant-id": "example-tenant-id-val-88551", + "tenant-name": "example-tenant-name-val-88551", + "vservers": { + "vserver": [ + { + "vserver-id": "!!!!! TOO_MANY_ENTITIES !!!!!" + }, + { + "vserver-id": "example-vserver-id-val-34666", + "vserver-name": "example-vserver-name-val-34666", + "vserver-name2": "example-vserver-name2-val-34666", + "prov-status": "PREPROV", + "vserver-selflink": "example-vserver-selflink-val-34666", + "in-maint": true, + "is-closed-loop-disabled": true, + "resource-version": "1464193654", + "volumes": { + "volume": [ + { + "volume-id": "example-volume-id-val-79195", + "volume-selflink": "example-volume-selflink-val-79195", + "resource-version": "1464193654", + "relationship-list": {} + } + ] + }, + "relationship-list": {}, + "l-interfaces": { + "l-interface": [ + { + "interface-name": "example-interface-name-val-25679", + "interface-role": "example-interface-role-val-25679", + "v6-wan-link-ip": "example-v6-wan-link-ip-val-25679", + "selflink": "example-selflink-val-25679", + "interface-id": "example-interface-id-val-25679", + "macaddr": "example-macaddr-val-25679", + "network-name": "example-network-name-val-25679", + "resource-version": "1464193654", + "vlans": { + "vlan": [ + { + "vlan-interface": "example-vlan-interface-val-28675", + "vlan-id-inner": 22278797, + "vlan-id-outer": 22278797, + "resource-version": "1464193654", + "speed-value": "example-speed-value-val-28675", + "speed-units": "example-speed-units-val-28675", + "vlan-description": "example-vlan-description-val-28675", + "relationship-list": {}, + "l3-interface-ipv4-address-list": [ + { + "l3-interface-ipv4-address": "example-l3-interface-ipv4-address-val-39271", + "l3-interface-ipv4-prefix-length": 78868308, + "vlan-id-inner": 78868308, + "vlan-id-outer": 78868308, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": {} + } + ], + "l3-interface-ipv6-address-list": [ + { + "l3-interface-ipv6-address": "example-l3-interface-ipv6-address-val-4005", + "l3-interface-ipv6-prefix-length": 78340763, + "vlan-id-inner": 78340763, + "vlan-id-outer": 78340763, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": {} + } + ] + } + ] + }, + "sriov-vfs": { + "sriov-vf": [ + { + "pci-id": "example-pci-id-val-85354", + "vf-vlan-filter": "example-vf-vlan-filter-val-85354", + "vf-mac-filter": "example-vf-mac-filter-val-85354", + "vf-vlan-strip": true, + "vf-vlan-anti-spoof-check": true, + "vf-mac-anti-spoof-check": true, + "vf-mirrors": "example-vf-mirrors-val-85354", + "vf-broadcast-allow": true, + "vf-unknown-multicast-allow": true, + "vf-unknown-unicast-allow": true, + "resource-version": "1464193654", + "relationship-list": {} + } + ] + }, + "relationship-list": {}, + "l3-interface-ipv4-address-list": [ + { + "l3-interface-ipv4-address": "example-l3-interface-ipv4-address-val-21446", + "l3-interface-ipv4-prefix-length": 71127022, + "vlan-id-inner": 71127022, + "vlan-id-outer": 71127022, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": {} + } + ], + "l3-interface-ipv6-address-list": [ + { + "l3-interface-ipv6-address": "example-l3-interface-ipv6-address-val-88071", + "l3-interface-ipv6-prefix-length": 55080281, + "vlan-id-inner": 55080281, + "vlan-id-outer": 55080281, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": {} + } + ] + } + ] + } + } + ] + } + } + ] + } + } +} \ No newline at end of file diff --git a/src/test/resources/event-reader/invalid-event-5.json b/src/test/resources/event-reader/invalid-event-5.json new file mode 100644 index 0000000..c05ab30 --- /dev/null +++ b/src/test/resources/event-reader/invalid-event-5.json @@ -0,0 +1,165 @@ +{ + "cambria.partition": "AAI", + "event-header": { + "id": "20160525162737-61c49d41-5338-4755-af54-06cee9fe4acf", + "timestamp": "20160525-16:27:37:353", + "source-name": "RO", + "domain": "devINT1", + "sequence-number": "0", + "severity": "NORMAL", + "event-type": "AAI-EVENT", + "version": "v7", + "action": "CREATE", + "entity-type": "vserver", + "top-entity-type": "cloud-region", + "entity-link": "https://dummy-host.onap.org:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/tenants/tenant/example-tenant-id-val-88551/vservers/vserver/example-vserver-id-val-34666", + "topic-name": "topicName", + "event-id": "7994f700-766b-47ed-a322-194346edd92e" + }, + "entity": { + "cloud-owner": "region1", + "cloud-region-id": "AAIregion1", + "tenants": { + "tenant": [ + { + "tenant-id": "example-tenant-id-val-88551", + "tenant-name": "example-tenant-name-val-88551", + "vservers": { + "vserver": [ + { + "vserver-id": "example-vserver-id-val-34666", + "vserver-name": "example-vserver-name-val-34666", + "vserver-name2": "example-vserver-name2-val-34666", + "prov-status": "PREPROV", + "vserver-selflink": "example-vserver-selflink-val-34666", + "in-maint": true, + "is-closed-loop-disabled": true, + "resource-version-MISSING": "1464193654", + "volumes": { + "volume": [ + { + "volume-id": "example-volume-id-val-79195", + "volume-selflink": "example-volume-selflink-val-79195", + "resource-version": "1464193654", + "relationship-list": { + + } + } + ] + }, + "relationship-list": { + + }, + "l-interfaces": { + "l-interface": [ + { + "interface-name": "example-interface-name-val-25679", + "interface-role": "example-interface-role-val-25679", + "v6-wan-link-ip": "example-v6-wan-link-ip-val-25679", + "selflink": "example-selflink-val-25679", + "interface-id": "example-interface-id-val-25679", + "macaddr": "example-macaddr-val-25679", + "network-name": "example-network-name-val-25679", + "resource-version": "1464193654", + "vlans": { + "vlan": [ + { + "vlan-interface": "example-vlan-interface-val-28675", + "vlan-id-inner": 22278797, + "vlan-id-outer": 22278797, + "resource-version": "1464193654", + "speed-value": "example-speed-value-val-28675", + "speed-units": "example-speed-units-val-28675", + "vlan-description": "example-vlan-description-val-28675", + "relationship-list": { + + }, + "l3-interface-ipv4-address-list": [ + { + "l3-interface-ipv4-address": "example-l3-interface-ipv4-address-val-39271", + "l3-interface-ipv4-prefix-length": 78868308, + "vlan-id-inner": 78868308, + "vlan-id-outer": 78868308, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ], + "l3-interface-ipv6-address-list": [ + { + "l3-interface-ipv6-address": "example-l3-interface-ipv6-address-val-4005", + "l3-interface-ipv6-prefix-length": 78340763, + "vlan-id-inner": 78340763, + "vlan-id-outer": 78340763, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ] + } + ] + }, + "sriov-vfs": { + "sriov-vf": [ + { + "pci-id": "example-pci-id-val-85354", + "vf-vlan-filter": "example-vf-vlan-filter-val-85354", + "vf-mac-filter": "example-vf-mac-filter-val-85354", + "vf-vlan-strip": true, + "vf-vlan-anti-spoof-check": true, + "vf-mac-anti-spoof-check": true, + "vf-mirrors": "example-vf-mirrors-val-85354", + "vf-broadcast-allow": true, + "vf-unknown-multicast-allow": true, + "vf-unknown-unicast-allow": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ] + }, + "relationship-list": { + + }, + "l3-interface-ipv4-address-list": [ + { + "l3-interface-ipv4-address": "example-l3-interface-ipv4-address-val-21446", + "l3-interface-ipv4-prefix-length": 71127022, + "vlan-id-inner": 71127022, + "vlan-id-outer": 71127022, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ], + "l3-interface-ipv6-address-list": [ + { + "l3-interface-ipv6-address": "example-l3-interface-ipv6-address-val-88071", + "l3-interface-ipv6-prefix-length": 55080281, + "vlan-id-inner": 55080281, + "vlan-id-outer": 55080281, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ] + } + ] + } + } + ] + } + } + ] + } + } +} \ No newline at end of file diff --git a/src/test/resources/event-reader/test-validation-service-beans.xml b/src/test/resources/event-reader/test-validation-service-beans.xml new file mode 100644 index 0000000..0d60484 --- /dev/null +++ b/src/test/resources/event-reader/test-validation-service-beans.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/event-reader/vserver-create-event.json b/src/test/resources/event-reader/vserver-create-event.json new file mode 100644 index 0000000..46f22c4 --- /dev/null +++ b/src/test/resources/event-reader/vserver-create-event.json @@ -0,0 +1,165 @@ +{ + "cambria.partition": "AAI", + "event-header": { + "id": "20160525162737-61c49d41-5338-4755-af54-06cee9fe4acf", + "timestamp": "20160525-16:27:37:353", + "source-name": "RO", + "domain": "devINT1", + "sequence-number": "0", + "severity": "NORMAL", + "event-type": "AAI-EVENT", + "version": "v7", + "action": "CREATE", + "entity-type": "vserver", + "top-entity-type": "cloud-region", + "entity-link": "https://dummy-host.onap.org:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/tenants/tenant/example-tenant-id-val-88551/vservers/vserver/example-vserver-id-val-34666", + "topic-name": "topicName", + "event-id": "7994f700-766b-47ed-a322-194346edd92e" + }, + "entity": { + "cloud-owner": "region1", + "cloud-region-id": "AAIregion1", + "tenants": { + "tenant": [ + { + "tenant-id": "example-tenant-id-val-88551", + "tenant-name": "example-tenant-name-val-88551", + "vservers": { + "vserver": [ + { + "vserver-id": "example-vserver-id-val-34666", + "vserver-name": "example-vserver-name-val-34666", + "vserver-name2": "example-vserver-name2-val-34666", + "prov-status": "PREPROV", + "vserver-selflink": "example-vserver-selflink-val-34666", + "in-maint": true, + "is-closed-loop-disabled": true, + "resource-version": "1464193654", + "volumes": { + "volume": [ + { + "volume-id": "example-volume-id-val-79195", + "volume-selflink": "example-volume-selflink-val-79195", + "resource-version": "1464193654", + "relationship-list": { + + } + } + ] + }, + "relationship-list": { + + }, + "l-interfaces": { + "l-interface": [ + { + "interface-name": "example-interface-name-val-25679", + "interface-role": "example-interface-role-val-25679", + "v6-wan-link-ip": "example-v6-wan-link-ip-val-25679", + "selflink": "example-selflink-val-25679", + "interface-id": "example-interface-id-val-25679", + "macaddr": "example-macaddr-val-25679", + "network-name": "example-network-name-val-25679", + "resource-version": "1464193654", + "vlans": { + "vlan": [ + { + "vlan-interface": "example-vlan-interface-val-28675", + "vlan-id-inner": 22278797, + "vlan-id-outer": 22278797, + "resource-version": "1464193654", + "speed-value": "example-speed-value-val-28675", + "speed-units": "example-speed-units-val-28675", + "vlan-description": "example-vlan-description-val-28675", + "relationship-list": { + + }, + "l3-interface-ipv4-address-list": [ + { + "l3-interface-ipv4-address": "example-l3-interface-ipv4-address-val-39271", + "l3-interface-ipv4-prefix-length": 78868308, + "vlan-id-inner": 78868308, + "vlan-id-outer": 78868308, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ], + "l3-interface-ipv6-address-list": [ + { + "l3-interface-ipv6-address": "example-l3-interface-ipv6-address-val-4005", + "l3-interface-ipv6-prefix-length": 78340763, + "vlan-id-inner": 78340763, + "vlan-id-outer": 78340763, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ] + } + ] + }, + "sriov-vfs": { + "sriov-vf": [ + { + "pci-id": "example-pci-id-val-85354", + "vf-vlan-filter": "example-vf-vlan-filter-val-85354", + "vf-mac-filter": "example-vf-mac-filter-val-85354", + "vf-vlan-strip": true, + "vf-vlan-anti-spoof-check": true, + "vf-mac-anti-spoof-check": true, + "vf-mirrors": "example-vf-mirrors-val-85354", + "vf-broadcast-allow": true, + "vf-unknown-multicast-allow": true, + "vf-unknown-unicast-allow": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ] + }, + "relationship-list": { + + }, + "l3-interface-ipv4-address-list": [ + { + "l3-interface-ipv4-address": "example-l3-interface-ipv4-address-val-21446", + "l3-interface-ipv4-prefix-length": 71127022, + "vlan-id-inner": 71127022, + "vlan-id-outer": 71127022, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ], + "l3-interface-ipv6-address-list": [ + { + "l3-interface-ipv6-address": "example-l3-interface-ipv6-address-val-88071", + "l3-interface-ipv6-prefix-length": 55080281, + "vlan-id-inner": 55080281, + "vlan-id-outer": 55080281, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ] + } + ] + } + } + ] + } + } + ] + } + } +} \ No newline at end of file diff --git a/src/test/resources/info-service/test-validation-service-beans.xml b/src/test/resources/info-service/test-validation-service-beans.xml new file mode 100644 index 0000000..d1c6ace --- /dev/null +++ b/src/test/resources/info-service/test-validation-service-beans.xml @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/json-reader/sample.json b/src/test/resources/json-reader/sample.json new file mode 100644 index 0000000..26bb497 --- /dev/null +++ b/src/test/resources/json-reader/sample.json @@ -0,0 +1,13 @@ +{ + "event-header": { + "entity-type": "vserver", + "sample-integer": 1, + "sample-boolean": true, + "sample-object": { + "property": "value" + }, + "sample-array": [ + "one" + ] + } +} \ No newline at end of file diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml new file mode 100644 index 0000000..47c6154 --- /dev/null +++ b/src/test/resources/logback.xml @@ -0,0 +1,180 @@ + + + + + + + + + + + + + + + + + + + + + + + + + ${logDirectory}/${generalLogName}.log + + ${logDirectory}/${generalLogName}.%d{yyyy-MM-dd}.log.zip + + 60 + + + ${errorLogPattern} + + + + + + INFO + + 256 + + + + + + + ${logDirectory}/${auditLogName}.log + + ${logDirectory}/${auditLogName}.%d{yyyy-MM-dd}.log.zip + + 60 + + + ${auditLogPattern} + + + + 256 + + + + + ${logDirectory}/${metricsLogName}.log + + ${logDirectory}/${metricsLogName}.%d{yyyy-MM-dd}.log.zip + + 60 + + + ${metricsLogPattern} + + + + + 256 + + + + + + ${logDirectory}/${debugLogName}.log + + + ${logDirectory}/${debugLogName}.%d{yyyy-MM-dd}.log.zip + + 60 + + + ${errorLogPattern} + + + + + + + + + e.level.toInt() < INFO.toInt() + + + DENY + NEUTRAL + + 256 + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/model-instance-mapping.json_conf b/src/test/resources/model-instance-mapping.json_conf new file mode 100644 index 0000000..12d39ea --- /dev/null +++ b/src/test/resources/model-instance-mapping.json_conf @@ -0,0 +1,28 @@ +[ + { + "mappingType": "RELATIONSHIP", + "model": { + "root": "model-elements/model-element", + "id": "relationship-list/relationship/relationship-data/relationship-value[../relationship-key/text()='model.model-name-version-id']", + "value": "relationship-list/relationship/related-to-property/property-value[../property-key/text()='model.model-name']", + "filter": { + "path": "relationship-list/relationship/related-to-property/property-value[../property-key/text()='model.model-type']", + "valid": ["widget"] + } + }, + "instance": { + "origin": "$.inventory-response-item[0]", + "root": "$.inventory-response-items.inventory-response-item[*]" + } + }, + { + "mappingType": "ATTRIBUTE", + "model": { + "value": "metadata/metadatum/metaname" + }, + "instance": { + "origin": "$.inventory-response-item[0]", + "value": "$..extra-properties.metadatum[*].metaname" + } + } +] diff --git a/src/test/resources/model-validation/instance-reader/connector-attributes.json b/src/test/resources/model-validation/instance-reader/connector-attributes.json new file mode 100644 index 0000000..3a4536f --- /dev/null +++ b/src/test/resources/model-validation/instance-reader/connector-attributes.json @@ -0,0 +1,399 @@ +{ + "inventory-response-item": [ + { + "model-name": "WAN Connector v0.1", + "connector": { + "resource-instance-id": "100559", + "resource-version": "1465571381", + "persona-model-id": "dc700a83-c507-47d9-b775-1fdfcdd5f9eb", + "persona-model-version": "0.1" + }, + "extra-properties": { + "metadatum": [ + { + "metaname": "vpn-id", + "metaval": "vpn-id value 1", + "resource-version": "1466418452" + }, + { + "metaname": "unexpected", + "metaval": "unexpected value 1", + "resource-version": "1466418452" + } + ] + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "virtual-data-center": { + "vdc-id": "15001220", + "vdc-name": "SAN_DIEGO_CA01", + "resource-version": "1465571382" + }, + "extra-properties": {}, + "inventory-response-items": { + "inventory-response-item": [ + { + "model-name": "vLAN on a Physical Wire", + "logical-link": { + "link-name": "sn6ca391ve2-xe-10/2/3.117|sn4ca01pbg", + "link-type": "l2bridge", + "resource-version": "1465571381", + "persona-model-id": "32bee148-2cae-4f3d-a42e-22c9e4f078a2", + "persona-model-version": "1" + }, + "extra-properties": {}, + "inventory-response-items": { + "inventory-response-item": [ + { + "model-name": "pBgf", + "pserver": { + "hostname": "sn4ca01pbg", + "in-maint": false, + "resource-version": "1470978156" + }, + "extra-properties": {}, + "inventory-response-items": {} + } + ] + } + }, + { + "model-name": "VL ELAN", + "logical-link": { + "link-name": "sn6ca391ve2-ae6.1322|dbzx0003v", + "link-type": "l2bridge", + "resource-version": "1465571381", + "persona-model-id": "932518e5-4260-4cc4-8038-df604a367f85", + "persona-model-version": "1" + }, + "extra-properties": {}, + "inventory-response-items": { + "inventory-response-item": [ + { + "model-name": "vDbe", + "generic-vnf": { + "vnf-id": "VAPP-2883", + "vnf-name": "dbzx0004v", + "vnf-type": "vSRX vDBE-V VNF", + "service-id": "12a96a9d-4b4c-4349-a950-fe1159602621", + "prov-status": "ACTIVE", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1470978155" + }, + "extra-properties": {}, + "inventory-response-items": {} + } + ] + } + }, + { + "model-name": "VL ELAN", + "logical-link": { + "link-name": "sn6ca392ve2-ae6.1322|dbzx0003v", + "link-type": "l2bridge", + "resource-version": "1465571382", + "persona-model-id": "932518e5-4260-4cc4-8038-df604a367f85", + "persona-model-version": "1" + }, + "extra-properties": {}, + "inventory-response-items": { + "inventory-response-item": [ + { + "model-name": "vDbe", + "generic-vnf": { + "vnf-id": "VAPP-2883", + "vnf-name": "dbzx0004v", + "vnf-type": "vSRX vDBE-V VNF", + "service-id": "12a96a9d-4b4c-4349-a950-fe1159602621", + "prov-status": "ACTIVE", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1470978155" + }, + "extra-properties": {}, + "inventory-response-items": {} + } + ] + } + }, + { + "model-name": "VL ELAN", + "logical-link": { + "link-name": "sn6ca392ve2-ae6.1927|asbg0003v", + "link-type": "l2bridge", + "resource-version": "1465571382", + "persona-model-id": "932518e5-4260-4cc4-8038-df604a367f85", + "persona-model-version": "1" + }, + "extra-properties": {}, + "inventory-response-items": { + "inventory-response-item": [ + { + "model-name": "vDbe", + "generic-vnf": { + "vnf-id": "VAPP-9320", + "vnf-name": "asbg0003v", + "vnf-type": "ASBGv No TLS", + "service-id": "c7611ebe-c324-48f1-8085-94aef0c6ef3d", + "prov-status": "PROV", + "ipv4-oam-address": "135.193.152.168", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1470978156" + }, + "extra-properties": {}, + "inventory-response-items": {} + } + ] + } + }, + { + "model-name": "vLAN on a Physical Wire", + "logical-link": { + "link-name": "sn6ca392ve2-xe-10/2/3.117|sn4ca01pbg", + "link-type": "l2bridge", + "resource-version": "1465571382", + "persona-model-id": "32bee148-2cae-4f3d-a42e-22c9e4f078a2", + "persona-model-version": "1" + }, + "extra-properties": {}, + "inventory-response-items": { + "inventory-response-item": [ + { + "model-name": "pBgf", + "pserver": { + "hostname": "sn4ca01pbg", + "in-maint": false, + "resource-version": "1470978156" + }, + "extra-properties": {}, + "inventory-response-items": {} + } + ] + } + }, + { + "model-name": "VL ELAN", + "logical-link": { + "link-name": "sn6ca391ve2-ae6.1927|asbg0003v", + "link-type": "l2bridge", + "resource-version": "1465571381", + "persona-model-id": "932518e5-4260-4cc4-8038-df604a367f85", + "persona-model-version": "1" + }, + "extra-properties": {}, + "inventory-response-items": { + "inventory-response-item": [ + { + "model-name": "vDbe", + "generic-vnf": { + "vnf-id": "VAPP-9320", + "vnf-name": "asbg0003v", + "vnf-type": "ASBGv No TLS", + "service-id": "c7611ebe-c324-48f1-8085-94aef0c6ef3d", + "prov-status": "PROV", + "ipv4-oam-address": "135.193.152.168", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1470978156" + }, + "extra-properties": {}, + "inventory-response-items": {} + } + ] + } + } + ] + } + }, + { + "virtual-data-center": { + "vdc-id": "15001219", + "vdc-name": "ALPHARETTA_GA01", + "resource-version": "1465571380" + }, + "extra-properties": {}, + "inventory-response-items": { + "inventory-response-item": [ + { + "model-name": "VL ELAN", + "logical-link": { + "link-name": "alrga392ve2-ae6.1322|dbzx0004v", + "link-type": "l2bridge", + "resource-version": "1465571380", + "persona-model-id": "932518e5-4260-4cc4-8038-df604a367f85", + "persona-model-version": "1" + }, + "extra-properties": {}, + "inventory-response-items": { + "inventory-response-item": [ + { + "model-name": "vDbe", + "generic-vnf": { + "vnf-id": "VAPP-1883", + "vnf-name": "dbzx0003v", + "vnf-type": "vSRX vDBE-V VNF", + "service-id": "12a96a9d-4b4c-4349-a950-fe1159602621", + "prov-status": "ACTIVE", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1470978153" + }, + "extra-properties": {}, + "inventory-response-items": {} + } + ] + } + }, + { + "model-name": "VL ELAN", + "logical-link": { + "link-name": "alrga391ve2-ae6.1322|dbzx0004v", + "link-type": "l2bridge", + "resource-version": "1465571379", + "persona-model-id": "932518e5-4260-4cc4-8038-df604a367f85", + "persona-model-version": "1" + }, + "extra-properties": {}, + "inventory-response-items": { + "inventory-response-item": [ + { + "model-name": "vDbe", + "generic-vnf": { + "vnf-id": "VAPP-1883", + "vnf-name": "dbzx0003v", + "vnf-type": "vSRX vDBE-V VNF", + "service-id": "12a96a9d-4b4c-4349-a950-fe1159602621", + "prov-status": "ACTIVE", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1470978153" + }, + "extra-properties": {}, + "inventory-response-items": {} + } + ] + } + }, + { + "model-name": "VL ELAN", + "logical-link": { + "link-name": "alrga392ve2-ae6.1927|asbg0004v", + "link-type": "l2bridge", + "resource-version": "1465571380", + "persona-model-id": "932518e5-4260-4cc4-8038-df604a367f85", + "persona-model-version": "1" + }, + "extra-properties": {}, + "inventory-response-items": { + "inventory-response-item": [ + { + "model-name": "vDbe", + "generic-vnf": { + "vnf-id": "VAPP-5305", + "vnf-name": "asbg0004v", + "vnf-type": "ASBGv No TLS", + "service-id": "c7611ebe-c324-48f1-8085-94aef0c6ef3d", + "prov-status": "PROV", + "ipv4-oam-address": "135.190.182.168", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1470978152" + }, + "extra-properties": {}, + "inventory-response-items": {} + } + ] + } + }, + { + "model-name": "vLAN on a Physical Wire", + "logical-link": { + "link-name": "alrga391ve2-xe-10/2/3.117|ar4ga01pbg", + "link-type": "l2bridge", + "resource-version": "1465571379", + "persona-model-id": "32bee148-2cae-4f3d-a42e-22c9e4f078a2", + "persona-model-version": "1" + }, + "extra-properties": {}, + "inventory-response-items": { + "inventory-response-item": [ + { + "model-name": "pBgf", + "pserver": { + "hostname": "ar4ga01pbg", + "in-maint": false, + "resource-version": "1470978153" + }, + "extra-properties": {}, + "inventory-response-items": {} + } + ] + } + }, + { + "model-name": "VL ELAN", + "logical-link": { + "link-name": "alrga391ve2-ae6.1927|asbg0004v", + "link-type": "l2bridge", + "resource-version": "1465571380", + "persona-model-id": "932518e5-4260-4cc4-8038-df604a367f85", + "persona-model-version": "1" + }, + "extra-properties": {}, + "inventory-response-items": { + "inventory-response-item": [ + { + "model-name": "vDbe", + "generic-vnf": { + "vnf-id": "VAPP-5305", + "vnf-name": "asbg0004v", + "vnf-type": "ASBGv No TLS", + "service-id": "c7611ebe-c324-48f1-8085-94aef0c6ef3d", + "prov-status": "PROV", + "ipv4-oam-address": "135.190.182.168", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1470978152" + }, + "extra-properties": {}, + "inventory-response-items": {} + } + ] + } + }, + { + "model-name": "vLAN on a Physical Wire", + "logical-link": { + "link-name": "alrga392ve2-xe-10/2/3.117|ar4ga01pbg", + "link-type": "l2bridge", + "resource-version": "1465571380", + "persona-model-id": "32bee148-2cae-4f3d-a42e-22c9e4f078a2", + "persona-model-version": "1" + }, + "extra-properties": {}, + "inventory-response-items": { + "inventory-response-item": [ + { + "model-name": "pBgf", + "pserver": { + "hostname": "ar4ga01pbg", + "in-maint": false, + "resource-version": "1470978153" + }, + "extra-properties": {}, + "inventory-response-items": {} + } + ] + } + } + ] + } + } + ] + } + } + ] +} \ No newline at end of file diff --git a/src/test/resources/model-validation/instance-reader/connector-model-name.json b/src/test/resources/model-validation/instance-reader/connector-model-name.json new file mode 100644 index 0000000..60e6401 --- /dev/null +++ b/src/test/resources/model-validation/instance-reader/connector-model-name.json @@ -0,0 +1,84 @@ +{ + "model-name": "Test Connector Model Name", + "connector": { + "resource-instance-id": "c7611ebe-c324-48f1-8085-94aef0c12fd", + "resource-version": "1467975776", + "persona-model-id": "connector-widget-id", + "persona-model-version": "v1.0", + "widget-model-id": "example-widget-model-id-val-69486", + "widget-model-version": "v1.0" + }, + "extra-properties": { + + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "model-name": "Test VC Model Name", + "virtual-data-center": { + "vdc-id": "vdc-01", + "vdc-name": "example-vdc-name-val-10107", + "resource-version": "1467975781" + }, + "extra-properties": { + + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "model-name": "Test LL Model Name", + "logical-link": { + "link-name": "example-link-name-val-23759", + "link-type": "example-link-type-val-23759", + "speed-value": "example-speed-value-val-23759", + "speed-units": "example-speed-units-val-23759", + "ip-version": "example-ip-version-val-23759", + "routing-protocol": "example-routing-protocol-val-23759", + "resource-version": "1467975786", + "persona-model-id": "example-persona-model-id-val-23759", + "persona-model-version": "example-persona-model-version-val-23759", + "widget-model-id": "example-widget-model-id-val-23759", + "widget-model-version": "example-widget-model-version-val-23759" + }, + "extra-properties": { + + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "pserver": { + "hostname": "example-hostname-val-79914", + "ptnii-equip-name": "example-ptnii-equip-name-val-79914", + "number-of-cpus": 79914, + "disk-in-gigabytes": 79914, + "ram-in-megabytes": 79914, + "equip-type": "example-equip-type-val-79914", + "equip-vendor": "example-equip-vendor-val-79914", + "equip-model": "example-equip-model-val-79914", + "fqdn": "example-fqdn-val-79914", + "pserver-selflink": "example-pserver-selflink-val-79914", + "ipv4-oam-address": "example-ipv4-oam-address-val-79914", + "serial-number": "example-serial-number-val-79914", + "pserver-id": "example-pserver-id-val-79914", + "internet-topology": "example-internet-topology-val-79914", + "in-maint": true, + "resource-version": "1467994603", + "pserver-name2": "example-pserver-name2-val-79914", + "purpose": "example-purpose-val-79914" + }, + "extra-properties": { + + }, + "inventory-response-items": { + + } + } + ] + } + } + ] + } + } + ] + } +} diff --git a/src/test/resources/model-validation/instance-reader/connector-sibling-inventory-items.json b/src/test/resources/model-validation/instance-reader/connector-sibling-inventory-items.json new file mode 100644 index 0000000..b032966 --- /dev/null +++ b/src/test/resources/model-validation/instance-reader/connector-sibling-inventory-items.json @@ -0,0 +1,118 @@ +{ + "connector": { + "resource-instance-id": "c7611ebe-c324-48f1-8085-94aef0c12fd", + "resource-version": "1467975776", + "persona-model-id": "connector-widget-id", + "persona-model-version": "v1.0", + "widget-model-id": "example-widget-model-id-val-69486", + "widget-model-version": "v1.0" + }, + "extra-properties": { + + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "virtual-data-center": { + "vdc-id": "vdc-01", + "vdc-name": "example-vdc-name-val-10107", + "resource-version": "1467975781" + }, + "extra-properties": { + + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "model-name": "Test LL Model Name", + "logical-link": { + "link-name": "example-link-name-val-23759", + "link-type": "example-link-type-val-23759", + "speed-value": "example-speed-value-val-23759", + "speed-units": "example-speed-units-val-23759", + "ip-version": "example-ip-version-val-23759", + "routing-protocol": "example-routing-protocol-val-23759", + "resource-version": "1467975786", + "persona-model-id": "example-persona-model-id-val-23759", + "persona-model-version": "example-persona-model-version-val-23759", + "widget-model-id": "example-widget-model-id-val-23759", + "widget-model-version": "example-widget-model-version-val-23759" + }, + "extra-properties": { + + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "generic-vnf": { + "vnf-id": "generic-vnf-01", + "vnf-name": "example-vnf-name-val-3501", + "vnf-name2": "example-vnf-name2-val-3501", + "vnf-type": "example-vnf-type-val-3501", + "regional-resource-zone": "example-regional-resource-zone-val-3501", + "prov-status": "example-prov-status-val-3501", + "operational-state": "example-operational-state-val-3501", + "license-key": "example-license-key-val-3501", + "equipment-role": "example-equipment-role-val-3501", + "orchestration-status": "example-orchestration-status-val-3501", + "heat-stack-id": "example-heat-stack-id-val-3501", + "mso-catalog-key": "example-mso-catalog-key-val-3501", + "management-option": "example-management-option-val-3501", + "ipv4-oam-address": "example-ipv4-oam-address-val-3501", + "ipv4-loopback0-address": "example-ipv4-loopback0-address-val-3501", + "nm-lan-v6-address": "example-nm-lan-v6-address-val-3501", + "management-v6-address": "example-management-v6-address-val-3501", + "vcpu": 1817, + "vcpu-units": "example-vcpu-units-val-3501", + "vmemory": 6020, + "vmemory-units": "example-vmemory-units-val-3501", + "vdisk": 5281, + "vdisk-units": "example-vdisk-units-val-3501", + "in-maint": false, + "is-closed-loop-disabled": true, + "resource-version": "1468321711" + }, + "extra-properties": { + + }, + "inventory-response-items": { + + } + }, + { + "pserver": { + "hostname": "example-hostname-val-79914", + "ptnii-equip-name": "example-ptnii-equip-name-val-79914", + "number-of-cpus": 79914, + "disk-in-gigabytes": 79914, + "ram-in-megabytes": 79914, + "equip-type": "example-equip-type-val-79914", + "equip-vendor": "example-equip-vendor-val-79914", + "equip-model": "example-equip-model-val-79914", + "fqdn": "example-fqdn-val-79914", + "pserver-selflink": "example-pserver-selflink-val-79914", + "ipv4-oam-address": "example-ipv4-oam-address-val-79914", + "serial-number": "example-serial-number-val-79914", + "pserver-id": "example-pserver-id-val-79914", + "internet-topology": "example-internet-topology-val-79914", + "in-maint": true, + "resource-version": "1467994603", + "pserver-name2": "example-pserver-name2-val-79914", + "purpose": "example-purpose-val-79914" + }, + "extra-properties": { + + }, + "inventory-response-items": { + + } + } + ] + } + } + ] + } + } + ] + } +} diff --git a/src/test/resources/model-validation/instance-reader/connector.json b/src/test/resources/model-validation/instance-reader/connector.json new file mode 100644 index 0000000..1870dc8 --- /dev/null +++ b/src/test/resources/model-validation/instance-reader/connector.json @@ -0,0 +1,82 @@ +{ + "connector": { + "resource-instance-id": "c7611ebe-c324-48f1-8085-94aef0c12fd", + "resource-version": "1467975776", + "persona-model-id": "connector-widget-id", + "persona-model-version": "v1.0", + "widget-model-id": "example-widget-model-id-val-69486", + "widget-model-version": "v1.0" + }, + "extra-properties": { + + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "virtual-data-center": { + "vdc-id": "vdc-01", + "vdc-name": "example-vdc-name-val-10107", + "resource-version": "1467975781" + }, + "extra-properties": { + + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "model-name": "Test LL Model Name", + "logical-link": { + "link-name": "example-link-name-val-23759", + "link-type": "example-link-type-val-23759", + "speed-value": "example-speed-value-val-23759", + "speed-units": "example-speed-units-val-23759", + "ip-version": "example-ip-version-val-23759", + "routing-protocol": "example-routing-protocol-val-23759", + "resource-version": "1467975786", + "persona-model-id": "example-persona-model-id-val-23759", + "persona-model-version": "example-persona-model-version-val-23759", + "widget-model-id": "example-widget-model-id-val-23759", + "widget-model-version": "example-widget-model-version-val-23759" + }, + "extra-properties": { + + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "pserver": { + "hostname": "example-hostname-val-79914", + "ptnii-equip-name": "example-ptnii-equip-name-val-79914", + "number-of-cpus": 79914, + "disk-in-gigabytes": 79914, + "ram-in-megabytes": 79914, + "equip-type": "example-equip-type-val-79914", + "equip-vendor": "example-equip-vendor-val-79914", + "equip-model": "example-equip-model-val-79914", + "fqdn": "example-fqdn-val-79914", + "pserver-selflink": "example-pserver-selflink-val-79914", + "ipv4-oam-address": "example-ipv4-oam-address-val-79914", + "serial-number": "example-serial-number-val-79914", + "pserver-id": "example-pserver-id-val-79914", + "internet-topology": "example-internet-topology-val-79914", + "in-maint": true, + "resource-version": "1467994603", + "pserver-name2": "example-pserver-name2-val-79914", + "purpose": "example-purpose-val-79914" + }, + "extra-properties": { + + }, + "inventory-response-items": { + + } + } + ] + } + } + ] + } + } + ] + } +} diff --git a/src/test/resources/model-validation/instance-reader/expected-generic-vnf.json b/src/test/resources/model-validation/instance-reader/expected-generic-vnf.json new file mode 100644 index 0000000..ab5bb10 --- /dev/null +++ b/src/test/resources/model-validation/instance-reader/expected-generic-vnf.json @@ -0,0 +1,36 @@ +{ + "generic-vnf": { + "vnf-id": "generic-vnf-01", + "vnf-name": "example-vnf-name-val-3501", + "vnf-name2": "example-vnf-name2-val-3501", + "vnf-type": "example-vnf-type-val-3501", + "regional-resource-zone": "example-regional-resource-zone-val-3501", + "prov-status": "example-prov-status-val-3501", + "operational-state": "example-operational-state-val-3501", + "license-key": "example-license-key-val-3501", + "equipment-role": "example-equipment-role-val-3501", + "orchestration-status": "example-orchestration-status-val-3501", + "heat-stack-id": "example-heat-stack-id-val-3501", + "mso-catalog-key": "example-mso-catalog-key-val-3501", + "management-option": "example-management-option-val-3501", + "ipv4-oam-address": "example-ipv4-oam-address-val-3501", + "ipv4-loopback0-address": "example-ipv4-loopback0-address-val-3501", + "nm-lan-v6-address": "example-nm-lan-v6-address-val-3501", + "management-v6-address": "example-management-v6-address-val-3501", + "vcpu": 1817, + "vcpu-units": "example-vcpu-units-val-3501", + "vmemory": 6020, + "vmemory-units": "example-vmemory-units-val-3501", + "vdisk": 5281, + "vdisk-units": "example-vdisk-units-val-3501", + "in-maint": false, + "is-closed-loop-disabled": true, + "resource-version": "1468321711" + }, + "extra-properties": { + + }, + "inventory-response-items": { + + } +} diff --git a/src/test/resources/model-validation/instance-reader/expected-logical-link.json b/src/test/resources/model-validation/instance-reader/expected-logical-link.json new file mode 100644 index 0000000..90bb7de --- /dev/null +++ b/src/test/resources/model-validation/instance-reader/expected-logical-link.json @@ -0,0 +1,51 @@ +{ + "model-name": "Test LL Model Name", + "logical-link": { + "link-name": "example-link-name-val-23759", + "link-type": "example-link-type-val-23759", + "speed-value": "example-speed-value-val-23759", + "speed-units": "example-speed-units-val-23759", + "ip-version": "example-ip-version-val-23759", + "routing-protocol": "example-routing-protocol-val-23759", + "resource-version": "1467975786", + "persona-model-id": "example-persona-model-id-val-23759", + "persona-model-version": "example-persona-model-version-val-23759", + "widget-model-id": "example-widget-model-id-val-23759", + "widget-model-version": "example-widget-model-version-val-23759" + }, + "extra-properties": { + + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "pserver": { + "hostname": "example-hostname-val-79914", + "ptnii-equip-name": "example-ptnii-equip-name-val-79914", + "number-of-cpus": 79914, + "disk-in-gigabytes": 79914, + "ram-in-megabytes": 79914, + "equip-type": "example-equip-type-val-79914", + "equip-vendor": "example-equip-vendor-val-79914", + "equip-model": "example-equip-model-val-79914", + "fqdn": "example-fqdn-val-79914", + "pserver-selflink": "example-pserver-selflink-val-79914", + "ipv4-oam-address": "example-ipv4-oam-address-val-79914", + "serial-number": "example-serial-number-val-79914", + "pserver-id": "example-pserver-id-val-79914", + "internet-topology": "example-internet-topology-val-79914", + "in-maint": true, + "resource-version": "1467994603", + "pserver-name2": "example-pserver-name2-val-79914", + "purpose": "example-purpose-val-79914" + }, + "extra-properties": { + + }, + "inventory-response-items": { + + } + } + ] + } +} \ No newline at end of file diff --git a/src/test/resources/model-validation/instance-reader/expected-pserver.json b/src/test/resources/model-validation/instance-reader/expected-pserver.json new file mode 100644 index 0000000..8d4b8c5 --- /dev/null +++ b/src/test/resources/model-validation/instance-reader/expected-pserver.json @@ -0,0 +1,28 @@ +{ + "pserver": { + "hostname": "example-hostname-val-79914", + "ptnii-equip-name": "example-ptnii-equip-name-val-79914", + "number-of-cpus": 79914, + "disk-in-gigabytes": 79914, + "ram-in-megabytes": 79914, + "equip-type": "example-equip-type-val-79914", + "equip-vendor": "example-equip-vendor-val-79914", + "equip-model": "example-equip-model-val-79914", + "fqdn": "example-fqdn-val-79914", + "pserver-selflink": "example-pserver-selflink-val-79914", + "ipv4-oam-address": "example-ipv4-oam-address-val-79914", + "serial-number": "example-serial-number-val-79914", + "pserver-id": "example-pserver-id-val-79914", + "internet-topology": "example-internet-topology-val-79914", + "in-maint": true, + "resource-version": "1467994603", + "pserver-name2": "example-pserver-name2-val-79914", + "purpose": "example-purpose-val-79914" + }, + "extra-properties": { + + }, + "inventory-response-items": { + + } +} \ No newline at end of file diff --git a/src/test/resources/model-validation/instance-reader/expected-virtual-data-center-model-name.json b/src/test/resources/model-validation/instance-reader/expected-virtual-data-center-model-name.json new file mode 100644 index 0000000..e72a52f --- /dev/null +++ b/src/test/resources/model-validation/instance-reader/expected-virtual-data-center-model-name.json @@ -0,0 +1,66 @@ +{ + "model-name": "Test VC Model Name", + "virtual-data-center": { + "vdc-id": "vdc-01", + "vdc-name": "example-vdc-name-val-10107", + "resource-version": "1467975781" + }, + "extra-properties": { + + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "model-name": "Test LL Model Name", + "logical-link": { + "link-name": "example-link-name-val-23759", + "link-type": "example-link-type-val-23759", + "speed-value": "example-speed-value-val-23759", + "speed-units": "example-speed-units-val-23759", + "ip-version": "example-ip-version-val-23759", + "routing-protocol": "example-routing-protocol-val-23759", + "resource-version": "1467975786", + "persona-model-id": "example-persona-model-id-val-23759", + "persona-model-version": "example-persona-model-version-val-23759", + "widget-model-id": "example-widget-model-id-val-23759", + "widget-model-version": "example-widget-model-version-val-23759" + }, + "extra-properties": { + + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "pserver": { + "hostname": "example-hostname-val-79914", + "ptnii-equip-name": "example-ptnii-equip-name-val-79914", + "number-of-cpus": 79914, + "disk-in-gigabytes": 79914, + "ram-in-megabytes": 79914, + "equip-type": "example-equip-type-val-79914", + "equip-vendor": "example-equip-vendor-val-79914", + "equip-model": "example-equip-model-val-79914", + "fqdn": "example-fqdn-val-79914", + "pserver-selflink": "example-pserver-selflink-val-79914", + "ipv4-oam-address": "example-ipv4-oam-address-val-79914", + "serial-number": "example-serial-number-val-79914", + "pserver-id": "example-pserver-id-val-79914", + "internet-topology": "example-internet-topology-val-79914", + "in-maint": true, + "resource-version": "1467994603", + "pserver-name2": "example-pserver-name2-val-79914", + "purpose": "example-purpose-val-79914" + }, + "extra-properties": { + + }, + "inventory-response-items": { + + } + } + ] + } + } + ] + } +} \ No newline at end of file diff --git a/src/test/resources/model-validation/instance-reader/expected-virtual-data-center.json b/src/test/resources/model-validation/instance-reader/expected-virtual-data-center.json new file mode 100644 index 0000000..7445823 --- /dev/null +++ b/src/test/resources/model-validation/instance-reader/expected-virtual-data-center.json @@ -0,0 +1,65 @@ +{ + "virtual-data-center": { + "vdc-id": "vdc-01", + "vdc-name": "example-vdc-name-val-10107", + "resource-version": "1467975781" + }, + "extra-properties": { + + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "model-name": "Test LL Model Name", + "logical-link": { + "link-name": "example-link-name-val-23759", + "link-type": "example-link-type-val-23759", + "speed-value": "example-speed-value-val-23759", + "speed-units": "example-speed-units-val-23759", + "ip-version": "example-ip-version-val-23759", + "routing-protocol": "example-routing-protocol-val-23759", + "resource-version": "1467975786", + "persona-model-id": "example-persona-model-id-val-23759", + "persona-model-version": "example-persona-model-version-val-23759", + "widget-model-id": "example-widget-model-id-val-23759", + "widget-model-version": "example-widget-model-version-val-23759" + }, + "extra-properties": { + + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "pserver": { + "hostname": "example-hostname-val-79914", + "ptnii-equip-name": "example-ptnii-equip-name-val-79914", + "number-of-cpus": 79914, + "disk-in-gigabytes": 79914, + "ram-in-megabytes": 79914, + "equip-type": "example-equip-type-val-79914", + "equip-vendor": "example-equip-vendor-val-79914", + "equip-model": "example-equip-model-val-79914", + "fqdn": "example-fqdn-val-79914", + "pserver-selflink": "example-pserver-selflink-val-79914", + "ipv4-oam-address": "example-ipv4-oam-address-val-79914", + "serial-number": "example-serial-number-val-79914", + "pserver-id": "example-pserver-id-val-79914", + "internet-topology": "example-internet-topology-val-79914", + "in-maint": true, + "resource-version": "1467994603", + "pserver-name2": "example-pserver-name2-val-79914", + "purpose": "example-purpose-val-79914" + }, + "extra-properties": { + + }, + "inventory-response-items": { + + } + } + ] + } + } + ] + } +} \ No newline at end of file diff --git a/src/test/resources/model-validation/instance-reader/model-instance-mapping-attributes.json_conf b/src/test/resources/model-validation/instance-reader/model-instance-mapping-attributes.json_conf new file mode 100644 index 0000000..1abe24f --- /dev/null +++ b/src/test/resources/model-validation/instance-reader/model-instance-mapping-attributes.json_conf @@ -0,0 +1,12 @@ +[ + { + "mappingType": "ATTRIBUTE", + "model": { + "value": "metadata/metadatum/metaname" + }, + "instance": { + "origin": "$.inventory-response-item[0]", + "value": "$..extra-properties.metadatum[*].metaname" + } + } +] \ No newline at end of file diff --git a/src/test/resources/model-validation/instance-reader/model-instance-mapping-root-missing.json_conf b/src/test/resources/model-validation/instance-reader/model-instance-mapping-root-missing.json_conf new file mode 100644 index 0000000..c8d5591 --- /dev/null +++ b/src/test/resources/model-validation/instance-reader/model-instance-mapping-root-missing.json_conf @@ -0,0 +1,16 @@ +[ + { + "mappingType" : "RELATIONSHIP", + "model": { + "root": "model-elements/model-element", + "filter": { + "path": "relationship-list/relationship/related-to-property/property-value[../property-key/text()='model.model-type']", + "valid": ["widget"] + }, + "value": "relationship-list/relationship/related-to-property/property-value[../property-key/text()='model.model-name']" + }, + "instance": { + "origin": "$.inventory-response-item[0]" + } + } +] \ No newline at end of file diff --git a/src/test/resources/model-validation/instance-reader/model-instance-mapping-root-unknown.json_conf b/src/test/resources/model-validation/instance-reader/model-instance-mapping-root-unknown.json_conf new file mode 100644 index 0000000..990d0c7 --- /dev/null +++ b/src/test/resources/model-validation/instance-reader/model-instance-mapping-root-unknown.json_conf @@ -0,0 +1,17 @@ +[ + { + "mappingType" : "RELATIONSHIP", + "model": { + "root": "model-elements/model-element", + "filter": { + "path": "relationship-list/relationship/related-to-property/property-value[../property-key/text()='model.model-type']", + "valid": ["widget"] + }, + "value": "relationship-list/relationship/related-to-property/property-value[../property-key/text()='model.model-name']" + }, + "instance": { + "origin": "$.inventory-response-item[0]", + "root": "NOT_KNOWN" + } + } +] \ No newline at end of file diff --git a/src/test/resources/model-validation/instance-reader/model-instance-mapping.json_conf b/src/test/resources/model-validation/instance-reader/model-instance-mapping.json_conf new file mode 100644 index 0000000..917c575 --- /dev/null +++ b/src/test/resources/model-validation/instance-reader/model-instance-mapping.json_conf @@ -0,0 +1,17 @@ +[ + { + "mappingType": "RELATIONSHIP", + "model": { + "root": "model-elements/model-element", + "filter": { + "path": "relationship-list/relationship/related-to-property/property-value[../property-key/text()='model.model-type']", + "valid": ["widget"] + }, + "value": "relationship-list/relationship/related-to-property/property-value[../property-key/text()='model.model-name']" + }, + "instance": { + "origin": "$.inventory-response-item[0]", + "root": "$.inventory-response-items.inventory-response-item[*]" + } + } +] \ No newline at end of file diff --git a/src/test/resources/model-validation/instance-reader/test-validation-service-beans.xml b/src/test/resources/model-validation/instance-reader/test-validation-service-beans.xml new file mode 100644 index 0000000..baf07b2 --- /dev/null +++ b/src/test/resources/model-validation/instance-reader/test-validation-service-beans.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/model-validation/instance-validator/aai-environment.properties b/src/test/resources/model-validation/instance-validator/aai-environment.properties new file mode 100644 index 0000000..c595e7f --- /dev/null +++ b/src/test/resources/model-validation/instance-validator/aai-environment.properties @@ -0,0 +1,31 @@ +# ============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===================================================== + +httpProtocol=file +baseModelURI=src/test/resources/model-validation/instance-validator/all-models.xml + +# the following fields are autowired but will never be used +host= +port= +trustStorePath= +trustStorePassword.x= +keyStorePath= +keyStorePassword.x= +keyManagerFactoryAlgorithm= +keyStoreType= +securityProtocol= +connectionTimeout= +readTimeout= diff --git a/src/test/resources/model-validation/instance-validator/all-models.xml b/src/test/resources/model-validation/instance-validator/all-models.xml new file mode 100644 index 0000000..9acbd2b --- /dev/null +++ b/src/test/resources/model-validation/instance-validator/all-models.xml @@ -0,0 +1,1370 @@ + + + + + 22382f81-70cb-470d-8ab2-3e1b9fad10df + widget + generic-vnf + 6dcdbbc8-23b6-42c3-ac9f-2c0a3fe8cfba + v1.0 + 1466698747 + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/43095b8a-8e9c-4a76-8490-6120140f6804/model-elements/model-element/41e6d6e5-aa69-4d33-b9f2-975bf418d1e3/ + + model.model-invariant-id + 43095b8a-8e9c-4a76-8490-6120140f6804 + + + model-element.model-element-uuid + 41e6d6e5-aa69-4d33-b9f2-975bf418d1e3 + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/0d23052d-8ffe-433e-a25d-da5da027bb7c/model-elements/model-element/17e48d38-e055-4158-ae6b-a170e8a647cd/ + + model.model-invariant-id + 0d23052d-8ffe-433e-a25d-da5da027bb7c + + + model-element.model-element-uuid + 17e48d38-e055-4158-ae6b-a170e8a647cd + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/be890aae-cf27-4b6a-aeae-e6fa4b5ee17f/named-query-elements/named-query-element/1ac142fb-2caf-4f59-975e-8ad7631c301e/named-query-elements/named-query-element/311f1cad-b41c-4833-8b9f-0d54d85f9009/named-query-elements/named-query-element/dc38d8ae-0993-4426-af79-a7aff4a4b4f3/named-query-elements/named-query-element/a97e8ab3-addd-40ee-9d29-3de505a56374/ + + named-query.named-query-uuid + be890aae-cf27-4b6a-aeae-e6fa4b5ee17f + + + named-query-element.named-query-element-uuid + 1ac142fb-2caf-4f59-975e-8ad7631c301e + + + named-query-element.named-query-element-uuid + 311f1cad-b41c-4833-8b9f-0d54d85f9009 + + + named-query-element.named-query-element-uuid + dc38d8ae-0993-4426-af79-a7aff4a4b4f3 + + + named-query-element.named-query-element-uuid + a97e8ab3-addd-40ee-9d29-3de505a56374 + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/55f38763-9820-4fce-82a1-e0fa3c38ed24/named-query-elements/named-query-element/dc799ed9-45a5-4323-a2dc-bd1ec3242499/named-query-elements/named-query-element/97ae5271-9ad9-4815-804d-89af014d5b07/named-query-elements/named-query-element/7d189446-54de-49db-b786-8e946f0aece5/named-query-elements/named-query-element/920399b7-21c1-4e81-8fb9-a3b2283a72ba/named-query-elements/named-query-element/759ef1e4-3eca-4d55-8a9c-a8be31179f47/ + + named-query.named-query-uuid + 55f38763-9820-4fce-82a1-e0fa3c38ed24 + + + named-query-element.named-query-element-uuid + dc799ed9-45a5-4323-a2dc-bd1ec3242499 + + + named-query-element.named-query-element-uuid + 97ae5271-9ad9-4815-804d-89af014d5b07 + + + named-query-element.named-query-element-uuid + 7d189446-54de-49db-b786-8e946f0aece5 + + + named-query-element.named-query-element-uuid + 920399b7-21c1-4e81-8fb9-a3b2283a72ba + + + named-query-element.named-query-element-uuid + 759ef1e4-3eca-4d55-8a9c-a8be31179f47 + + + + + + connector-widget-id + widget + connector + connector-model-id + v2.0 + 1466689944 + + + 43095b8a-8e9c-4a76-8490-6120140f6804 + resource + vSbg + b23fb31b-4c21-45f7-9d92-96ed70e63df1 + v1.0 + 1466698622 + + + 41e6d6e5-aa69-4d33-b9f2-975bf418d1e3 + F + unbounded + + 1466698619 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/22382f81-70cb-470d-8ab2-3e1b9fad10df/ + + model.model-invariant-id + 22382f81-70cb-470d-8ab2-3e1b9fad10df + + + model.model-name + generic-vnf + + + model.model-type + widget + + + + + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/682ae094-0aaa-4381-a55d-bc633c40e4c0/model-elements/model-element/9ce59457-81b7-4f0e-8b72-a044a1be4bdf/model-elements/model-element/6cf69470-ccbf-4034-a37f-f714c135f05c/ + + model.model-invariant-id + 682ae094-0aaa-4381-a55d-bc633c40e4c0 + + + model-element.model-element-uuid + 9ce59457-81b7-4f0e-8b72-a044a1be4bdf + + + model-element.model-element-uuid + 6cf69470-ccbf-4034-a37f-f714c135f05c + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161/model-elements/model-element/c44dbdf9-494e-49c1-b462-74e24e837b22/model-elements/model-element/059db56c-6d72-4023-9fc3-0db29534ddff/ + + model.model-invariant-id + e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161 + + + model-element.model-element-uuid + c44dbdf9-494e-49c1-b462-74e24e837b22 + + + model-element.model-element-uuid + 059db56c-6d72-4023-9fc3-0db29534ddff + + + + + + 523f0645-8182-4c91-9d6a-2f968e923937 + widget + pserver + c277c968-7e2b-4a88-9094-2b8a55dfb9f4 + v1.0 + 1466698757 + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/5ed1c299-4d31-4531-ae43-4bb56f8f10c8/model-elements/model-element/76624fe1-0f28-4e17-ae9f-f0e2bba6d13d/ + + model.model-invariant-id + 5ed1c299-4d31-4531-ae43-4bb56f8f10c8 + + + model-element.model-element-uuid + 76624fe1-0f28-4e17-ae9f-f0e2bba6d13d + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/6614ffae-6e64-4c78-9dea-4d5c0f057ea2/model-elements/model-element/0204aad0-fe13-4f75-b022-f91f245f0e9e/ + + model.model-invariant-id + 6614ffae-6e64-4c78-9dea-4d5c0f057ea2 + + + model-element.model-element-uuid + 0204aad0-fe13-4f75-b022-f91f245f0e9e + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/55f38763-9820-4fce-82a1-e0fa3c38ed24/named-query-elements/named-query-element/dc799ed9-45a5-4323-a2dc-bd1ec3242499/named-query-elements/named-query-element/97ae5271-9ad9-4815-804d-89af014d5b07/named-query-elements/named-query-element/7d189446-54de-49db-b786-8e946f0aece5/named-query-elements/named-query-element/920399b7-21c1-4e81-8fb9-a3b2283a72ba/named-query-elements/named-query-element/a79552d6-20dc-4b9e-b4d4-f29a8a2a8447/ + + named-query.named-query-uuid + 55f38763-9820-4fce-82a1-e0fa3c38ed24 + + + named-query-element.named-query-element-uuid + dc799ed9-45a5-4323-a2dc-bd1ec3242499 + + + named-query-element.named-query-element-uuid + 97ae5271-9ad9-4815-804d-89af014d5b07 + + + named-query-element.named-query-element-uuid + 7d189446-54de-49db-b786-8e946f0aece5 + + + named-query-element.named-query-element-uuid + 920399b7-21c1-4e81-8fb9-a3b2283a72ba + + + named-query-element.named-query-element-uuid + a79552d6-20dc-4b9e-b4d4-f29a8a2a8447 + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/be890aae-cf27-4b6a-aeae-e6fa4b5ee17f/named-query-elements/named-query-element/1ac142fb-2caf-4f59-975e-8ad7631c301e/named-query-elements/named-query-element/311f1cad-b41c-4833-8b9f-0d54d85f9009/named-query-elements/named-query-element/dc38d8ae-0993-4426-af79-a7aff4a4b4f3/named-query-elements/named-query-element/41294247-9f7e-4abf-becd-3bbca6945c09/ + + named-query.named-query-uuid + be890aae-cf27-4b6a-aeae-e6fa4b5ee17f + + + named-query-element.named-query-element-uuid + 1ac142fb-2caf-4f59-975e-8ad7631c301e + + + named-query-element.named-query-element-uuid + 311f1cad-b41c-4833-8b9f-0d54d85f9009 + + + named-query-element.named-query-element-uuid + dc38d8ae-0993-4426-af79-a7aff4a4b4f3 + + + named-query-element.named-query-element-uuid + 41294247-9f7e-4abf-becd-3bbca6945c09 + + + + + + 99469866-95bb-400e-8786-f83e87696725 + widget + virtual-data-center + 3c70c43f-99ed-4476-82f4-92a30616e512 + v1.0 + 1466698727 + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/668464da-6d41-4599-bdbb-2576147b440e/model-elements/model-element/93a37846-b497-490e-bc97-7d130022d6db/model-elements/model-element/200de3d5-c207-47c2-a507-8846ba1d7068/ + + model.model-invariant-id + 668464da-6d41-4599-bdbb-2576147b440e + + + model-element.model-element-uuid + 93a37846-b497-490e-bc97-7d130022d6db + + + model-element.model-element-uuid + 200de3d5-c207-47c2-a507-8846ba1d7068 + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/be890aae-cf27-4b6a-aeae-e6fa4b5ee17f/named-query-elements/named-query-element/1ac142fb-2caf-4f59-975e-8ad7631c301e/named-query-elements/named-query-element/311f1cad-b41c-4833-8b9f-0d54d85f9009/ + + named-query.named-query-uuid + be890aae-cf27-4b6a-aeae-e6fa4b5ee17f + + + named-query-element.named-query-element-uuid + 1ac142fb-2caf-4f59-975e-8ad7631c301e + + + named-query-element.named-query-element-uuid + 311f1cad-b41c-4833-8b9f-0d54d85f9009 + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/55f38763-9820-4fce-82a1-e0fa3c38ed24/named-query-elements/named-query-element/dc799ed9-45a5-4323-a2dc-bd1ec3242499/named-query-elements/named-query-element/97ae5271-9ad9-4815-804d-89af014d5b07/named-query-elements/named-query-element/7d189446-54de-49db-b786-8e946f0aece5/ + + named-query.named-query-uuid + 55f38763-9820-4fce-82a1-e0fa3c38ed24 + + + named-query-element.named-query-element-uuid + dc799ed9-45a5-4323-a2dc-bd1ec3242499 + + + named-query-element.named-query-element-uuid + 97ae5271-9ad9-4815-804d-89af014d5b07 + + + named-query-element.named-query-element-uuid + 7d189446-54de-49db-b786-8e946f0aece5 + + + + + + 5ed1c299-4d31-4531-ae43-4bb56f8f10c8 + resource + ipe + e8f973a5-418a-44f2-9784-159e3e37d708 + v1.0 + 1466698622 + + + 76624fe1-0f28-4e17-ae9f-f0e2bba6d13d + F + unbounded + + 1466698621 + + + b7b48ba6-427b-4d23-ada7-a67ac9e0f84f + F + unbounded + + 1466698621 + + + ebc25508-b2e3-4021-b684-269cfd2b63c0 + T + unbounded + + 1466698621 + + + f610d699-11af-4c13-a918-a89344e4a1bd + T + unbounded + + 1466698621 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/49032ff1-5466-4054-b64b-15395ac10c00/ + + model.model-invariant-id + 49032ff1-5466-4054-b64b-15395ac10c00 + + + model.model-name + vlan + + + model.model-type + widget + + + + + + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/0a706320-b8e7-4b18-9485-fba156ea00cf/ + + model.model-invariant-id + 0a706320-b8e7-4b18-9485-fba156ea00cf + + + model.model-name + l-interface + + + model.model-type + widget + + + + + + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/3d9f4b1d-360c-4862-9623-703b150157ce/ + + model.model-invariant-id + 3d9f4b1d-360c-4862-9623-703b150157ce + + + model.model-name + p-interface + + + model.model-type + widget + + + + + + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/523f0645-8182-4c91-9d6a-2f968e923937/ + + model.model-invariant-id + 523f0645-8182-4c91-9d6a-2f968e923937 + + + model.model-name + pserver + + + model.model-type + widget + + + + + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/682ae094-0aaa-4381-a55d-bc633c40e4c0/model-elements/model-element/9ce59457-81b7-4f0e-8b72-a044a1be4bdf/model-elements/model-element/304ddca5-47cd-49ec-a2d7-1ce17baa5b70/ + + model.model-invariant-id + 682ae094-0aaa-4381-a55d-bc633c40e4c0 + + + model-element.model-element-uuid + 9ce59457-81b7-4f0e-8b72-a044a1be4bdf + + + model-element.model-element-uuid + 304ddca5-47cd-49ec-a2d7-1ce17baa5b70 + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161/model-elements/model-element/c44dbdf9-494e-49c1-b462-74e24e837b22/model-elements/model-element/193ec825-44ce-4416-85ac-20a6b6663575/ + + model.model-invariant-id + e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161 + + + model-element.model-element-uuid + c44dbdf9-494e-49c1-b462-74e24e837b22 + + + model-element.model-element-uuid + 193ec825-44ce-4416-85ac-20a6b6663575 + + + + + + 668464da-6d41-4599-bdbb-2576147b440e + resource + WAN Connector v0.1 + dc700a83-c507-47d9-b775-1fdfcdd5f9eb + 0.1 + Connects a customer vpn to the border elements of a vendor product + 1466698623 + + + 93a37846-b497-490e-bc97-7d130022d6db + T + unbounded + + 1466698622 + + + 200de3d5-c207-47c2-a507-8846ba1d7068 + T + unbounded + + 1466698622 + + + 7ccfe6b5-6566-4b44-83d3-b79f5de7a87b + T + unbounded + + 1466698622 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161/ + + model.model-invariant-id + e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161 + + + model.model-name + VL ELAN + + + model.model-type + resource + + + + + + dfd30146-74f4-49e9-bad6-019d413352ac + T + unbounded + + 1466698622 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/682ae094-0aaa-4381-a55d-bc633c40e4c0/ + + model.model-invariant-id + 682ae094-0aaa-4381-a55d-bc633c40e4c0 + + + model.model-name + vLAN on a Physical Wire + + + model.model-type + resource + + + + + + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/99469866-95bb-400e-8786-f83e87696725/ + + model.model-invariant-id + 99469866-95bb-400e-8786-f83e87696725 + + + model.model-name + virtual-data-center + + + model.model-type + widget + + + + + + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/15f47352-28b7-4bbd-9828-393eaf79eeff/ + + model.model-invariant-id + 15f47352-28b7-4bbd-9828-393eaf79eeff + + + model.model-name + connector + + + model.model-type + widget + + + + + + + + product + product-value-1 + 1466698623 + + + vpn-id + vpn-id-value-1 + 1466698623 + + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/460c6de2-a92b-4e3b-9ba3-538ce782b2fa/model-elements/model-element/71b825be-febf-45f7-b86a-ca0e3de19c90/model-elements/model-element/986167cb-57d3-4aad-8896-784a22c5289c/ + + model.model-invariant-id + 460c6de2-a92b-4e3b-9ba3-538ce782b2fa + + + model-element.model-element-uuid + 71b825be-febf-45f7-b86a-ca0e3de19c90 + + + model-element.model-element-uuid + 986167cb-57d3-4aad-8896-784a22c5289c + + + + + + 460c6de2-a92b-4e3b-9ba3-538ce782b2fa + service + WAN Bonding v0.1 + 0ee8c1bc-7cbd-4b0a-a1ac-e9999255abc1 + 0.1 + service-instance of the wan object + 1466698623 + + + 71b825be-febf-45f7-b86a-ca0e3de19c90 + T + unbounded + + 1466698623 + + + 986167cb-57d3-4aad-8896-784a22c5289c + T + unbounded + + 1466698623 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/668464da-6d41-4599-bdbb-2576147b440e/ + + model.model-invariant-id + 668464da-6d41-4599-bdbb-2576147b440e + + + model.model-name + WAN Connector v0.1 + + + model.model-type + resource + + + + + + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/46b92144-923a-4d20-b85a-3cbd847668a9/ + + model.model-invariant-id + 46b92144-923a-4d20-b85a-3cbd847668a9 + + + model.model-name + service-instance + + + model.model-type + widget + + + + + + + + b + product + 1466698623 + + + a + vpn-id + 1466698623 + + + + + generic-vnf-widget-id + widget + generic-vnf + generic-vnf-model-id + v1.0 + 1466624623 + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/vMME-resource-id/model-elements/model-element/af4b6df2-65d0-4d10-b25e-02206799e1fa/ + + model.model-invariant-id + vMME-resource-id + + + model-element.model-element-uuid + af4b6df2-65d0-4d10-b25e-02206799e1fa + + + + + + 6614ffae-6e64-4c78-9dea-4d5c0f057ea2 + resource + pBgf + 9038f1d7-61f2-49ef-a61d-ace468d4ab32 + v1.0 + 1466698622 + + + 0204aad0-fe13-4f75-b022-f91f245f0e9e + F + unbounded + + 1466698620 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/523f0645-8182-4c91-9d6a-2f968e923937/ + + model.model-invariant-id + 523f0645-8182-4c91-9d6a-2f968e923937 + + + model.model-name + pserver + + + model.model-type + widget + + + + + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161/model-elements/model-element/c44dbdf9-494e-49c1-b462-74e24e837b22/model-elements/model-element/ad161a89-ef32-4b2c-b86d-7fbb7a251571/ + + model.model-invariant-id + e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161 + + + model-element.model-element-uuid + c44dbdf9-494e-49c1-b462-74e24e837b22 + + + model-element.model-element-uuid + ad161a89-ef32-4b2c-b86d-7fbb7a251571 + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/682ae094-0aaa-4381-a55d-bc633c40e4c0/model-elements/model-element/9ce59457-81b7-4f0e-8b72-a044a1be4bdf/model-elements/model-element/d0d50aad-bb97-4865-a3bb-72dbf41be50b/ + + model.model-invariant-id + 682ae094-0aaa-4381-a55d-bc633c40e4c0 + + + model-element.model-element-uuid + 9ce59457-81b7-4f0e-8b72-a044a1be4bdf + + + model-element.model-element-uuid + d0d50aad-bb97-4865-a3bb-72dbf41be50b + + + + + + 15f47352-28b7-4bbd-9828-393eaf79eeff + widget + connector + 4f0dbd2d-b667-4d19-a563-84a764e62fa7 + v1.0 + 1466698717 + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/55f38763-9820-4fce-82a1-e0fa3c38ed24/named-query-elements/named-query-element/dc799ed9-45a5-4323-a2dc-bd1ec3242499/named-query-elements/named-query-element/97ae5271-9ad9-4815-804d-89af014d5b07/ + + named-query.named-query-uuid + 55f38763-9820-4fce-82a1-e0fa3c38ed24 + + + named-query-element.named-query-element-uuid + dc799ed9-45a5-4323-a2dc-bd1ec3242499 + + + named-query-element.named-query-element-uuid + 97ae5271-9ad9-4815-804d-89af014d5b07 + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/668464da-6d41-4599-bdbb-2576147b440e/model-elements/model-element/93a37846-b497-490e-bc97-7d130022d6db/ + + model.model-invariant-id + 668464da-6d41-4599-bdbb-2576147b440e + + + model-element.model-element-uuid + 93a37846-b497-490e-bc97-7d130022d6db + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/be890aae-cf27-4b6a-aeae-e6fa4b5ee17f/named-query-elements/named-query-element/1ac142fb-2caf-4f59-975e-8ad7631c301e/ + + named-query.named-query-uuid + be890aae-cf27-4b6a-aeae-e6fa4b5ee17f + + + named-query-element.named-query-element-uuid + 1ac142fb-2caf-4f59-975e-8ad7631c301e + + + + + + 682ae094-0aaa-4381-a55d-bc633c40e4c0 + resource + vLAN on a Physical Wire + 32bee148-2cae-4f3d-a42e-22c9e4f078a2 + 1 + An l2-bridge used by a wan connector connects an ipe to a BGF + 1466698622 + + + 9ce59457-81b7-4f0e-8b72-a044a1be4bdf + T + unbounded + + 1466698622 + + + d0d50aad-bb97-4865-a3bb-72dbf41be50b + T + unbounded + + 1466698622 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/6614ffae-6e64-4c78-9dea-4d5c0f057ea2/ + + model.model-invariant-id + 6614ffae-6e64-4c78-9dea-4d5c0f057ea2 + + + model.model-name + pBgf + + + model.model-type + resource + + + + + + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/fa01ef50-bbb5-49d4-91d1-ebbda9816e01/ + + model.model-invariant-id + fa01ef50-bbb5-49d4-91d1-ebbda9816e01 + + + model.model-name + logical-link + + + model.model-type + widget + + + + + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/668464da-6d41-4599-bdbb-2576147b440e/model-elements/model-element/93a37846-b497-490e-bc97-7d130022d6db/model-elements/model-element/200de3d5-c207-47c2-a507-8846ba1d7068/model-elements/model-element/dfd30146-74f4-49e9-bad6-019d413352ac/ + + model.model-invariant-id + 668464da-6d41-4599-bdbb-2576147b440e + + + model-element.model-element-uuid + 93a37846-b497-490e-bc97-7d130022d6db + + + model-element.model-element-uuid + 200de3d5-c207-47c2-a507-8846ba1d7068 + + + model-element.model-element-uuid + dfd30146-74f4-49e9-bad6-019d413352ac + + + + + + 46b92144-923a-4d20-b85a-3cbd847668a9 + widget + service-instance + 82194af1-3c2c-485a-8f44-420e22a9eaa4 + v1.0 + 1466698646 + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/55f38763-9820-4fce-82a1-e0fa3c38ed24/named-query-elements/named-query-element/dc799ed9-45a5-4323-a2dc-bd1ec3242499/ + + named-query.named-query-uuid + 55f38763-9820-4fce-82a1-e0fa3c38ed24 + + + named-query-element.named-query-element-uuid + dc799ed9-45a5-4323-a2dc-bd1ec3242499 + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/460c6de2-a92b-4e3b-9ba3-538ce782b2fa/model-elements/model-element/71b825be-febf-45f7-b86a-ca0e3de19c90/ + + model.model-invariant-id + 460c6de2-a92b-4e3b-9ba3-538ce782b2fa + + + model-element.model-element-uuid + 71b825be-febf-45f7-b86a-ca0e3de19c90 + + + + + + 3d9f4b1d-360c-4862-9623-703b150157ce + widget + p-interface + 479f5f13-51d9-4ccb-bddf-f554f1af0cfc + v1.0 + 1466698621 + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/5ed1c299-4d31-4531-ae43-4bb56f8f10c8/model-elements/model-element/76624fe1-0f28-4e17-ae9f-f0e2bba6d13d/model-elements/model-element/b7b48ba6-427b-4d23-ada7-a67ac9e0f84f/ + + model.model-invariant-id + 5ed1c299-4d31-4531-ae43-4bb56f8f10c8 + + + model-element.model-element-uuid + 76624fe1-0f28-4e17-ae9f-f0e2bba6d13d + + + model-element.model-element-uuid + b7b48ba6-427b-4d23-ada7-a67ac9e0f84f + + + + + + 0d23052d-8ffe-433e-a25d-da5da027bb7c + resource + vDbe + fe8aac07-ce6c-4f9f-aa0d-b561c77da9e8 + v1.0 + 1466698622 + + + 17e48d38-e055-4158-ae6b-a170e8a647cd + F + unbounded + + 1466698618 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/22382f81-70cb-470d-8ab2-3e1b9fad10df/ + + model.model-invariant-id + 22382f81-70cb-470d-8ab2-3e1b9fad10df + + + model.model-name + generic-vnf + + + model.model-type + widget + + + + + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/682ae094-0aaa-4381-a55d-bc633c40e4c0/model-elements/model-element/9ce59457-81b7-4f0e-8b72-a044a1be4bdf/model-elements/model-element/1d73a0dc-e7f6-4b6d-9450-5dda720d1a7f/ + + model.model-invariant-id + 682ae094-0aaa-4381-a55d-bc633c40e4c0 + + + model-element.model-element-uuid + 9ce59457-81b7-4f0e-8b72-a044a1be4bdf + + + model-element.model-element-uuid + 1d73a0dc-e7f6-4b6d-9450-5dda720d1a7f + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161/model-elements/model-element/c44dbdf9-494e-49c1-b462-74e24e837b22/model-elements/model-element/a1b205ea-17bb-442b-83a3-38b4e0fcb099/ + + model.model-invariant-id + e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161 + + + model-element.model-element-uuid + c44dbdf9-494e-49c1-b462-74e24e837b22 + + + model-element.model-element-uuid + a1b205ea-17bb-442b-83a3-38b4e0fcb099 + + + + + + vMME-resource-id + resource + vMME + vMME-model-id + v1.0 + 1466624623 + + + af4b6df2-65d0-4d10-b25e-02206799e1fa + true + unbounded + + 1466624623 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/generic-vnf-widget-id/ + + model.model-invariant-id + generic-vnf-widget-id + + + model.model-name + generic-vnf + + + model.model-type + widget + + + + + + + + fa01ef50-bbb5-49d4-91d1-ebbda9816e01 + widget + logical-link + 8742d5b3-ee98-4165-8bd5-fc012a7885b9 + v1.0 + 1466698737 + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161/model-elements/model-element/c44dbdf9-494e-49c1-b462-74e24e837b22/ + + model.model-invariant-id + e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161 + + + model-element.model-element-uuid + c44dbdf9-494e-49c1-b462-74e24e837b22 + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/682ae094-0aaa-4381-a55d-bc633c40e4c0/model-elements/model-element/9ce59457-81b7-4f0e-8b72-a044a1be4bdf/ + + model.model-invariant-id + 682ae094-0aaa-4381-a55d-bc633c40e4c0 + + + model-element.model-element-uuid + 9ce59457-81b7-4f0e-8b72-a044a1be4bdf + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/55f38763-9820-4fce-82a1-e0fa3c38ed24/named-query-elements/named-query-element/dc799ed9-45a5-4323-a2dc-bd1ec3242499/named-query-elements/named-query-element/97ae5271-9ad9-4815-804d-89af014d5b07/named-query-elements/named-query-element/7d189446-54de-49db-b786-8e946f0aece5/named-query-elements/named-query-element/920399b7-21c1-4e81-8fb9-a3b2283a72ba/ + + named-query.named-query-uuid + 55f38763-9820-4fce-82a1-e0fa3c38ed24 + + + named-query-element.named-query-element-uuid + dc799ed9-45a5-4323-a2dc-bd1ec3242499 + + + named-query-element.named-query-element-uuid + 97ae5271-9ad9-4815-804d-89af014d5b07 + + + named-query-element.named-query-element-uuid + 7d189446-54de-49db-b786-8e946f0aece5 + + + named-query-element.named-query-element-uuid + 920399b7-21c1-4e81-8fb9-a3b2283a72ba + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/be890aae-cf27-4b6a-aeae-e6fa4b5ee17f/named-query-elements/named-query-element/1ac142fb-2caf-4f59-975e-8ad7631c301e/named-query-elements/named-query-element/311f1cad-b41c-4833-8b9f-0d54d85f9009/named-query-elements/named-query-element/dc38d8ae-0993-4426-af79-a7aff4a4b4f3/ + + named-query.named-query-uuid + be890aae-cf27-4b6a-aeae-e6fa4b5ee17f + + + named-query-element.named-query-element-uuid + 1ac142fb-2caf-4f59-975e-8ad7631c301e + + + named-query-element.named-query-element-uuid + 311f1cad-b41c-4833-8b9f-0d54d85f9009 + + + named-query-element.named-query-element-uuid + dc38d8ae-0993-4426-af79-a7aff4a4b4f3 + + + + + + 0a706320-b8e7-4b18-9485-fba156ea00cf + widget + l-interface + d9131b0d-698f-4297-8699-af0a3ac7ebdc + v1.0 + 1466698767 + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/5ed1c299-4d31-4531-ae43-4bb56f8f10c8/model-elements/model-element/76624fe1-0f28-4e17-ae9f-f0e2bba6d13d/model-elements/model-element/b7b48ba6-427b-4d23-ada7-a67ac9e0f84f/model-elements/model-element/ebc25508-b2e3-4021-b684-269cfd2b63c0/ + + model.model-invariant-id + 5ed1c299-4d31-4531-ae43-4bb56f8f10c8 + + + model-element.model-element-uuid + 76624fe1-0f28-4e17-ae9f-f0e2bba6d13d + + + model-element.model-element-uuid + b7b48ba6-427b-4d23-ada7-a67ac9e0f84f + + + model-element.model-element-uuid + ebc25508-b2e3-4021-b684-269cfd2b63c0 + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/be890aae-cf27-4b6a-aeae-e6fa4b5ee17f/named-query-elements/named-query-element/1ac142fb-2caf-4f59-975e-8ad7631c301e/named-query-elements/named-query-element/311f1cad-b41c-4833-8b9f-0d54d85f9009/named-query-elements/named-query-element/dc38d8ae-0993-4426-af79-a7aff4a4b4f3/named-query-elements/named-query-element/29ac58b9-37fa-4d6a-9d2e-29f33e1e3b7a/ + + named-query.named-query-uuid + be890aae-cf27-4b6a-aeae-e6fa4b5ee17f + + + named-query-element.named-query-element-uuid + 1ac142fb-2caf-4f59-975e-8ad7631c301e + + + named-query-element.named-query-element-uuid + 311f1cad-b41c-4833-8b9f-0d54d85f9009 + + + named-query-element.named-query-element-uuid + dc38d8ae-0993-4426-af79-a7aff4a4b4f3 + + + named-query-element.named-query-element-uuid + 29ac58b9-37fa-4d6a-9d2e-29f33e1e3b7a + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/55f38763-9820-4fce-82a1-e0fa3c38ed24/named-query-elements/named-query-element/dc799ed9-45a5-4323-a2dc-bd1ec3242499/named-query-elements/named-query-element/97ae5271-9ad9-4815-804d-89af014d5b07/named-query-elements/named-query-element/7d189446-54de-49db-b786-8e946f0aece5/named-query-elements/named-query-element/920399b7-21c1-4e81-8fb9-a3b2283a72ba/named-query-elements/named-query-element/eda1554f-3eff-4195-9185-bcbc4f75826f/ + + named-query.named-query-uuid + 55f38763-9820-4fce-82a1-e0fa3c38ed24 + + + named-query-element.named-query-element-uuid + dc799ed9-45a5-4323-a2dc-bd1ec3242499 + + + named-query-element.named-query-element-uuid + 97ae5271-9ad9-4815-804d-89af014d5b07 + + + named-query-element.named-query-element-uuid + 7d189446-54de-49db-b786-8e946f0aece5 + + + named-query-element.named-query-element-uuid + 920399b7-21c1-4e81-8fb9-a3b2283a72ba + + + named-query-element.named-query-element-uuid + eda1554f-3eff-4195-9185-bcbc4f75826f + + + + + + 49032ff1-5466-4054-b64b-15395ac10c00 + widget + vlan + 2febb0bc-b776-45b3-af50-75a578a8a4c4 + v1.0 + 1466698621 + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/5ed1c299-4d31-4531-ae43-4bb56f8f10c8/model-elements/model-element/76624fe1-0f28-4e17-ae9f-f0e2bba6d13d/model-elements/model-element/b7b48ba6-427b-4d23-ada7-a67ac9e0f84f/model-elements/model-element/ebc25508-b2e3-4021-b684-269cfd2b63c0/model-elements/model-element/f610d699-11af-4c13-a918-a89344e4a1bd/ + + model.model-invariant-id + 5ed1c299-4d31-4531-ae43-4bb56f8f10c8 + + + model-element.model-element-uuid + 76624fe1-0f28-4e17-ae9f-f0e2bba6d13d + + + model-element.model-element-uuid + b7b48ba6-427b-4d23-ada7-a67ac9e0f84f + + + model-element.model-element-uuid + ebc25508-b2e3-4021-b684-269cfd2b63c0 + + + model-element.model-element-uuid + f610d699-11af-4c13-a918-a89344e4a1bd + + + + + + e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161 + resource + VL ELAN + 932518e5-4260-4cc4-8038-df604a367f85 + 1 + An l2-bridge used by a wan connector connects an ipe to a SBG or DBE + 1466698622 + + + c44dbdf9-494e-49c1-b462-74e24e837b22 + T + unbounded + + 1466698621 + + + a1b205ea-17bb-442b-83a3-38b4e0fcb099 + T + unbounded + + 1466698621 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/0d23052d-8ffe-433e-a25d-da5da027bb7c/ + + model.model-invariant-id + 0d23052d-8ffe-433e-a25d-da5da027bb7c + + + model.model-name + vDbe + + + model.model-type + resource + + + + + + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/fa01ef50-bbb5-49d4-91d1-ebbda9816e01/ + + model.model-invariant-id + fa01ef50-bbb5-49d4-91d1-ebbda9816e01 + + + model.model-name + logical-link + + + model.model-type + widget + + + + + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/668464da-6d41-4599-bdbb-2576147b440e/model-elements/model-element/93a37846-b497-490e-bc97-7d130022d6db/model-elements/model-element/200de3d5-c207-47c2-a507-8846ba1d7068/model-elements/model-element/7ccfe6b5-6566-4b44-83d3-b79f5de7a87b/ + + model.model-invariant-id + 668464da-6d41-4599-bdbb-2576147b440e + + + model-element.model-element-uuid + 93a37846-b497-490e-bc97-7d130022d6db + + + model-element.model-element-uuid + 200de3d5-c207-47c2-a507-8846ba1d7068 + + + model-element.model-element-uuid + 7ccfe6b5-6566-4b44-83d3-b79f5de7a87b + + + + + \ No newline at end of file diff --git a/src/test/resources/model-validation/instance-validator/connector-instance-errors.json b/src/test/resources/model-validation/instance-validator/connector-instance-errors.json new file mode 100644 index 0000000..b932344 --- /dev/null +++ b/src/test/resources/model-validation/instance-validator/connector-instance-errors.json @@ -0,0 +1,113 @@ +{ + "cambria.partition": "AAI", + "event-header": { + "id": "20160525162737-61c49d41-5338-4755-af54-06cee9fe4acf", + "timestamp": "20160525-16:27:37:353", + "source-name": "RO", + "domain": "devINT1", + "sequence-number": "0", + "severity": "NORMAL", + "event-type": "AAI-EVENT", + "version": "v9", + "action": "CREATE", + "entity-type": "connector", + "top-entity-type": "connector", + "entity-link": "https://dummy-host.onap.org:8443/aai/v9/business/connectors/connector/c7611ebe-c324-48f1-8085-94aef0c12fd" + }, + "entity": { + "inventory-response-item": [ + { + "connector": { + "resource-instance-id": "c7611ebe-c324-48f1-8085-94aef0c12fd", + "resource-version": "1467975776", + "persona-model-id": "connector-widget-id", + "persona-model-version": "v1.0", + "widget-model-id": "example-widget-model-id-val-69486", + "widget-model-version": "v1.0" + }, + "extra-properties": { + "metadatum": [ + { + "metaname": "vpn-id", + "metaval": "vpn-id-value-1", + "resource-version": "1465990410" + }, + { + "metaname": "unexpected", + "metaval": "unexpected-value-1", + "resource-version": "1465990410" + } + ] + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "virtual-data-center": { + "vdc-id": "vdc-01", + "vdc-name": "example-vdc-name-val-10107", + "resource-version": "1467975781" + }, + "extra-properties": { + + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "logical-link": { + "link-name": "example-link-name-val-23759", + "link-type": "example-link-type-val-23759", + "speed-value": "example-speed-value-val-23759", + "speed-units": "example-speed-units-val-23759", + "ip-version": "example-ip-version-val-23759", + "routing-protocol": "example-routing-protocol-val-23759", + "resource-version": "1467975786", + "persona-model-id": "example-persona-model-id-val-23759", + "persona-model-version": "example-persona-model-version-val-23759", + "widget-model-id": "example-widget-model-id-val-23759", + "widget-model-version": "example-widget-model-version-val-23759" + }, + "extra-properties": { + + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "pserver": { + "hostname": "example-hostname-val-79914", + "ptnii-equip-name": "example-ptnii-equip-name-val-79914", + "number-of-cpus": 79914, + "disk-in-gigabytes": 79914, + "ram-in-megabytes": 79914, + "equip-type": "example-equip-type-val-79914", + "equip-vendor": "example-equip-vendor-val-79914", + "equip-model": "example-equip-model-val-79914", + "fqdn": "example-fqdn-val-79914", + "pserver-selflink": "example-pserver-selflink-val-79914", + "ipv4-oam-address": "example-ipv4-oam-address-val-79914", + "serial-number": "example-serial-number-val-79914", + "pserver-id": "example-pserver-id-val-79914", + "internet-topology": "example-internet-topology-val-79914", + "in-maint": true, + "resource-version": "1467994603", + "pserver-name2": "example-pserver-name2-val-79914", + "purpose": "example-purpose-val-79914" + }, + "extra-properties": { + + }, + "inventory-response-items": { + + } + } + ] + } + } + ] + } + } + ] + } + } + ] + } +} \ No newline at end of file diff --git a/src/test/resources/model-validation/instance-validator/connector-instance-multiple-missing-attrs.json b/src/test/resources/model-validation/instance-validator/connector-instance-multiple-missing-attrs.json new file mode 100644 index 0000000..5b92692 --- /dev/null +++ b/src/test/resources/model-validation/instance-validator/connector-instance-multiple-missing-attrs.json @@ -0,0 +1,50 @@ +{ + "cambria.partition": "AAI", + "event-header": { + "id": "20160525162737-61c49d41-5338-4755-af54-06cee9fe4acf", + "timestamp": "20160525-16:27:37:353", + "source-name": "RO", + "domain": "devINT1", + "sequence-number": "0", + "severity": "NORMAL", + "event-type": "AAI-EVENT", + "version": "v9", + "action": "CREATE", + "entity-type": "connector", + "top-entity-type": "connector", + "entity-link": "https://dummy-host.onap.org:8443/aai/v9/business/connectors/connector/c7611ebe-c324-48f1-8085-94aef0c12fd" + }, + "entity": { + "inventory-response-item": [ + { + "connector": { + "resource-instance-id": "c7611ebe-c324-48f1-8085-94aef0c12fd", + "resource-version": "1467975776", + "persona-model-id": "connector-widget-id", + "persona-model-version": "v1.0", + "widget-model-id": "example-widget-model-id-val-69486", + "widget-model-version": "v1.0" + }, + "extra-properties": { + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "virtual-data-center": { + "vdc-id": "vdc-01", + "vdc-name": "example-vdc-name-val-10107", + "resource-version": "1467975781" + }, + "extra-properties": { + + }, + "inventory-response-items": { + + } + } + ] + } + } + ] + } +} \ No newline at end of file diff --git a/src/test/resources/model-validation/instance-validator/connector-instance-multiple-unexpected-attrs.json b/src/test/resources/model-validation/instance-validator/connector-instance-multiple-unexpected-attrs.json new file mode 100644 index 0000000..254433b --- /dev/null +++ b/src/test/resources/model-validation/instance-validator/connector-instance-multiple-unexpected-attrs.json @@ -0,0 +1,72 @@ +{ + "cambria.partition": "AAI", + "event-header": { + "id": "20160525162737-61c49d41-5338-4755-af54-06cee9fe4acf", + "timestamp": "20160525-16:27:37:353", + "source-name": "RO", + "domain": "devINT1", + "sequence-number": "0", + "severity": "NORMAL", + "event-type": "AAI-EVENT", + "version": "v9", + "action": "CREATE", + "entity-type": "connector", + "top-entity-type": "connector", + "entity-link": "https://dummy-host.onap.org:8443/aai/v9/business/connectors/connector/c7611ebe-c324-48f1-8085-94aef0c12fd" + }, + "entity": { + "inventory-response-item": [ + { + "connector": { + "resource-instance-id": "c7611ebe-c324-48f1-8085-94aef0c12fd", + "resource-version": "1467975776", + "persona-model-id": "connector-widget-id", + "persona-model-version": "v1.0", + "widget-model-id": "example-widget-model-id-val-69486", + "widget-model-version": "v1.0" + }, + "extra-properties": { + "metadatum": [ + { + "metaname": "vpn-id", + "metaval": "vpn-id-value-1", + "resource-version": "1465990410" + }, + { + "metaname": "product", + "metaval": "product-value-1", + "resource-version": "1465990410" + }, + { + "metaname": "city", + "metaval": "city-value-1", + "resource-version": "1465990410" + }, + { + "metaname": "state", + "metaval": "state-value-1", + "resource-version": "1465990410" + } + ] + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "virtual-data-center": { + "vdc-id": "vdc-01", + "vdc-name": "example-vdc-name-val-10107", + "resource-version": "1467975781" + }, + "extra-properties": { + + }, + "inventory-response-items": { + + } + } + ] + } + } + ] + } +} \ No newline at end of file diff --git a/src/test/resources/model-validation/instance-validator/connector-instance-no-model-id.json b/src/test/resources/model-validation/instance-validator/connector-instance-no-model-id.json new file mode 100644 index 0000000..8d2664d --- /dev/null +++ b/src/test/resources/model-validation/instance-validator/connector-instance-no-model-id.json @@ -0,0 +1,111 @@ +{ + "cambria.partition": "AAI", + "event-header": { + "id": "20160525162737-61c49d41-5338-4755-af54-06cee9fe4acf", + "timestamp": "20160525-16:27:37:353", + "source-name": "RO", + "domain": "devINT1", + "sequence-number": "0", + "severity": "NORMAL", + "event-type": "AAI-EVENT", + "version": "v9", + "action": "CREATE", + "entity-type": "connector", + "top-entity-type": "connector", + "entity-link": "https://dummy-host.onap.org:8443/aai/v9/business/connectors/connector/c7611ebe-c324-48f1-8085-94aef0c12fd" + }, + "entity": { + "inventory-response-item": [ + { + "connector": { + "resource-instance-id": "c7611ebe-c324-48f1-8085-94aef0c12fd", + "resource-version": "1467975776", + "widget-model-id": "example-widget-model-id-val-69486", + "widget-model-version": "v1.0" + }, + "extra-properties": { + "metadatum": [ + { + "metaname": "vpn-id", + "metaval": "vpn-id-value-1", + "resource-version": "1465990410" + }, + { + "metaname": "unexpected", + "metaval": "unexpected-value-1", + "resource-version": "1465990410" + } + ] + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "virtual-data-center": { + "vdc-id": "vdc-01", + "vdc-name": "example-vdc-name-val-10107", + "resource-version": "1467975781" + }, + "extra-properties": { + + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "logical-link": { + "link-name": "example-link-name-val-23759", + "link-type": "example-link-type-val-23759", + "speed-value": "example-speed-value-val-23759", + "speed-units": "example-speed-units-val-23759", + "ip-version": "example-ip-version-val-23759", + "routing-protocol": "example-routing-protocol-val-23759", + "resource-version": "1467975786", + "persona-model-id": "example-persona-model-id-val-23759", + "persona-model-version": "example-persona-model-version-val-23759", + "widget-model-id": "example-widget-model-id-val-23759", + "widget-model-version": "example-widget-model-version-val-23759" + }, + "extra-properties": { + + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "pserver": { + "hostname": "example-hostname-val-79914", + "ptnii-equip-name": "example-ptnii-equip-name-val-79914", + "number-of-cpus": 79914, + "disk-in-gigabytes": 79914, + "ram-in-megabytes": 79914, + "equip-type": "example-equip-type-val-79914", + "equip-vendor": "example-equip-vendor-val-79914", + "equip-model": "example-equip-model-val-79914", + "fqdn": "example-fqdn-val-79914", + "pserver-selflink": "example-pserver-selflink-val-79914", + "ipv4-oam-address": "example-ipv4-oam-address-val-79914", + "serial-number": "example-serial-number-val-79914", + "pserver-id": "example-pserver-id-val-79914", + "internet-topology": "example-internet-topology-val-79914", + "in-maint": true, + "resource-version": "1467994603", + "pserver-name2": "example-pserver-name2-val-79914", + "purpose": "example-purpose-val-79914" + }, + "extra-properties": { + + }, + "inventory-response-items": { + + } + } + ] + } + } + ] + } + } + ] + } + } + ] + } +} \ No newline at end of file diff --git a/src/test/resources/model-validation/instance-validator/connector-instance-success.json b/src/test/resources/model-validation/instance-validator/connector-instance-success.json new file mode 100644 index 0000000..629321c --- /dev/null +++ b/src/test/resources/model-validation/instance-validator/connector-instance-success.json @@ -0,0 +1,62 @@ +{ + "cambria.partition": "AAI", + "event-header": { + "id": "20160525162737-61c49d41-5338-4755-af54-06cee9fe4acf", + "timestamp": "20160525-16:27:37:353", + "source-name": "RO", + "domain": "devINT1", + "sequence-number": "0", + "severity": "NORMAL", + "event-type": "AAI-EVENT", + "version": "v9", + "action": "CREATE", + "entity-type": "connector", + "top-entity-type": "connector", + "entity-link": "https://dummy-host.onap.org:8443/aai/v9/business/connectors/connector/c7611ebe-c324-48f1-8085-94aef0c12fd" + }, + "entity": { + "inventory-response-item": [ + { + "connector": { + "resource-instance-id": "c7611ebe-c324-48f1-8085-94aef0c12fd", + "resource-version": "1467975776", + "persona-model-id": "connector-widget-id", + "persona-model-version": "v1.0", + "widget-model-id": "example-widget-model-id-val-69486", + "widget-model-version": "v1.0" + }, + "extra-properties": { + "metadatum": [ + { + "metaname": "vpn-id", + "metaval": "vpn-id-value-1", + "resource-version": "1465990410" + }, + { + "metaname": "product", + "metaval": "product-value-1", + "resource-version": "1465990410" + } + ] + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "virtual-data-center": { + "vdc-id": "vdc-01", + "vdc-name": "example-vdc-name-val-10107", + "resource-version": "1467975781" + }, + "extra-properties": { + + }, + "inventory-response-items": { + + } + } + ] + } + } + ] + } +} \ No newline at end of file diff --git a/src/test/resources/model-validation/instance-validator/connector-instance-unknown-model-id.json b/src/test/resources/model-validation/instance-validator/connector-instance-unknown-model-id.json new file mode 100644 index 0000000..c293606 --- /dev/null +++ b/src/test/resources/model-validation/instance-validator/connector-instance-unknown-model-id.json @@ -0,0 +1,113 @@ +{ + "cambria.partition": "AAI", + "event-header": { + "id": "20160525162737-61c49d41-5338-4755-af54-06cee9fe4acf", + "timestamp": "20160525-16:27:37:353", + "source-name": "RO", + "domain": "devINT1", + "sequence-number": "0", + "severity": "NORMAL", + "event-type": "AAI-EVENT", + "version": "v9", + "action": "CREATE", + "entity-type": "connector", + "top-entity-type": "connector", + "entity-link": "https://dummy-host.onap.org:8443/aai/v9/business/connectors/connector/c7611ebe-c324-48f1-8085-94aef0c12fd" + }, + "entity": { + "inventory-response-item": [ + { + "connector": { + "resource-instance-id": "c7611ebe-c324-48f1-8085-94aef0c12fd", + "resource-version": "1467975776", + "persona-model-id": "UNKNOWN-MODEL", + "persona-model-version": "v1.0", + "widget-model-id": "example-widget-model-id-val-69486", + "widget-model-version": "v1.0" + }, + "extra-properties": { + "metadatum": [ + { + "metaname": "vpn-id", + "metaval": "vpn-id-value-1", + "resource-version": "1465990410" + }, + { + "metaname": "unexpected", + "metaval": "unexpected-value-1", + "resource-version": "1465990410" + } + ] + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "virtual-data-center": { + "vdc-id": "vdc-01", + "vdc-name": "example-vdc-name-val-10107", + "resource-version": "1467975781" + }, + "extra-properties": { + + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "logical-link": { + "link-name": "example-link-name-val-23759", + "link-type": "example-link-type-val-23759", + "speed-value": "example-speed-value-val-23759", + "speed-units": "example-speed-units-val-23759", + "ip-version": "example-ip-version-val-23759", + "routing-protocol": "example-routing-protocol-val-23759", + "resource-version": "1467975786", + "persona-model-id": "example-persona-model-id-val-23759", + "persona-model-version": "example-persona-model-version-val-23759", + "widget-model-id": "example-widget-model-id-val-23759", + "widget-model-version": "example-widget-model-version-val-23759" + }, + "extra-properties": { + + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "pserver": { + "hostname": "example-hostname-val-79914", + "ptnii-equip-name": "example-ptnii-equip-name-val-79914", + "number-of-cpus": 79914, + "disk-in-gigabytes": 79914, + "ram-in-megabytes": 79914, + "equip-type": "example-equip-type-val-79914", + "equip-vendor": "example-equip-vendor-val-79914", + "equip-model": "example-equip-model-val-79914", + "fqdn": "example-fqdn-val-79914", + "pserver-selflink": "example-pserver-selflink-val-79914", + "ipv4-oam-address": "example-ipv4-oam-address-val-79914", + "serial-number": "example-serial-number-val-79914", + "pserver-id": "example-pserver-id-val-79914", + "internet-topology": "example-internet-topology-val-79914", + "in-maint": true, + "resource-version": "1467994603", + "pserver-name2": "example-pserver-name2-val-79914", + "purpose": "example-purpose-val-79914" + }, + "extra-properties": { + + }, + "inventory-response-items": { + + } + } + ] + } + } + ] + } + } + ] + } + } + ] + } +} \ No newline at end of file diff --git a/src/test/resources/model-validation/instance-validator/connector-instance.json b/src/test/resources/model-validation/instance-validator/connector-instance.json new file mode 100644 index 0000000..4fb489e --- /dev/null +++ b/src/test/resources/model-validation/instance-validator/connector-instance.json @@ -0,0 +1,113 @@ +{ + "cambria.partition": "AAI", + "event-header": { + "id": "20160525162737-61c49d41-5338-4755-af54-06cee9fe4acf", + "timestamp": "20160525-16:27:37:353", + "source-name": "RO", + "domain": "devINT1", + "sequence-number": "0", + "severity": "NORMAL", + "event-type": "AAI-EVENT", + "version": "v9", + "action": "CREATE", + "entity-type": "connector", + "top-entity-type": "connector", + "entity-link": "https://dummy-host.onap.org:8443/aai/v9/business/connectors/connector/c7611ebe-c324-48f1-8085-94aef0c12fd" + }, + "entity": { + "inventory-response-item": [ + { + "connector": { + "resource-instance-id": "c7611ebe-c324-48f1-8085-94aef0c12fd", + "resource-version": "1467975776", + "persona-model-id": "connector-widget-id", + "persona-model-version": "v1.0", + "widget-model-id": "example-widget-model-id-val-69486", + "widget-model-version": "v1.0" + }, + "extra-properties": { + "metadatum": [ + { + "metaname": "vpn-id", + "metaval": "vpn-id-value-1", + "resource-version": "1465990410" + }, + { + "metaname": "product", + "metaval": "product-value-1", + "resource-version": "1465990410" + } + ] + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "virtual-data-center": { + "vdc-id": "vdc-01", + "vdc-name": "example-vdc-name-val-10107", + "resource-version": "1467975781" + }, + "extra-properties": { + + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "logical-link": { + "link-name": "example-link-name-val-23759", + "link-type": "example-link-type-val-23759", + "speed-value": "example-speed-value-val-23759", + "speed-units": "example-speed-units-val-23759", + "ip-version": "example-ip-version-val-23759", + "routing-protocol": "example-routing-protocol-val-23759", + "resource-version": "1467975786", + "persona-model-id": "example-persona-model-id-val-23759", + "persona-model-version": "example-persona-model-version-val-23759", + "widget-model-id": "example-widget-model-id-val-23759", + "widget-model-version": "example-widget-model-version-val-23759" + }, + "extra-properties": { + + }, + "inventory-response-items": { + "inventory-response-item": [ + { + "pserver": { + "hostname": "example-hostname-val-79914", + "ptnii-equip-name": "example-ptnii-equip-name-val-79914", + "number-of-cpus": 79914, + "disk-in-gigabytes": 79914, + "ram-in-megabytes": 79914, + "equip-type": "example-equip-type-val-79914", + "equip-vendor": "example-equip-vendor-val-79914", + "equip-model": "example-equip-model-val-79914", + "fqdn": "example-fqdn-val-79914", + "pserver-selflink": "example-pserver-selflink-val-79914", + "ipv4-oam-address": "example-ipv4-oam-address-val-79914", + "serial-number": "example-serial-number-val-79914", + "pserver-id": "example-pserver-id-val-79914", + "internet-topology": "example-internet-topology-val-79914", + "in-maint": true, + "resource-version": "1467994603", + "pserver-name2": "example-pserver-name2-val-79914", + "purpose": "example-purpose-val-79914" + }, + "extra-properties": { + + }, + "inventory-response-items": { + + } + } + ] + } + } + ] + } + } + ] + } + } + ] + } +} \ No newline at end of file diff --git a/src/test/resources/model-validation/instance-validator/connector-widget-id.xml b/src/test/resources/model-validation/instance-validator/connector-widget-id.xml new file mode 100644 index 0000000..924ce67 --- /dev/null +++ b/src/test/resources/model-validation/instance-validator/connector-widget-id.xml @@ -0,0 +1,79 @@ + + + connector-widget-id + widget + connector + connector-model-id + v1.0 + 1466417894 + + + 8c0fd413-0d2b-491b-ad14-10c434c359bb + T + unbounded + + 1466417894 + + + + model + https://dummy-host.onap.org:8443/aai/v7/service-design-and-creation/models/model/virtual-data-center-widget-id/ + + model.model-name-version-id + virtual-data-center-widget-id + + + model.model-name + virtual-data-center + + + model.model-type + widget + + + + + + + + vpn-id + a + 1466417844 + + + product + b + 1466417844 + + + + + model-element + https://dummy-host.onap.org:8443/aai/v7/service-design-and-creation/model-elements/model-element/54629607-160a-4dcf-8c5c-15b8a3756f9a/ + + model-element.model-element-uuid + 54629607-160a-4dcf-8c5c-15b8a3756f9a + + + model.model-name-version-id + wan-connector-service-id + + + + \ No newline at end of file diff --git a/src/test/resources/model-validation/instance-validator/model-instance-mapping.json_conf b/src/test/resources/model-validation/instance-validator/model-instance-mapping.json_conf new file mode 100644 index 0000000..12d39ea --- /dev/null +++ b/src/test/resources/model-validation/instance-validator/model-instance-mapping.json_conf @@ -0,0 +1,28 @@ +[ + { + "mappingType": "RELATIONSHIP", + "model": { + "root": "model-elements/model-element", + "id": "relationship-list/relationship/relationship-data/relationship-value[../relationship-key/text()='model.model-name-version-id']", + "value": "relationship-list/relationship/related-to-property/property-value[../property-key/text()='model.model-name']", + "filter": { + "path": "relationship-list/relationship/related-to-property/property-value[../property-key/text()='model.model-type']", + "valid": ["widget"] + } + }, + "instance": { + "origin": "$.inventory-response-item[0]", + "root": "$.inventory-response-items.inventory-response-item[*]" + } + }, + { + "mappingType": "ATTRIBUTE", + "model": { + "value": "metadata/metadatum/metaname" + }, + "instance": { + "origin": "$.inventory-response-item[0]", + "value": "$..extra-properties.metadatum[*].metaname" + } + } +] diff --git a/src/test/resources/model-validation/instance-validator/test-validation-service-beans.xml b/src/test/resources/model-validation/instance-validator/test-validation-service-beans.xml new file mode 100644 index 0000000..82fe160 --- /dev/null +++ b/src/test/resources/model-validation/instance-validator/test-validation-service-beans.xml @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/model-validation/instance-validator/validation-service.properties b/src/test/resources/model-validation/instance-validator/validation-service.properties new file mode 100644 index 0000000..4e1b264 --- /dev/null +++ b/src/test/resources/model-validation/instance-validator/validation-service.properties @@ -0,0 +1,29 @@ +# ============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===================================================== + +topic.publish.enable=true +topic.publish.retries=3 +topic.consume.enable=true +topic.consume.polling.interval.seconds=3 + +event.domain=devINT1 +event.action.exclude=DELETE +event.type.rule=AAI-EVENT,AAI-DATA-EXPORT-API,GIZMO-EVENT +event.type.model=AAI-DATA-EXPORT-NQ +event.type.end=END-EVENT + +model.cache.expirySeconds=3 +aai.oxm.version=12 diff --git a/src/test/resources/model-validation/model-parser/all-models.xml b/src/test/resources/model-validation/model-parser/all-models.xml new file mode 100644 index 0000000..a295a5f --- /dev/null +++ b/src/test/resources/model-validation/model-parser/all-models.xml @@ -0,0 +1,1370 @@ + + + + + 22382f81-70cb-470d-8ab2-3e1b9fad10df + widget + generic-vnf + 6dcdbbc8-23b6-42c3-ac9f-2c0a3fe8cfba + v1.0 + 1466698747 + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/43095b8a-8e9c-4a76-8490-6120140f6804/model-elements/model-element/41e6d6e5-aa69-4d33-b9f2-975bf418d1e3/ + + model.model-name-version-id + 43095b8a-8e9c-4a76-8490-6120140f6804 + + + model-element.model-element-uuid + 41e6d6e5-aa69-4d33-b9f2-975bf418d1e3 + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/0d23052d-8ffe-433e-a25d-da5da027bb7c/model-elements/model-element/17e48d38-e055-4158-ae6b-a170e8a647cd/ + + model.model-name-version-id + 0d23052d-8ffe-433e-a25d-da5da027bb7c + + + model-element.model-element-uuid + 17e48d38-e055-4158-ae6b-a170e8a647cd + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/be890aae-cf27-4b6a-aeae-e6fa4b5ee17f/named-query-elements/named-query-element/1ac142fb-2caf-4f59-975e-8ad7631c301e/named-query-elements/named-query-element/311f1cad-b41c-4833-8b9f-0d54d85f9009/named-query-elements/named-query-element/dc38d8ae-0993-4426-af79-a7aff4a4b4f3/named-query-elements/named-query-element/a97e8ab3-addd-40ee-9d29-3de505a56374/ + + named-query.named-query-uuid + be890aae-cf27-4b6a-aeae-e6fa4b5ee17f + + + named-query-element.named-query-element-uuid + 1ac142fb-2caf-4f59-975e-8ad7631c301e + + + named-query-element.named-query-element-uuid + 311f1cad-b41c-4833-8b9f-0d54d85f9009 + + + named-query-element.named-query-element-uuid + dc38d8ae-0993-4426-af79-a7aff4a4b4f3 + + + named-query-element.named-query-element-uuid + a97e8ab3-addd-40ee-9d29-3de505a56374 + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/55f38763-9820-4fce-82a1-e0fa3c38ed24/named-query-elements/named-query-element/dc799ed9-45a5-4323-a2dc-bd1ec3242499/named-query-elements/named-query-element/97ae5271-9ad9-4815-804d-89af014d5b07/named-query-elements/named-query-element/7d189446-54de-49db-b786-8e946f0aece5/named-query-elements/named-query-element/920399b7-21c1-4e81-8fb9-a3b2283a72ba/named-query-elements/named-query-element/759ef1e4-3eca-4d55-8a9c-a8be31179f47/ + + named-query.named-query-uuid + 55f38763-9820-4fce-82a1-e0fa3c38ed24 + + + named-query-element.named-query-element-uuid + dc799ed9-45a5-4323-a2dc-bd1ec3242499 + + + named-query-element.named-query-element-uuid + 97ae5271-9ad9-4815-804d-89af014d5b07 + + + named-query-element.named-query-element-uuid + 7d189446-54de-49db-b786-8e946f0aece5 + + + named-query-element.named-query-element-uuid + 920399b7-21c1-4e81-8fb9-a3b2283a72ba + + + named-query-element.named-query-element-uuid + 759ef1e4-3eca-4d55-8a9c-a8be31179f47 + + + + + + connector-widget-id + widget + connector + connector-model-id + v2.0 + 1466689944 + + + 43095b8a-8e9c-4a76-8490-6120140f6804 + resource + vSbg + b23fb31b-4c21-45f7-9d92-96ed70e63df1 + v1.0 + 1466698622 + + + 41e6d6e5-aa69-4d33-b9f2-975bf418d1e3 + F + unbounded + + 1466698619 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/22382f81-70cb-470d-8ab2-3e1b9fad10df/ + + model.model-name-version-id + 22382f81-70cb-470d-8ab2-3e1b9fad10df + + + model.model-name + generic-vnf + + + model.model-type + widget + + + + + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/682ae094-0aaa-4381-a55d-bc633c40e4c0/model-elements/model-element/9ce59457-81b7-4f0e-8b72-a044a1be4bdf/model-elements/model-element/6cf69470-ccbf-4034-a37f-f714c135f05c/ + + model.model-name-version-id + 682ae094-0aaa-4381-a55d-bc633c40e4c0 + + + model-element.model-element-uuid + 9ce59457-81b7-4f0e-8b72-a044a1be4bdf + + + model-element.model-element-uuid + 6cf69470-ccbf-4034-a37f-f714c135f05c + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161/model-elements/model-element/c44dbdf9-494e-49c1-b462-74e24e837b22/model-elements/model-element/059db56c-6d72-4023-9fc3-0db29534ddff/ + + model.model-name-version-id + e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161 + + + model-element.model-element-uuid + c44dbdf9-494e-49c1-b462-74e24e837b22 + + + model-element.model-element-uuid + 059db56c-6d72-4023-9fc3-0db29534ddff + + + + + + 523f0645-8182-4c91-9d6a-2f968e923937 + widget + pserver + c277c968-7e2b-4a88-9094-2b8a55dfb9f4 + v1.0 + 1466698757 + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/5ed1c299-4d31-4531-ae43-4bb56f8f10c8/model-elements/model-element/76624fe1-0f28-4e17-ae9f-f0e2bba6d13d/ + + model.model-name-version-id + 5ed1c299-4d31-4531-ae43-4bb56f8f10c8 + + + model-element.model-element-uuid + 76624fe1-0f28-4e17-ae9f-f0e2bba6d13d + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/6614ffae-6e64-4c78-9dea-4d5c0f057ea2/model-elements/model-element/0204aad0-fe13-4f75-b022-f91f245f0e9e/ + + model.model-name-version-id + 6614ffae-6e64-4c78-9dea-4d5c0f057ea2 + + + model-element.model-element-uuid + 0204aad0-fe13-4f75-b022-f91f245f0e9e + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/55f38763-9820-4fce-82a1-e0fa3c38ed24/named-query-elements/named-query-element/dc799ed9-45a5-4323-a2dc-bd1ec3242499/named-query-elements/named-query-element/97ae5271-9ad9-4815-804d-89af014d5b07/named-query-elements/named-query-element/7d189446-54de-49db-b786-8e946f0aece5/named-query-elements/named-query-element/920399b7-21c1-4e81-8fb9-a3b2283a72ba/named-query-elements/named-query-element/a79552d6-20dc-4b9e-b4d4-f29a8a2a8447/ + + named-query.named-query-uuid + 55f38763-9820-4fce-82a1-e0fa3c38ed24 + + + named-query-element.named-query-element-uuid + dc799ed9-45a5-4323-a2dc-bd1ec3242499 + + + named-query-element.named-query-element-uuid + 97ae5271-9ad9-4815-804d-89af014d5b07 + + + named-query-element.named-query-element-uuid + 7d189446-54de-49db-b786-8e946f0aece5 + + + named-query-element.named-query-element-uuid + 920399b7-21c1-4e81-8fb9-a3b2283a72ba + + + named-query-element.named-query-element-uuid + a79552d6-20dc-4b9e-b4d4-f29a8a2a8447 + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/be890aae-cf27-4b6a-aeae-e6fa4b5ee17f/named-query-elements/named-query-element/1ac142fb-2caf-4f59-975e-8ad7631c301e/named-query-elements/named-query-element/311f1cad-b41c-4833-8b9f-0d54d85f9009/named-query-elements/named-query-element/dc38d8ae-0993-4426-af79-a7aff4a4b4f3/named-query-elements/named-query-element/41294247-9f7e-4abf-becd-3bbca6945c09/ + + named-query.named-query-uuid + be890aae-cf27-4b6a-aeae-e6fa4b5ee17f + + + named-query-element.named-query-element-uuid + 1ac142fb-2caf-4f59-975e-8ad7631c301e + + + named-query-element.named-query-element-uuid + 311f1cad-b41c-4833-8b9f-0d54d85f9009 + + + named-query-element.named-query-element-uuid + dc38d8ae-0993-4426-af79-a7aff4a4b4f3 + + + named-query-element.named-query-element-uuid + 41294247-9f7e-4abf-becd-3bbca6945c09 + + + + + + 99469866-95bb-400e-8786-f83e87696725 + widget + virtual-data-center + 3c70c43f-99ed-4476-82f4-92a30616e512 + v1.0 + 1466698727 + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/668464da-6d41-4599-bdbb-2576147b440e/model-elements/model-element/93a37846-b497-490e-bc97-7d130022d6db/model-elements/model-element/200de3d5-c207-47c2-a507-8846ba1d7068/ + + model.model-name-version-id + 668464da-6d41-4599-bdbb-2576147b440e + + + model-element.model-element-uuid + 93a37846-b497-490e-bc97-7d130022d6db + + + model-element.model-element-uuid + 200de3d5-c207-47c2-a507-8846ba1d7068 + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/be890aae-cf27-4b6a-aeae-e6fa4b5ee17f/named-query-elements/named-query-element/1ac142fb-2caf-4f59-975e-8ad7631c301e/named-query-elements/named-query-element/311f1cad-b41c-4833-8b9f-0d54d85f9009/ + + named-query.named-query-uuid + be890aae-cf27-4b6a-aeae-e6fa4b5ee17f + + + named-query-element.named-query-element-uuid + 1ac142fb-2caf-4f59-975e-8ad7631c301e + + + named-query-element.named-query-element-uuid + 311f1cad-b41c-4833-8b9f-0d54d85f9009 + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/55f38763-9820-4fce-82a1-e0fa3c38ed24/named-query-elements/named-query-element/dc799ed9-45a5-4323-a2dc-bd1ec3242499/named-query-elements/named-query-element/97ae5271-9ad9-4815-804d-89af014d5b07/named-query-elements/named-query-element/7d189446-54de-49db-b786-8e946f0aece5/ + + named-query.named-query-uuid + 55f38763-9820-4fce-82a1-e0fa3c38ed24 + + + named-query-element.named-query-element-uuid + dc799ed9-45a5-4323-a2dc-bd1ec3242499 + + + named-query-element.named-query-element-uuid + 97ae5271-9ad9-4815-804d-89af014d5b07 + + + named-query-element.named-query-element-uuid + 7d189446-54de-49db-b786-8e946f0aece5 + + + + + + 5ed1c299-4d31-4531-ae43-4bb56f8f10c8 + resource + ipe + e8f973a5-418a-44f2-9784-159e3e37d708 + v1.0 + 1466698622 + + + 76624fe1-0f28-4e17-ae9f-f0e2bba6d13d + F + unbounded + + 1466698621 + + + b7b48ba6-427b-4d23-ada7-a67ac9e0f84f + F + unbounded + + 1466698621 + + + ebc25508-b2e3-4021-b684-269cfd2b63c0 + T + unbounded + + 1466698621 + + + f610d699-11af-4c13-a918-a89344e4a1bd + T + unbounded + + 1466698621 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/49032ff1-5466-4054-b64b-15395ac10c00/ + + model.model-name-version-id + 49032ff1-5466-4054-b64b-15395ac10c00 + + + model.model-name + vlan + + + model.model-type + widget + + + + + + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/0a706320-b8e7-4b18-9485-fba156ea00cf/ + + model.model-name-version-id + 0a706320-b8e7-4b18-9485-fba156ea00cf + + + model.model-name + l-interface + + + model.model-type + widget + + + + + + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/3d9f4b1d-360c-4862-9623-703b150157ce/ + + model.model-name-version-id + 3d9f4b1d-360c-4862-9623-703b150157ce + + + model.model-name + p-interface + + + model.model-type + widget + + + + + + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/523f0645-8182-4c91-9d6a-2f968e923937/ + + model.model-name-version-id + 523f0645-8182-4c91-9d6a-2f968e923937 + + + model.model-name + pserver + + + model.model-type + widget + + + + + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/682ae094-0aaa-4381-a55d-bc633c40e4c0/model-elements/model-element/9ce59457-81b7-4f0e-8b72-a044a1be4bdf/model-elements/model-element/304ddca5-47cd-49ec-a2d7-1ce17baa5b70/ + + model.model-name-version-id + 682ae094-0aaa-4381-a55d-bc633c40e4c0 + + + model-element.model-element-uuid + 9ce59457-81b7-4f0e-8b72-a044a1be4bdf + + + model-element.model-element-uuid + 304ddca5-47cd-49ec-a2d7-1ce17baa5b70 + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161/model-elements/model-element/c44dbdf9-494e-49c1-b462-74e24e837b22/model-elements/model-element/193ec825-44ce-4416-85ac-20a6b6663575/ + + model.model-name-version-id + e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161 + + + model-element.model-element-uuid + c44dbdf9-494e-49c1-b462-74e24e837b22 + + + model-element.model-element-uuid + 193ec825-44ce-4416-85ac-20a6b6663575 + + + + + + 668464da-6d41-4599-bdbb-2576147b440e + resource + WAN Connector v0.1 + dc700a83-c507-47d9-b775-1fdfcdd5f9eb + 0.1 + Connects a customer vpn to the border elements of a vendor product + 1466698623 + + + 93a37846-b497-490e-bc97-7d130022d6db + T + unbounded + + 1466698622 + + + 200de3d5-c207-47c2-a507-8846ba1d7068 + T + unbounded + + 1466698622 + + + 7ccfe6b5-6566-4b44-83d3-b79f5de7a87b + T + unbounded + + 1466698622 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161/ + + model.model-name-version-id + e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161 + + + model.model-name + VL ELAN + + + model.model-type + resource + + + + + + dfd30146-74f4-49e9-bad6-019d413352ac + T + unbounded + + 1466698622 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/682ae094-0aaa-4381-a55d-bc633c40e4c0/ + + model.model-name-version-id + 682ae094-0aaa-4381-a55d-bc633c40e4c0 + + + model.model-name + vLAN on a Physical Wire + + + model.model-type + resource + + + + + + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/99469866-95bb-400e-8786-f83e87696725/ + + model.model-name-version-id + 99469866-95bb-400e-8786-f83e87696725 + + + model.model-name + virtual-data-center + + + model.model-type + widget + + + + + + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/15f47352-28b7-4bbd-9828-393eaf79eeff/ + + model.model-name-version-id + 15f47352-28b7-4bbd-9828-393eaf79eeff + + + model.model-name + connector + + + model.model-type + widget + + + + + + + + product + product-value-1 + 1466698623 + + + vpn-id + vpn-id-value-1 + 1466698623 + + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/460c6de2-a92b-4e3b-9ba3-538ce782b2fa/model-elements/model-element/71b825be-febf-45f7-b86a-ca0e3de19c90/model-elements/model-element/986167cb-57d3-4aad-8896-784a22c5289c/ + + model.model-name-version-id + 460c6de2-a92b-4e3b-9ba3-538ce782b2fa + + + model-element.model-element-uuid + 71b825be-febf-45f7-b86a-ca0e3de19c90 + + + model-element.model-element-uuid + 986167cb-57d3-4aad-8896-784a22c5289c + + + + + + 460c6de2-a92b-4e3b-9ba3-538ce782b2fa + service + WAN Bonding v0.1 + 0ee8c1bc-7cbd-4b0a-a1ac-e9999255abc1 + 0.1 + service-instance of the wan object + 1466698623 + + + 71b825be-febf-45f7-b86a-ca0e3de19c90 + T + unbounded + + 1466698623 + + + 986167cb-57d3-4aad-8896-784a22c5289c + T + unbounded + + 1466698623 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/668464da-6d41-4599-bdbb-2576147b440e/ + + model.model-name-version-id + 668464da-6d41-4599-bdbb-2576147b440e + + + model.model-name + NetBond WAN Connector v0.1 + + + model.model-type + resource + + + + + + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/46b92144-923a-4d20-b85a-3cbd847668a9/ + + model.model-name-version-id + 46b92144-923a-4d20-b85a-3cbd847668a9 + + + model.model-name + service-instance + + + model.model-type + widget + + + + + + + + b + product + 1466698623 + + + a + vpn-id + 1466698623 + + + + + generic-vnf-widget-id + widget + generic-vnf + generic-vnf-model-id + v1.0 + 1466624623 + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/vMME-resource-id/model-elements/model-element/af4b6df2-65d0-4d10-b25e-02206799e1fa/ + + model.model-name-version-id + vMME-resource-id + + + model-element.model-element-uuid + af4b6df2-65d0-4d10-b25e-02206799e1fa + + + + + + 6614ffae-6e64-4c78-9dea-4d5c0f057ea2 + resource + pBgf + 9038f1d7-61f2-49ef-a61d-ace468d4ab32 + v1.0 + 1466698622 + + + 0204aad0-fe13-4f75-b022-f91f245f0e9e + F + unbounded + + 1466698620 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/523f0645-8182-4c91-9d6a-2f968e923937/ + + model.model-name-version-id + 523f0645-8182-4c91-9d6a-2f968e923937 + + + model.model-name + pserver + + + model.model-type + widget + + + + + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161/model-elements/model-element/c44dbdf9-494e-49c1-b462-74e24e837b22/model-elements/model-element/ad161a89-ef32-4b2c-b86d-7fbb7a251571/ + + model.model-name-version-id + e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161 + + + model-element.model-element-uuid + c44dbdf9-494e-49c1-b462-74e24e837b22 + + + model-element.model-element-uuid + ad161a89-ef32-4b2c-b86d-7fbb7a251571 + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/682ae094-0aaa-4381-a55d-bc633c40e4c0/model-elements/model-element/9ce59457-81b7-4f0e-8b72-a044a1be4bdf/model-elements/model-element/d0d50aad-bb97-4865-a3bb-72dbf41be50b/ + + model.model-name-version-id + 682ae094-0aaa-4381-a55d-bc633c40e4c0 + + + model-element.model-element-uuid + 9ce59457-81b7-4f0e-8b72-a044a1be4bdf + + + model-element.model-element-uuid + d0d50aad-bb97-4865-a3bb-72dbf41be50b + + + + + + 15f47352-28b7-4bbd-9828-393eaf79eeff + widget + connector + 4f0dbd2d-b667-4d19-a563-84a764e62fa7 + v1.0 + 1466698717 + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/55f38763-9820-4fce-82a1-e0fa3c38ed24/named-query-elements/named-query-element/dc799ed9-45a5-4323-a2dc-bd1ec3242499/named-query-elements/named-query-element/97ae5271-9ad9-4815-804d-89af014d5b07/ + + named-query.named-query-uuid + 55f38763-9820-4fce-82a1-e0fa3c38ed24 + + + named-query-element.named-query-element-uuid + dc799ed9-45a5-4323-a2dc-bd1ec3242499 + + + named-query-element.named-query-element-uuid + 97ae5271-9ad9-4815-804d-89af014d5b07 + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/668464da-6d41-4599-bdbb-2576147b440e/model-elements/model-element/93a37846-b497-490e-bc97-7d130022d6db/ + + model.model-name-version-id + 668464da-6d41-4599-bdbb-2576147b440e + + + model-element.model-element-uuid + 93a37846-b497-490e-bc97-7d130022d6db + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/be890aae-cf27-4b6a-aeae-e6fa4b5ee17f/named-query-elements/named-query-element/1ac142fb-2caf-4f59-975e-8ad7631c301e/ + + named-query.named-query-uuid + be890aae-cf27-4b6a-aeae-e6fa4b5ee17f + + + named-query-element.named-query-element-uuid + 1ac142fb-2caf-4f59-975e-8ad7631c301e + + + + + + 682ae094-0aaa-4381-a55d-bc633c40e4c0 + resource + vLAN on a Physical Wire + 32bee148-2cae-4f3d-a42e-22c9e4f078a2 + 1 + An l2-bridge used by a wan connector connects an ipe to a BGF + 1466698622 + + + 9ce59457-81b7-4f0e-8b72-a044a1be4bdf + T + unbounded + + 1466698622 + + + d0d50aad-bb97-4865-a3bb-72dbf41be50b + T + unbounded + + 1466698622 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/6614ffae-6e64-4c78-9dea-4d5c0f057ea2/ + + model.model-name-version-id + 6614ffae-6e64-4c78-9dea-4d5c0f057ea2 + + + model.model-name + pBgf + + + model.model-type + resource + + + + + + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/fa01ef50-bbb5-49d4-91d1-ebbda9816e01/ + + model.model-name-version-id + fa01ef50-bbb5-49d4-91d1-ebbda9816e01 + + + model.model-name + logical-link + + + model.model-type + widget + + + + + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/668464da-6d41-4599-bdbb-2576147b440e/model-elements/model-element/93a37846-b497-490e-bc97-7d130022d6db/model-elements/model-element/200de3d5-c207-47c2-a507-8846ba1d7068/model-elements/model-element/dfd30146-74f4-49e9-bad6-019d413352ac/ + + model.model-name-version-id + 668464da-6d41-4599-bdbb-2576147b440e + + + model-element.model-element-uuid + 93a37846-b497-490e-bc97-7d130022d6db + + + model-element.model-element-uuid + 200de3d5-c207-47c2-a507-8846ba1d7068 + + + model-element.model-element-uuid + dfd30146-74f4-49e9-bad6-019d413352ac + + + + + + 46b92144-923a-4d20-b85a-3cbd847668a9 + widget + service-instance + 82194af1-3c2c-485a-8f44-420e22a9eaa4 + v1.0 + 1466698646 + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/55f38763-9820-4fce-82a1-e0fa3c38ed24/named-query-elements/named-query-element/dc799ed9-45a5-4323-a2dc-bd1ec3242499/ + + named-query.named-query-uuid + 55f38763-9820-4fce-82a1-e0fa3c38ed24 + + + named-query-element.named-query-element-uuid + dc799ed9-45a5-4323-a2dc-bd1ec3242499 + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/460c6de2-a92b-4e3b-9ba3-538ce782b2fa/model-elements/model-element/71b825be-febf-45f7-b86a-ca0e3de19c90/ + + model.model-name-version-id + 460c6de2-a92b-4e3b-9ba3-538ce782b2fa + + + model-element.model-element-uuid + 71b825be-febf-45f7-b86a-ca0e3de19c90 + + + + + + 3d9f4b1d-360c-4862-9623-703b150157ce + widget + p-interface + 479f5f13-51d9-4ccb-bddf-f554f1af0cfc + v1.0 + 1466698621 + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/5ed1c299-4d31-4531-ae43-4bb56f8f10c8/model-elements/model-element/76624fe1-0f28-4e17-ae9f-f0e2bba6d13d/model-elements/model-element/b7b48ba6-427b-4d23-ada7-a67ac9e0f84f/ + + model.model-name-version-id + 5ed1c299-4d31-4531-ae43-4bb56f8f10c8 + + + model-element.model-element-uuid + 76624fe1-0f28-4e17-ae9f-f0e2bba6d13d + + + model-element.model-element-uuid + b7b48ba6-427b-4d23-ada7-a67ac9e0f84f + + + + + + 0d23052d-8ffe-433e-a25d-da5da027bb7c + resource + vDbe + fe8aac07-ce6c-4f9f-aa0d-b561c77da9e8 + v1.0 + 1466698622 + + + 17e48d38-e055-4158-ae6b-a170e8a647cd + F + unbounded + + 1466698618 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/22382f81-70cb-470d-8ab2-3e1b9fad10df/ + + model.model-name-version-id + 22382f81-70cb-470d-8ab2-3e1b9fad10df + + + model.model-name + generic-vnf + + + model.model-type + widget + + + + + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/682ae094-0aaa-4381-a55d-bc633c40e4c0/model-elements/model-element/9ce59457-81b7-4f0e-8b72-a044a1be4bdf/model-elements/model-element/1d73a0dc-e7f6-4b6d-9450-5dda720d1a7f/ + + model.model-name-version-id + 682ae094-0aaa-4381-a55d-bc633c40e4c0 + + + model-element.model-element-uuid + 9ce59457-81b7-4f0e-8b72-a044a1be4bdf + + + model-element.model-element-uuid + 1d73a0dc-e7f6-4b6d-9450-5dda720d1a7f + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161/model-elements/model-element/c44dbdf9-494e-49c1-b462-74e24e837b22/model-elements/model-element/a1b205ea-17bb-442b-83a3-38b4e0fcb099/ + + model.model-name-version-id + e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161 + + + model-element.model-element-uuid + c44dbdf9-494e-49c1-b462-74e24e837b22 + + + model-element.model-element-uuid + a1b205ea-17bb-442b-83a3-38b4e0fcb099 + + + + + + vMME-resource-id + resource + vMME + vMME-model-id + v1.0 + 1466624623 + + + af4b6df2-65d0-4d10-b25e-02206799e1fa + true + unbounded + + 1466624623 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/generic-vnf-widget-id/ + + model.model-name-version-id + generic-vnf-widget-id + + + model.model-name + generic-vnf + + + model.model-type + widget + + + + + + + + fa01ef50-bbb5-49d4-91d1-ebbda9816e01 + widget + logical-link + 8742d5b3-ee98-4165-8bd5-fc012a7885b9 + v1.0 + 1466698737 + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161/model-elements/model-element/c44dbdf9-494e-49c1-b462-74e24e837b22/ + + model.model-name-version-id + e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161 + + + model-element.model-element-uuid + c44dbdf9-494e-49c1-b462-74e24e837b22 + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/682ae094-0aaa-4381-a55d-bc633c40e4c0/model-elements/model-element/9ce59457-81b7-4f0e-8b72-a044a1be4bdf/ + + model.model-name-version-id + 682ae094-0aaa-4381-a55d-bc633c40e4c0 + + + model-element.model-element-uuid + 9ce59457-81b7-4f0e-8b72-a044a1be4bdf + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/55f38763-9820-4fce-82a1-e0fa3c38ed24/named-query-elements/named-query-element/dc799ed9-45a5-4323-a2dc-bd1ec3242499/named-query-elements/named-query-element/97ae5271-9ad9-4815-804d-89af014d5b07/named-query-elements/named-query-element/7d189446-54de-49db-b786-8e946f0aece5/named-query-elements/named-query-element/920399b7-21c1-4e81-8fb9-a3b2283a72ba/ + + named-query.named-query-uuid + 55f38763-9820-4fce-82a1-e0fa3c38ed24 + + + named-query-element.named-query-element-uuid + dc799ed9-45a5-4323-a2dc-bd1ec3242499 + + + named-query-element.named-query-element-uuid + 97ae5271-9ad9-4815-804d-89af014d5b07 + + + named-query-element.named-query-element-uuid + 7d189446-54de-49db-b786-8e946f0aece5 + + + named-query-element.named-query-element-uuid + 920399b7-21c1-4e81-8fb9-a3b2283a72ba + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/be890aae-cf27-4b6a-aeae-e6fa4b5ee17f/named-query-elements/named-query-element/1ac142fb-2caf-4f59-975e-8ad7631c301e/named-query-elements/named-query-element/311f1cad-b41c-4833-8b9f-0d54d85f9009/named-query-elements/named-query-element/dc38d8ae-0993-4426-af79-a7aff4a4b4f3/ + + named-query.named-query-uuid + be890aae-cf27-4b6a-aeae-e6fa4b5ee17f + + + named-query-element.named-query-element-uuid + 1ac142fb-2caf-4f59-975e-8ad7631c301e + + + named-query-element.named-query-element-uuid + 311f1cad-b41c-4833-8b9f-0d54d85f9009 + + + named-query-element.named-query-element-uuid + dc38d8ae-0993-4426-af79-a7aff4a4b4f3 + + + + + + 0a706320-b8e7-4b18-9485-fba156ea00cf + widget + l-interface + d9131b0d-698f-4297-8699-af0a3ac7ebdc + v1.0 + 1466698767 + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/5ed1c299-4d31-4531-ae43-4bb56f8f10c8/model-elements/model-element/76624fe1-0f28-4e17-ae9f-f0e2bba6d13d/model-elements/model-element/b7b48ba6-427b-4d23-ada7-a67ac9e0f84f/model-elements/model-element/ebc25508-b2e3-4021-b684-269cfd2b63c0/ + + model.model-name-version-id + 5ed1c299-4d31-4531-ae43-4bb56f8f10c8 + + + model-element.model-element-uuid + 76624fe1-0f28-4e17-ae9f-f0e2bba6d13d + + + model-element.model-element-uuid + b7b48ba6-427b-4d23-ada7-a67ac9e0f84f + + + model-element.model-element-uuid + ebc25508-b2e3-4021-b684-269cfd2b63c0 + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/be890aae-cf27-4b6a-aeae-e6fa4b5ee17f/named-query-elements/named-query-element/1ac142fb-2caf-4f59-975e-8ad7631c301e/named-query-elements/named-query-element/311f1cad-b41c-4833-8b9f-0d54d85f9009/named-query-elements/named-query-element/dc38d8ae-0993-4426-af79-a7aff4a4b4f3/named-query-elements/named-query-element/29ac58b9-37fa-4d6a-9d2e-29f33e1e3b7a/ + + named-query.named-query-uuid + be890aae-cf27-4b6a-aeae-e6fa4b5ee17f + + + named-query-element.named-query-element-uuid + 1ac142fb-2caf-4f59-975e-8ad7631c301e + + + named-query-element.named-query-element-uuid + 311f1cad-b41c-4833-8b9f-0d54d85f9009 + + + named-query-element.named-query-element-uuid + dc38d8ae-0993-4426-af79-a7aff4a4b4f3 + + + named-query-element.named-query-element-uuid + 29ac58b9-37fa-4d6a-9d2e-29f33e1e3b7a + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/55f38763-9820-4fce-82a1-e0fa3c38ed24/named-query-elements/named-query-element/dc799ed9-45a5-4323-a2dc-bd1ec3242499/named-query-elements/named-query-element/97ae5271-9ad9-4815-804d-89af014d5b07/named-query-elements/named-query-element/7d189446-54de-49db-b786-8e946f0aece5/named-query-elements/named-query-element/920399b7-21c1-4e81-8fb9-a3b2283a72ba/named-query-elements/named-query-element/eda1554f-3eff-4195-9185-bcbc4f75826f/ + + named-query.named-query-uuid + 55f38763-9820-4fce-82a1-e0fa3c38ed24 + + + named-query-element.named-query-element-uuid + dc799ed9-45a5-4323-a2dc-bd1ec3242499 + + + named-query-element.named-query-element-uuid + 97ae5271-9ad9-4815-804d-89af014d5b07 + + + named-query-element.named-query-element-uuid + 7d189446-54de-49db-b786-8e946f0aece5 + + + named-query-element.named-query-element-uuid + 920399b7-21c1-4e81-8fb9-a3b2283a72ba + + + named-query-element.named-query-element-uuid + eda1554f-3eff-4195-9185-bcbc4f75826f + + + + + + 49032ff1-5466-4054-b64b-15395ac10c00 + widget + vlan + 2febb0bc-b776-45b3-af50-75a578a8a4c4 + v1.0 + 1466698621 + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/5ed1c299-4d31-4531-ae43-4bb56f8f10c8/model-elements/model-element/76624fe1-0f28-4e17-ae9f-f0e2bba6d13d/model-elements/model-element/b7b48ba6-427b-4d23-ada7-a67ac9e0f84f/model-elements/model-element/ebc25508-b2e3-4021-b684-269cfd2b63c0/model-elements/model-element/f610d699-11af-4c13-a918-a89344e4a1bd/ + + model.model-name-version-id + 5ed1c299-4d31-4531-ae43-4bb56f8f10c8 + + + model-element.model-element-uuid + 76624fe1-0f28-4e17-ae9f-f0e2bba6d13d + + + model-element.model-element-uuid + b7b48ba6-427b-4d23-ada7-a67ac9e0f84f + + + model-element.model-element-uuid + ebc25508-b2e3-4021-b684-269cfd2b63c0 + + + model-element.model-element-uuid + f610d699-11af-4c13-a918-a89344e4a1bd + + + + + + e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161 + resource + VL ELAN + 932518e5-4260-4cc4-8038-df604a367f85 + 1 + An l2-bridge used by a wan connector connects an ipe to a SBG or DBE + 1466698622 + + + c44dbdf9-494e-49c1-b462-74e24e837b22 + T + unbounded + + 1466698621 + + + a1b205ea-17bb-442b-83a3-38b4e0fcb099 + T + unbounded + + 1466698621 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/0d23052d-8ffe-433e-a25d-da5da027bb7c/ + + model.model-name-version-id + 0d23052d-8ffe-433e-a25d-da5da027bb7c + + + model.model-name + vDbe + + + model.model-type + resource + + + + + + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/fa01ef50-bbb5-49d4-91d1-ebbda9816e01/ + + model.model-name-version-id + fa01ef50-bbb5-49d4-91d1-ebbda9816e01 + + + model.model-name + logical-link + + + model.model-type + widget + + + + + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/668464da-6d41-4599-bdbb-2576147b440e/model-elements/model-element/93a37846-b497-490e-bc97-7d130022d6db/model-elements/model-element/200de3d5-c207-47c2-a507-8846ba1d7068/model-elements/model-element/7ccfe6b5-6566-4b44-83d3-b79f5de7a87b/ + + model.model-name-version-id + 668464da-6d41-4599-bdbb-2576147b440e + + + model-element.model-element-uuid + 93a37846-b497-490e-bc97-7d130022d6db + + + model-element.model-element-uuid + 200de3d5-c207-47c2-a507-8846ba1d7068 + + + model-element.model-element-uuid + 7ccfe6b5-6566-4b44-83d3-b79f5de7a87b + + + + + \ No newline at end of file diff --git a/src/test/resources/model-validation/model-reader/aai-environment.properties b/src/test/resources/model-validation/model-reader/aai-environment.properties new file mode 100644 index 0000000..3450105 --- /dev/null +++ b/src/test/resources/model-validation/model-reader/aai-environment.properties @@ -0,0 +1,30 @@ +# ============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===================================================== + +httpProtocol=file +baseModelURI=src/test/resources/model-validation/model-reader/all-models.xml + +# the following fields are autowired but will never be used +host= +port= +trustStorePath= +keyStorePath= +keyStorePassword.x= +keyManagerFactoryAlgorithm= +keyStoreType= +securityProtocol= +connectionTimeout= +readTimeout= diff --git a/src/test/resources/model-validation/model-reader/all-models.xml b/src/test/resources/model-validation/model-reader/all-models.xml new file mode 100644 index 0000000..afc5dda --- /dev/null +++ b/src/test/resources/model-validation/model-reader/all-models.xml @@ -0,0 +1,1370 @@ + + + + + 22382f81-70cb-470d-8ab2-3e1b9fad10df + widget + generic-vnf + 6dcdbbc8-23b6-42c3-ac9f-2c0a3fe8cfba + v1.0 + 1466698747 + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/43095b8a-8e9c-4a76-8490-6120140f6804/model-elements/model-element/41e6d6e5-aa69-4d33-b9f2-975bf418d1e3/ + + model.model-name-version-id + 43095b8a-8e9c-4a76-8490-6120140f6804 + + + model-element.model-element-uuid + 41e6d6e5-aa69-4d33-b9f2-975bf418d1e3 + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/0d23052d-8ffe-433e-a25d-da5da027bb7c/model-elements/model-element/17e48d38-e055-4158-ae6b-a170e8a647cd/ + + model.model-name-version-id + 0d23052d-8ffe-433e-a25d-da5da027bb7c + + + model-element.model-element-uuid + 17e48d38-e055-4158-ae6b-a170e8a647cd + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/be890aae-cf27-4b6a-aeae-e6fa4b5ee17f/named-query-elements/named-query-element/1ac142fb-2caf-4f59-975e-8ad7631c301e/named-query-elements/named-query-element/311f1cad-b41c-4833-8b9f-0d54d85f9009/named-query-elements/named-query-element/dc38d8ae-0993-4426-af79-a7aff4a4b4f3/named-query-elements/named-query-element/a97e8ab3-addd-40ee-9d29-3de505a56374/ + + named-query.named-query-uuid + be890aae-cf27-4b6a-aeae-e6fa4b5ee17f + + + named-query-element.named-query-element-uuid + 1ac142fb-2caf-4f59-975e-8ad7631c301e + + + named-query-element.named-query-element-uuid + 311f1cad-b41c-4833-8b9f-0d54d85f9009 + + + named-query-element.named-query-element-uuid + dc38d8ae-0993-4426-af79-a7aff4a4b4f3 + + + named-query-element.named-query-element-uuid + a97e8ab3-addd-40ee-9d29-3de505a56374 + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/55f38763-9820-4fce-82a1-e0fa3c38ed24/named-query-elements/named-query-element/dc799ed9-45a5-4323-a2dc-bd1ec3242499/named-query-elements/named-query-element/97ae5271-9ad9-4815-804d-89af014d5b07/named-query-elements/named-query-element/7d189446-54de-49db-b786-8e946f0aece5/named-query-elements/named-query-element/920399b7-21c1-4e81-8fb9-a3b2283a72ba/named-query-elements/named-query-element/759ef1e4-3eca-4d55-8a9c-a8be31179f47/ + + named-query.named-query-uuid + 55f38763-9820-4fce-82a1-e0fa3c38ed24 + + + named-query-element.named-query-element-uuid + dc799ed9-45a5-4323-a2dc-bd1ec3242499 + + + named-query-element.named-query-element-uuid + 97ae5271-9ad9-4815-804d-89af014d5b07 + + + named-query-element.named-query-element-uuid + 7d189446-54de-49db-b786-8e946f0aece5 + + + named-query-element.named-query-element-uuid + 920399b7-21c1-4e81-8fb9-a3b2283a72ba + + + named-query-element.named-query-element-uuid + 759ef1e4-3eca-4d55-8a9c-a8be31179f47 + + + + + + connector-widget-id + widget + connector + connector-model-id + v2.0 + 1466689944 + + + 43095b8a-8e9c-4a76-8490-6120140f6804 + resource + vSbg + b23fb31b-4c21-45f7-9d92-96ed70e63df1 + v1.0 + 1466698622 + + + 41e6d6e5-aa69-4d33-b9f2-975bf418d1e3 + F + unbounded + + 1466698619 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/22382f81-70cb-470d-8ab2-3e1b9fad10df/ + + model.model-name-version-id + 22382f81-70cb-470d-8ab2-3e1b9fad10df + + + model.model-name + generic-vnf + + + model.model-type + widget + + + + + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/682ae094-0aaa-4381-a55d-bc633c40e4c0/model-elements/model-element/9ce59457-81b7-4f0e-8b72-a044a1be4bdf/model-elements/model-element/6cf69470-ccbf-4034-a37f-f714c135f05c/ + + model.model-name-version-id + 682ae094-0aaa-4381-a55d-bc633c40e4c0 + + + model-element.model-element-uuid + 9ce59457-81b7-4f0e-8b72-a044a1be4bdf + + + model-element.model-element-uuid + 6cf69470-ccbf-4034-a37f-f714c135f05c + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161/model-elements/model-element/c44dbdf9-494e-49c1-b462-74e24e837b22/model-elements/model-element/059db56c-6d72-4023-9fc3-0db29534ddff/ + + model.model-name-version-id + e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161 + + + model-element.model-element-uuid + c44dbdf9-494e-49c1-b462-74e24e837b22 + + + model-element.model-element-uuid + 059db56c-6d72-4023-9fc3-0db29534ddff + + + + + + 523f0645-8182-4c91-9d6a-2f968e923937 + widget + pserver + c277c968-7e2b-4a88-9094-2b8a55dfb9f4 + v1.0 + 1466698757 + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/5ed1c299-4d31-4531-ae43-4bb56f8f10c8/model-elements/model-element/76624fe1-0f28-4e17-ae9f-f0e2bba6d13d/ + + model.model-name-version-id + 5ed1c299-4d31-4531-ae43-4bb56f8f10c8 + + + model-element.model-element-uuid + 76624fe1-0f28-4e17-ae9f-f0e2bba6d13d + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/6614ffae-6e64-4c78-9dea-4d5c0f057ea2/model-elements/model-element/0204aad0-fe13-4f75-b022-f91f245f0e9e/ + + model.model-name-version-id + 6614ffae-6e64-4c78-9dea-4d5c0f057ea2 + + + model-element.model-element-uuid + 0204aad0-fe13-4f75-b022-f91f245f0e9e + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/55f38763-9820-4fce-82a1-e0fa3c38ed24/named-query-elements/named-query-element/dc799ed9-45a5-4323-a2dc-bd1ec3242499/named-query-elements/named-query-element/97ae5271-9ad9-4815-804d-89af014d5b07/named-query-elements/named-query-element/7d189446-54de-49db-b786-8e946f0aece5/named-query-elements/named-query-element/920399b7-21c1-4e81-8fb9-a3b2283a72ba/named-query-elements/named-query-element/a79552d6-20dc-4b9e-b4d4-f29a8a2a8447/ + + named-query.named-query-uuid + 55f38763-9820-4fce-82a1-e0fa3c38ed24 + + + named-query-element.named-query-element-uuid + dc799ed9-45a5-4323-a2dc-bd1ec3242499 + + + named-query-element.named-query-element-uuid + 97ae5271-9ad9-4815-804d-89af014d5b07 + + + named-query-element.named-query-element-uuid + 7d189446-54de-49db-b786-8e946f0aece5 + + + named-query-element.named-query-element-uuid + 920399b7-21c1-4e81-8fb9-a3b2283a72ba + + + named-query-element.named-query-element-uuid + a79552d6-20dc-4b9e-b4d4-f29a8a2a8447 + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/be890aae-cf27-4b6a-aeae-e6fa4b5ee17f/named-query-elements/named-query-element/1ac142fb-2caf-4f59-975e-8ad7631c301e/named-query-elements/named-query-element/311f1cad-b41c-4833-8b9f-0d54d85f9009/named-query-elements/named-query-element/dc38d8ae-0993-4426-af79-a7aff4a4b4f3/named-query-elements/named-query-element/41294247-9f7e-4abf-becd-3bbca6945c09/ + + named-query.named-query-uuid + be890aae-cf27-4b6a-aeae-e6fa4b5ee17f + + + named-query-element.named-query-element-uuid + 1ac142fb-2caf-4f59-975e-8ad7631c301e + + + named-query-element.named-query-element-uuid + 311f1cad-b41c-4833-8b9f-0d54d85f9009 + + + named-query-element.named-query-element-uuid + dc38d8ae-0993-4426-af79-a7aff4a4b4f3 + + + named-query-element.named-query-element-uuid + 41294247-9f7e-4abf-becd-3bbca6945c09 + + + + + + 99469866-95bb-400e-8786-f83e87696725 + widget + virtual-data-center + 3c70c43f-99ed-4476-82f4-92a30616e512 + v1.0 + 1466698727 + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/668464da-6d41-4599-bdbb-2576147b440e/model-elements/model-element/93a37846-b497-490e-bc97-7d130022d6db/model-elements/model-element/200de3d5-c207-47c2-a507-8846ba1d7068/ + + model.model-name-version-id + 668464da-6d41-4599-bdbb-2576147b440e + + + model-element.model-element-uuid + 93a37846-b497-490e-bc97-7d130022d6db + + + model-element.model-element-uuid + 200de3d5-c207-47c2-a507-8846ba1d7068 + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/be890aae-cf27-4b6a-aeae-e6fa4b5ee17f/named-query-elements/named-query-element/1ac142fb-2caf-4f59-975e-8ad7631c301e/named-query-elements/named-query-element/311f1cad-b41c-4833-8b9f-0d54d85f9009/ + + named-query.named-query-uuid + be890aae-cf27-4b6a-aeae-e6fa4b5ee17f + + + named-query-element.named-query-element-uuid + 1ac142fb-2caf-4f59-975e-8ad7631c301e + + + named-query-element.named-query-element-uuid + 311f1cad-b41c-4833-8b9f-0d54d85f9009 + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/55f38763-9820-4fce-82a1-e0fa3c38ed24/named-query-elements/named-query-element/dc799ed9-45a5-4323-a2dc-bd1ec3242499/named-query-elements/named-query-element/97ae5271-9ad9-4815-804d-89af014d5b07/named-query-elements/named-query-element/7d189446-54de-49db-b786-8e946f0aece5/ + + named-query.named-query-uuid + 55f38763-9820-4fce-82a1-e0fa3c38ed24 + + + named-query-element.named-query-element-uuid + dc799ed9-45a5-4323-a2dc-bd1ec3242499 + + + named-query-element.named-query-element-uuid + 97ae5271-9ad9-4815-804d-89af014d5b07 + + + named-query-element.named-query-element-uuid + 7d189446-54de-49db-b786-8e946f0aece5 + + + + + + 5ed1c299-4d31-4531-ae43-4bb56f8f10c8 + resource + ipe + e8f973a5-418a-44f2-9784-159e3e37d708 + v1.0 + 1466698622 + + + 76624fe1-0f28-4e17-ae9f-f0e2bba6d13d + F + unbounded + + 1466698621 + + + b7b48ba6-427b-4d23-ada7-a67ac9e0f84f + F + unbounded + + 1466698621 + + + ebc25508-b2e3-4021-b684-269cfd2b63c0 + T + unbounded + + 1466698621 + + + f610d699-11af-4c13-a918-a89344e4a1bd + T + unbounded + + 1466698621 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/49032ff1-5466-4054-b64b-15395ac10c00/ + + model.model-name-version-id + 49032ff1-5466-4054-b64b-15395ac10c00 + + + model.model-name + vlan + + + model.model-type + widget + + + + + + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/0a706320-b8e7-4b18-9485-fba156ea00cf/ + + model.model-name-version-id + 0a706320-b8e7-4b18-9485-fba156ea00cf + + + model.model-name + l-interface + + + model.model-type + widget + + + + + + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/3d9f4b1d-360c-4862-9623-703b150157ce/ + + model.model-name-version-id + 3d9f4b1d-360c-4862-9623-703b150157ce + + + model.model-name + p-interface + + + model.model-type + widget + + + + + + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/523f0645-8182-4c91-9d6a-2f968e923937/ + + model.model-name-version-id + 523f0645-8182-4c91-9d6a-2f968e923937 + + + model.model-name + pserver + + + model.model-type + widget + + + + + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/682ae094-0aaa-4381-a55d-bc633c40e4c0/model-elements/model-element/9ce59457-81b7-4f0e-8b72-a044a1be4bdf/model-elements/model-element/304ddca5-47cd-49ec-a2d7-1ce17baa5b70/ + + model.model-name-version-id + 682ae094-0aaa-4381-a55d-bc633c40e4c0 + + + model-element.model-element-uuid + 9ce59457-81b7-4f0e-8b72-a044a1be4bdf + + + model-element.model-element-uuid + 304ddca5-47cd-49ec-a2d7-1ce17baa5b70 + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161/model-elements/model-element/c44dbdf9-494e-49c1-b462-74e24e837b22/model-elements/model-element/193ec825-44ce-4416-85ac-20a6b6663575/ + + model.model-name-version-id + e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161 + + + model-element.model-element-uuid + c44dbdf9-494e-49c1-b462-74e24e837b22 + + + model-element.model-element-uuid + 193ec825-44ce-4416-85ac-20a6b6663575 + + + + + + 668464da-6d41-4599-bdbb-2576147b440e + resource + WAN Connector v0.1 + dc700a83-c507-47d9-b775-1fdfcdd5f9eb + 0.1 + Connects a customer vpn to the border elements of a vendor product + 1466698623 + + + 93a37846-b497-490e-bc97-7d130022d6db + T + unbounded + + 1466698622 + + + 200de3d5-c207-47c2-a507-8846ba1d7068 + T + unbounded + + 1466698622 + + + 7ccfe6b5-6566-4b44-83d3-b79f5de7a87b + T + unbounded + + 1466698622 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161/ + + model.model-name-version-id + e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161 + + + model.model-name + VL ELAN + + + model.model-type + resource + + + + + + dfd30146-74f4-49e9-bad6-019d413352ac + T + unbounded + + 1466698622 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/682ae094-0aaa-4381-a55d-bc633c40e4c0/ + + model.model-name-version-id + 682ae094-0aaa-4381-a55d-bc633c40e4c0 + + + model.model-name + vLAN on a Physical Wire + + + model.model-type + resource + + + + + + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/99469866-95bb-400e-8786-f83e87696725/ + + model.model-name-version-id + 99469866-95bb-400e-8786-f83e87696725 + + + model.model-name + virtual-data-center + + + model.model-type + widget + + + + + + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/15f47352-28b7-4bbd-9828-393eaf79eeff/ + + model.model-name-version-id + 15f47352-28b7-4bbd-9828-393eaf79eeff + + + model.model-name + connector + + + model.model-type + widget + + + + + + + + product + product-value-1 + 1466698623 + + + vpn-id + vpn-id-value-1 + 1466698623 + + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/460c6de2-a92b-4e3b-9ba3-538ce782b2fa/model-elements/model-element/71b825be-febf-45f7-b86a-ca0e3de19c90/model-elements/model-element/986167cb-57d3-4aad-8896-784a22c5289c/ + + model.model-name-version-id + 460c6de2-a92b-4e3b-9ba3-538ce782b2fa + + + model-element.model-element-uuid + 71b825be-febf-45f7-b86a-ca0e3de19c90 + + + model-element.model-element-uuid + 986167cb-57d3-4aad-8896-784a22c5289c + + + + + + 460c6de2-a92b-4e3b-9ba3-538ce782b2fa + service + WAN Bonding v0.1 + 0ee8c1bc-7cbd-4b0a-a1ac-e9999255abc1 + 0.1 + service-instance of the wan object + 1466698623 + + + 71b825be-febf-45f7-b86a-ca0e3de19c90 + T + unbounded + + 1466698623 + + + 986167cb-57d3-4aad-8896-784a22c5289c + T + unbounded + + 1466698623 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/668464da-6d41-4599-bdbb-2576147b440e/ + + model.model-name-version-id + 668464da-6d41-4599-bdbb-2576147b440e + + + model.model-name + WAN Connector v0.1 + + + model.model-type + resource + + + + + + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/46b92144-923a-4d20-b85a-3cbd847668a9/ + + model.model-name-version-id + 46b92144-923a-4d20-b85a-3cbd847668a9 + + + model.model-name + service-instance + + + model.model-type + widget + + + + + + + + b + product + 1466698623 + + + a + vpn-id + 1466698623 + + + + + generic-vnf-widget-id + widget + generic-vnf + generic-vnf-model-id + v1.0 + 1466624623 + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/vMME-resource-id/model-elements/model-element/af4b6df2-65d0-4d10-b25e-02206799e1fa/ + + model.model-name-version-id + vMME-resource-id + + + model-element.model-element-uuid + af4b6df2-65d0-4d10-b25e-02206799e1fa + + + + + + 6614ffae-6e64-4c78-9dea-4d5c0f057ea2 + resource + pBgf + 9038f1d7-61f2-49ef-a61d-ace468d4ab32 + v1.0 + 1466698622 + + + 0204aad0-fe13-4f75-b022-f91f245f0e9e + F + unbounded + + 1466698620 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/523f0645-8182-4c91-9d6a-2f968e923937/ + + model.model-name-version-id + 523f0645-8182-4c91-9d6a-2f968e923937 + + + model.model-name + pserver + + + model.model-type + widget + + + + + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161/model-elements/model-element/c44dbdf9-494e-49c1-b462-74e24e837b22/model-elements/model-element/ad161a89-ef32-4b2c-b86d-7fbb7a251571/ + + model.model-name-version-id + e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161 + + + model-element.model-element-uuid + c44dbdf9-494e-49c1-b462-74e24e837b22 + + + model-element.model-element-uuid + ad161a89-ef32-4b2c-b86d-7fbb7a251571 + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/682ae094-0aaa-4381-a55d-bc633c40e4c0/model-elements/model-element/9ce59457-81b7-4f0e-8b72-a044a1be4bdf/model-elements/model-element/d0d50aad-bb97-4865-a3bb-72dbf41be50b/ + + model.model-name-version-id + 682ae094-0aaa-4381-a55d-bc633c40e4c0 + + + model-element.model-element-uuid + 9ce59457-81b7-4f0e-8b72-a044a1be4bdf + + + model-element.model-element-uuid + d0d50aad-bb97-4865-a3bb-72dbf41be50b + + + + + + 15f47352-28b7-4bbd-9828-393eaf79eeff + widget + connector + 4f0dbd2d-b667-4d19-a563-84a764e62fa7 + v1.0 + 1466698717 + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/55f38763-9820-4fce-82a1-e0fa3c38ed24/named-query-elements/named-query-element/dc799ed9-45a5-4323-a2dc-bd1ec3242499/named-query-elements/named-query-element/97ae5271-9ad9-4815-804d-89af014d5b07/ + + named-query.named-query-uuid + 55f38763-9820-4fce-82a1-e0fa3c38ed24 + + + named-query-element.named-query-element-uuid + dc799ed9-45a5-4323-a2dc-bd1ec3242499 + + + named-query-element.named-query-element-uuid + 97ae5271-9ad9-4815-804d-89af014d5b07 + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/668464da-6d41-4599-bdbb-2576147b440e/model-elements/model-element/93a37846-b497-490e-bc97-7d130022d6db/ + + model.model-name-version-id + 668464da-6d41-4599-bdbb-2576147b440e + + + model-element.model-element-uuid + 93a37846-b497-490e-bc97-7d130022d6db + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/be890aae-cf27-4b6a-aeae-e6fa4b5ee17f/named-query-elements/named-query-element/1ac142fb-2caf-4f59-975e-8ad7631c301e/ + + named-query.named-query-uuid + be890aae-cf27-4b6a-aeae-e6fa4b5ee17f + + + named-query-element.named-query-element-uuid + 1ac142fb-2caf-4f59-975e-8ad7631c301e + + + + + + 682ae094-0aaa-4381-a55d-bc633c40e4c0 + resource + vLAN on a Physical Wire + 32bee148-2cae-4f3d-a42e-22c9e4f078a2 + 1 + An l2-bridge used by a wan connector connects an ipe to a BGF + 1466698622 + + + 9ce59457-81b7-4f0e-8b72-a044a1be4bdf + T + unbounded + + 1466698622 + + + d0d50aad-bb97-4865-a3bb-72dbf41be50b + T + unbounded + + 1466698622 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/6614ffae-6e64-4c78-9dea-4d5c0f057ea2/ + + model.model-name-version-id + 6614ffae-6e64-4c78-9dea-4d5c0f057ea2 + + + model.model-name + pBgf + + + model.model-type + resource + + + + + + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/fa01ef50-bbb5-49d4-91d1-ebbda9816e01/ + + model.model-name-version-id + fa01ef50-bbb5-49d4-91d1-ebbda9816e01 + + + model.model-name + logical-link + + + model.model-type + widget + + + + + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/668464da-6d41-4599-bdbb-2576147b440e/model-elements/model-element/93a37846-b497-490e-bc97-7d130022d6db/model-elements/model-element/200de3d5-c207-47c2-a507-8846ba1d7068/model-elements/model-element/dfd30146-74f4-49e9-bad6-019d413352ac/ + + model.model-name-version-id + 668464da-6d41-4599-bdbb-2576147b440e + + + model-element.model-element-uuid + 93a37846-b497-490e-bc97-7d130022d6db + + + model-element.model-element-uuid + 200de3d5-c207-47c2-a507-8846ba1d7068 + + + model-element.model-element-uuid + dfd30146-74f4-49e9-bad6-019d413352ac + + + + + + 46b92144-923a-4d20-b85a-3cbd847668a9 + widget + service-instance + 82194af1-3c2c-485a-8f44-420e22a9eaa4 + v1.0 + 1466698646 + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/55f38763-9820-4fce-82a1-e0fa3c38ed24/named-query-elements/named-query-element/dc799ed9-45a5-4323-a2dc-bd1ec3242499/ + + named-query.named-query-uuid + 55f38763-9820-4fce-82a1-e0fa3c38ed24 + + + named-query-element.named-query-element-uuid + dc799ed9-45a5-4323-a2dc-bd1ec3242499 + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/460c6de2-a92b-4e3b-9ba3-538ce782b2fa/model-elements/model-element/71b825be-febf-45f7-b86a-ca0e3de19c90/ + + model.model-name-version-id + 460c6de2-a92b-4e3b-9ba3-538ce782b2fa + + + model-element.model-element-uuid + 71b825be-febf-45f7-b86a-ca0e3de19c90 + + + + + + 3d9f4b1d-360c-4862-9623-703b150157ce + widget + p-interface + 479f5f13-51d9-4ccb-bddf-f554f1af0cfc + v1.0 + 1466698621 + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/5ed1c299-4d31-4531-ae43-4bb56f8f10c8/model-elements/model-element/76624fe1-0f28-4e17-ae9f-f0e2bba6d13d/model-elements/model-element/b7b48ba6-427b-4d23-ada7-a67ac9e0f84f/ + + model.model-name-version-id + 5ed1c299-4d31-4531-ae43-4bb56f8f10c8 + + + model-element.model-element-uuid + 76624fe1-0f28-4e17-ae9f-f0e2bba6d13d + + + model-element.model-element-uuid + b7b48ba6-427b-4d23-ada7-a67ac9e0f84f + + + + + + 0d23052d-8ffe-433e-a25d-da5da027bb7c + resource + vDbe + fe8aac07-ce6c-4f9f-aa0d-b561c77da9e8 + v1.0 + 1466698622 + + + 17e48d38-e055-4158-ae6b-a170e8a647cd + F + unbounded + + 1466698618 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/22382f81-70cb-470d-8ab2-3e1b9fad10df/ + + model.model-name-version-id + 22382f81-70cb-470d-8ab2-3e1b9fad10df + + + model.model-name + generic-vnf + + + model.model-type + widget + + + + + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/682ae094-0aaa-4381-a55d-bc633c40e4c0/model-elements/model-element/9ce59457-81b7-4f0e-8b72-a044a1be4bdf/model-elements/model-element/1d73a0dc-e7f6-4b6d-9450-5dda720d1a7f/ + + model.model-name-version-id + 682ae094-0aaa-4381-a55d-bc633c40e4c0 + + + model-element.model-element-uuid + 9ce59457-81b7-4f0e-8b72-a044a1be4bdf + + + model-element.model-element-uuid + 1d73a0dc-e7f6-4b6d-9450-5dda720d1a7f + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161/model-elements/model-element/c44dbdf9-494e-49c1-b462-74e24e837b22/model-elements/model-element/a1b205ea-17bb-442b-83a3-38b4e0fcb099/ + + model.model-name-version-id + e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161 + + + model-element.model-element-uuid + c44dbdf9-494e-49c1-b462-74e24e837b22 + + + model-element.model-element-uuid + a1b205ea-17bb-442b-83a3-38b4e0fcb099 + + + + + + vMME-resource-id + resource + vMME + vMME-model-id + v1.0 + 1466624623 + + + af4b6df2-65d0-4d10-b25e-02206799e1fa + true + unbounded + + 1466624623 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/generic-vnf-widget-id/ + + model.model-name-version-id + generic-vnf-widget-id + + + model.model-name + generic-vnf + + + model.model-type + widget + + + + + + + + fa01ef50-bbb5-49d4-91d1-ebbda9816e01 + widget + logical-link + 8742d5b3-ee98-4165-8bd5-fc012a7885b9 + v1.0 + 1466698737 + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161/model-elements/model-element/c44dbdf9-494e-49c1-b462-74e24e837b22/ + + model.model-name-version-id + e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161 + + + model-element.model-element-uuid + c44dbdf9-494e-49c1-b462-74e24e837b22 + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/682ae094-0aaa-4381-a55d-bc633c40e4c0/model-elements/model-element/9ce59457-81b7-4f0e-8b72-a044a1be4bdf/ + + model.model-name-version-id + 682ae094-0aaa-4381-a55d-bc633c40e4c0 + + + model-element.model-element-uuid + 9ce59457-81b7-4f0e-8b72-a044a1be4bdf + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/55f38763-9820-4fce-82a1-e0fa3c38ed24/named-query-elements/named-query-element/dc799ed9-45a5-4323-a2dc-bd1ec3242499/named-query-elements/named-query-element/97ae5271-9ad9-4815-804d-89af014d5b07/named-query-elements/named-query-element/7d189446-54de-49db-b786-8e946f0aece5/named-query-elements/named-query-element/920399b7-21c1-4e81-8fb9-a3b2283a72ba/ + + named-query.named-query-uuid + 55f38763-9820-4fce-82a1-e0fa3c38ed24 + + + named-query-element.named-query-element-uuid + dc799ed9-45a5-4323-a2dc-bd1ec3242499 + + + named-query-element.named-query-element-uuid + 97ae5271-9ad9-4815-804d-89af014d5b07 + + + named-query-element.named-query-element-uuid + 7d189446-54de-49db-b786-8e946f0aece5 + + + named-query-element.named-query-element-uuid + 920399b7-21c1-4e81-8fb9-a3b2283a72ba + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/be890aae-cf27-4b6a-aeae-e6fa4b5ee17f/named-query-elements/named-query-element/1ac142fb-2caf-4f59-975e-8ad7631c301e/named-query-elements/named-query-element/311f1cad-b41c-4833-8b9f-0d54d85f9009/named-query-elements/named-query-element/dc38d8ae-0993-4426-af79-a7aff4a4b4f3/ + + named-query.named-query-uuid + be890aae-cf27-4b6a-aeae-e6fa4b5ee17f + + + named-query-element.named-query-element-uuid + 1ac142fb-2caf-4f59-975e-8ad7631c301e + + + named-query-element.named-query-element-uuid + 311f1cad-b41c-4833-8b9f-0d54d85f9009 + + + named-query-element.named-query-element-uuid + dc38d8ae-0993-4426-af79-a7aff4a4b4f3 + + + + + + 0a706320-b8e7-4b18-9485-fba156ea00cf + widget + l-interface + d9131b0d-698f-4297-8699-af0a3ac7ebdc + v1.0 + 1466698767 + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/5ed1c299-4d31-4531-ae43-4bb56f8f10c8/model-elements/model-element/76624fe1-0f28-4e17-ae9f-f0e2bba6d13d/model-elements/model-element/b7b48ba6-427b-4d23-ada7-a67ac9e0f84f/model-elements/model-element/ebc25508-b2e3-4021-b684-269cfd2b63c0/ + + model.model-name-version-id + 5ed1c299-4d31-4531-ae43-4bb56f8f10c8 + + + model-element.model-element-uuid + 76624fe1-0f28-4e17-ae9f-f0e2bba6d13d + + + model-element.model-element-uuid + b7b48ba6-427b-4d23-ada7-a67ac9e0f84f + + + model-element.model-element-uuid + ebc25508-b2e3-4021-b684-269cfd2b63c0 + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/be890aae-cf27-4b6a-aeae-e6fa4b5ee17f/named-query-elements/named-query-element/1ac142fb-2caf-4f59-975e-8ad7631c301e/named-query-elements/named-query-element/311f1cad-b41c-4833-8b9f-0d54d85f9009/named-query-elements/named-query-element/dc38d8ae-0993-4426-af79-a7aff4a4b4f3/named-query-elements/named-query-element/29ac58b9-37fa-4d6a-9d2e-29f33e1e3b7a/ + + named-query.named-query-uuid + be890aae-cf27-4b6a-aeae-e6fa4b5ee17f + + + named-query-element.named-query-element-uuid + 1ac142fb-2caf-4f59-975e-8ad7631c301e + + + named-query-element.named-query-element-uuid + 311f1cad-b41c-4833-8b9f-0d54d85f9009 + + + named-query-element.named-query-element-uuid + dc38d8ae-0993-4426-af79-a7aff4a4b4f3 + + + named-query-element.named-query-element-uuid + 29ac58b9-37fa-4d6a-9d2e-29f33e1e3b7a + + + + named-query-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/named-queries/named-query/55f38763-9820-4fce-82a1-e0fa3c38ed24/named-query-elements/named-query-element/dc799ed9-45a5-4323-a2dc-bd1ec3242499/named-query-elements/named-query-element/97ae5271-9ad9-4815-804d-89af014d5b07/named-query-elements/named-query-element/7d189446-54de-49db-b786-8e946f0aece5/named-query-elements/named-query-element/920399b7-21c1-4e81-8fb9-a3b2283a72ba/named-query-elements/named-query-element/eda1554f-3eff-4195-9185-bcbc4f75826f/ + + named-query.named-query-uuid + 55f38763-9820-4fce-82a1-e0fa3c38ed24 + + + named-query-element.named-query-element-uuid + dc799ed9-45a5-4323-a2dc-bd1ec3242499 + + + named-query-element.named-query-element-uuid + 97ae5271-9ad9-4815-804d-89af014d5b07 + + + named-query-element.named-query-element-uuid + 7d189446-54de-49db-b786-8e946f0aece5 + + + named-query-element.named-query-element-uuid + 920399b7-21c1-4e81-8fb9-a3b2283a72ba + + + named-query-element.named-query-element-uuid + eda1554f-3eff-4195-9185-bcbc4f75826f + + + + + + 49032ff1-5466-4054-b64b-15395ac10c00 + widget + vlan + 2febb0bc-b776-45b3-af50-75a578a8a4c4 + v1.0 + 1466698621 + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/5ed1c299-4d31-4531-ae43-4bb56f8f10c8/model-elements/model-element/76624fe1-0f28-4e17-ae9f-f0e2bba6d13d/model-elements/model-element/b7b48ba6-427b-4d23-ada7-a67ac9e0f84f/model-elements/model-element/ebc25508-b2e3-4021-b684-269cfd2b63c0/model-elements/model-element/f610d699-11af-4c13-a918-a89344e4a1bd/ + + model.model-name-version-id + 5ed1c299-4d31-4531-ae43-4bb56f8f10c8 + + + model-element.model-element-uuid + 76624fe1-0f28-4e17-ae9f-f0e2bba6d13d + + + model-element.model-element-uuid + b7b48ba6-427b-4d23-ada7-a67ac9e0f84f + + + model-element.model-element-uuid + ebc25508-b2e3-4021-b684-269cfd2b63c0 + + + model-element.model-element-uuid + f610d699-11af-4c13-a918-a89344e4a1bd + + + + + + e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161 + resource + VL ELAN + 932518e5-4260-4cc4-8038-df604a367f85 + 1 + An l2-bridge used by a wan connector connects an ipe to a SBG or DBE + 1466698622 + + + c44dbdf9-494e-49c1-b462-74e24e837b22 + T + unbounded + + 1466698621 + + + a1b205ea-17bb-442b-83a3-38b4e0fcb099 + T + unbounded + + 1466698621 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/0d23052d-8ffe-433e-a25d-da5da027bb7c/ + + model.model-name-version-id + 0d23052d-8ffe-433e-a25d-da5da027bb7c + + + model.model-name + vDbe + + + model.model-type + resource + + + + + + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/fa01ef50-bbb5-49d4-91d1-ebbda9816e01/ + + model.model-name-version-id + fa01ef50-bbb5-49d4-91d1-ebbda9816e01 + + + model.model-name + logical-link + + + model.model-type + widget + + + + + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/668464da-6d41-4599-bdbb-2576147b440e/model-elements/model-element/93a37846-b497-490e-bc97-7d130022d6db/model-elements/model-element/200de3d5-c207-47c2-a507-8846ba1d7068/model-elements/model-element/7ccfe6b5-6566-4b44-83d3-b79f5de7a87b/ + + model.model-name-version-id + 668464da-6d41-4599-bdbb-2576147b440e + + + model-element.model-element-uuid + 93a37846-b497-490e-bc97-7d130022d6db + + + model-element.model-element-uuid + 200de3d5-c207-47c2-a507-8846ba1d7068 + + + model-element.model-element-uuid + 7ccfe6b5-6566-4b44-83d3-b79f5de7a87b + + + + + \ No newline at end of file diff --git a/src/test/resources/model-validation/model-reader/connector-widget-id-no-children-1.xml b/src/test/resources/model-validation/model-reader/connector-widget-id-no-children-1.xml new file mode 100644 index 0000000..e60416c --- /dev/null +++ b/src/test/resources/model-validation/model-reader/connector-widget-id-no-children-1.xml @@ -0,0 +1,51 @@ + + + connector-widget-id + widget + connector + connector-model-id + v1.0 + 1466417894 + + + vpn-id + a + 1466417844 + + + product + b + 1466417844 + + + + + model-element + https://dummy-host.onap.org:8443/aai/v7/service-design-and-creation/model-elements/model-element/54629607-160a-4dcf-8c5c-15b8a3756f9a/ + + model-element.model-element-uuid + 54629607-160a-4dcf-8c5c-15b8a3756f9a + + + model.model-name-version-id + wan-connector-service-id + + + + \ No newline at end of file diff --git a/src/test/resources/model-validation/model-reader/connector-widget-id-no-children-2.xml b/src/test/resources/model-validation/model-reader/connector-widget-id-no-children-2.xml new file mode 100644 index 0000000..924ce67 --- /dev/null +++ b/src/test/resources/model-validation/model-reader/connector-widget-id-no-children-2.xml @@ -0,0 +1,79 @@ + + + connector-widget-id + widget + connector + connector-model-id + v1.0 + 1466417894 + + + 8c0fd413-0d2b-491b-ad14-10c434c359bb + T + unbounded + + 1466417894 + + + + model + https://dummy-host.onap.org:8443/aai/v7/service-design-and-creation/models/model/virtual-data-center-widget-id/ + + model.model-name-version-id + virtual-data-center-widget-id + + + model.model-name + virtual-data-center + + + model.model-type + widget + + + + + + + + vpn-id + a + 1466417844 + + + product + b + 1466417844 + + + + + model-element + https://dummy-host.onap.org:8443/aai/v7/service-design-and-creation/model-elements/model-element/54629607-160a-4dcf-8c5c-15b8a3756f9a/ + + model-element.model-element-uuid + 54629607-160a-4dcf-8c5c-15b8a3756f9a + + + model.model-name-version-id + wan-connector-service-id + + + + \ No newline at end of file diff --git a/src/test/resources/model-validation/model-reader/connector-widget-id.xml b/src/test/resources/model-validation/model-reader/connector-widget-id.xml new file mode 100644 index 0000000..bd2edfc --- /dev/null +++ b/src/test/resources/model-validation/model-reader/connector-widget-id.xml @@ -0,0 +1,107 @@ + + + connector-widget-id + widget + connector + connector-model-id + v1.0 + 1466417894 + + + 8c0fd413-0d2b-491b-ad14-10c434c359bb + T + unbounded + + 1466417894 + + + 6d2dbb11-d509-4e03-8ed9-05bf4aad99d2 + T + unbounded + + 1466417894 + + + + model + https://dummy-host.onap.org:8443/aai/v7/service-design-and-creation/models/model/l2-bridge-for-wan-connector-resource-id/ + + model.model-name-version-id + e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161 + + + model.model-name + l2-bridge-for-wan-connector + + + model.model-type + resource + + + + + + + + + model + https://dummy-host.onap.org:8443/aai/v7/service-design-and-creation/models/model/virtual-data-center-widget-id/ + + model.model-name-version-id + virtual-data-center-widget-id + + + model.model-name + virtual-data-center + + + model.model-type + widget + + + + + + + + vpn-id + a + 1466417844 + + + product + b + 1466417844 + + + + + model-element + https://dummy-host.onap.org:8443/aai/v7/service-design-and-creation/model-elements/model-element/54629607-160a-4dcf-8c5c-15b8a3756f9a/ + + model-element.model-element-uuid + 54629607-160a-4dcf-8c5c-15b8a3756f9a + + + model.model-name-version-id + wan-connector-service-id + + + + \ No newline at end of file diff --git a/src/test/resources/model-validation/model-reader/logical-link-widget-id.xml b/src/test/resources/model-validation/model-reader/logical-link-widget-id.xml new file mode 100644 index 0000000..39c08a3 --- /dev/null +++ b/src/test/resources/model-validation/model-reader/logical-link-widget-id.xml @@ -0,0 +1,181 @@ + + + e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161 + resource + VL ELAN + 932518e5-4260-4cc4-8038-df604a367f85 + 1 + An l2-bridge used by a wan connector connects an ipe to a SBG or DBE + 1466698622 + + + c44dbdf9-494e-49c1-b462-74e24e837b22 + T + unbounded + + 1466698621 + + + ad161a89-ef32-4b2c-b86d-7fbb7a251571 + T + unbounded + + 1466698621 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/6614ffae-6e64-4c78-9dea-4d5c0f057ea2/ + + model.model-name-version-id + 6614ffae-6e64-4c78-9dea-4d5c0f057ea2 + + + model.model-name + pBgf + + + model.model-type + resource + + + + + + a1b205ea-17bb-442b-83a3-38b4e0fcb099 + T + unbounded + + 1466698621 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/0d23052d-8ffe-433e-a25d-da5da027bb7c/ + + model.model-name-version-id + 0d23052d-8ffe-433e-a25d-da5da027bb7c + + + model.model-name + vDbe + + + model.model-type + resource + + + + + + 193ec825-44ce-4416-85ac-20a6b6663575 + T + unbounded + + pserver|lag-interface|l-interface + pserver|p-interface|l-interface + vlan|l-interface + + 1466698621 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/5ed1c299-4d31-4531-ae43-4bb56f8f10c8/ + + model.model-name-version-id + 5ed1c299-4d31-4531-ae43-4bb56f8f10c8 + + + model.model-name + ipe + + + model.model-type + resource + + + + + + 059db56c-6d72-4023-9fc3-0db29534ddff + T + unbounded + + 1466698621 + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/43095b8a-8e9c-4a76-8490-6120140f6804/ + + model.model-name-version-id + 43095b8a-8e9c-4a76-8490-6120140f6804 + + + model.model-name + vSbg + + + model.model-type + resource + + + + + + + + model + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/fa01ef50-bbb5-49d4-91d1-ebbda9816e01/ + + model.model-name-version-id + fa01ef50-bbb5-49d4-91d1-ebbda9816e01 + + + model.model-name + logical-link + + + model.model-type + widget + + + + + + + + model-element + https://dummy-host.test.onap.org:8443/aai/v7/service-design-and-creation/models/model/668464da-6d41-4599-bdbb-2576147b440e/model-elements/model-element/93a37846-b497-490e-bc97-7d130022d6db/model-elements/model-element/200de3d5-c207-47c2-a507-8846ba1d7068/model-elements/model-element/7ccfe6b5-6566-4b44-83d3-b79f5de7a87b/ + + model.model-name-version-id + 668464da-6d41-4599-bdbb-2576147b440e + + + model-element.model-element-uuid + 93a37846-b497-490e-bc97-7d130022d6db + + + model-element.model-element-uuid + 200de3d5-c207-47c2-a507-8846ba1d7068 + + + model-element.model-element-uuid + 7ccfe6b5-6566-4b44-83d3-b79f5de7a87b + + + + \ No newline at end of file diff --git a/src/test/resources/model-validation/model-reader/model-instance-mapping-attributes-1.json b/src/test/resources/model-validation/model-reader/model-instance-mapping-attributes-1.json new file mode 100644 index 0000000..916f898 --- /dev/null +++ b/src/test/resources/model-validation/model-reader/model-instance-mapping-attributes-1.json @@ -0,0 +1,11 @@ +[ + { + "mappingType": "ATTRIBUTE", + "model": { + "value": "metadata/metadatum/metaname" + }, + "instance": { + "value": "$..metadata.metadatum[*].metaname" + } + } +] \ No newline at end of file diff --git a/src/test/resources/model-validation/model-reader/model-instance-mapping-attributes-2.json b/src/test/resources/model-validation/model-reader/model-instance-mapping-attributes-2.json new file mode 100644 index 0000000..7bd8829 --- /dev/null +++ b/src/test/resources/model-validation/model-reader/model-instance-mapping-attributes-2.json @@ -0,0 +1,11 @@ +[ + { + "mappingType": "ATTRIBUTE", + "model": { + "value": "unkown" + }, + "instance": { + "value": "$..metadata.metadatum[*].metaname" + } + } +] \ No newline at end of file diff --git a/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-filter-1.json b/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-filter-1.json new file mode 100644 index 0000000..4d550f0 --- /dev/null +++ b/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-filter-1.json @@ -0,0 +1,18 @@ +[ + { + "mappingType": "RELATIONSHIP", + "model": { + "root": "model-elements/model-element", + "id": "relationship-list/relationship/relationship-data/relationship-value[../relationship-key/text()='model.model-name-version-id']", + "value": "relationship-list/relationship/related-to-property/property-value[../property-key/text()='model.model-name']", + "filter": { + "path": "relationship-list/relationship/related-to-property/property-value[../property-key/text()='model.model-type']", + "valid": ["INVALID_TYPE"] + } + }, + "instance": { + "origin": "$.inventory-response-item[0]", + "root": "$.inventory-response-items.inventory-response-item[*]" + } + } +] \ No newline at end of file diff --git a/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-filter-2.json b/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-filter-2.json new file mode 100644 index 0000000..2c9799e --- /dev/null +++ b/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-filter-2.json @@ -0,0 +1,18 @@ +[ + { + "mappingType": "RELATIONSHIP", + "model": { + "root": "model-elements/model-element", + "id": "relationship-list/relationship/relationship-data/relationship-value[../relationship-key/text()='model.model-name-version-id']", + "value": "relationship-list/relationship/related-to-property/property-value[../property-key/text()='model.model-name']", + "filter": { + "path": "relationship-list/relationship/related-to-property/property-value[../property-key/text()='model.model-type']", + "valid": [] + } + }, + "instance": { + "origin": "$.inventory-response-item[0]", + "root": "$.inventory-response-items.inventory-response-item[*]" + } + } +] \ No newline at end of file diff --git a/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-filter-3.json b/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-filter-3.json new file mode 100644 index 0000000..6442d7b --- /dev/null +++ b/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-filter-3.json @@ -0,0 +1,17 @@ +[ + { + "mappingType": "RELATIONSHIP", + "model": { + "root": "model-elements/model-element", + "id": "relationship-list/relationship/relationship-data/relationship-value[../relationship-key/text()='model.model-name-version-id']", + "value": "relationship-list/relationship/related-to-property/property-value[../property-key/text()='model.model-name']", + "filter": { + "path": "relationship-list/relationship/related-to-property/property-value[../property-key/text()='model.model-type']" + } + }, + "instance": { + "origin": "$.inventory-response-item[0]", + "root": "$.inventory-response-items.inventory-response-item[*]" + } + } +] \ No newline at end of file diff --git a/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-filter-4.json b/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-filter-4.json new file mode 100644 index 0000000..4f50042 --- /dev/null +++ b/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-filter-4.json @@ -0,0 +1,18 @@ +[ + { + "mappingType": "RELATIONSHIP", + "model": { + "root": "model-elements/model-element", + "id": "relationship-list/relationship/relationship-data/relationship-value[../relationship-key/text()='model.model-name-version-id']", + "value": "relationship-list/relationship/related-to-property/property-value[../property-key/text()='model.model-name']", + "filter": { + "path": "INVALID_PATH", + "valid": ["widget"] + } + }, + "instance": { + "origin": "$.inventory-response-item[0]", + "root": "$.inventory-response-items.inventory-response-item[*]" + } + } +] \ No newline at end of file diff --git a/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-filter-5.json b/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-filter-5.json new file mode 100644 index 0000000..8085cfd --- /dev/null +++ b/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-filter-5.json @@ -0,0 +1,17 @@ +[ + { + "mappingType": "RELATIONSHIP", + "model": { + "root": "model-elements/model-element", + "id": "relationship-list/relationship/relationship-data/relationship-value[../relationship-key/text()='model.model-name-version-id']", + "value": "relationship-list/relationship/related-to-property/property-value[../property-key/text()='model.model-name']", + "filter": { + "valid": ["widget"] + } + }, + "instance": { + "origin": "$.inventory-response-item[0]", + "root": "$.inventory-response-items.inventory-response-item[*]" + } + } +] \ No newline at end of file diff --git a/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-filter-6.json b/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-filter-6.json new file mode 100644 index 0000000..67be561 --- /dev/null +++ b/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-filter-6.json @@ -0,0 +1,14 @@ +[ + { + "mappingType": "RELATIONSHIP", + "model": { + "root": "model-elements/model-element", + "id": "relationship-list/relationship/relationship-data/relationship-value[../relationship-key/text()='model.model-name-version-id']", + "value": "relationship-list/relationship/related-to-property/property-value[../property-key/text()='model.model-name']" + }, + "instance": { + "origin": "$.inventory-response-item[0]", + "root": "$.inventory-response-items.inventory-response-item[*]" + } + } +] \ No newline at end of file diff --git a/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-root-1.json b/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-root-1.json new file mode 100644 index 0000000..de11bb2 --- /dev/null +++ b/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-root-1.json @@ -0,0 +1,18 @@ +[ + { + "mappingType": "RELATIONSHIP", + "model": { + "root": "INVALID_ROOT", + "id": "relationship-list/relationship/relationship-data/relationship-value[../relationship-key/text()='model.model-name-version-id']", + "value": "relationship-list/relationship/related-to-property/property-value[../property-key/text()='model.model-name']", + "filter": { + "path": "relationship-list/relationship/related-to-property/property-value[../property-key/text()='model.model-type']", + "valid": ["widget"] + } + }, + "instance": { + "origin": "$.inventory-response-item[0]", + "root": "$.inventory-response-items.inventory-response-item[*]" + } + } +] \ No newline at end of file diff --git a/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-root-2.json b/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-root-2.json new file mode 100644 index 0000000..7bc88ae --- /dev/null +++ b/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-root-2.json @@ -0,0 +1,17 @@ +[ + { + "mappingType": "RELATIONSHIP", + "model": { + "id": "relationship-list/relationship/relationship-data/relationship-value[../relationship-key/text()='model.model-name-version-id']", + "value": "relationship-list/relationship/related-to-property/property-value[../property-key/text()='model.model-name']", + "filter": { + "path": "relationship-list/relationship/related-to-property/property-value[../property-key/text()='model.model-type']", + "valid": ["widget"] + } + }, + "instance": { + "origin": "$.inventory-response-item[0]", + "root": "$.inventory-response-items.inventory-response-item[*]" + } + } +] \ No newline at end of file diff --git a/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-with-id.json b/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-with-id.json new file mode 100644 index 0000000..2c9799e --- /dev/null +++ b/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships-with-id.json @@ -0,0 +1,18 @@ +[ + { + "mappingType": "RELATIONSHIP", + "model": { + "root": "model-elements/model-element", + "id": "relationship-list/relationship/relationship-data/relationship-value[../relationship-key/text()='model.model-name-version-id']", + "value": "relationship-list/relationship/related-to-property/property-value[../property-key/text()='model.model-name']", + "filter": { + "path": "relationship-list/relationship/related-to-property/property-value[../property-key/text()='model.model-type']", + "valid": [] + } + }, + "instance": { + "origin": "$.inventory-response-item[0]", + "root": "$.inventory-response-items.inventory-response-item[*]" + } + } +] \ No newline at end of file diff --git a/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships.json b/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships.json new file mode 100644 index 0000000..89bcae9 --- /dev/null +++ b/src/test/resources/model-validation/model-reader/model-instance-mapping-relationships.json @@ -0,0 +1,18 @@ +[ + { + "mappingType": "RELATIONSHIP", + "model": { + "root": "model-elements/model-element", + "id": "relationship-list/relationship/relationship-data/relationship-value[../relationship-key/text()='model.model-name-version-id']", + "value": "relationship-list/relationship/related-to-property/property-value[../property-key/text()='model.model-name']", + "filter": { + "path": "relationship-list/relationship/related-to-property/property-value[../property-key/text()='model.model-type']", + "valid": ["widget"] + } + }, + "instance": { + "origin": "$.inventory-response-item[0]", + "root": "$.inventory-response-items.inventory-response-item[*]" + } + } +] \ No newline at end of file diff --git a/src/test/resources/model-validation/model-reader/test-validation-service-beans.xml b/src/test/resources/model-validation/model-reader/test-validation-service-beans.xml new file mode 100644 index 0000000..81dab3e --- /dev/null +++ b/src/test/resources/model-validation/model-reader/test-validation-service-beans.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/model-validation/model-reader/validation-service.properties b/src/test/resources/model-validation/model-reader/validation-service.properties new file mode 100644 index 0000000..4e1b264 --- /dev/null +++ b/src/test/resources/model-validation/model-reader/validation-service.properties @@ -0,0 +1,29 @@ +# ============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===================================================== + +topic.publish.enable=true +topic.publish.retries=3 +topic.consume.enable=true +topic.consume.polling.interval.seconds=3 + +event.domain=devINT1 +event.action.exclude=DELETE +event.type.rule=AAI-EVENT,AAI-DATA-EXPORT-API,GIZMO-EVENT +event.type.model=AAI-DATA-EXPORT-NQ +event.type.end=END-EVENT + +model.cache.expirySeconds=3 +aai.oxm.version=12 diff --git a/src/test/resources/model-validation/model-reader/virtual-data-center-widget-id.xml b/src/test/resources/model-validation/model-reader/virtual-data-center-widget-id.xml new file mode 100644 index 0000000..aadee37 --- /dev/null +++ b/src/test/resources/model-validation/model-reader/virtual-data-center-widget-id.xml @@ -0,0 +1,72 @@ + + + virtual-data-center-widget-id + widget + virtual-data-center + vdc-model-id + v1.0 + 1466417894 + + + 6d2dbb11-d509-4e03-8ed9-05bf4aad99d2 + T + unbounded + + 1466417894 + + + + model + https://dummy-host.onap.org:8443/aai/v7/service-design-and-creation/models/model/l2-bridge-for-wan-connector-resource-id/ + + model.model-name-version-id + e2ccd5c5-bc6e-4ed0-8378-6805ee6ba161 + + + model.model-name + l2-bridge-for-wan-connector + + + model.model-type + resource + + + + + + + + + model-element + https://dummy-host.onap.org:8443/aai/v7/service-design-and-creation/model-elements/model-element/8c0fd413-0d2b-491b-ad14-10c434c359bb/ + + model-element.model-element-uuid + 8c0fd413-0d2b-491b-ad14-10c434c359bb + + + model-element.model-element-uuid + 54629607-160a-4dcf-8c5c-15b8a3756f9a + + + model.model-name-version-id + wan-connector-service-id + + + + \ No newline at end of file diff --git a/src/test/resources/oxm-reader/multiple/test_business_v10.xml b/src/test/resources/oxm-reader/multiple/test_business_v10.xml new file mode 100644 index 0000000..f0dc93f --- /dev/null +++ b/src/test/resources/oxm-reader/multiple/test_business_v10.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 new file mode 100644 index 0000000..2529c6d --- /dev/null +++ b/src/test/resources/oxm-reader/multiple/test_business_v13.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 new file mode 100644 index 0000000..9767de6 --- /dev/null +++ b/src/test/resources/oxm-reader/multiple/test_network_v10.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 new file mode 100644 index 0000000..892f626 --- /dev/null +++ b/src/test/resources/oxm-reader/multiple/test_network_v13.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 new file mode 100644 index 0000000..c9f064a --- /dev/null +++ b/src/test/resources/oxm-reader/oxm-reader-beans.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/oxm-reader/schemaIngest.properties b/src/test/resources/oxm-reader/schemaIngest.properties new file mode 100644 index 0000000..bb1027e --- /dev/null +++ b/src/test/resources/oxm-reader/schemaIngest.properties @@ -0,0 +1,20 @@ +# ============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===================================================== + +# 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 diff --git a/src/test/resources/oxm-reader/single/aai_oxm_v0.xml b/src/test/resources/oxm-reader/single/aai_oxm_v0.xml new file mode 100644 index 0000000..ffab598 --- /dev/null +++ b/src/test/resources/oxm-reader/single/aai_oxm_v0.xml @@ -0,0 +1,23 @@ + + + + + + + \ No newline at end of file diff --git a/src/test/resources/oxm-reader/single/aai_oxm_v10.xml b/src/test/resources/oxm-reader/single/aai_oxm_v10.xml new file mode 100644 index 0000000..b4c880a --- /dev/null +++ b/src/test/resources/oxm-reader/single/aai_oxm_v10.xml @@ -0,0 +1,6569 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/oxm-reader/single/aai_oxm_v8.xml b/src/test/resources/oxm-reader/single/aai_oxm_v8.xml new file mode 100644 index 0000000..40939a4 --- /dev/null +++ b/src/test/resources/oxm-reader/single/aai_oxm_v8.xml @@ -0,0 +1,4362 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/oxm-reader/single/aai_oxm_v9.xml b/src/test/resources/oxm-reader/single/aai_oxm_v9.xml new file mode 100644 index 0000000..6fe7379 --- /dev/null +++ b/src/test/resources/oxm-reader/single/aai_oxm_v9.xml @@ -0,0 +1,4772 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 new file mode 100644 index 0000000..ffab598 --- /dev/null +++ b/src/test/resources/oxm-reader/single/aai_oxm_vnonDigit.xml @@ -0,0 +1,23 @@ + + + + + + + \ 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/test_v10_edges.json new file mode 100644 index 0000000..e69de29 diff --git a/src/test/resources/rest-config/aai-environment.properties b/src/test/resources/rest-config/aai-environment.properties new file mode 100644 index 0000000..988ae90 --- /dev/null +++ b/src/test/resources/rest-config/aai-environment.properties @@ -0,0 +1,29 @@ +# ============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===================================================== + +# Used by org.onap.aai.validation.config.TestRestConfig +host=localhost +port=8080 +httpProtocol=https +trustStorePath=/dir1/dir2/trustStorePath +trustStorePassword.x=70c87528c88dcd9f9c2558d30e817868 +keyStorePath=/dir1/dir2/keyStorePath +keyStorePassword.x=70c87528c88dcd9f9c2558d30e817868 +keyManagerFactoryAlgorithm=AES +keyStoreType=jks +securityProtocol=TLS +connectionTimeout=100 +readTimeout=200 diff --git a/src/test/resources/rest-config/test-validation-service-beans.xml b/src/test/resources/rest-config/test-validation-service-beans.xml new file mode 100644 index 0000000..487bfe9 --- /dev/null +++ b/src/test/resources/rest-config/test-validation-service-beans.xml @@ -0,0 +1,29 @@ + + + + + + + + + + diff --git a/src/test/resources/rule-driven-validator/results/expected/generic-vnf-create-event.exp.json b/src/test/resources/rule-driven-validator/results/expected/generic-vnf-create-event.exp.json new file mode 100644 index 0000000..ef0848a --- /dev/null +++ b/src/test/resources/rule-driven-validator/results/expected/generic-vnf-create-event.exp.json @@ -0,0 +1,35 @@ +{ + "validationId": "", + "validationTimestamp": "", + "entityId": { + "vnf-id": "e5365951-9d90-4853-afae-c34a0707e3b6" + }, + "entityType": "generic-vnf", + "entityLink": "network/generic-vnfs/generic-vnf/e5365951-9d90-4853-afae-c34a0707e3b6", + "resourceVersion": "1476736914", + "entity":"fkdlfkdl", + "violations": [ + { + "violationId": "f47ce3b89d92659086e986f674cec4a7bed54601b8007aac69c6157101973b90", + "category": "INVALID_VALUE", + "severity": "CRITICAL", + "violationType": "Rule", + "validationRule": "prov-status", + "violationDetails": { + "prov-status": null + }, + "errorMessage": "Invalid prov-status value. Must be PREPROV, NVTPROV, PROV, CAPPED, DECOM, or RETIRED" + }, + { + "violationId": "227d68c5fb944636cc9b8a08e8fcefadf13bfd1ba2c40547d664b7150f1ebc14", + "category": "INVALID_VALUE", + "severity": "MINOR", + "violationType": "Rule", + "validationRule": "valid_ipv4_addr", + "violationDetails": { + "ipv4-oam-address": "" + }, + "errorMessage": "Invalid value - attribute is not a valid IPv4 address" + } + ] +} \ No newline at end of file diff --git a/src/test/resources/rule-driven-validator/results/expected/gizmo-pserver-create-event-invalid-ipaddress.exp.json b/src/test/resources/rule-driven-validator/results/expected/gizmo-pserver-create-event-invalid-ipaddress.exp.json new file mode 100644 index 0000000..b6b851c --- /dev/null +++ b/src/test/resources/rule-driven-validator/results/expected/gizmo-pserver-create-event-invalid-ipaddress.exp.json @@ -0,0 +1,24 @@ +{ + "validationId":"5d37dd63-8289-4e0c-8da0-9007c1de4e39", + "validationTimestamp":"20180220T173524Z", + "entityId":{ + "hostname":"myhost" + }, + "entityType":"pserver", + "entityLink":"", + "resourceVersion":"1477013499", + "violations":[ + { + "violationId":"f0c12d0f91779de43034ca5be323d0e0b076d228f49a998a910127af0da0009b", + "modelName":null, + "category":"INVALID_VALUE", + "severity":"MINOR", + "violationType":"Rule", + "validationRule":"valid_ipv4_addr", + "violationDetails":{ + "vertex.properties.ipv4-oam-address":"1.2.3." + }, + "errorMessage":"Invalid value - attribute is not a valid IPv4 address" + } + ] +} \ No newline at end of file diff --git a/src/test/resources/rule-driven-validator/results/expected/gizmo-pserver-create-event.exp.json b/src/test/resources/rule-driven-validator/results/expected/gizmo-pserver-create-event.exp.json new file mode 100644 index 0000000..256a488 --- /dev/null +++ b/src/test/resources/rule-driven-validator/results/expected/gizmo-pserver-create-event.exp.json @@ -0,0 +1,13 @@ +{ + "validationId":"f7c28a16-2bdf-40a9-9414-ad430e2550c8", + "validationTimestamp":"20180220T172745Z", + "entityId":{ + "hostname":"myhost" + }, + "entityType":"pserver", + "entityLink":"", + "resourceVersion":"1477013499", + "violations":[ + + ] +} \ No newline at end of file diff --git a/src/test/resources/rule-driven-validator/results/expected/vserver-create-AAI-EVENT-devINT1-TRINITY-VNF-NAME-BAD.exp.json b/src/test/resources/rule-driven-validator/results/expected/vserver-create-AAI-EVENT-devINT1-TRINITY-VNF-NAME-BAD.exp.json new file mode 100644 index 0000000..a8a4ae2 --- /dev/null +++ b/src/test/resources/rule-driven-validator/results/expected/vserver-create-AAI-EVENT-devINT1-TRINITY-VNF-NAME-BAD.exp.json @@ -0,0 +1,128 @@ +{ + "validationId": "VALIDATIONID", + "validationTimestamp": "TIMESTAMP", + "entityId": { + "vserver-id": "c385bb3e-6ebd-4898-bc92-792e0ac2db50" + }, + "entityType": "vserver", + "entityLink": "cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/tenants/tenant/example-tenant-id-val-88551/vservers/vserver/example-vserver-id-val-34666", + "resourceVersion": "1475160142", + "violations": [ + { + "violationId": "3855354af5e3da4383dd39beac0c814e5125e0afa3bf0332f9289aa6178db5d6", + "category": "INVALID_VALUE", + "severity": "CRITICAL", + "violationType": "Rule", + "validationRule": "prov-status", + "violationDetails": { + "prov-status": "ACTIVE" + }, + "errorMessage": "Invalid prov-status value. Must be PREPROV, NVTPROV, PROV, CAPPED, DECOM, or RETIRED" + }, + { + "violationId": "2adb3dbf7ab2acb68033608ab5641962a953f720a76a7fe8c143792851ca0901", + "category": "INVALID_NAME", + "severity": "MINOR", + "violationType": "Rule", + "validationRule": "vserver related to TRINITY image and generic-vnf.vnf-name matches naming convention", + "violationDetails": { + "relationship-list.relationship[*]": [ + { + "related-to": "generic-vnf", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/network/generic-vnfs/generic-vnf/ctpx12345v/", + "relationship-data": [ + { + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "ctpx12345v" + } + ], + "related-to-property": [ + { + "property-key": "generic-vnf.vnf-name", + "property-value": "ctpx12345v" + } + ] + }, + { + "related-to": "vf-module", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/network/generic-vnfs/generic-vnf/ctpx12345v/vf-modules/vf-module/ctpx12345v/", + "relationship-data": [ + { + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "ctpx12345v" + }, + { + "relationship-key": "vf-module.vf-module-id", + "relationship-value": "ctpx12345v" + } + ] + }, + { + "related-to": "image", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/images/image/TRINITY-IMAGE/", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "region1" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "AAIregion1" + }, + { + "relationship-key": "image.image-id", + "relationship-value": "TRINITY-IMAGE" + } + ], + "related-to-property": [ + { + "property-key": "image.image-name", + "property-value": "TRINITY IMAGE" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/cloud-infrastructure/pservers/pserver/TRINITY-PSERVER/", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "TRINITY-PSERVER" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "flavor", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/flavors/flavor/TRINITY-Flavor/", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "region1" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "AAIregion1" + }, + { + "relationship-key": "flavor.flavor-id", + "relationship-value": "TRINITY-Flavor" + } + ], + "related-to-property": [ + { + "property-key": "flavor.flavor-name", + "property-value": "TRINITY Flavor" + } + ] + } + ] + }, + "errorMessage": "Invalid name - if vserver is related to an image named TRINITY, then the related generic-vnf name must match xxxxnnnnv (where x = character and n = number)" + } + ] +} \ No newline at end of file diff --git a/src/test/resources/rule-driven-validator/results/expected/vserver-create-AAI-EVENT-devINT1-TRINITY-VNF-NAME-GOOD.exp.json b/src/test/resources/rule-driven-validator/results/expected/vserver-create-AAI-EVENT-devINT1-TRINITY-VNF-NAME-GOOD.exp.json new file mode 100644 index 0000000..6e63d7f --- /dev/null +++ b/src/test/resources/rule-driven-validator/results/expected/vserver-create-AAI-EVENT-devINT1-TRINITY-VNF-NAME-GOOD.exp.json @@ -0,0 +1,23 @@ +{ + "validationId": "VALIDATIONID", + "validationTimestamp": "TIMESTAMP", + "entityId": { + "vserver-id": "c385bb3e-6ebd-4898-bc92-792e0ac2db50" + }, + "entityType": "vserver", + "entityLink": "cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/tenants/tenant/example-tenant-id-val-88551/vservers/vserver/example-vserver-id-val-34666", + "resourceVersion": "1475160142", + "violations": [ + { + "violationId": "3855354af5e3da4383dd39beac0c814e5125e0afa3bf0332f9289aa6178db5d6", + "category": "INVALID_VALUE", + "severity": "CRITICAL", + "violationType": "Rule", + "validationRule": "prov-status", + "violationDetails": { + "prov-status": "ACTIVE" + }, + "errorMessage": "Invalid prov-status value. Must be PREPROV, NVTPROV, PROV, CAPPED, DECOM, or RETIRED" + } + ] +} \ No newline at end of file diff --git a/src/test/resources/rule-driven-validator/results/expected/vserver-create-event.exp.json b/src/test/resources/rule-driven-validator/results/expected/vserver-create-event.exp.json new file mode 100644 index 0000000..7042c13 --- /dev/null +++ b/src/test/resources/rule-driven-validator/results/expected/vserver-create-event.exp.json @@ -0,0 +1,208 @@ +{ + "validationId": "VALIDATIONID", + "validationTimestamp": "TIMESTAMP", + "entityId": { + "vserver-id": "example-vserver-id-val-34666" + }, + "entityType": "vserver", + "entityLink": "cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/tenants/tenant/example-tenant-id-val-88551/vservers/vserver/example-vserver-id-val-34666", + "resourceVersion": "1464193654", + "violations": [ + { + "violationId": "312ed832aed6adfff008732d5d3c4e03d46195ea38f2c305c4e58c9779e4721f", + "category": "INVALID_VALUE", + "severity": "CRITICAL", + "violationType": "Rule", + "validationRule": "prov-status", + "violationDetails": { + "prov-status": "INVALID" + }, + "errorMessage": "Invalid prov-status value. Must be PREPROV, NVTPROV, PROV, CAPPED, DECOM, or RETIRED" + }, + { + "violationId": "819a20606acf8eefa64ea06ddb1041edebdec7eb18c5695860eda5e3d1729460", + "modelName": null, + "category": "INVALID_NAME", + "severity": "MINOR", + "violationType": "Rule", + "validationRule": "vserver related to TRINITY image and generic-vnf.vnf-name matches naming convention", + "violationDetails": { + "relationship-list.relationship[*]": [ + { + "related-to": "generic-vnf", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/network/generic-vnfs/generic-vnf/bmsx0001v-1661/", + "relationship-data": [ + { + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "bmsx0001v-1661" + } + ], + "related-to-property": [ + { + "property-key": "generic-vnf.vnf-name", + "property-value": "bmsx000x" + } + ] + }, + { + "related-to": "image", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/images/image/ee49d429-283d-4f79-9c58-e11cc38d8856/", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "region1" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "AAIregion1" + }, + { + "relationship-key": "image.image-id", + "relationship-value": "ee49d429-283d-4f79-9c58-e11cc38d8856" + } + ], + "related-to-property": [ + { + "property-key": "image.image-name", + "property-value": "TRINITY" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/cloud-infrastructure/pservers/pserver/dpa2r03c007/", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "dpa2r03c007" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "flavor", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/flavors/flavor/5288f576-d9c6-46fc-9dcb-f6946a2b3597/", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "region1" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "AAIregion1" + }, + { + "relationship-key": "flavor.flavor-id", + "relationship-value": "5288f576-d9c6-46fc-9dcb-f6946a2b3597" + } + ], + "related-to-property": [ + { + "property-key": "flavor.flavor-name", + "property-value": "l5.xLarge" + } + ] + } + ] + }, + "errorMessage": "Invalid name - if vserver is related to an image named TRINITY, then the related generic-vnf name must match xxxxnnnnv (where x = character and n = number)" + }, + { + "violationId": "50819193f02c57e6878573dbe4d8d43942ee0b20cb539aed817c067072733f6e", + "modelName": null, + "category": "INVALID_NAME", + "severity": "MINOR", + "violationType": "Rule", + "validationRule": "vserver is related to a TRINITY image and vserver-name matches naming convention", + "violationDetails": { + "relationship-list.relationship[*]": [ + { + "related-to": "generic-vnf", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/network/generic-vnfs/generic-vnf/bmsx0001v-1661/", + "relationship-data": [ + { + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "bmsx0001v-1661" + } + ], + "related-to-property": [ + { + "property-key": "generic-vnf.vnf-name", + "property-value": "bmsx000x" + } + ] + }, + { + "related-to": "image", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/images/image/ee49d429-283d-4f79-9c58-e11cc38d8856/", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "region1" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "AAIregion1" + }, + { + "relationship-key": "image.image-id", + "relationship-value": "ee49d429-283d-4f79-9c58-e11cc38d8856" + } + ], + "related-to-property": [ + { + "property-key": "image.image-name", + "property-value": "TRINITY" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/cloud-infrastructure/pservers/pserver/dpa2r03c007/", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "dpa2r03c007" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "flavor", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/flavors/flavor/5288f576-d9c6-46fc-9dcb-f6946a2b3597/", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "region1" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "AAIregion1" + }, + { + "relationship-key": "flavor.flavor-id", + "relationship-value": "5288f576-d9c6-46fc-9dcb-f6946a2b3597" + } + ], + "related-to-property": [ + { + "property-key": "flavor.flavor-name", + "property-value": "l5.xLarge" + } + ] + } + ], + "vserver-name": "example-vserver-name-val-34666" + }, + "errorMessage": "Invalid name - if vserver is related to an image named TRINITY, then the vserver name must match xxxxnnnnvmnnn (where x = character and n = number)" + } + ] +} \ No newline at end of file diff --git a/src/test/resources/rule-driven-validator/results/expected/vserver-update-AAI-EVENT-devINT1.exp.json b/src/test/resources/rule-driven-validator/results/expected/vserver-update-AAI-EVENT-devINT1.exp.json new file mode 100644 index 0000000..4cf7264 --- /dev/null +++ b/src/test/resources/rule-driven-validator/results/expected/vserver-update-AAI-EVENT-devINT1.exp.json @@ -0,0 +1,38 @@ +{ + "validationId": "VALIDATIONID", + "validationTimestamp": "TIMESTAMP", + "entityId": { + "vserver-id": "fd280243-cd5c-424e-b629-533cabe2a164" + }, + "entityType": "vserver", + "entityLink": "cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/tenants/tenant/d52b9dea5d0f4e5d90be3590ac8c78a9/vservers/vserver/fd280243-cd5c-424e-b629-533cabe2a164", + "resourceVersion": "1476735222", + "violations": [ + { + "violationId": "af7226e6b786fb8ad20e1ef088c1b04fd0408093405ca51559f001607ab758e0", + "category": "INVALID_VALUE", + "severity": "CRITICAL", + "violationType": "Rule", + "validationRule": "prov-status", + "violationDetails": { + "prov-status": null + }, + "errorMessage": "Invalid prov-status value. Must be PREPROV, NVTPROV, PROV, CAPPED, DECOM, or RETIRED" + }, + { + "violationId": "daf1c3d071651c081f05f913e0fe2ba4750d2a1fa1699d60a7693126615c4a07", + "category": "MISSING_REL", + "severity": "MINOR", + "violationType": "Rule", + "validationRule": "vserver is related to a vnf (vce or newvce or vpe or generic-vnf)", + "violationDetails": { + "relationship-list.relationship[*].related-to": [ + "image", + "pserver", + "flavor" + ] + }, + "errorMessage": "Missing relationship - a vserver must be related to a vnf (vce or newvce or vpe or generic-vnf)" + } + ] +} \ No newline at end of file diff --git a/src/test/resources/rule-driven-validator/rules/aai-event/common_rules.groovy b/src/test/resources/rule-driven-validator/rules/aai-event/common_rules.groovy new file mode 100644 index 0000000..70980fe --- /dev/null +++ b/src/test/resources/rule-driven-validator/rules/aai-event/common_rules.groovy @@ -0,0 +1,69 @@ +/* + * ============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===================================================== + */ + +rule { + name 'prov-status' + category 'INVALID_VALUE' + description 'prov-status value restricted to one of PREPROV, NVTPROV, PROV, CAPPED, DECOM, RETIRED' + errorText 'Invalid prov-status value. Must be PREPROV, NVTPROV, PROV, CAPPED, DECOM, or RETIRED' + severity 'CRITICAL' + attributes 'status' + validate '''switch (status) { + case "PREPROV": + case "NVTPROV": + case "PROV": + case "CAPPED": + case "DECOM": + case "RETIRED": + return true + default: return false + }''' +} + +// The following are used by both vce and newvce + +rule { + name 'vnf-name' + category 'INVALID_NAME' + description 'Invalid naming convention' + errorText 'Invalid name - attribute does not match xxxxxnnnvbc (where x = alphanumeric and n = numeric)' + severity 'MINOR' + attributes 'name' + validate 'name != null && name.matches("[a-z,0-9]{5}[0-9]{3}vbc")' +} + +rule { + name 'vnf-type' + category 'INVALID_VALUE' + description 'Invalid value' + errorText 'Invalid value - attribute must equal esx-vce' + severity 'MINOR' + attributes 'name' + validate 'name != null && name.matches("esx-vce")' +} + +rule { + name 'heat-stack-id equals first 11 bytes of vnf-name' + category 'INVALID_VALUE' + description 'The value of heat-stack-id must equal the first 11 bytes of vnf-name' + errorText 'Invalid value - the value of heat-stack-id must equal the first 11 bytes of vnf-name' + severity 'MINOR' + attributes 'heatstackid', 'vnfname' + validate '''def firstEleven = { str -> str ? str.take(11) : null } + heatstackid.equals(firstEleven(vnfname))''' +} diff --git a/src/test/resources/rule-driven-validator/rules/aai-event/entity-complex.groovy b/src/test/resources/rule-driven-validator/rules/aai-event/entity-complex.groovy new file mode 100644 index 0000000..48d2f26 --- /dev/null +++ b/src/test/resources/rule-driven-validator/rules/aai-event/entity-complex.groovy @@ -0,0 +1,146 @@ +/* + * ============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===================================================== + */ + +entity { + type 'complex' + validation { + useRule { + name 'CLLI' + attributes 'physical-location-id' + } + useRule { + name 'not AAI default' + attributes 'street1' + } + useRule { + name 'not AAI default' + attributes 'city' + } + useRule { + name 'not AAI default' + attributes 'state' + } + useRule { + name 'not AAI default' + attributes 'postal-code' + } + useRule { + name 'not AAI default' + attributes 'region' + } + useRule { + name 'not AAI default' + attributes 'country' + } + useRule { + name 'critical not AAI default' + attributes 'physical-location-type' + } + useRule { + name 'length five or null' + attributes 'complex-name' + } + useRule {name 'complex is related to availability zone' } + useRule {name 'complex is related to 1 oam-network' } + useRule { + name 'if a customer is related to an oam-network then oam-network.network-name must match naming convention' + attributes 'relationship-list.relationship[*]' + } + } +} + +rule { + name 'CLLI' + category 'FIELD_LENGTH' + description 'Field must be 8 or 11 characters long' + errorText 'Invalid length - field must be 8 or 11 characters long' + severity 'CRITICAL' + attributes 'field' + validate 'field.size() == 8 || field.size() == 11' +} + +rule { + name 'not AAI default' + category 'FIELD_LENGTH' + description 'Invalid length - field must not be AAIDEFAULT or null' + errorText 'Invalid Value - must not be AAIDEFAULT or null' + severity 'MINOR' + attributes 'field' + validate 'field != null && field.size() > 0 && !field.equalsIgnoreCase("AAIDEFAULT")' +} + +rule { + name 'length five or null' + category 'FIELD_LENGTH' + description 'Field must be 5 characters long or null' + errorText 'Invalid Length - field must be 5 characters long or null' + severity 'MINOR' + attributes 'field' + validate 'field == null || field.size() == 5' +} + +rule { + name 'critical not AAI default' + category 'INVALID_VALUE' + description 'Field must not be AAIDEFAULT or null' + errorText 'Invalid Value - must not be AAIDEFAULT or null' + severity 'CRITICAL' + attributes 'field' + validate 'field != null && field.size() > 0 && !field.equalsIgnoreCase("AAIDEFAULT")' +} + +rule { + name 'complex is related to availability zone' + category 'MISSING_REL' + description 'Validates that a complex is related to an availability zone' + errorText 'Missing relationship - a complex must be related to an availability zone' + severity 'CRITICAL' + attributes 'relationship-list.relationship[*].related-to' + validate 'related-to != null && related-to.contains("availability-zone")' +} + +rule { + name 'complex is related to 1 oam-network' + category 'MISSING_REL' + description 'Validates that a complex is related to 1 oam-network (and not more than 1 oam-network)' + errorText 'Missing relationship - complex must be related to 1 oam-network' + severity 'MAJOR' + attributes 'relationship-list.relationship[*].related-to' + validate 'related-to != null && related-to.count("oam-network") == 1' +} + +rule { + name 'if a customer is related to an oam-network then oam-network.network-name must match naming convention' + category 'INVALID_NAME' + description 'validates that if a customer is related to an oam-network then oam-network.network-name must match naming convention' + errorText 'Invalid name - if a customer is related to an oam-network then network-name must start with VLAN' + severity 'MINOR' + attributes 'relationships' + validate ''' + def getStringProperty = { jsonObject, propertyName -> jsonObject.get(propertyName).getAsString() } + + relatedToOamNetwork = relationships.findAll { getStringProperty(it, "related-to") == "oam-network" } + + networkNameIsValid = relationships.findAll { getStringProperty(it, "related-to") == "oam-network" } + .collect { it."related-to-property".get(0) } + .findAll { getStringProperty(it, "property-key") == "oam-network.network-name" } + .find { getStringProperty(it, "property-value").startsWith("VLAN") } + + return !relatedToOamNetwork || networkNameIsValid + ''' +} diff --git a/src/test/resources/rule-driven-validator/rules/aai-event/entity-newvce.groovy b/src/test/resources/rule-driven-validator/rules/aai-event/entity-newvce.groovy new file mode 100644 index 0000000..dce812a --- /dev/null +++ b/src/test/resources/rule-driven-validator/rules/aai-event/entity-newvce.groovy @@ -0,0 +1,43 @@ +/* + * ============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===================================================== + */ + +entity { + type 'newvce' + validation { + useRule { + name 'prov-status' + attributes 'prov-status' + } + useRule { + name 'vnf-name' + attributes 'vnf-name' + } + useRule { + name 'vnf-type' + attributes 'vnf-type' + } + useRule { + name 'valid_ipv4_addr' + attributes 'ipv4-oam-address' + } + useRule { + name 'heat-stack-id equals first 11 bytes of vnf-name' + attributes 'heat-stack-id', 'vnf-name' + } + } +} diff --git a/src/test/resources/rule-driven-validator/rules/aai-event/generic-vnf-rules.groovy b/src/test/resources/rule-driven-validator/rules/aai-event/generic-vnf-rules.groovy new file mode 100644 index 0000000..d890c36 --- /dev/null +++ b/src/test/resources/rule-driven-validator/rules/aai-event/generic-vnf-rules.groovy @@ -0,0 +1,56 @@ +/* + * ============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===================================================== + */ + +entity { + type 'generic-vnf' + validation { + useRule { + name 'prov-status' + attributes 'prov-status' + } + useRule { + name 'valid_ipv4_addr' + attributes 'ipv4-oam-address' + } + useRule { + name 'ipv4_addr_present' + attributes 'equipment-role', 'l-interfaces.l-interface[*].l3-interface-ipv4-address-list' + } + } +} + +rule { + name 'valid_ipv4_addr' + category 'INVALID_VALUE' + description 'Validate an IPv4 address' + errorText 'Invalid value - attribute is not a valid IPv4 address' + severity 'MINOR' + attributes 'ipaddr' + validate 'ipaddr != null && ipaddr.matches("^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])")' +} + +// If generic-vnf.equipment-role="UCPE" and there is an l-interface - then there must be an IPV4 address related to the l-interface +rule { + name 'ipv4_addr_present' + category 'MISSING_REL' + description 'Validates that ICPE equipment has a related IPv4 address' + errorText 'UCPE l-interface missing the IPv4 relationship' + severity 'MINOR' + attributes 'equipment', 'ipv4' + validate 'equipment != "UCPE" || ipv4 != null' +} diff --git a/src/test/resources/rule-driven-validator/rules/aai-event/rule-vserver-all_others.groovy b/src/test/resources/rule-driven-validator/rules/aai-event/rule-vserver-all_others.groovy new file mode 100644 index 0000000..d922df9 --- /dev/null +++ b/src/test/resources/rule-driven-validator/rules/aai-event/rule-vserver-all_others.groovy @@ -0,0 +1,118 @@ +/* + * ============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===================================================== + */ + +rule { + name 'vserver is related to a vnf (vce or newvce or vpe or generic-vnf)' + category 'MISSING_REL' + description 'Validates that a vserver is related to a vnf (vce or newvce or vpe or generic-vnf)' + errorText 'Missing relationship - a vserver must be related to a vnf (vce or newvce or vpe or generic-vnf)' + severity 'MINOR' + attributes 'related-to' + validate 'related-to != null && (related-to.contains("vce") || related-to.contains("newvce") || related-to.contains("vpe") || related-to.contains("generic-vnf"))' +} + +rule { + name 'vserver is related to 1 pserver' + category 'MISSING_REL' + description 'Validates that a vserver is related to 1 pserver (and not more than 1 pserver)' + errorText 'Missing relationship - vserver must be related to 1 pserver' + severity 'MINOR' + attributes 'relationship-list.relationship[*].related-to' + validate 'related-to == null || related-to.count("pserver") == 1' +} + +rule { + name 'vserver is related to 0 or 1 image' + category 'MISSING_REL' + description 'Validates that a vserver is either not related to an image or related to only 1 image' + errorText 'Missing relationship - vserver must be related to 0 or 1 image' + severity 'MINOR' + attributes 'relationship-list.relationship[*].related-to' + validate 'related-to == null || related-to.count("image") <= 1' +} + +rule { + name 'vserver is related to 0 or 1 flavor' + category 'MISSING_REL' + description 'Validates that a vserver is either not related to a flavor or related to only 1 flavor' + errorText 'Missing relationship - vserver must be related to 0 or 1 flavor' + severity 'MINOR' + attributes 'relationship-list.relationship[*].related-to' + validate 'related-to == null || related-to.count("flavor") <= 1' +} + +rule { + name 'vserver is related to vpe and vserver-name matches naming convention' + category 'INVALID_NAME' + description 'Validates that if a vserver is related to a vpe then vserver-name must contain me6' + errorText 'Invalid name - if vserver is related to vpe then vserver-name must contain me6' + severity 'MINOR' + attributes 'relationship-list.relationship[*].related-to', 'vserver-name' + validate '!related-to.contains("vpe") || vserver-name =~ "me6"' +} + +rule { + name 'vserver is related to vce and vserver-name matches naming convention' + category 'INVALID_NAME' + description 'Validates that if a vserver is related to a vce then vserver-name must match naming convention' + errorText 'Invalid name - if vserver is related to vce then vserver-name must match xxxxxxxxvbcnnceb (where x = alphanumeric and n = numeric)' + severity 'MINOR' + attributes 'relationship-list.relationship[*].related-to', 'vserver-name' + validate '!related-to.contains("vce") || vserver-name =~ "[a-z0-9]{8}vbc[0-9]{2}ceb"' +} + +rule { + name 'vserver is related to a TRINITY image and vserver-name matches naming convention' + category 'INVALID_NAME' + description 'Validates that if vserver is related to an image named TRINITY, then the vserver name matches naming convention' + errorText 'Invalid name - if vserver is related to an image named TRINITY, then the vserver name must match xxxxnnnnvmnnn (where x = character and n = number)' + severity 'MINOR' + attributes 'relationships', 'vservername' + validate ''' + def getStringProperty = { jsonObject, propertyName -> jsonObject.get(propertyName)?.getAsString() } + + relatedToTrinity = relationships.findAll { getStringProperty(it, "related-to") == "image" } + .findAll { it."related-to-property" != null } + .collect { it."related-to-property".get(0) } + .findAll { getStringProperty(it, "property-key") == "image.image-name" } + .find { getStringProperty(it, "property-value").startsWith("TRINITY") } + + // If (and only if) related to TRINITY then check the vserver name + return !relatedToTrinity || vservername != null && vservername ==~ "[a-z]{4}[0-9]{4}vm[0-9]{3}" + ''' +} + +rule { + name 'availability-zone must be related to a service-capability and service-capability.service-type matches naming convention' + category 'INVALID_NAME' + description 'Validates that an availability-zone is related to a service-capability and service-capability.service-type matches naming convention' + errorText 'Invalid name - availability-zone must be related to a service-capability and service-capability.service-type must be set to SDN-ETHERNET-INTERNET' + severity 'CRITICAL' + attributes 'relationships' + validate ''' + def getStringProperty = { jsonObject, propertyName -> jsonObject.get(propertyName)?.getAsString() } + + if (!relationships.find { getStringProperty(it, "related-to") == "service-capability" }) { return true } + + return relationships.findAll { getStringProperty(it, "related-to") == "service-capability" } + .findAll { it."related-to-property" != null } + .collect { it."relationship-data".get(0) } + .findAll { getStringProperty(it, "relationship-key") == "service-capability.service-type" } + .find { getStringProperty(it, "relationship-value") == "SDN-ETHERNET-INTERNET" } + ''' +} diff --git a/src/test/resources/rule-driven-validator/rules/aai-event/rule-vserver-related-generic-vnf.groovy b/src/test/resources/rule-driven-validator/rules/aai-event/rule-vserver-related-generic-vnf.groovy new file mode 100644 index 0000000..feeffa8 --- /dev/null +++ b/src/test/resources/rule-driven-validator/rules/aai-event/rule-vserver-related-generic-vnf.groovy @@ -0,0 +1,42 @@ +/* + * ============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===================================================== + */ + +rule { + name 'vserver related to TRINITY image and generic-vnf.vnf-name matches naming convention' + category 'INVALID_NAME' + description 'Validates that if vserver is related to an image named TRINITY, then the related generic-vnf name matches naming convention' + errorText 'Invalid name - if vserver is related to an image named TRINITY, then the related generic-vnf name must match xxxxnnnnv (where x = character and n = number)' + severity 'MINOR' + attributes 'relationships' + validate ''' + def getStringProperty = { jsonObject, propertyName -> jsonObject.get(propertyName).getAsString() } + + vnf_name = relationships.findAll { getStringProperty(it, "related-to") == "generic-vnf" } + .collect { it."related-to-property".get(0) } + .find { getStringProperty(it, "property-key") == "generic-vnf.vnf-name" } + .findResult { getStringProperty(it, "property-value") } + + relatedToTrinity = relationships.findAll { getStringProperty(it, "related-to") == "image" } + .collect { it."related-to-property".get(0) } + .findAll { getStringProperty(it, "property-key") == "image.image-name" } + .find { getStringProperty(it, "property-value").startsWith("TRINITY") } + + // If (and only if) related to TRINITY then check the generic-vnf name + return !relatedToTrinity || vnf_name?.matches("[a-z]{4}[0-9]{4}v") + ''' +} \ No newline at end of file diff --git a/src/test/resources/rule-driven-validator/rules/aai-event/vserver-rules.groovy b/src/test/resources/rule-driven-validator/rules/aai-event/vserver-rules.groovy new file mode 100644 index 0000000..d379e17 --- /dev/null +++ b/src/test/resources/rule-driven-validator/rules/aai-event/vserver-rules.groovy @@ -0,0 +1,44 @@ +/* + * ============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===================================================== + */ + +entity { + type 'vserver' + validation { + useRule { + name 'prov-status' + attributes 'prov-status' + } + useRule {name 'vserver is related to 0 or 1 image' } + useRule {name 'vserver is related to 0 or 1 flavor' } + useRule {name 'vserver is related to 1 pserver' } + useRule {name 'vserver is related to vpe and vserver-name matches naming convention' } + useRule {name 'vserver is related to vce and vserver-name matches naming convention' } + useRule { + name 'vserver related to TRINITY image and generic-vnf.vnf-name matches naming convention' + attributes 'relationship-list.relationship[*]' + } + useRule { + name 'vserver is related to a TRINITY image and vserver-name matches naming convention' + attributes 'relationship-list.relationship[*]', 'vserver-name' + } + useRule { + name 'vserver is related to a vnf (vce or newvce or vpe or generic-vnf)' + attributes 'relationship-list.relationship[*].related-to' + } + } +} diff --git a/src/test/resources/rule-driven-validator/rules/gizmo-event/common_rules.groovy b/src/test/resources/rule-driven-validator/rules/gizmo-event/common_rules.groovy new file mode 100644 index 0000000..b30816e --- /dev/null +++ b/src/test/resources/rule-driven-validator/rules/gizmo-event/common_rules.groovy @@ -0,0 +1,27 @@ +/* + * ============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===================================================== + */ + +rule { + name 'valid_ipv4_addr' + category 'INVALID_VALUE' + description 'Validate an IPv4 address' + errorText 'Invalid value - attribute is not a valid IPv4 address' + severity 'MINOR' + attributes 'ipaddr' + validate 'ipaddr != null && ipaddr.matches("^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])")' +} diff --git a/src/test/resources/rule-driven-validator/rules/gizmo-event/pserver-rules.groovy b/src/test/resources/rule-driven-validator/rules/gizmo-event/pserver-rules.groovy new file mode 100644 index 0000000..79b3cc2 --- /dev/null +++ b/src/test/resources/rule-driven-validator/rules/gizmo-event/pserver-rules.groovy @@ -0,0 +1,27 @@ +/* + * ============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===================================================== + */ + +entity { + type 'pserver' + validation { + useRule { + name 'valid_ipv4_addr' + attributes 'vertex.properties.ipv4-oam-address' + } + } +} diff --git a/src/test/resources/rule-driven-validator/test-rule-driven-validator-beans.xml b/src/test/resources/rule-driven-validator/test-rule-driven-validator-beans.xml new file mode 100644 index 0000000..b087680 --- /dev/null +++ b/src/test/resources/rule-driven-validator/test-rule-driven-validator-beans.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/rule-driven-validator/test_events/generic-vnf-create-event.json b/src/test/resources/rule-driven-validator/test_events/generic-vnf-create-event.json new file mode 100644 index 0000000..e1e5618 --- /dev/null +++ b/src/test/resources/rule-driven-validator/test_events/generic-vnf-create-event.json @@ -0,0 +1,46 @@ +{ + "cambria.partition": "AAI", + "entity": { + "resource-version": "1476736914", + "equipment-role": "UCPE", + "ipv4-oam-address": "", + "is-closed-loop-disabled": false, + "vnf-name": "USETEJORLFL0154UJTE08", + "vnf-type": "TE", + "nm-lan-v6-address": "2001:1890:e00e:fffe::943", + "vnf-id": "e5365951-9d90-4853-afae-c34a0707e3b6", + "in-maint": false, + "ipv4-loopback0-address": "", + "management-option": "ATT", + "orchestration-status": "created", + "service-id": "d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4", + "management-v6-address": "", + "relationship-list": { + "relationship": [{ + "relationship-data":[{ + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "USETEJORLFL0154UJZZ01" + }], + "related-to-property": [{ + "property-key": "service-instance.service-instance-name" + }], + "related-link": "https://aai-app-e2e.test.onap.org:8443/aai/v8/business/customers/customer/300DLE/service-subscriptions/service-subscription/uCPE-VMS/service-instances/service-instance/USETEJORLFL0154UJZZ01/", + "related-to": "service-instance" + }] + } + }, + "event-header": { + "timestamp": "20161017-20:41:55:044", + "id": "20161017204155-be84d9c2-909c-427c-9ad5-0bdcdb498a06", + "action": "CREATE", + "domain": "e2e1", + "source-name": "SDNC", + "entity-link": "https://aai-app.test.onap.org:8443/aai/v8/network/generic-vnfs/generic-vnf/e5365951-9d90-4853-afae-c34a0707e3b6", + "entity-type": "generic-vnf", + "sequence-number": "0", + "severity": "NORMAL", + "event-type": "AAI-EVENT", + "top-entity-type": "generic-vnf", + "version": "v8" + } +} diff --git a/src/test/resources/rule-driven-validator/test_events/gizmo-pserver-create-event-invalid-ipaddress.json b/src/test/resources/rule-driven-validator/test_events/gizmo-pserver-create-event-invalid-ipaddress.json new file mode 100644 index 0000000..0be90fe --- /dev/null +++ b/src/test/resources/rule-driven-validator/test_events/gizmo-pserver-create-event-invalid-ipaddress.json @@ -0,0 +1,33 @@ +{ + "cambria.partition":"AAI", + "entity":{ + "timestamp":1514927928167, + "operation":"CREATE", + "vertex":{ + "properties":{ + "ipv4-oam-address":"1.2.3.", + "resource-version":"1477013499", + "purpose":"my-purpose", + "fqdn":"myhost.onap.net", + "in-maint":false, + "equip-model":"DL380p-nd", + "equip-vendor":"HP", + "equip-type":"server", + "hostname":"myhost", + "ptnii-equip-name":"e-name" + }, + "key":"", + "type":"pserver", + "schema-version":"vX" + }, + "transaction-id":"c0a81fa7-5ef4-49cd-ab39-e42c53c9b9a4", + "database-transaction-id":"b3e2853e-f643-47a3-a0c3-cb54cc997ad3" + }, + "event-header":{ + "timestamp":"1514927928167", + "id":"c0a81fa7-5ef4-49cd-ab39-e42c53c9b9a4", + "source-name":"GIZMO", + "entity-type":"pserver", + "event-type":"GIZMO-EVENT" + } +} \ No newline at end of file diff --git a/src/test/resources/rule-driven-validator/test_events/gizmo-pserver-create-event.json b/src/test/resources/rule-driven-validator/test_events/gizmo-pserver-create-event.json new file mode 100644 index 0000000..2ba5550 --- /dev/null +++ b/src/test/resources/rule-driven-validator/test_events/gizmo-pserver-create-event.json @@ -0,0 +1,33 @@ +{ + "cambria.partition":"AAI", + "entity":{ + "timestamp":1514927928167, + "operation":"CREATE", + "vertex":{ + "properties":{ + "ipv4-oam-address":"1.2.3.4", + "resource-version":"1477013499", + "purpose":"my-purpose", + "fqdn":"myhost.onap.net", + "in-maint":false, + "equip-model":"DL380p-nd", + "equip-vendor":"HP", + "equip-type":"server", + "hostname":"myhost", + "ptnii-equip-name":"e-name" + }, + "key":"", + "type":"pserver", + "schema-version":"vX" + }, + "transaction-id":"c0a81fa7-5ef4-49cd-ab39-e42c53c9b9a4", + "database-transaction-id":"b3e2853e-f643-47a3-a0c3-cb54cc997ad3" + }, + "event-header":{ + "timestamp":"1514927928167", + "id":"c0a81fa7-5ef4-49cd-ab39-e42c53c9b9a4", + "source-name":"GIZMO", + "entity-type":"pserver", + "event-type":"GIZMO-EVENT" + } +} \ No newline at end of file diff --git a/src/test/resources/rule-driven-validator/test_events/vserver-create-AAI-EVENT-devINT1-TRINITY-VNF-NAME-BAD.json b/src/test/resources/rule-driven-validator/test_events/vserver-create-AAI-EVENT-devINT1-TRINITY-VNF-NAME-BAD.json new file mode 100644 index 0000000..b5c0a31 --- /dev/null +++ b/src/test/resources/rule-driven-validator/test_events/vserver-create-AAI-EVENT-devINT1-TRINITY-VNF-NAME-BAD.json @@ -0,0 +1,144 @@ +{ + "cambria.partition": "AAI", + "event-header": { + "id": "20160525162737-61c49d41-5338-4755-af54-06cee9fe4acf", + "timestamp": "20160525-16:27:37:353", + "source-name": "RO", + "domain": "devINT1", + "sequence-number": "0", + "severity": "NORMAL", + "event-type": "AAI-EVENT", + "version": "v7", + "action": "CREATE", + "entity-type": "vserver", + "top-entity-type": "cloud-region", + "entity-link": "https://dummy-host.onap.org:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/tenants/tenant/example-tenant-id-val-88551/vservers/vserver/example-vserver-id-val-34666" + }, + "entity": { + "cloud-owner": "region1", + "cloud-region-id": "AAIregion1", + "tenants": { + "tenant": [{ + "tenant-id": "example-tenant-id-val-88551", + "tenant-name": "example-tenant-name-val-88551", + "vservers": { + "vserver": [{ + "vserver-id": "c385bb3e-6ebd-4898-bc92-792e0ac2db50", + "vserver-name": "bems0001vm001", + "vserver-name2": "bems0001vm001bem001-1452", + "prov-status": "ACTIVE", + "vserver-selflink": "TRINITY vserverLink", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1475160142", + "relationship-list": { + "relationship": [{ + "related-to": "generic-vnf", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/network/generic-vnfs/generic-vnf/ctpx12345v/", + "relationship-data": [{ + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "ctpx12345v" + }], + "related-to-property": [{ + "property-key": "generic-vnf.vnf-name", + "property-value": "ctpx12345v" + }] + }, + { + "related-to": "vf-module", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/network/generic-vnfs/generic-vnf/ctpx12345v/vf-modules/vf-module/ctpx12345v/", + "relationship-data": [{ + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "ctpx12345v" + }, + { + "relationship-key": "vf-module.vf-module-id", + "relationship-value": "ctpx12345v" + }] + }, + { + "related-to": "image", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/images/image/TRINITY-IMAGE/", + "relationship-data": [{ + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "region1" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "AAIregion1" + }, + { + "relationship-key": "image.image-id", + "relationship-value": "TRINITY-IMAGE" + }], + "related-to-property": [{ + "property-key": "image.image-name", + "property-value": "TRINITY IMAGE" + }] + }, + { + "related-to": "pserver", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/cloud-infrastructure/pservers/pserver/TRINITY-PSERVER/", + "relationship-data": [{ + "relationship-key": "pserver.hostname", + "relationship-value": "TRINITY-PSERVER" + }], + "related-to-property": [{ + "property-key": "pserver.pserver-name2" + }] + }, + { + "related-to": "flavor", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/flavors/flavor/TRINITY-Flavor/", + "relationship-data": [{ + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "region1" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "AAIregion1" + }, + { + "relationship-key": "flavor.flavor-id", + "relationship-value": "TRINITY-Flavor" + }], + "related-to-property": [{ + "property-key": "flavor.flavor-name", + "property-value": "TRINITY Flavor" + }] + }] + }, + "l-interfaces": { + "l-interface": [{ + "interface-name": "BSFT-EMS-VMVNIC1", + "resource-version": "1455590484", + "l3-interface-ipv4-address-list": [{ + "l3-interface-ipv4-address": "130.3.148.14", + "l3-interface-ipv4-prefix-length": 32, + "resource-version": "1455590484", + "relationship-list": { + "relationship": [{ + "related-to": "subnet", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/network/l3-networks/l3-network/AIC_SBG_NSDNet_Trinity_OAMP_3900-1234-1/subnets/subnet/AIC_SBG_NSDNet_Trinity_OAMP_3900-1234-1-ipv4/", + "relationship-data": [{ + "relationship-key": "l3-network.network-id", + "relationship-value": "AIC_SBG_NSDNet_Trinity_OAMP_3900-1234-1" + }, + { + "relationship-key": "subnet.subnet-id", + "relationship-value": "AIC_SBG_NSDNet_Trinity_OAMP_3900-1234-1-ipv4" + }], + "related-to-property": [{ + "property-key": "subnet.subnet-name" + }] + }] + } + }] + }] + } + }] + } + }] + } + } +} diff --git a/src/test/resources/rule-driven-validator/test_events/vserver-create-AAI-EVENT-devINT1-TRINITY-VNF-NAME-GOOD.json b/src/test/resources/rule-driven-validator/test_events/vserver-create-AAI-EVENT-devINT1-TRINITY-VNF-NAME-GOOD.json new file mode 100644 index 0000000..962210a --- /dev/null +++ b/src/test/resources/rule-driven-validator/test_events/vserver-create-AAI-EVENT-devINT1-TRINITY-VNF-NAME-GOOD.json @@ -0,0 +1,144 @@ +{ + "cambria.partition": "AAI", + "event-header": { + "id": "20160525162737-61c49d41-5338-4755-af54-06cee9fe4acf", + "timestamp": "20160525-16:27:37:353", + "source-name": "RO", + "domain": "devINT1", + "sequence-number": "0", + "severity": "NORMAL", + "event-type": "AAI-EVENT", + "version": "v7", + "action": "CREATE", + "entity-type": "vserver", + "top-entity-type": "cloud-region", + "entity-link": "https://dummy-host.test.onap.org:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/tenants/tenant/example-tenant-id-val-88551/vservers/vserver/example-vserver-id-val-34666" + }, + "entity": { + "cloud-owner": "region1", + "cloud-region-id": "AAIregion1", + "tenants": { + "tenant": [{ + "tenant-id": "example-tenant-id-val-88551", + "tenant-name": "example-tenant-name-val-88551", + "vservers": { + "vserver": [{ + "vserver-id": "c385bb3e-6ebd-4898-bc92-792e0ac2db50", + "vserver-name": "bems0001vm001", + "vserver-name2": "bems0001vm001bem001-1452", + "prov-status": "ACTIVE", + "vserver-selflink": "TRINITY vserverLink", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1475160142", + "relationship-list": { + "relationship": [{ + "related-to": "generic-vnf", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/network/generic-vnfs/generic-vnf/ctpx0001v/", + "relationship-data": [{ + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "ctpx0001v" + }], + "related-to-property": [{ + "property-key": "generic-vnf.vnf-name", + "property-value": "ctpx0001v" + }] + }, + { + "related-to": "vf-module", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/network/generic-vnfs/generic-vnf/ctpx0001v/vf-modules/vf-module/ctpx0001v/", + "relationship-data": [{ + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "ctpx0001v" + }, + { + "relationship-key": "vf-module.vf-module-id", + "relationship-value": "ctpx0001v" + }] + }, + { + "related-to": "image", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/images/image/TRINITY-IMAGE/", + "relationship-data": [{ + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "region1" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "AAIregion1" + }, + { + "relationship-key": "image.image-id", + "relationship-value": "TRINITY-IMAGE" + }], + "related-to-property": [{ + "property-key": "image.image-name", + "property-value": "TRINITY IMAGE" + }] + }, + { + "related-to": "pserver", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/cloud-infrastructure/pservers/pserver/TRINITY-PSERVER/", + "relationship-data": [{ + "relationship-key": "pserver.hostname", + "relationship-value": "TRINITY-PSERVER" + }], + "related-to-property": [{ + "property-key": "pserver.pserver-name2" + }] + }, + { + "related-to": "flavor", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/flavors/flavor/TRINITY-Flavor/", + "relationship-data": [{ + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "region1" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "AAIregion1" + }, + { + "relationship-key": "flavor.flavor-id", + "relationship-value": "TRINITY-Flavor" + }], + "related-to-property": [{ + "property-key": "flavor.flavor-name", + "property-value": "TRINITY Flavor" + }] + }] + }, + "l-interfaces": { + "l-interface": [{ + "interface-name": "BSFT-EMS-VMVNIC1", + "resource-version": "1455590484", + "l3-interface-ipv4-address-list": [{ + "l3-interface-ipv4-address": "130.3.148.14", + "l3-interface-ipv4-prefix-length": 32, + "resource-version": "1455590484", + "relationship-list": { + "relationship": [{ + "related-to": "subnet", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/network/l3-networks/l3-network/VendorCloud_Trinity_OAMP_3900-1234-1/subnets/subnet/VendorCloud_Trinity_OAMP_3900-1234-1-ipv4/", + "relationship-data": [{ + "relationship-key": "l3-network.network-id", + "relationship-value": "VendorCloud_Trinity_OAMP_3900-1234-1" + }, + { + "relationship-key": "subnet.subnet-id", + "relationship-value": "VendorCloud_Trinity_OAMP_3900-1234-1-ipv4" + }], + "related-to-property": [{ + "property-key": "subnet.subnet-name" + }] + }] + } + }] + }] + } + }] + } + }] + } + } +} diff --git a/src/test/resources/rule-driven-validator/test_events/vserver-create-event.json b/src/test/resources/rule-driven-validator/test_events/vserver-create-event.json new file mode 100644 index 0000000..85bcdf3 --- /dev/null +++ b/src/test/resources/rule-driven-validator/test_events/vserver-create-event.json @@ -0,0 +1,243 @@ +{ + "cambria.partition": "AAI", + "event-header": { + "id": "20160525162737-61c49d41-5338-4755-af54-06cee9fe4acf", + "timestamp": "20160525-16:27:37:353", + "source-name": "RO", + "domain": "devINT1", + "sequence-number": "0", + "severity": "NORMAL", + "event-type": "AAI-EVENT", + "version": "v7", + "action": "CREATE", + "entity-type": "vserver", + "top-entity-type": "cloud-region", + "entity-link": "https://dummy-host.test.onap.org:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/tenants/tenant/example-tenant-id-val-88551/vservers/vserver/example-vserver-id-val-34666" + }, + "entity": { + "cloud-owner": "region1", + "cloud-region-id": "AAIregion1", + "tenants": { + "tenant": [ + { + "tenant-id": "example-tenant-id-val-88551", + "tenant-name": "example-tenant-name-val-88551", + "vservers": { + "vserver": [ + { + "vserver-id": "example-vserver-id-val-34666", + "vserver-name": "example-vserver-name-val-34666", + "vserver-name2": "example-vserver-name2-val-34666", + "prov-status": "INVALID", + "vserver-selflink": "example-vserver-selflink-val-34666", + "in-maint": true, + "is-closed-loop-disabled": true, + "resource-version": "1464193654", + "volumes": { + "volume": [ + { + "volume-id": "example-volume-id-val-79195", + "volume-selflink": "example-volume-selflink-val-79195", + "resource-version": "1464193654", + "relationship-list": { + + } + } + ] + }, + "relationship-list": { + "relationship": [ + { + "related-to": "generic-vnf", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/network/generic-vnfs/generic-vnf/bmsx0001v-1661/", + "relationship-data": [ + { + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "bmsx0001v-1661" + } + ], + "related-to-property": [ + { + "property-key": "generic-vnf.vnf-name", + "property-value": "bmsx000x" + } + ] + }, + { + "related-to": "image", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/images/image/ee49d429-283d-4f79-9c58-e11cc38d8856/", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "region1" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "AAIregion1" + }, + { + "relationship-key": "image.image-id", + "relationship-value": "ee49d429-283d-4f79-9c58-e11cc38d8856" + } + ], + "related-to-property": [ + { + "property-key": "image.image-name", + "property-value": "TRINITY" + } + ] + }, + { + "related-to": "pserver", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/cloud-infrastructure/pservers/pserver/dpa2r03c007/", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "dpa2r03c007" + } + ], + "related-to-property": [ + { + "property-key": "pserver.pserver-name2" + } + ] + }, + { + "related-to": "flavor", + "related-link": "https://dummy-host.onap.org:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/flavors/flavor/5288f576-d9c6-46fc-9dcb-f6946a2b3597/", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "region1" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "AAIregion1" + }, + { + "relationship-key": "flavor.flavor-id", + "relationship-value": "5288f576-d9c6-46fc-9dcb-f6946a2b3597" + } + ], + "related-to-property": [ + { + "property-key": "flavor.flavor-name", + "property-value": "l5.xLarge" + } + ] + } + ] + }, + "l-interfaces": { + "l-interface": [ + { + "interface-name": "example-interface-name-val-25679", + "interface-role": "example-interface-role-val-25679", + "v6-wan-link-ip": "example-v6-wan-link-ip-val-25679", + "selflink": "example-selflink-val-25679", + "interface-id": "example-interface-id-val-25679", + "macaddr": "example-macaddr-val-25679", + "network-name": "example-network-name-val-25679", + "resource-version": "1464193654", + "vlans": { + "vlan": [ + { + "vlan-interface": "example-vlan-interface-val-28675", + "vlan-id-inner": 22278797, + "vlan-id-outer": 22278797, + "resource-version": "1464193654", + "speed-value": "example-speed-value-val-28675", + "speed-units": "example-speed-units-val-28675", + "vlan-description": "example-vlan-description-val-28675", + "relationship-list": { + + }, + "l3-interface-ipv4-address-list": [ + { + "l3-interface-ipv4-address": "example-l3-interface-ipv4-address-val-39271", + "l3-interface-ipv4-prefix-length": 78868308, + "vlan-id-inner": 78868308, + "vlan-id-outer": 78868308, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ], + "l3-interface-ipv6-address-list": [ + { + "l3-interface-ipv6-address": "example-l3-interface-ipv6-address-val-4005", + "l3-interface-ipv6-prefix-length": 78340763, + "vlan-id-inner": 78340763, + "vlan-id-outer": 78340763, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ] + } + ] + }, + "sriov-vfs": { + "sriov-vf": [ + { + "pci-id": "example-pci-id-val-85354", + "vf-vlan-filter": "example-vf-vlan-filter-val-85354", + "vf-mac-filter": "example-vf-mac-filter-val-85354", + "vf-vlan-strip": true, + "vf-vlan-anti-spoof-check": true, + "vf-mac-anti-spoof-check": true, + "vf-mirrors": "example-vf-mirrors-val-85354", + "vf-broadcast-allow": true, + "vf-unknown-multicast-allow": true, + "vf-unknown-unicast-allow": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ] + }, + "relationship-list": { + + }, + "l3-interface-ipv4-address-list": [ + { + "l3-interface-ipv4-address": "example-l3-interface-ipv4-address-val-21446", + "l3-interface-ipv4-prefix-length": 71127022, + "vlan-id-inner": 71127022, + "vlan-id-outer": 71127022, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ], + "l3-interface-ipv6-address-list": [ + { + "l3-interface-ipv6-address": "example-l3-interface-ipv6-address-val-88071", + "l3-interface-ipv6-prefix-length": 55080281, + "vlan-id-inner": 55080281, + "vlan-id-outer": 55080281, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ] + } + ] + } + } + ] + } + } + ] + } + } +} \ No newline at end of file diff --git a/src/test/resources/rule-driven-validator/test_events/vserver-update-AAI-EVENT-devINT1.json b/src/test/resources/rule-driven-validator/test_events/vserver-update-AAI-EVENT-devINT1.json new file mode 100644 index 0000000..92bec16 --- /dev/null +++ b/src/test/resources/rule-driven-validator/test_events/vserver-update-AAI-EVENT-devINT1.json @@ -0,0 +1,108 @@ +{ + "cambria.partition": "AAI", + "entity": { + "cloud-region-id": "AAIregion1", + "cloud-owner": "region1", + "tenants": { + "tenant": [{ + "vservers": { + "vserver": [{ + "resource-version": "1476735222", + "is-closed-loop-disabled": false, + "vserver-selflink": "http://compute.test.onap.org:8774/v2/d52b9dea5d0f4e5d90be3590ac8c78a9/servers/fd280243-cd5c-424e-b629-533cabe2a164", + "vserver-name": "vm-54", + "vserver-id": "fd280243-cd5c-424e-b629-533cabe2a164", + "in-maint": false, + "vserver-name2": "VM_54", + "l-interfaces": { + "l-interface": [{ + "resource-version": "1452288058", + "macaddr": "02:fd:59:37:be:3c", + "selflink": "http://network.test.onap.org:9696/v2.0/ports/fd5937be-3ca4-4db0-89c9-e210bf8bf31f", + "interface-id": "fd5937be-3ca4-4db0-89c9-e210bf8bf31f", + "l3-interface-ipv4-address-list": [{ + "resource-version": "1452288058", + "l3-interface-ipv4-address": "192.168.112.56", + "neutron-network-id": "a2e5433f-38c7-420e-9c06-134ee893de3f", + "neutron-subnet-id": "b58a5b21-1f3b-42b8-93a6-109b2a700fdb", + "is-floating": false, + "l3-interface-ipv4-prefix-length": 24 + }], + "interface-name": "fd5937be-3ca4-4db0-89c9-e210bf8bf31f", + "network-name": "CinderVolumeNetwork" + }] + }, + "relationship-list": { + "relationship": [{ + "relationship-data": [{ + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "region1" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "AAIregion1" + }, + { + "relationship-key": "image.image-id", + "relationship-value": "fc2b5df5-0e28-4c05-9e8c-75cebbd537e5" + }], + "related-to-property": [{ + "property-value": "TestVM", + "property-key": "image.image-name" + }], + "related-link": "https://aai-app-e2e.test.onap.org:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/images/image/fc2b5df5-0e28-4c05-9e8c-75cebbd537e5/", + "related-to": "image" + }, + { + "relationship-data": [{ + "relationship-key": "pserver.hostname", + "relationship-value": "dummy-host.test.onap.org" + }], + "related-to-property": [{ + "property-key": "pserver.pserver-name2" + }], + "related-link": "https://aai-app-e2e.test.onap.org:8443/aai/v7/cloud-infrastructure/pservers/pserver/dummy-host.test.onap.org/", + "related-to": "pserver" + }, + { + "relationship-data": [{ + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "region1" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "AAIregion1" + }, + { + "relationship-key": "flavor.flavor-id", + "relationship-value": "31" + }], + "related-to-property": [{ + "property-value": "m1.small", + "property-key": "flavor.flavor-name" + }], + "related-link": "https://aai-app-e2e.test.onap.org:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/flavors/flavor/31/", + "related-to": "flavor" + }] + } + }] + }, + "tenant-id": "d52b9dea5d0f4e5d90be3590ac8c78a9" + }] + } + }, + "event-header": { + "timestamp": "20161017-20:13:45:472", + "id": "20161017201345-af157723-3835-4619-b6d8-dc16c19308bb", + "action": "UPDATE", + "domain": "devINT1", + "source-name": "RO", + "entity-link": "https://aai-app.test.onap.org:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/tenants/tenant/d52b9dea5d0f4e5d90be3590ac8c78a9/vservers/vserver/fd280243-cd5c-424e-b629-533cabe2a164", + "entity-type": "vserver", + "sequence-number": "0", + "severity": "NORMAL", + "event-type": "AAI-EVENT", + "top-entity-type": "cloud-region", + "version": "v8" + } +} diff --git a/src/test/resources/topic-admin-config/test-validation-service-beans.xml b/src/test/resources/topic-admin-config/test-validation-service-beans.xml new file mode 100644 index 0000000..caf63c3 --- /dev/null +++ b/src/test/resources/topic-admin-config/test-validation-service-beans.xml @@ -0,0 +1,28 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/topic-admin-config/validation-service.properties b/src/test/resources/topic-admin-config/validation-service.properties new file mode 100644 index 0000000..01b02dd --- /dev/null +++ b/src/test/resources/topic-admin-config/validation-service.properties @@ -0,0 +1,20 @@ +# ============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===================================================== + +topic.publish.enable=true +topic.publish.retries=3 +topic.consume.enable=true +topic.consume.polling.interval.seconds=3 \ No newline at end of file diff --git a/src/test/resources/topic-config/test-topic-config-beans.xml b/src/test/resources/topic-config/test-topic-config-beans.xml new file mode 100644 index 0000000..0466f81 --- /dev/null +++ b/src/test/resources/topic-config/test-topic-config-beans.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + aai-event + aai-data-export + + + + + aai-data-integrity + + + + + + + + + classpath:topic-config/topic-aai-event.properties + classpath:topic-config/topic-aai-data-export.properties + classpath:topic-config/topic-aai-data-integrity.properties + + + + \ No newline at end of file diff --git a/src/test/resources/topic-config/test-validation-service-beans.xml b/src/test/resources/topic-config/test-validation-service-beans.xml new file mode 100644 index 0000000..9d880a3 --- /dev/null +++ b/src/test/resources/topic-config/test-validation-service-beans.xml @@ -0,0 +1,25 @@ + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/topic-config/topic-aai-data-export.properties b/src/test/resources/topic-config/topic-aai-data-export.properties new file mode 100644 index 0000000..af182ca --- /dev/null +++ b/src/test/resources/topic-config/topic-aai-data-export.properties @@ -0,0 +1,23 @@ +# ============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===================================================== + +aai-data-export.name=aai-data-export +aai-data-export.host=export-dummy-host +aai-data-export.username=export-dummy-username +aai-data-export.password=export-dummy-password +aai-data-export.consumer.group=export-dummy-consumer-group +aai-data-export.consumer.id=export-dummy-consumer-id +aai-data-export.transport.type=export-dummy-transport-type \ No newline at end of file diff --git a/src/test/resources/topic-config/topic-aai-data-integrity.properties b/src/test/resources/topic-config/topic-aai-data-integrity.properties new file mode 100644 index 0000000..f5a5839 --- /dev/null +++ b/src/test/resources/topic-config/topic-aai-data-integrity.properties @@ -0,0 +1,22 @@ +# ============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===================================================== + +aai-data-integrity.name=aai-data-integrity +aai-data-integrity.host=integrity-dummy-host +aai-data-integrity.publisher.partition=integrity-dummy-partition +aai-data-integrity.username=integrity-dummy-username +aai-data-integrity.password=integrity-dummy-password +aai-data-integrity.transport.type=integrity-dummy-transport-type \ No newline at end of file diff --git a/src/test/resources/topic-config/topic-aai-event.properties b/src/test/resources/topic-config/topic-aai-event.properties new file mode 100644 index 0000000..2779f13 --- /dev/null +++ b/src/test/resources/topic-config/topic-aai-event.properties @@ -0,0 +1,23 @@ +# ============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===================================================== + +aai-event.name=aai-event +aai-event.host=event-dummy-host +aai-event.username=event-dummy-username +aai-event.password=event-dummy-password +aai-event.consumer.group=event-dummy-consumer-group +aai-event.consumer.id=event-dummy-consumer-id +aai-event.transport.type=event-dummy-transport-type \ No newline at end of file diff --git a/src/test/resources/validation-controller-config/test-validation-service-beans.xml b/src/test/resources/validation-controller-config/test-validation-service-beans.xml new file mode 100644 index 0000000..b6f8099 --- /dev/null +++ b/src/test/resources/validation-controller-config/test-validation-service-beans.xml @@ -0,0 +1,29 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/validation-controller-config/validation-controller-config.properties b/src/test/resources/validation-controller-config/validation-controller-config.properties new file mode 100644 index 0000000..d30008f --- /dev/null +++ b/src/test/resources/validation-controller-config/validation-controller-config.properties @@ -0,0 +1,21 @@ +# ============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===================================================== + +event.domain=devINT1 +event.action.exclude=DELETE +event.type.rule=AAI-EVENT,AAI-DATA-EXPORT-API +event.type.model=AAI-DATA-EXPORT-NQ +event.type.end=END-EVENT \ No newline at end of file diff --git a/src/test/resources/validation-result/test-validation-service-beans.xml b/src/test/resources/validation-result/test-validation-service-beans.xml new file mode 100644 index 0000000..9a67d0a --- /dev/null +++ b/src/test/resources/validation-result/test-validation-service-beans.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/validation-result/vserver-create-event.json b/src/test/resources/validation-result/vserver-create-event.json new file mode 100644 index 0000000..21e4da8 --- /dev/null +++ b/src/test/resources/validation-result/vserver-create-event.json @@ -0,0 +1,163 @@ +{ + "cambria.partition": "AAI", + "event-header": { + "id": "20160525162737-61c49d41-5338-4755-af54-06cee9fe4acf", + "timestamp": "20160525-16:27:37:353", + "source-name": "RO", + "domain": "devINT1", + "sequence-number": "0", + "severity": "NORMAL", + "event-type": "AAI-EVENT", + "version": "v7", + "action": "CREATE", + "entity-type": "vserver", + "top-entity-type": "cloud-region", + "entity-link": "https://dummy-host.onap.org:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/tenants/tenant/example-tenant-id-val-88551/vservers/vserver/example-vserver-id-val-34666" + }, + "entity": { + "cloud-owner": "region1", + "cloud-region-id": "AAIregion1", + "tenants": { + "tenant": [ + { + "tenant-id": "example-tenant-id-val-88551", + "tenant-name": "example-tenant-name-val-88551", + "vservers": { + "vserver": [ + { + "vserver-id": "example-vserver-id-val-34666", + "vserver-name": "example-vserver-name-val-34666", + "vserver-name2": "example-vserver-name2-val-34666", + "prov-status": "PREPROV", + "vserver-selflink": "example-vserver-selflink-val-34666", + "in-maint": true, + "is-closed-loop-disabled": true, + "resource-version": "1464193654", + "volumes": { + "volume": [ + { + "volume-id": "example-volume-id-val-79195", + "volume-selflink": "example-volume-selflink-val-79195", + "resource-version": "1464193654", + "relationship-list": { + + } + } + ] + }, + "relationship-list": { + + }, + "l-interfaces": { + "l-interface": [ + { + "interface-name": "example-interface-name-val-25679", + "interface-role": "example-interface-role-val-25679", + "v6-wan-link-ip": "example-v6-wan-link-ip-val-25679", + "selflink": "example-selflink-val-25679", + "interface-id": "example-interface-id-val-25679", + "macaddr": "example-macaddr-val-25679", + "network-name": "example-network-name-val-25679", + "resource-version": "1464193654", + "vlans": { + "vlan": [ + { + "vlan-interface": "example-vlan-interface-val-28675", + "vlan-id-inner": 22278797, + "vlan-id-outer": 22278797, + "resource-version": "1464193654", + "speed-value": "example-speed-value-val-28675", + "speed-units": "example-speed-units-val-28675", + "vlan-description": "example-vlan-description-val-28675", + "relationship-list": { + + }, + "l3-interface-ipv4-address-list": [ + { + "l3-interface-ipv4-address": "example-l3-interface-ipv4-address-val-39271", + "l3-interface-ipv4-prefix-length": 78868308, + "vlan-id-inner": 78868308, + "vlan-id-outer": 78868308, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ], + "l3-interface-ipv6-address-list": [ + { + "l3-interface-ipv6-address": "example-l3-interface-ipv6-address-val-4005", + "l3-interface-ipv6-prefix-length": 78340763, + "vlan-id-inner": 78340763, + "vlan-id-outer": 78340763, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ] + } + ] + }, + "sriov-vfs": { + "sriov-vf": [ + { + "pci-id": "example-pci-id-val-85354", + "vf-vlan-filter": "example-vf-vlan-filter-val-85354", + "vf-mac-filter": "example-vf-mac-filter-val-85354", + "vf-vlan-strip": true, + "vf-vlan-anti-spoof-check": true, + "vf-mac-anti-spoof-check": true, + "vf-mirrors": "example-vf-mirrors-val-85354", + "vf-broadcast-allow": true, + "vf-unknown-multicast-allow": true, + "vf-unknown-unicast-allow": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ] + }, + "relationship-list": { + + }, + "l3-interface-ipv4-address-list": [ + { + "l3-interface-ipv4-address": "example-l3-interface-ipv4-address-val-21446", + "l3-interface-ipv4-prefix-length": 71127022, + "vlan-id-inner": 71127022, + "vlan-id-outer": 71127022, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ], + "l3-interface-ipv6-address-list": [ + { + "l3-interface-ipv6-address": "example-l3-interface-ipv6-address-val-88071", + "l3-interface-ipv6-prefix-length": 55080281, + "vlan-id-inner": 55080281, + "vlan-id-outer": 55080281, + "is-floating": true, + "resource-version": "1464193654", + "relationship-list": { + + } + } + ] + } + ] + } + } + ] + } + } + ] + } + } +} \ No newline at end of file diff --git a/src/test/resources/validation-service.properties b/src/test/resources/validation-service.properties new file mode 100644 index 0000000..9321c41 --- /dev/null +++ b/src/test/resources/validation-service.properties @@ -0,0 +1,27 @@ +# ============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===================================================== + +topic.publish.enable=true +topic.publish.retries=3 +topic.consume.enable=true +topic.consume.polling.interval.seconds=7 + +event.domain=devINT1 +event.action.exclude=DELETE +event.type.rule=AAI-EVENT,AAI-DATA-EXPORT-API,GIZMO-EVENT,SPIKE-EVENT,EMPTY-RULESET-EVENT +event.type.model=AAI-DATA-EXPORT-NQ + +model.cache.expirySeconds=3 \ No newline at end of file -- cgit 1.2.3-korg