import org.onap.holmes.engine.request.CompileRuleRequest;\r
import org.onap.holmes.engine.request.DeployRuleRequest;\r
import org.powermock.api.easymock.PowerMock;\r
-import org.powermock.reflect.Whitebox;\r
\r
-import javax.servlet.http.HttpServletRequest;\r
-import javax.ws.rs.WebApplicationException;\r
-import java.util.Locale;\r
+import jakarta.ws.rs.WebApplicationException;\r
\r
import static org.easymock.EasyMock.*;\r
\r
closedLoopControlNameCache = new ClosedLoopControlNameCache();\r
engineResources = new EngineResources();\r
engineResources.setClosedLoopControlNameCache(closedLoopControlNameCache);\r
-\r
- Whitebox.setInternalState(engineResources,"droolsEngine", droolsEngine);\r
+ engineResources.setDroolsEngine(droolsEngine);\r
PowerMock.resetAll();\r
}\r
\r
@Test\r
public void deployRule_exception() throws CorrelationException {\r
DeployRuleRequest deployRuleRequest = new DeployRuleRequest();\r
- HttpServletRequest httpRequest = PowerMock.createMock(HttpServletRequest.class);\r
\r
thrown.expect(WebApplicationException.class);\r
\r
- expect(httpRequest.getHeader("language-option")).andReturn("en_US");\r
expect(droolsEngine.deployRule(anyObject(DeployRuleRequest.class))).\r
andThrow(new CorrelationException(""));\r
PowerMock.replayAll();\r
- engineResources.deployRule(deployRuleRequest, httpRequest);\r
+ engineResources.deployRule(deployRuleRequest);\r
PowerMock.verifyAll();\r
}\r
\r
DeployRuleRequest deployRuleRequest = new DeployRuleRequest();\r
deployRuleRequest.setContent("package packageName;\n\nimport xxx.xxx.xxx;");\r
deployRuleRequest.setLoopControlName("loopControlName");\r
- HttpServletRequest httpRequest = PowerMock.createMock(HttpServletRequest.class);\r
\r
- expect(httpRequest.getHeader("language-option")).andReturn("en_US");\r
expect(droolsEngine.deployRule(anyObject(DeployRuleRequest.class))).andReturn("packageName");\r
PowerMock.replayAll();\r
- engineResources.deployRule(deployRuleRequest, httpRequest);\r
+ engineResources.deployRule(deployRuleRequest);\r
PowerMock.verifyAll();\r
}\r
\r
@Test\r
public void undeployRule_exception() throws CorrelationException {\r
String packageName = "packageName";\r
- HttpServletRequest httpRequest = PowerMock.createMock(HttpServletRequest.class);\r
\r
thrown.expect(WebApplicationException.class);\r
\r
- expect(httpRequest.getHeader("language-option")).andReturn("en_US");\r
droolsEngine.undeployRule(anyObject(String.class));\r
expectLastCall().andThrow(new CorrelationException(""));\r
PowerMock.replayAll();\r
- engineResources.undeployRule(packageName, httpRequest);\r
+ engineResources.undeployRule(packageName);\r
PowerMock.verifyAll();\r
}\r
\r
@Test\r
public void undeployRule_normal() throws CorrelationException {\r
String packageName = "packageName";\r
- HttpServletRequest httpRequest = PowerMock.createMock(HttpServletRequest.class);\r
\r
- expect(httpRequest.getHeader("language-option")).andReturn("en_US");\r
droolsEngine.undeployRule(anyObject(String.class));\r
PowerMock.replayAll();\r
- engineResources.undeployRule(packageName, httpRequest);\r
+ engineResources.undeployRule(packageName);\r
PowerMock.verifyAll();\r
}\r
\r
@Test\r
public void compileRule_exception() throws CorrelationException {\r
CompileRuleRequest compileRuleRequest = new CompileRuleRequest();\r
- HttpServletRequest httpRequest = PowerMock.createMock(HttpServletRequest.class);\r
\r
thrown.expect(WebApplicationException.class);\r
\r
- expect(httpRequest.getHeader("language-option")).andReturn("en_US");\r
droolsEngine.compileRule(anyObject(String.class));\r
expectLastCall().andThrow(new CorrelationException(""));\r
PowerMock.replayAll();\r
- engineResources.compileRule(compileRuleRequest, httpRequest);\r
+ engineResources.compileRule(compileRuleRequest);\r
PowerMock.verifyAll();\r
}\r
\r
@Test\r
public void compileRule_normal() throws CorrelationException {\r
CompileRuleRequest compileRuleRequest = new CompileRuleRequest();\r
- HttpServletRequest httpRequest = PowerMock.createMock(HttpServletRequest.class);\r
-\r
- expect(httpRequest.getHeader("language-option")).andReturn("en_US");\r
droolsEngine.compileRule(anyObject(String.class));\r
PowerMock.replayAll();\r
- engineResources.compileRule(compileRuleRequest, httpRequest);\r
+ engineResources.compileRule(compileRuleRequest);\r
PowerMock.verifyAll();\r
}\r
}\r