aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src
diff options
context:
space:
mode:
authorRob Daugherty <rd472p@att.com>2018-11-07 18:30:09 -0500
committerRob Daugherty <rd472p@att.com>2018-11-07 20:45:00 -0500
commiteec3403e1439f536a2aaf89474a6d4b1ca08df29 (patch)
tree9f86c14d0a4bc5e5ebc8f519ad452502451ba5e7 /bpmn/so-bpmn-infrastructure-common/src
parent61affc6311906aee71b16ee8632c1e7468cd1990 (diff)
parent29641940921b96ed1367958c14e6da2be6577575 (diff)
11/7: merge casablanca to master
Commit: dbb53cabbff772880134699eb81dee775d7df8df Subject: Send correct resourceModuleName Issue: SO-1178 Commit: d3759e15184562647ea83b92cf02140fc705cb0d by ss835w Subject: Update Regex Logic to take into account new scale out URI... Issue: SO-117 Commit: 5dadc2c5790c961a74085d3d10b6f5aec6b7ba30 Subject: Fix msb url in homing cloudsite Issue: SO-1180 Commit: 9a9b0fa23afe8d46171fe95f1090de5a7f701d3d Subject: Updated Reference data for AutoScaleOut Issue: SO-1174 Commit: 3178cad6c756140b18eb658277598e3e2d2d3dcf Subject: ConfigurationParameter is empty for scaleout Issue: SO-1083 Commit: 402bf528e9a796f6ce31ad36c16316c2b31acc48 Subject: Added Null check for gtConfigurationParameter Issue: SO-1179 Commit: fb6ab40a64e74876ba1f08c4d3bdb6a040c21b94 Subject: Bug fixes November 5th Issue: SO-1188 Commit: ce37ae979311ed4e55150426d477db262773beb0 Subject: Removed slashes and added catch block Issue: SO-1183 Commit: 16aa0b6cc42c7287fc080c81451e301c0acc14cf Subject: removed retry from rainy day table Issue: SO-1185 Commit: 2073a3b4c20965252c7f3a0c1aea8e4407e876fa Subject: Fixing scaleOut workflow looping issue Issue: SO-1182 Commit: 5ca364a5e975877244ee51796602043a4b078a23 Subject: Make homingBB optinal and fix homing process Issue: SO-1168 Commit: 1c554c3332ccf6be4e576e9159bbb0f901197379 Subject: bug fixing with reading dmaap message Issue: SO-1191 Change-Id: Id747bc05b791787f304316396bc5fcd20d350b6f Issue-ID: SO-1190 Signed-off-by: Rob Daugherty <rd472p@att.com>
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationId.java35
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java2
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationIdTest.java36
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClientTest.java22
4 files changed, 35 insertions, 60 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationId.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationId.java
index 90b48ab2c1..159298b4ad 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationId.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationId.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Copyright (C) 2018 Nokia.
+ * ================================================================================
* 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
@@ -31,41 +33,32 @@ import java.util.Spliterator;
public final class JsonUtilForCorrelationId {
- private static final String JSON_HEADER = "pnfRegistrationFields";
private static final String JSON_CORRELATION_ID_FIELD_NAME = "correlationId";
static List<String> parseJsonToGelAllCorrelationId(String json) {
- List<String> list = new ArrayList<>();
JsonElement je = new JsonParser().parse(json);
- if (je.isJsonObject()) {
- getCorrelationIdFromJsonObject(je.getAsJsonObject()).ifPresent(corr -> list.add(corr));
- } else {
- JsonArray array = je.getAsJsonArray();
- Spliterator<JsonElement> spliterator = array.spliterator();
- spliterator.forEachRemaining(jsonElement -> {
- parseJsonElementToJsonObject(jsonElement)
- .ifPresent(jsonObject -> getCorrelationIdFromJsonObject(jsonObject)
- .ifPresent(correlationId -> list.add(correlationId)));
- });
- }
+ JsonArray array = je.getAsJsonArray();
+ List<String> list = new ArrayList<>();
+ Spliterator<JsonElement> spliterator = array.spliterator();
+ spliterator.forEachRemaining(jsonElement -> {
+ handleEscapedCharacters(jsonElement)
+ .ifPresent(jsonObject -> getCorrelationId(jsonObject)
+ .ifPresent(correlationId -> list.add(correlationId)));
+ });
return list;
}
- private static Optional<JsonObject> parseJsonElementToJsonObject(JsonElement jsonElement) {
+ private static Optional<JsonObject> handleEscapedCharacters(JsonElement jsonElement) {
if (jsonElement.isJsonObject()) {
return Optional.ofNullable(jsonElement.getAsJsonObject());
}
return Optional.ofNullable(new JsonParser().parse(jsonElement.getAsString()).getAsJsonObject());
}
- private static Optional<String> getCorrelationIdFromJsonObject(JsonObject jsonObject) {
- if (jsonObject.has(JSON_HEADER)) {
- JsonObject jo = jsonObject.getAsJsonObject(JSON_HEADER);
- if (jo.has(JSON_CORRELATION_ID_FIELD_NAME)) {
- return Optional.ofNullable(jo.get(JSON_CORRELATION_ID_FIELD_NAME).getAsString());
- }
+ private static Optional<String> getCorrelationId(JsonObject jsonObject) {
+ if (jsonObject.has(JSON_CORRELATION_ID_FIELD_NAME)) {
+ return Optional.ofNullable(jsonObject.get(JSON_CORRELATION_ID_FIELD_NAME).getAsString());
}
return Optional.empty();
}
-
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java
index 518d7ff194..373e84bb9d 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Copyright (C) 2018 Nokia.
+ * ================================================================================
* 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
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationIdTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationIdTest.java
index 24d1810ac6..fde112b009 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationIdTest.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationIdTest.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Copyright (C) 2018 Nokia.
+ * ================================================================================
* 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
@@ -24,30 +26,18 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.util.List;
import org.junit.Test;
-import org.onap.so.bpmn.infrastructure.pnf.dmaap.JsonUtilForCorrelationId;
public class JsonUtilForCorrelationIdTest {
- private static final String JSON_EXAMPLE_WITH_CORRELATION_ID = "[\n"
- + " {\n"
- + " \"pnfRegistrationFields\" : {\n"
- + " \"correlationId\" : \"corrTest1\",\n"
- + " \"value\" : \"value1\"\n"
- + " }\n"
- + " },\n"
- + " {\n"
- + " \"pnfRegistrationFields\" : {\n"
- + " \"correlationId\" : \"corrTest2\",\n"
- + " \"value\" : \"value2\"\n"
- + " }\n"
- + " }\n"
- + "]";
+ private static final String JSON_EXAMPLE_WITH_CORRELATION_ID = "[{\"correlationId\": \"corrTest1\","
+ + "\"key1\":\"value1\"},{\"correlationId\": \"corrTest2\",\"key2\":\"value2\"}]";
+
+ private static final String JSON_WITH_ONE_CORRELATION_ID = "[{\"correlationId\":\"corrTest3\"}]";
+
+ private static final String JSON_WITH_TWO_CORRELATION_ID_AND_ESCAPED_CHARACTERS =
+ "[\"{\\\"correlationId\\\":\\\"corrTest4\\\"}\", \"{\\\"correlationId\\\":\\\"corrTest5\\\"}\"]";
- private static final String JSON_EXAMPLE_WITH_CORRELATION_ID2 = "{\"pnfRegistrationFields\":{\"correlationId\":\"corrTest3\"}}";
- private static final String JSON_EXAMPLE_WITH_CORRELATION_ID3 = "[\"{\\\"pnfRegistrationFields\\\":"
- + "{\\\"correlationId\\\":\\\"corrTest4\\\"}}\", \"{\\\"pnfRegistrationFields\\\":"
- + "{\\\"correlationId\\\":\\\"corrTest5\\\"}}\"]";
- private static final String JSON_EXAMPLE_WITH_CORRELATION_ID4 = "{\"header\":{\"key\":\"value\"}}";
+ private static final String JSON_WITH_NO_CORRELATION_ID = "[{\"key1\":\"value1\"}]";
@Test
public void parseJsonSuccessful() {
@@ -56,21 +46,21 @@ public class JsonUtilForCorrelationIdTest {
assertThat(expectedResult).containsExactly("corrTest1", "corrTest2");
List<String> expectedResult2 = JsonUtilForCorrelationId
- .parseJsonToGelAllCorrelationId(JSON_EXAMPLE_WITH_CORRELATION_ID2);
+ .parseJsonToGelAllCorrelationId(JSON_WITH_ONE_CORRELATION_ID);
assertThat(expectedResult2).containsExactly("corrTest3");
}
@Test
public void parseJsonWithEscapeCharacters_Successful() {
List<String> expectedResult = JsonUtilForCorrelationId
- .parseJsonToGelAllCorrelationId(JSON_EXAMPLE_WITH_CORRELATION_ID3);
+ .parseJsonToGelAllCorrelationId(JSON_WITH_TWO_CORRELATION_ID_AND_ESCAPED_CHARACTERS);
assertThat(expectedResult).containsExactly("corrTest4", "corrTest5");
}
@Test
public void parseJson_emptyListReturnedWhenNothingFound() {
List<String> expectedResult = JsonUtilForCorrelationId
- .parseJsonToGelAllCorrelationId(JSON_EXAMPLE_WITH_CORRELATION_ID4);
+ .parseJsonToGelAllCorrelationId(JSON_WITH_NO_CORRELATION_ID);
assertThat(expectedResult).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 470061f6c2..33b4689629 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
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Copyright (C) 2018 Nokia.
+ * ================================================================================
* 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
@@ -56,22 +58,10 @@ public class PnfEventReadyDmaapClientTest {
private static final String CORRELATION_ID = "corrTestId";
private static final String CORRELATION_ID_NOT_FOUND_IN_MAP = "otherCorrId";
- private static final String JSON_EXAMPLE_WITH_CORRELATION_ID = "[\n"
- + " {\n"
- + " \"pnfRegistrationFields\" : {\n"
- + " \"correlationId\" : \"%s\",\n"
- + " \"value\" : \"value1\"\n"
- + " }\n"
- + " },\n"
- + " {\n"
- + " \"pnfRegistrationFields\" : {\n"
- + " \"correlationId\" : \"corr\",\n"
- + " \"value\" : \"value2\"\n"
- + " }\n"
- + " }\n"
- + "]";
- private static final String JSON_EXAMPLE_WITH_NO_CORRELATION_ID =
- "{\"pnfRegistrationFields\":{\"field\":\"value\"}}";
+ private static final String JSON_EXAMPLE_WITH_CORRELATION_ID = "[{\"correlationId\": \"%s\","
+ + "\"value\":\"value1\"},{\"correlationId\": \"corr\",\"value\":\"value2\"}]";
+
+ private static final String JSON_EXAMPLE_WITH_NO_CORRELATION_ID = "[{\"key1\":\"value1\"}]";
private static final String HOST = "hostTest";
private static final int PORT = 1234;