Extract the Common Tool
[holmes/common.git] / holmes-actions / src / test / java / org / onap / holmes / common / utils / CorrelationRuleMapperTest.java
1 /*
2  * Copyright 2017 ZTE Corporation.
3  *
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  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 static org.easymock.EasyMock.expect;
20 import static org.junit.Assert.*;
21
22 import java.sql.Date;
23 import java.sql.ResultSet;
24 import java.util.Properties;
25 import org.junit.Test;
26 import org.powermock.api.easymock.PowerMock;
27
28 public class CorrelationRuleMapperTest {
29
30     @Test
31     public void map() throws Exception {
32         CorrelationRuleMapper mapper = new CorrelationRuleMapper();
33         ResultSet resultSet = PowerMock.createMock(ResultSet.class);
34         expect(resultSet.getString("name")).andReturn("");
35         expect(resultSet.getString("rid")).andReturn("");
36         expect(resultSet.getString("description")).andReturn("");
37         expect(resultSet.getInt("enable")).andReturn(0);
38         expect(resultSet.getInt("templateID")).andReturn(1);
39         expect(resultSet.getString("engineID")).andReturn("");
40         expect(resultSet.getString("engineType")).andReturn("");
41         expect(resultSet.getString("creator")).andReturn("");
42         expect(resultSet.getDate("createTime")).andReturn(new Date(System.currentTimeMillis()));
43         expect(resultSet.getString("updator")).andReturn("");
44         expect(resultSet.getDate("updateTime")).andReturn(new Date(System.currentTimeMillis()));
45         expect(resultSet.getObject("params")).andReturn(new Properties());
46         expect(resultSet.getString("content")).andReturn("");
47         expect(resultSet.getString("vendor")).andReturn("");
48         expect(resultSet.getString("package")).andReturn("");
49         expect(resultSet.getString("ctrlloop")).andReturn("");
50         PowerMock.replay(resultSet);
51         mapper.map(0, resultSet, null);
52         PowerMock.verify(resultSet);
53     }
54 }