Change the groupid from openo to onap
[holmes/engine-management.git] / engine-d / src / test / java / org / onap / holmes / engine / wrapper / RuleMgtWrapperTest.java
diff --git a/engine-d/src/test/java/org/onap/holmes/engine/wrapper/RuleMgtWrapperTest.java b/engine-d/src/test/java/org/onap/holmes/engine/wrapper/RuleMgtWrapperTest.java
new file mode 100644 (file)
index 0000000..cd7aff4
--- /dev/null
@@ -0,0 +1,62 @@
+/**\r
+ * Copyright 2017 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
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\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.powermock.api.easymock.PowerMock;\r
+import org.powermock.reflect.Whitebox;\r
+\r
+public class RuleMgtWrapperTest {\r
+\r
+    @Rule\r
+    public ExpectedException thrown = ExpectedException.none();\r
+    private DbDaoUtil daoUtil;\r
+    private RuleMgtWrapper ruleMgtWrapper;\r
+\r
+    @Before\r
+    public void setUp() {\r
+        daoUtil = PowerMock.createMock(DbDaoUtil.class);\r
+        ruleMgtWrapper = new RuleMgtWrapper();\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
+        PowerMock.replayAll();\r
+        ruleMgtWrapper.queryRuleByEnable(enable);\r
+        PowerMock.verifyAll();\r
+    }\r
+}\r