summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src/test/java/org
diff options
context:
space:
mode:
authorgrabinsk <maciej.grabinski@nokia.com>2019-09-18 14:59:44 +0200
committergrabinsk <maciej.grabinski@nokia.com>2019-09-18 15:23:48 +0200
commite3b9b0d3162e8eba5df9903f03a4741ffb1115c7 (patch)
tree6dc981f2f563ac799dcbd405a4c67ea0c93f9a42 /bpmn/so-bpmn-infrastructure-common/src/test/java/org
parente288bedf6a7b83c6127cbb1bc4281084cdbc218e (diff)
Prevent reading twice from ResponseEntity stream, since this caused IOErrors.
Also moving empty response checks to parseJsonToGelAllPnfCorrelationId Issue-ID: SO-2349 Signed-off-by: grabinsk <maciej.grabinski@nokia.com> Change-Id: I316856d56106a1ae715812628695406f4147765d Signed-off-by: grabinsk <maciej.grabinski@nokia.com>
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src/test/java/org')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationIdTest.java9
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java8
2 files changed, 13 insertions, 4 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationIdTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationIdTest.java
index 8741208d26..4edee24531 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationIdTest.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForPnfCorrelationIdTest.java
@@ -63,4 +63,13 @@ public class JsonUtilForPnfCorrelationIdTest {
assertThat(expectedResult).isEmpty();
}
+ @Test
+ public void shouldReturnEmptyListWhenInputIsNull() {
+ assertThat(JsonUtilForPnfCorrelationId.parseJsonToGelAllPnfCorrelationId(null)).isEmpty();
+ }
+
+ @Test
+ public void shouldReturnEmptyListWhenInputIsEmpty() {
+ assertThat(JsonUtilForPnfCorrelationId.parseJsonToGelAllPnfCorrelationId("")).isEmpty();
+ }
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java
index 19e08d9d59..cccfe0c762 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java
@@ -30,8 +30,8 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
-import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -41,7 +41,7 @@ import org.apache.http.HttpResponse;
import org.apache.http.ProtocolVersion;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
-import org.apache.http.entity.StringEntity;
+import org.apache.http.entity.InputStreamEntity;
import org.apache.http.message.BasicHttpResponse;
import org.junit.Before;
import org.junit.Test;
@@ -182,8 +182,8 @@ public class PnfEventReadyDmaapClientTest {
threadRunFlag.setAccessible(false);
}
- private HttpResponse createResponse(String json) throws UnsupportedEncodingException {
- HttpEntity entity = new StringEntity(json);
+ private HttpResponse createResponse(String json) {
+ HttpEntity entity = new InputStreamEntity(new ByteArrayInputStream(json.getBytes()));
ProtocolVersion protocolVersion = new ProtocolVersion("", 1, 1);
HttpResponse response = new BasicHttpResponse(protocolVersion, 1, "");
response.setEntity(entity);