summaryrefslogtreecommitdiffstats
path: root/models-provider/src/test/java
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2020-03-13 12:34:58 +0000
committerliamfallon <liam.fallon@est.tech>2020-03-13 16:55:55 +0000
commit96e93d0c2642717ed5b37dcc2721ee2755141e76 (patch)
tree59c5520d8649797adac9dce2623c843f7fd62d2a /models-provider/src/test/java
parent309c49634bf9fcb53458d3e5f07684cb7bfbdd6f (diff)
Consistent returns on Service Template gets
This review enables specification of versions of entities on incoming service templates using a ':' delimiter. So this will load version 1.00, version 2.0.0, and version 3.0.0: org.onap.entitiy:1.0.0: version: 1.0.0 org.onap.entity:2.0.0: version: 2.0.0 org.onap.entity version: 3.0.0 So this will load version 1.00, version 2.0.0, and version 4.0.0: org.onap.entitiy:1.0.0: version: 1.0.0 org.onap.entity:2.0.0: version: 2.0.0 org.onap.entity: version: 3.0.0 org.onap.entity: version: 4.0.0 This will load org.onap.entity:1.0.0 name: org.onap.entity version: 1.0.0 This will throw an exception org.onap.entity:1.0.0 name: org.onap.some.other.entity version: 1.0.0 This will throw an exception org.onap.entity:1.0.0: name: org.onap.entity version: 2.0.0 Issue-ID: POLICY-2377 Change-Id: I34bccf065b4ee4d2fe71b052bf009d4a40e2cba8 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-provider/src/test/java')
-rw-r--r--models-provider/src/test/java/org/onap/policy/models/provider/revisionhierarchy/HierarchyFetchTest.java67
1 files changed, 67 insertions, 0 deletions
diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/revisionhierarchy/HierarchyFetchTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/revisionhierarchy/HierarchyFetchTest.java
new file mode 100644
index 000000000..35ec95b45
--- /dev/null
+++ b/models-provider/src/test/java/org/onap/policy/models/provider/revisionhierarchy/HierarchyFetchTest.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.models.provider.revisionhierarchy;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.util.Base64;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.policy.common.utils.coder.YamlJsonTranslator;
+import org.onap.policy.common.utils.resources.TextFileUtils;
+import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.provider.PolicyModelsProvider;
+import org.onap.policy.models.provider.PolicyModelsProviderFactory;
+import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+
+public class HierarchyFetchTest {
+
+ private static PolicyModelsProviderParameters parameters;
+
+ @BeforeClass
+ public static void beforeSetupParameters() {
+ parameters = new PolicyModelsProviderParameters();
+ parameters.setDatabaseDriver("org.h2.Driver");
+ parameters.setDatabaseUrl("jdbc:h2:mem:testdb");
+ parameters.setDatabaseUser("policy");
+ parameters.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
+ parameters.setPersistenceUnit("ToscaConceptTest");
+ }
+
+ @Test
+ public void testInitAndClose() throws Exception {
+ PolicyModelsProvider databaseProvider =
+ new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
+
+ ToscaServiceTemplate serviceTemplate = new YamlJsonTranslator().fromYaml(
+ TextFileUtils
+ .getTextFileAsString("src/test/resources/servicetemplates/MultipleRevisionServiceTemplate.yaml"),
+ ToscaServiceTemplate.class);
+
+ assertThatThrownBy(() -> {
+ databaseProvider.createPolicies(serviceTemplate);
+ }).isInstanceOf(PfModelRuntimeException.class);
+
+ databaseProvider.close();
+ }
+}