2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.applicationconfig;
23 import org.openecomp.core.utilities.applicationconfig.dao.type.ApplicationConfigEntity;
24 import org.openecomp.core.utilities.applicationconfig.type.ConfigurationData;
25 import org.openecomp.sdc.applicationconfig.impl.ApplicationConfigManagerImpl;
26 import org.openecomp.sdc.common.errors.CoreException;
27 import org.testng.Assert;
28 import org.testng.annotations.Test;
30 import java.util.Collection;
33 * Created by Talio on 8/9/2016.
35 public class ApplicationConfigManagerTest {
37 public static final String TEST_NAMESPACE_1 = "test-app-namespace";
38 public static final String TEST_NAMESPACE_2 = "test-namespace";
39 public static final String TEST_KEY = "test-app-key";
40 public static final String TEST_VALUE = "test-app-value";
41 ApplicationConfigManager applicationConfigManager = new ApplicationConfigManagerImpl();
44 public void testInsertIntoTable() {
46 applicationConfigManager.insertIntoTable(TEST_NAMESPACE_1, TEST_KEY, TEST_VALUE);
47 } catch (CoreException exception) {
48 Assert.assertEquals(exception.getMessage(),
49 "Error occurred while loading questionnaire schema templates");
54 @Test(dependsOnMethods = "testInsertIntoTable")
55 public void testGetValueFromTable() {
56 ConfigurationData value = applicationConfigManager.getFromTable(TEST_NAMESPACE_1, TEST_KEY);
58 Assert.assertEquals(value.getValue(), TEST_VALUE);
62 @Test(dependsOnMethods = "testInsertIntoTable")
63 public void testGetValueFromTableNegative() {
65 ConfigurationData value =
66 applicationConfigManager.getFromTable("not-existing-namespace", "not-existing-key");
67 } catch (CoreException ce) {
68 Assert.assertEquals(ce.getMessage(),
69 "Configuration for namespace not-existing-namespace and key not-existing-key was not found");
75 public void testGetList() {
76 applicationConfigManager.insertIntoTable(TEST_NAMESPACE_2, "key1", "val1");
77 applicationConfigManager.insertIntoTable(TEST_NAMESPACE_2, "key2", "val2");
78 applicationConfigManager.insertIntoTable(TEST_NAMESPACE_2, "key3", "val3");
80 Collection<ApplicationConfigEntity> ACElist =
81 applicationConfigManager.getListOfConfigurationByNamespace(TEST_NAMESPACE_2);
83 Assert.assertNotNull(ACElist);
84 Assert.assertEquals(ACElist.size(), 3);