Migrate from DW to Springboot
[holmes/rule-management.git] / rulemgt / src / test / java / org / onap / holmes / rulemgt / wrapper / RuleQueryWrapperTest.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.rulemgt.wrapper;
18
19 import org.easymock.EasyMock;
20 import org.hamcrest.core.IsNull;
21 import org.junit.Assert;
22 import org.junit.Before;
23 import org.junit.Test;
24 import org.onap.holmes.common.api.entity.CorrelationRule;
25 import org.onap.holmes.rulemgt.db.jdbi.CorrelationRuleDao;
26 import org.powermock.api.easymock.PowerMock;
27
28 import java.util.ArrayList;
29 import java.util.List;
30
31
32 public class RuleQueryWrapperTest {
33     private CorrelationRuleDao correlationRuleDao;
34     private RuleQueryWrapper ruleQueryWrapper;
35
36     @Before
37     public void setUp() {
38         correlationRuleDao = PowerMock.createMock(CorrelationRuleDao.class);
39         ruleQueryWrapper = PowerMock.createMock(RuleQueryWrapper.class);
40     }
41
42     @Test
43     public void queryRuleByEnable() throws Exception{
44         int enable = 0;
45         EasyMock.expect(ruleQueryWrapper.queryRuleByEnable(EasyMock.anyInt())).andReturn(new ArrayList<CorrelationRule>());
46         PowerMock.replayAll();
47         List<CorrelationRule> correlationRules = ruleQueryWrapper.queryRuleByEnable(enable);
48         PowerMock.verifyAll();
49         Assert.assertThat(correlationRules, IsNull.<List<CorrelationRule>>notNullValue());
50     }
51
52     @Test
53     public void queryRuleByEngineInstance() throws Exception{
54         String engineInstance = "127.0.0.1";
55         EasyMock.expect(ruleQueryWrapper.queryRuleByEngineInstance(EasyMock.anyObject(String.class))).andReturn(new ArrayList<CorrelationRule>());
56         PowerMock.replayAll();
57         List<CorrelationRule> correlationRules = ruleQueryWrapper.queryRuleByEngineInstance(engineInstance);
58         PowerMock.verifyAll();
59         Assert.assertThat(correlationRules, IsNull.<List<CorrelationRule>>notNullValue());
60     }
61 }