4217025da9a8e86ee6612fb0c5d6bca31e875ce5
[sdc.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.sdc.applicationconfig;
22
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;
29
30 import java.util.Collection;
31
32 /**
33  * Created by Talio on 8/9/2016.
34  */
35 public class ApplicationConfigManagerTest {
36
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();
42
43   /*
44   @Test
45   public void testInsertIntoTable() {
46     try {
47       applicationConfigManager.insertIntoTable(TEST_NAMESPACE_1, TEST_KEY, TEST_VALUE);
48     } catch (CoreException exception) {
49       Assert.assertEquals(exception.getMessage(),
50           "Error occurred while loading questionnaire schema templates");
51     }
52   }
53
54
55   @Test(dependsOnMethods = "testInsertIntoTable")
56   public void testGetValueFromTable() {
57     ConfigurationData value = applicationConfigManager.getFromTable(TEST_NAMESPACE_1, TEST_KEY);
58
59     Assert.assertEquals(value.getValue(), TEST_VALUE);
60   }
61
62
63   @Test(dependsOnMethods = "testInsertIntoTable")
64   public void testGetValueFromTableNegative() {
65     try {
66       ConfigurationData value =
67           applicationConfigManager.getFromTable("not-existing-namespace", "not-existing-key");
68     } catch (CoreException ce) {
69       Assert.assertEquals(ce.getMessage(),
70           "Configuration for namespace not-existing-namespace and key not-existing-key was not found");
71     }
72
73   }
74
75   @Test
76   public void testGetList() {
77     applicationConfigManager.insertIntoTable(TEST_NAMESPACE_2, "key1", "val1");
78     applicationConfigManager.insertIntoTable(TEST_NAMESPACE_2, "key2", "val2");
79     applicationConfigManager.insertIntoTable(TEST_NAMESPACE_2, "key3", "val3");
80
81     Collection<ApplicationConfigEntity> ACElist =
82         applicationConfigManager.getListOfConfigurationByNamespace(TEST_NAMESPACE_2);
83
84     Assert.assertNotNull(ACElist);
85     Assert.assertEquals(ACElist.size(), 3);
86   }
87
88   */
89 }