summaryrefslogtreecommitdiffstats
path: root/rulemgt/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'rulemgt/src/test/java')
-rw-r--r--rulemgt/src/test/java/org/onap/holmes/rulemgt/bolt/enginebolt/EngineServiceTest.java22
-rw-r--r--rulemgt/src/test/java/org/onap/holmes/rulemgt/bolt/enginebolt/EngineWrapperTest.java17
-rw-r--r--rulemgt/src/test/java/org/onap/holmes/rulemgt/wrapper/RuleMgtWrapperTest.java6
3 files changed, 23 insertions, 22 deletions
diff --git a/rulemgt/src/test/java/org/onap/holmes/rulemgt/bolt/enginebolt/EngineServiceTest.java b/rulemgt/src/test/java/org/onap/holmes/rulemgt/bolt/enginebolt/EngineServiceTest.java
index 82e51a5..91be5d3 100644
--- a/rulemgt/src/test/java/org/onap/holmes/rulemgt/bolt/enginebolt/EngineServiceTest.java
+++ b/rulemgt/src/test/java/org/onap/holmes/rulemgt/bolt/enginebolt/EngineServiceTest.java
@@ -1,12 +1,12 @@
/**
* Copyright 2017 ZTE Corporation.
- *
+ * <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,10 +18,6 @@
package org.onap.holmes.rulemgt.bolt.enginebolt;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-
-import java.util.HashMap;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.impl.client.CloseableHttpClient;
@@ -30,22 +26,28 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
import org.onap.holmes.common.utils.HttpsUtils;
import org.onap.holmes.rulemgt.bean.request.CorrelationDeployRule4Engine;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.modules.junit4.rule.PowerMockRule;
import org.powermock.reflect.Whitebox;
+import java.util.HashMap;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+
@PrepareForTest({HttpClients.class, CloseableHttpClient.class, HttpsUtils.class})
@PowerMockIgnore("javax.net.ssl.*")
+@RunWith(PowerMockRunner.class)
public class EngineServiceTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
- @Rule
- public PowerMockRule powerMockRule = new PowerMockRule();
private EngineService engineService;
private HttpResponse httpResponseMock;
private CloseableHttpClient closeableHttpClient;
diff --git a/rulemgt/src/test/java/org/onap/holmes/rulemgt/bolt/enginebolt/EngineWrapperTest.java b/rulemgt/src/test/java/org/onap/holmes/rulemgt/bolt/enginebolt/EngineWrapperTest.java
index 0664db7..0dd2fbd 100644
--- a/rulemgt/src/test/java/org/onap/holmes/rulemgt/bolt/enginebolt/EngineWrapperTest.java
+++ b/rulemgt/src/test/java/org/onap/holmes/rulemgt/bolt/enginebolt/EngineWrapperTest.java
@@ -17,9 +17,6 @@
package org.onap.holmes.rulemgt.bolt.enginebolt;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.easymock.EasyMock;
@@ -28,16 +25,18 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
+import org.onap.holmes.common.exception.CorrelationException;
import org.onap.holmes.common.utils.HttpsUtils;
import org.onap.holmes.rulemgt.bean.request.CorrelationCheckRule4Engine;
import org.onap.holmes.rulemgt.bean.request.CorrelationDeployRule4Engine;
-import org.onap.holmes.common.exception.CorrelationException;
import org.powermock.api.easymock.PowerMock;
-import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+
@PrepareForTest({EngineWrapper.class, EngineService.class, HttpsUtils.class, HttpResponse.class,
StatusLine.class})
@RunWith(PowerMockRunner.class)
@@ -97,7 +96,7 @@ public class EngineWrapperTest {
public void deployEngine_parse_content_exception() throws Exception {
PowerMock.resetAll();
String content = "";
- PowerMockito.mockStatic(HttpsUtils.class);
+ PowerMock.mockStatic(HttpsUtils.class);
thrown.expect(CorrelationException.class);
thrown.expectMessage(
"Failed to parse the value returned by the engine management service.");
@@ -107,7 +106,7 @@ public class EngineWrapperTest {
.andReturn(httpResponse);
EasyMock.expect(httpResponse.getStatusLine()).andReturn(statusLineMock);
EasyMock.expect(statusLineMock.getStatusCode()).andReturn(200);
- PowerMockito.when(HttpsUtils.extractResponseEntity(httpResponse)).thenReturn(content);
+ EasyMock.expect(HttpsUtils.extractResponseEntity(httpResponse)).andReturn(content);
PowerMock.replayAll();
engineWrapper.deployEngine(new CorrelationDeployRule4Engine(),"10.96.33.34");
@@ -119,14 +118,14 @@ public class EngineWrapperTest {
public void deployEngine_success() throws Exception {
PowerMock.resetAll();
String content = "{\"packageName\":\"test\"}";
- PowerMockito.mockStatic(HttpsUtils.class);
+ PowerMock.mockStatic(HttpsUtils.class);
EasyMock.expect(
engineServiceMock.deploy(EasyMock.anyObject(CorrelationDeployRule4Engine.class),
EasyMock.anyObject(String.class)))
.andReturn(httpResponse);
EasyMock.expect(httpResponse.getStatusLine()).andReturn(statusLineMock);
EasyMock.expect(statusLineMock.getStatusCode()).andReturn(200);
- PowerMockito.when(HttpsUtils.extractResponseEntity(httpResponse)).thenReturn(content);
+ EasyMock.expect(HttpsUtils.extractResponseEntity(httpResponse)).andReturn(content);
PowerMock.replayAll();
String result = engineWrapper.deployEngine(new CorrelationDeployRule4Engine(),"10.96.33.34");
diff --git a/rulemgt/src/test/java/org/onap/holmes/rulemgt/wrapper/RuleMgtWrapperTest.java b/rulemgt/src/test/java/org/onap/holmes/rulemgt/wrapper/RuleMgtWrapperTest.java
index 90384ce..7033aff 100644
--- a/rulemgt/src/test/java/org/onap/holmes/rulemgt/wrapper/RuleMgtWrapperTest.java
+++ b/rulemgt/src/test/java/org/onap/holmes/rulemgt/wrapper/RuleMgtWrapperTest.java
@@ -22,6 +22,7 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
import org.onap.holmes.common.api.entity.CorrelationRule;
import org.onap.holmes.common.exception.CorrelationException;
import org.onap.holmes.common.utils.DbDaoUtil;
@@ -33,7 +34,7 @@ import org.onap.holmes.rulemgt.db.CorrelationRuleDao;
import org.onap.holmes.rulemgt.db.CorrelationRuleQueryDao;
import org.onap.holmes.rulemgt.send.Ip4AddingRule;
import org.powermock.api.easymock.PowerMock;
-import org.powermock.modules.junit4.rule.PowerMockRule;
+import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;
import java.util.ArrayList;
@@ -44,12 +45,11 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
+@RunWith(PowerMockRunner.class)
public class RuleMgtWrapperTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
- @Rule
- public PowerMockRule powerMockRule = new PowerMockRule();
private RuleMgtWrapper ruleMgtWrapper;