Add collaboration feature
[sdc.git] / openecomp-be / lib / openecomp-core-lib / openecomp-config-lib / src / test / java / org / openecomp / sdc / applicationconfig / dao / ApplicationConfigImplDaoTest.java
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.dao;
22
23 public class ApplicationConfigImplDaoTest {
24
25   /*
26
27   private static final String SCHEMA_GENERATOR_INITIALIZATION_ERROR =
28       "SCHEMA_GENERATOR_INITIALIZATION_ERROR";
29   private static final String SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG =
30       "Error occurred while loading questionnaire schema templates";
31   private static ApplicationConfigDao applicationConfigDao =
32       ApplicationConfigDaoFactory.getInstance().createInterface();
33   private static ApplicationConfig applicationConfig =
34       ApplicationConfigFactory.getInstance().createInterface();
35
36   private final static Logger log = (Logger) LoggerFactory.getLogger
37       (ApplicationConfigImplDaoTest.class.getName());
38
39   private final Logger logger = (Logger) LoggerFactory.getLogger(this.getClass().getName());
40
41   @BeforeClass
42   public static void init() {
43     try {
44
45       ApplicationConfigEntity applicationConfigEntity1 =
46           new ApplicationConfigEntity("test - namespace", "vsp", "vspTemplate");
47       ApplicationConfigEntity applicationConfigEntity2 =
48           new ApplicationConfigEntity("test - namespace", "nic", "nicTemplate");
49       ApplicationConfigEntity applicationConfigEntity3 =
50           new ApplicationConfigEntity("test - namespace", "component", "componentTemplate");
51
52       applicationConfigDao.create(applicationConfigEntity1);
53       applicationConfigDao.create(applicationConfigEntity2);
54       applicationConfigDao.create(applicationConfigEntity3);
55
56     } catch (Exception e) {
57       log.debug("",e);
58       throw new CoreException(new ErrorCode.ErrorCodeBuilder().
59           withCategory(ErrorCategory.APPLICATION).
60           withId(SCHEMA_GENERATOR_INITIALIZATION_ERROR).
61           withMessage(SCHEMA_GENERATOR_INITIALIZATION_ERROR_MSG).
62           build());
63     }
64   }
65
66   private static String loadFileToString(String path) {
67     return new String(FileUtils.toByteArray(FileUtils.loadFileToInputStream(path)));
68   }
69
70   @Test
71   public void testApplicationConfigTimestampValue() {
72     ConfigurationData configurationData = applicationConfig
73         .getConfigurationData("test - namespace", "vsp");
74
75     Assert.assertNotNull(configurationData);
76     Assert.assertNotEquals(configurationData.getTimeStamp(), 0);
77
78   }
79
80   @Test(dependsOnMethods = "testApplicationConfigTimestampValue")
81   public void testNotExistingApplicationConfigTimestampValue() {
82     try {
83       applicationConfig.getConfigurationData("test - namespace", "aaa");
84     } catch (CoreException ce) {
85       logger.debug("", ce);
86       Assert.assertEquals(ce.getMessage(),
87           "Configuration for namespace test - namespace and key aaa was not found");
88     }
89
90   }
91
92   @Test(dependsOnMethods = "testApplicationConfigTimestampValue")
93   public void testInsertApplicationConfiguration() {
94     String testTemplate = loadFileToString("questionnaire/testTemplate.txt");
95     applicationConfig.insertValue("test_namespace", "test_key", testTemplate);
96
97     Assert.assertEquals(testTemplate,
98         applicationConfig.getConfigurationData("test_namespace", "test_key").getValue());
99   }
100 */
101 }