1 package org.onap.simulator.presetGenerator.presets.mso;
3 import org.apache.commons.lang3.StringUtils;
4 import org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset;
5 import org.springframework.http.HttpMethod;
7 public abstract class PresetMSOBaseCreateInstancePost extends BaseMSOPreset {
9 private final String requestId;
10 protected String responseInstanceId;
11 public static final String DEFAULT_REQUEST_ID = "c0011670-0e1a-4b74-945d-8bf5aede1d9c";
12 protected String msoTestApi;
13 protected boolean withTestApi;
15 public PresetMSOBaseCreateInstancePost() {
19 public PresetMSOBaseCreateInstancePost(String requestId) {
20 this.requestId = requestId != null ? requestId : DEFAULT_REQUEST_ID;
21 this.responseInstanceId = DEFAULT_INSTANCE_ID;
24 public PresetMSOBaseCreateInstancePost(String requestId, String responseInstanceId) {
25 this.requestId = requestId != null ? requestId : DEFAULT_REQUEST_ID;
26 this.responseInstanceId = responseInstanceId;
29 public PresetMSOBaseCreateInstancePost(String requestId, String responseInstanceId, String msoTestApi) {
30 this(requestId, responseInstanceId, msoTestApi, true);
33 public PresetMSOBaseCreateInstancePost(String requestId, String responseInstanceId, String msoTestApi, boolean withTestApi) {
34 this(requestId, responseInstanceId);
35 this.msoTestApi = msoTestApi;
36 this.withTestApi= withTestApi;
39 public String addTestApi() {
40 if(this.withTestApi) {
41 return "\"testApi\": \"" + msoTestApi + "\",";
47 public HttpMethod getReqMethod() {
48 return HttpMethod.POST;
52 public int getResponseCode() {
56 public String getRequestId() {
61 public Object getResponseBody() {
62 return "{\"requestReferences\":{\"instanceId\":\"" + responseInstanceId + "\",\"requestId\":\"" + requestId + "\"}}";
65 protected String formatSuffix(int suffix) {
66 return (suffix==0) ? StringUtils.EMPTY : "_" + String.format("%03d", suffix);