/**\r
- * Copyright 2017 ZTE Corporation.\r
+ * Copyright 2017-2021 ZTE Corporation.\r
*\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
\r
package org.onap.holmes.engine.wrapper;\r
\r
-import static org.easymock.EasyMock.anyInt;\r
-import static org.easymock.EasyMock.anyObject;\r
-import static org.easymock.EasyMock.expect;\r
-\r
-import java.util.ArrayList;\r
import org.junit.Before;\r
import org.junit.Rule;\r
import org.junit.Test;\r
import org.junit.rules.ExpectedException;\r
-import org.onap.holmes.common.api.entity.CorrelationRule;\r
import org.onap.holmes.common.exception.CorrelationException;\r
-import org.onap.holmes.common.utils.DbDaoUtil;\r
-import org.onap.holmes.engine.db.CorrelationRuleDao;\r
+import org.onap.holmes.engine.db.CorrelationRuleDaoService;\r
import org.powermock.api.easymock.PowerMock;\r
-import org.powermock.reflect.Whitebox;\r
+\r
+import java.util.ArrayList;\r
+\r
+import static org.easymock.EasyMock.anyInt;\r
+import static org.easymock.EasyMock.expect;\r
\r
public class RuleMgtWrapperTest {\r
\r
@Rule\r
public ExpectedException thrown = ExpectedException.none();\r
- private DbDaoUtil daoUtil;\r
+ private CorrelationRuleDaoService correlationRuleDaoService;\r
private RuleMgtWrapper ruleMgtWrapper;\r
\r
@Before\r
public void setUp() {\r
- daoUtil = PowerMock.createMock(DbDaoUtil.class);\r
- ruleMgtWrapper = new RuleMgtWrapper();\r
+ correlationRuleDaoService = PowerMock.createMock(CorrelationRuleDaoService.class);\r
+ ruleMgtWrapper = new RuleMgtWrapper(correlationRuleDaoService);\r
\r
- Whitebox.setInternalState(ruleMgtWrapper, "daoUtil", daoUtil);\r
PowerMock.resetAll();\r
}\r
\r
@Test\r
public void queryRuleByEnable_normal() throws CorrelationException {\r
int enable = 3;\r
-\r
- CorrelationRuleDao correlationRuleDao = PowerMock.createMock(CorrelationRuleDao.class);\r
- expect(daoUtil.getJdbiDaoByOnDemand(anyObject(Class.class))).andReturn(correlationRuleDao);\r
- expect(correlationRuleDao.queryRuleByRuleEnable(anyInt())).andReturn(new ArrayList<CorrelationRule>());\r
+ expect(correlationRuleDaoService.queryRuleByRuleEnable(anyInt())).andReturn(new ArrayList());\r
PowerMock.replayAll();\r
ruleMgtWrapper.queryRuleByEnable(enable);\r
PowerMock.verifyAll();\r