2 * Copyright 2017-2020 ZTE Corporation.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.holmes.common.utils;
19 import org.jdbi.v3.core.Jdbi;
20 import org.junit.Rule;
21 import org.junit.Test;
22 import org.junit.rules.ExpectedException;
23 import org.junit.runner.RunWith;
24 import org.onap.holmes.common.database.DbDaoUtil;
25 import org.powermock.api.easymock.PowerMock;
26 import org.powermock.modules.junit4.PowerMockRunner;
28 import static org.easymock.EasyMock.anyObject;
29 import static org.easymock.EasyMock.expect;
31 @RunWith(PowerMockRunner.class)
32 public class DbDaoUtilTest {
35 public ExpectedException thrown = ExpectedException.none();
39 public void testGetJdbiDaoByOnDemand() {
40 Jdbi jdbi = PowerMock.createMock(Jdbi.class);
41 DbDaoUtil dbDaoUtil = new DbDaoUtil(jdbi);
42 expect(jdbi.onDemand(anyObject(Class.class))).andReturn(Class.class);
44 PowerMock.replayAll();
46 dbDaoUtil.getJdbiDaoByOnDemand(String.class);
48 PowerMock.verifyAll();