diff options
author | Ittay Stern <ittay.stern@att.com> | 2019-03-11 09:34:34 +0200 |
---|---|---|
committer | Ittay Stern <ittay.stern@att.com> | 2019-03-17 17:02:43 +0200 |
commit | 66af8b9b391879be78660d6ccb0a1f1f9340b423 (patch) | |
tree | fc0d510f7ea28a437bcb1e3b950d1281ac88a4e4 /vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetServiceInstancesByInvariantId.java | |
parent | 37ad0cc1d36ec6ff68ec39fcaaf2617eef7d08fe (diff) |
Merge automation from ECOMP's repository
Reference commit in ECOMP: 8e92a8c6
Issue-ID: VID-378
Change-Id: Ia32f4813378ef95097f788246aa5b1172e20ca48
Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetServiceInstancesByInvariantId.java')
-rw-r--r-- | vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetServiceInstancesByInvariantId.java | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetServiceInstancesByInvariantId.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetServiceInstancesByInvariantId.java new file mode 100644 index 000000000..8f7b6d0fb --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aai/PresetAAIGetServiceInstancesByInvariantId.java @@ -0,0 +1,90 @@ +package org.onap.simulator.presetGenerator.presets.aai; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Multimap; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseAAIPreset; +import org.springframework.http.HttpMethod; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class PresetAAIGetServiceInstancesByInvariantId extends BaseAAIPreset { + + private String globalCustomerId; + private String serviceType; + private String invariantId; + private Map<String, Multimap<String, String>> servicesWithRelationships; + + public PresetAAIGetServiceInstancesByInvariantId(String globalCustomerId, String serviceType, String invariantId, + Map<String, Multimap<String, String>> servicesWithRelationships) { + this.globalCustomerId = globalCustomerId; + this.serviceType = serviceType; + this.invariantId = invariantId; + this.servicesWithRelationships = servicesWithRelationships; + } + + @Override + public String getResponseBody() { + return "{" + + " \"service-instance\":[" + + servicesWithRelationships.entrySet().stream().map( + entry -> buildServiceInstance(entry.getKey(), entry.getValue()) + ).collect(Collectors.joining(",")) + + " ]" + + "}"; + } + + private String buildServiceInstance(String serviceInstanceId, Multimap<String, String> relationships) { + return " {" + + " \"service-instance-id\":\"" + serviceInstanceId + "\"," + + " \"service-instance-name\":\"service-instance-name\"," + + " \"service-instance-type\":\"service-instance-type\"," + + " \"service-instance-role\":\"service-instance-role\"," + + " \"model-invariant-id\":\"" + invariantId + "\"," + + " \"model-version-id\":\"7a6ee536-f052-46fa-aa7e-2fca9d674c44\"," + + " \"resource-version\":\"GARBAGE DATA\"," + + " \"orchestration-status\":\"GARBAGE DATA\"," + + " \"relationship-list\":{" + + " \"relationship\":[" + + relationships.entries().stream().map( + entry -> buildRelationship(entry.getKey(), entry.getValue()) + ).collect(Collectors.joining(",")) + + " ]" + + " }" + + " }"; + } + + private String buildRelationship(String relatedTo, final String relatedLink) { + return "" + + "{ " + + " \"related-to\": \"" + relatedTo + "\", " + + " \"relationship-label\": \"org.onap.relationships.inventory.ComposedOf\", " + + " \"related-link\": \"" + relatedLink + "\", " + + " \"relationship-data\": [" + + " { " + + " \"relationship-key\": \"GARBAGE DATA\", " + + " \"relationship-value\": \"GARBAGE DATA\" " + + " } " + + " ] " + + "}"; + } + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.GET; + } + + @Override + public String getReqPath() { + return getRootPath() + "/business/customers/customer/" + + globalCustomerId + "/service-subscriptions/service-subscription/" + + serviceType + "/service-instances"; + } + + @Override + public Map<String, List> getQueryParams() { + return ImmutableMap.of("model-invariant-id", ImmutableList.of(invariantId)); + } +} |