diff options
author | 2019-03-18 10:07:02 +0000 | |
---|---|---|
committer | 2019-03-18 10:07:02 +0000 | |
commit | a036637a4d466662128cde1823816578e76c69e0 (patch) | |
tree | d58add45a75701717e67de676463fc6b15068f9d /vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOBaseCreateInstancePost.java | |
parent | 756a9c041981e05a3f5bd740ebc0d3fc22579003 (diff) | |
parent | 66af8b9b391879be78660d6ccb0a1f1f9340b423 (diff) |
Merge "Merge automation from ECOMP's repository"
Diffstat (limited to 'vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOBaseCreateInstancePost.java')
-rw-r--r-- | vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOBaseCreateInstancePost.java | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOBaseCreateInstancePost.java b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOBaseCreateInstancePost.java new file mode 100644 index 000000000..05b8c8bec --- /dev/null +++ b/vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/mso/PresetMSOBaseCreateInstancePost.java @@ -0,0 +1,68 @@ +package org.onap.simulator.presetGenerator.presets.mso; + +import org.apache.commons.lang3.StringUtils; +import org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset; +import org.springframework.http.HttpMethod; + +public abstract class PresetMSOBaseCreateInstancePost extends BaseMSOPreset { + + private final String requestId; + protected String responseInstanceId; + public static final String DEFAULT_REQUEST_ID = "c0011670-0e1a-4b74-945d-8bf5aede1d9c"; + protected String msoTestApi; + protected boolean withTestApi; + + public PresetMSOBaseCreateInstancePost() { + this(null); + } + + public PresetMSOBaseCreateInstancePost(String requestId) { + this.requestId = requestId != null ? requestId : DEFAULT_REQUEST_ID; + this.responseInstanceId = DEFAULT_INSTANCE_ID; + } + + public PresetMSOBaseCreateInstancePost(String requestId, String responseInstanceId) { + this.requestId = requestId != null ? requestId : DEFAULT_REQUEST_ID; + this.responseInstanceId = responseInstanceId; + } + + public PresetMSOBaseCreateInstancePost(String requestId, String responseInstanceId, String msoTestApi) { + this(requestId, responseInstanceId, msoTestApi, true); + } + + public PresetMSOBaseCreateInstancePost(String requestId, String responseInstanceId, String msoTestApi, boolean withTestApi) { + this(requestId, responseInstanceId); + this.msoTestApi = msoTestApi; + this.withTestApi= withTestApi; + } + + public String addTestApi() { + if(this.withTestApi) { + return "\"testApi\": \"" + msoTestApi + "\","; + } + return ""; + } + + @Override + public HttpMethod getReqMethod() { + return HttpMethod.POST; + } + + @Override + public int getResponseCode() { + return 202; + } + + public String getRequestId() { + return requestId; + } + + @Override + public Object getResponseBody() { + return "{\"requestReferences\":{\"instanceId\":\"" + responseInstanceId + "\",\"requestId\":\"" + requestId + "\"}}"; + } + + protected String formatSuffix(int suffix) { + return (suffix==0) ? StringUtils.EMPTY : "_" + String.format("%03d", suffix); + } +} |