2 * Copyright 2017 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.rulemgt.wrapper;
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.CorrelationRuleDao;
26 import org.powermock.api.easymock.PowerMock;
28 import java.util.ArrayList;
29 import java.util.List;
32 public class RuleQueryWrapperTest {
33 private CorrelationRuleDao correlationRuleDao;
34 private RuleQueryWrapper ruleQueryWrapper;
38 correlationRuleDao = PowerMock.createMock(CorrelationRuleDao.class);
39 ruleQueryWrapper = PowerMock.createMock(RuleQueryWrapper.class);
43 public void queryRuleByEnable() throws Exception{
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());
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());