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.sdc.applicationconfig.impl.ApplicationConfigManagerImpl;
26 * Created by Talio on 8/9/2016.
28 public class ApplicationConfigManagerTest {
30 public static final String TEST_NAMESPACE_1 = "test-app-namespace";
31 public static final String TEST_NAMESPACE_2 = "test-namespace";
32 public static final String TEST_KEY = "test-app-key";
33 public static final String TEST_VALUE = "test-app-value";
34 ApplicationConfigManager applicationConfigManager = new ApplicationConfigManagerImpl();
38 public void testInsertIntoTable() {
40 applicationConfigManager.insertIntoTable(TEST_NAMESPACE_1, TEST_KEY, TEST_VALUE);
41 } catch (CoreException exception) {
42 Assert.assertEquals(exception.getMessage(),
43 "Error occurred while loading questionnaire schema templates");
48 @Test(dependsOnMethods = "testInsertIntoTable")
49 public void testGetValueFromTable() {
50 ConfigurationData value = applicationConfigManager.getFromTable(TEST_NAMESPACE_1, TEST_KEY);
52 Assert.assertEquals(value.getValue(), TEST_VALUE);
56 @Test(dependsOnMethods = "testInsertIntoTable")
57 public void testGetValueFromTableNegative() {
59 ConfigurationData value =
60 applicationConfigManager.getFromTable("not-existing-namespace", "not-existing-key");
61 } catch (CoreException ce) {
62 Assert.assertEquals(ce.getMessage(),
63 "Configuration for namespace not-existing-namespace and key not-existing-key was not found");
69 public void testGetList() {
70 applicationConfigManager.insertIntoTable(TEST_NAMESPACE_2, "key1", "val1");
71 applicationConfigManager.insertIntoTable(TEST_NAMESPACE_2, "key2", "val2");
72 applicationConfigManager.insertIntoTable(TEST_NAMESPACE_2, "key3", "val3");
74 Collection<ApplicationConfigEntity> ACElist =
75 applicationConfigManager.getListOfConfigurationByNamespace(TEST_NAMESPACE_2);
77 Assert.assertNotNull(ACElist);
78 Assert.assertEquals(ACElist.size(), 3);