summaryrefslogtreecommitdiffstats
path: root/vid-automation/src/main/java/org/onap
diff options
context:
space:
mode:
Diffstat (limited to 'vid-automation/src/main/java/org/onap')
-rw-r--r--vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetTenants.java36
1 files changed, 30 insertions, 6 deletions
diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetTenants.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetTenants.java
index 0808eaba6..575a8888e 100644
--- a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetTenants.java
+++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetTenants.java
@@ -1,5 +1,6 @@
package org.onap.simulator.presetGenerator.presets.aai;
+import org.apache.commons.lang3.StringUtils;
import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset;
import org.springframework.http.HttpMethod;
@@ -9,21 +10,46 @@ public class PresetAAIGetTenants extends BaseAAIPreset {
private final String subscriberId;
private final String serviceType;
private String responseBody;
+ private static final String responseBodyResourceDefault = "presets_templates/PresetAAIGetTenants.json";
public PresetAAIGetTenants(String subscriberId, String serviceType, String responseBodyResource) {
this.subscriberId = subscriberId;
this.serviceType = serviceType;
- this.responseBody = loadResourceAsString(responseBodyResource);
+ this.responseBody = loadResponseBody(responseBodyResource);
}
public PresetAAIGetTenants() {
this(
- "e433710f-9217-458d-a79d-1c7aff376d89",
- "TYLER SILVIA",
- "presets_templates/PresetAAIGetTenants.json"
+ "e433710f-9217-458d-a79d-1c7aff376d89",
+ "TYLER SILVIA",
+ responseBodyResourceDefault
);
}
+ public PresetAAIGetTenants(String subscriberId, String serviceType) {
+ this(
+ subscriberId,
+ serviceType,
+ responseBodyResourceDefault
+ );
+ }
+
+ private String loadResponseBody(String responseBodyResource) {
+
+ String responseBody = loadResourceAsString(responseBodyResource);
+
+ if (StringUtils.equals(responseBodyResource, responseBodyResourceDefault)) {
+ responseBody = setServiceTypeInTheResponse(responseBody);
+ }
+
+ return responseBody;
+ }
+
+ private String setServiceTypeInTheResponse(String resourceBodyAsString) {
+ final String serviceTypePlaceHolder = "<service-type>";
+ return resourceBodyAsString.replace(serviceTypePlaceHolder, this.serviceType);
+ }
+
@Override
public Object getResponseBody() {
return responseBody;
@@ -38,6 +64,4 @@ public class PresetAAIGetTenants extends BaseAAIPreset {
public String getReqPath() {
return getRootPath() + "/business/customers/customer/" + this.subscriberId + "/service-subscriptions/service-subscription/" + this.serviceType;
}
-
-
}