summaryrefslogtreecommitdiffstats
path: root/examples/examples-onap-vcpe/src/test/java
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-11-22 17:09:57 +0000
committerliamfallon <liam.fallon@est.tech>2019-11-25 11:02:30 +0000
commitb96fc5eb0980ce7bff21c61fe73f7e14b14b002b (patch)
tree606a2de5ba934ae1adfcce6c67c6a6758e3846d7 /examples/examples-onap-vcpe/src/test/java
parent96499223e328440c3623bcd3f8b9a648255a43ca (diff)
Update vCPE example for A&AI custom query
The change in policy-models to use custom queries means that the named queries used in apex examples must be updated to use custom queries. This review is the second of two reviews to implement this change. This patch updates the policy and its associated tests to work with A&AI custom queries. Issue-ID: POLICY-2125 Change-Id: I6a5b90002e43272e3cf296158f09f91a0f6d6907 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'examples/examples-onap-vcpe/src/test/java')
-rw-r--r--examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSimEndpoint.java17
1 files changed, 14 insertions, 3 deletions
diff --git a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSimEndpoint.java b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSimEndpoint.java
index 61100d4f4..5eb8fd338 100644
--- a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSimEndpoint.java
+++ b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSimEndpoint.java
@@ -66,6 +66,8 @@ public class OnapVCpeSimEndpoint {
private static final Gson gson = new GsonBuilder()
.registerTypeAdapter(Instant.class, new Serialization.GsonInstantAdapter()).create();
+ private static final AtomicInteger nextVnfId = new AtomicInteger(0);
+
/**
* Service get stats.
*
@@ -91,7 +93,7 @@ public class OnapVCpeSimEndpoint {
public Response serviceGuardPostRequest(final String jsonString) {
LOGGER.info("\n*** GUARD REQUEST START ***\n" + jsonString + "\n *** GUARD REQUEST END ***");
- String target = jsonString.substring(jsonString.indexOf("b4fe00ac"));
+ String target = jsonString.substring(jsonString.indexOf("00000000"));
target = target.substring(0, target.indexOf('"'));
int thisGuardMessageNumber = guardMessagesReceived.incrementAndGet();
@@ -128,8 +130,12 @@ public class OnapVCpeSimEndpoint {
LOGGER.info("\n*** AAI NODE QUERY GET START ***\nsearchNodeType=" + searchNodeType + "\nfilter=" + filter
+ "\n *** AAI REQUEST END ***");
+ String adjustedVserverUuid = "b4fe00ac-1da6-4b00-ac0d-8e8300db"
+ + String.format("%04d", nextVnfId.getAndIncrement());
+
String responseJsonString = TextFileUtils
- .getTextFileAsString("src/test/resources/aai/SearchNodeTypeResponse.json");
+ .getTextFileAsString("src/test/resources/aai/SearchNodeTypeResponse.json")
+ .replaceAll("b4fe00ac-1da6-4b00-ac0d-8e8300db0007", adjustedVserverUuid);
LOGGER.info("\n*** AAI RESPONSE START ***\n" + responseJsonString + "\n *** AAI RESPONSE END ***");
@@ -154,7 +160,12 @@ public class OnapVCpeSimEndpoint {
LOGGER.info("\n*** AAI NODE RESOURE POST QUERY START ***\\nformat=" + format + "\njson=" + jsonString
+ "\n *** AAI REQUEST END ***");
- String responseJsonString = TextFileUtils.getTextFileAsString("src/test/resources/aai/NodeQueryResponse.json");
+ int beginIndex = jsonString.indexOf("b4fe00ac-1da6-4b00-ac0d-8e8300db")
+ + "b4fe00ac-1da6-4b00-ac0d-8e8300db".length();
+ String nextVnfIdUrlEnding = jsonString.substring(beginIndex, beginIndex + 4);
+ String responseJsonString = TextFileUtils.getTextFileAsString("src/test/resources/aai/NodeQueryResponse.json")
+ .replaceAll("bbb3cefd-01c8-413c-9bdd-2b92f9ca3d38",
+ "00000000-0000-0000-0000-00000000" + nextVnfIdUrlEnding);
LOGGER.info("\n*** AAI RESPONSE START ***\n" + responseJsonString + "\n *** AAI RESPONSE END ***");