From b89572c4c6963ca3d6707e4a21e436bd2309f8ee Mon Sep 17 00:00:00 2001 From: youbowu Date: Mon, 27 Feb 2017 16:37:17 +0800 Subject: Fix the sonar detected error Issue-ID:HOLMES-50 Change-Id: Ia43c44cf70f6a0ac99592e4e302fda5f123cfc4f Signed-off-by: youbowu --- .../rulemgt/bolt/enginebolt/EngineServiceTest.java | 37 ++++++++++++++++++---- 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'rulemgt/src/test/java/org/openo') diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineServiceTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineServiceTest.java index d911f9c..596a408 100644 --- a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineServiceTest.java +++ b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineServiceTest.java @@ -18,15 +18,15 @@ package org.openo.holmes.rulemgt.bolt.enginebolt; -import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; import org.easymock.EasyMock; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.openo.holmes.rulemgt.RuleAppConfig; +import org.openo.holmes.rulemgt.bean.request.CorrelationCheckRule4Engine; +import org.openo.holmes.rulemgt.bean.request.CorrelationDeployRule4Engine; import org.powermock.api.easymock.PowerMock; import org.powermock.modules.junit4.rule.PowerMockRule; import org.powermock.reflect.Whitebox; @@ -38,18 +38,18 @@ public class EngineServiceTest { @Rule public PowerMockRule powerMockRule = new PowerMockRule(); private EngineService engineService; - private HttpEntity httpEntityMock; private HttpResponse httpResponseMock; - private HttpClient httpClient; private RuleAppConfig ruleAppConfig = new RuleAppConfig(); + private CorrelationDeployRule4Engine correlationDeployRule4Engine; @Before public void setUp() { engineService = new EngineService(); - httpEntityMock = PowerMock.createMock(HttpEntity.class); httpResponseMock = PowerMock.createMock(HttpResponse.class); - httpClient = PowerMock.createMock(HttpClient.class); Whitebox.setInternalState(engineService, "ruleAppConfig", ruleAppConfig); + correlationDeployRule4Engine = new CorrelationDeployRule4Engine(); + correlationDeployRule4Engine.setContent("{\"package\":\"test\"}"); + correlationDeployRule4Engine.setEngineId("engine_id"); } @Test @@ -61,4 +61,29 @@ public class EngineServiceTest { PowerMock.verifyAll(); } + + @Test + public void delete_exception() throws Exception { + thrown.expect(Exception.class); + + engineService.delete("test"); + + } + + @Test + public void deploy_exception() throws Exception { + + thrown.expect(Exception.class); + + engineService.deploy(correlationDeployRule4Engine); + + } + + @Test + public void check_normal() throws Exception { + thrown.expect(Exception.class); + + engineService.check(new CorrelationCheckRule4Engine()); + + } } \ No newline at end of file -- cgit 1.2.3-korg