diff options
Diffstat (limited to 'src/test/java/org/onap/aai/validation/ruledriven/rule/TestConfigurationLoader.java')
-rw-r--r-- | src/test/java/org/onap/aai/validation/ruledriven/rule/TestConfigurationLoader.java | 48 |
1 files changed, 26 insertions, 22 deletions
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 index a70d908..e074bcd 100644 --- a/src/test/java/org/onap/aai/validation/ruledriven/rule/TestConfigurationLoader.java +++ b/src/test/java/org/onap/aai/validation/ruledriven/rule/TestConfigurationLoader.java @@ -1,20 +1,24 @@ -/* - * ============LICENSE_START=================================================== - * Copyright (c) 2018 Amdocs - * ============================================================================ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2018-2019 European Software Marketing Ltd. + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * 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===================================================== + * ============LICENSE_END========================================================= */ + package org.onap.aai.validation.ruledriven.rule; import com.google.gson.JsonArray; @@ -22,7 +26,9 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Collections; import java.util.LinkedHashSet; +import java.util.List; import java.util.Set; import javax.inject.Inject; import org.junit.Test; @@ -36,25 +42,24 @@ public class TestConfigurationLoader { System.setProperty("APP_HOME", "."); } - private enum AAIRelation { + private static final String RULES_PATH = "bundleconfig/etc/rules"; + + private enum AaiRelation { + // @formatter:off RELATED_TO("related-to"), PROPERTY_KEY("property-key"), PROPERTY_VALUE("property-value"); + // @formatter:on private final String text; /** * @param text */ - private AAIRelation(final String text) { + private AaiRelation(final String text) { this.text = text; } - /* - * (non-Javadoc) - * - * @see java.lang.Enum#toString() - */ @Override public String toString() { return text; @@ -69,9 +74,8 @@ public class TestConfigurationLoader { */ @Test public void testTrinityRule() throws Exception { - Path configurationPath = Paths.get("bundleconfig/etc/rules"); - - RuleDrivenValidator validator = new RuleDrivenValidator(configurationPath, oxmReader, null, null); + List<Path> configurationPaths = Collections.singletonList(Paths.get(RULES_PATH)); + RuleDrivenValidator validator = new RuleDrivenValidator(configurationPaths, oxmReader, null, null); validator.initialise(); // Find the trinity rule @@ -91,18 +95,18 @@ public class TestConfigurationLoader { RuleTester ruleTester = new RuleTester(trinityRule, attributeValues); ruleTester.test(true); - JsonObject genericVnfData = createRelationshipData(relationships, "generic-vnf"); + final JsonObject genericVnfData = createRelationshipData(relationships, "generic-vnf"); ruleTester.test(true); // Add a new object for the image relationship - JsonObject imageData = createRelationshipData(relationships, "image"); + final 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); + final JsonObject imageNameProperty = createRelatedToProperty(imageData); ruleTester.test(true); setPropertyKey(imageNameProperty, "image.image-name"); @@ -174,16 +178,16 @@ public class TestConfigurationLoader { */ private JsonObject createRelationshipData(Set<JsonObject> relationships, String relatedObject) { JsonObject relationData = new JsonObject(); - relationData.addProperty(AAIRelation.RELATED_TO.toString(), relatedObject); + 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); + objectMap.addProperty(AaiRelation.PROPERTY_KEY.toString(), propertyKeyName); } private void setPropertyValue(JsonObject objectMap, String propertyValue) { - objectMap.addProperty(AAIRelation.PROPERTY_VALUE.toString(), propertyValue); + objectMap.addProperty(AaiRelation.PROPERTY_VALUE.toString(), propertyValue); } } |