Fix OSGi wiring issues
[ccsdk/features.git] / blueprints-processor / adaptors / data-adaptor-provider / src / test / java / org / onap / ccsdk / config / data / adaptor / dao / QueryExecutorDaoTest.java
1 /*\r
2  * Copyright © 2017-2018 AT&T Intellectual Property.\r
3  * Modifications Copyright © 2018 IBM.\r
4  * \r
5  * Licensed under the Apache License, Version 2.0 (the "License");\r
6  * you may not use this file except in compliance with the License.\r
7  * You may obtain a copy of the License at\r
8  * \r
9  * http://www.apache.org/licenses/LICENSE-2.0\r
10  * \r
11  * Unless required by applicable law or agreed to in writing, software\r
12  * distributed under the License is distributed on an "AS IS" BASIS,\r
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
14  * See the License for the specific language governing permissions and\r
15  * limitations under the License.\r
16  */\r
17 \r
18 package org.onap.ccsdk.config.data.adaptor.dao;\r
19 \r
20 import java.util.Date;\r
21 import org.junit.Assert;\r
22 import org.junit.Before;\r
23 import org.junit.FixMethodOrder;\r
24 import org.junit.Test;\r
25 import org.junit.runner.RunWith;\r
26 import org.junit.runners.MethodSorters;\r
27 import org.springframework.beans.factory.annotation.Autowired;\r
28 import org.springframework.test.context.ContextConfiguration;\r
29 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;\r
30 import com.att.eelf.configuration.EELFLogger;\r
31 import com.att.eelf.configuration.EELFManager;\r
32 \r
33 @RunWith(SpringJUnit4ClassRunner.class)\r
34 @ContextConfiguration(locations = {"classpath:test-context-h2db.xml"})\r
35 @FixMethodOrder(MethodSorters.NAME_ASCENDING)\r
36 public class QueryExecutorDaoTest {\r
37     private static EELFLogger logger = EELFManager.getInstance().getLogger(QueryExecutorDaoTest.class);\r
38 \r
39     @Autowired\r
40     private QueryExecutorDao queryExecutorDao;\r
41 \r
42     @Before\r
43     public void initialise() {\r
44 \r
45     }\r
46 \r
47     @Test\r
48     public void testInsertQueryExecution() throws Exception {\r
49 \r
50         String sql = "INSERT INTO CONFIG_RESOURCE"\r
51                 + "(config_resource_id, resource_id, resource_type, template_name, recipe_name, request_id, resource_data, mask_data, created_date, updated_by) "\r
52                 + "VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";\r
53         Object[] data =\r
54                 new Object[] {"12345", "vUSP - vDBE-IPX HUB", "1234567", "activate-action", "vrr-service-template",\r
55                         "resource-data", "mask-data", null, new Date(System.currentTimeMillis()), "ab1234"};\r
56         int result = queryExecutorDao.update(sql, data);\r
57         logger.info("Updated successfully rows :" + result);\r
58         Assert.assertNotNull("Failed to get Query Result", result);\r
59     }\r
60 \r
61     @Test\r
62     public void testUpdateQueryExecution() throws Exception {\r
63 \r
64         String sql = "UPDATE CONFIG_RESOURCE set recipe_name=? where config_resource_id=?";\r
65         Object[] data = new Object[] {"vce-service-template", "12345"};\r
66         int result = queryExecutorDao.update(sql, data);\r
67         logger.info("Updated successfully rows :" + result);\r
68         Assert.assertNotNull("Failed to get Query Result", result);\r
69     }\r
70 \r
71     @Test\r
72     public void testDeleteQueryExecution() throws Exception {\r
73 \r
74         String sql = "DELETE FROM CONFIG_RESOURCE where config_resource_id=?";\r
75         Object[] data = new Object[] {"12345"};\r
76         int result = queryExecutorDao.update(sql, data);\r
77         logger.info("Updated successfully rows :" + result);\r
78         Assert.assertNotNull("Failed to get Query Result", result);\r
79     }\r
80 \r
81 }\r