2 * Copyright © 2017-2018 AT&T Intellectual Property.
\r
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
\r
5 * in compliance with the License. You may obtain a copy of the License at
\r
7 * http://www.apache.org/licenses/LICENSE-2.0
\r
9 * Unless required by applicable law or agreed to in writing, software distributed under the License
\r
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
\r
11 * or implied. See the License for the specific language governing permissions and limitations under
\r
15 package org.onap.ccsdk.config.data.adaptor.dao;
\r
17 import java.util.HashMap;
\r
18 import java.util.List;
\r
19 import java.util.Map;
\r
20 import org.junit.Assert;
\r
21 import org.junit.Before;
\r
22 import org.junit.FixMethodOrder;
\r
23 import org.junit.Test;
\r
24 import org.junit.runner.RunWith;
\r
25 import org.junit.runners.MethodSorters;
\r
26 import org.onap.ccsdk.config.data.adaptor.DataAdaptorConstants;
\r
27 import org.onap.ccsdk.config.data.adaptor.domain.TransactionLog;
\r
28 import org.springframework.beans.factory.annotation.Autowired;
\r
29 import org.springframework.test.context.ContextConfiguration;
\r
30 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
\r
31 import com.att.eelf.configuration.EELFLogger;
\r
32 import com.att.eelf.configuration.EELFManager;
\r
34 @RunWith(SpringJUnit4ClassRunner.class)
\r
35 @ContextConfiguration(locations = {"classpath:test-context-h2db.xml"})
\r
36 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
\r
37 public class ConfigTransactionLogDaoTest {
\r
38 private static EELFLogger logger = EELFManager.getInstance().getLogger(ConfigTransactionLogDaoTest.class);
\r
41 private TransactionLogDao transactionLogDao;
\r
44 private NamedQueryExecutorDao namedQueryExecutorDao;
\r
47 public void initialise() {
\r
52 public void testQueryExecution() throws Exception {
\r
53 String requestId = "12345";
\r
56 .save(new TransactionLog(requestId, DataAdaptorConstants.LOG_MESSAGE_TYPE_LOG, "Received Request"));
\r
58 List<TransactionLog> result = transactionLogDao.getTransactionsByRequestId(requestId);
\r
59 logger.info("DB ArtifactReference :" + result);
\r
60 Assert.assertNotNull("Failed to get Query Result", result);
\r
62 List<TransactionLog> result2 =
\r
63 transactionLogDao.getTransactionsByRequestId(requestId, DataAdaptorConstants.LOG_MESSAGE_TYPE_LOG);
\r
64 logger.info("DB ArtifactReference :" + result2);
\r
65 Assert.assertNotNull("Failed to get Query Result", result2);
\r
67 String namedsql = "SELECT * FROM CONFIG_TRANSACTION_LOG WHERE request_id = :request_id";
\r
68 Map<String, Object> parameters = new HashMap<>();
\r
69 parameters.put("request_id", "12345");
\r
70 List<Map<String, Object>> namedresult = namedQueryExecutorDao.query(namedsql, parameters);
\r
71 logger.info("DB ArtifactReference :" + namedresult);
\r
72 Assert.assertNotNull("Failed to get Query Result", namedresult);
\r