Switched from Dropwizard to Springboot
[holmes/common.git] / holmes-actions / src / test / java / org / onap / holmes / common / utils / DbDaoUtilTest.java
1 /**
2  * Copyright 2017-2020 ZTE Corporation.
3  * <p>
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
7  * <p>
8  * http://www.apache.org/licenses/LICENSE-2.0
9  * <p>
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.
15  */
16
17 package org.onap.holmes.common.utils;
18
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;
27
28 import static org.easymock.EasyMock.anyObject;
29 import static org.easymock.EasyMock.expect;
30
31 @RunWith(PowerMockRunner.class)
32 public class DbDaoUtilTest {
33
34     @Rule
35     public ExpectedException thrown = ExpectedException.none();
36
37
38     @Test
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);
43
44         PowerMock.replayAll();
45
46         dbDaoUtil.getJdbiDaoByOnDemand(String.class);
47
48         PowerMock.verifyAll();
49     }
50
51 }