summaryrefslogtreecommitdiffstats
path: root/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest
diff options
context:
space:
mode:
Diffstat (limited to 'test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest')
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ArtifactRestUtils.java137
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AssetRestUtils.java61
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AutomationUtils.java14
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/BaseRestUtils.java7
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CatalogRestUtils.java2
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ComponentInstanceRestUtils.java6
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ConsumerRestUtils.java16
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/EcompUserRestUtils.java44
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/GroupRestUtils.java3
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ImportRestUtils.java13
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/LifecycleRestUtils.java6
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/PropertyRestUtils.java58
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtils.java29
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtilsExternalAPI.java2
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java162
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ServiceRestUtils.java25
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/UserRestUtils.java4
17 files changed, 279 insertions, 310 deletions
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ArtifactRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ArtifactRestUtils.java
index a7ab544725..448442e112 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ArtifactRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ArtifactRestUtils.java
@@ -50,15 +50,12 @@ import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.Utils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
-import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.util.ValidationUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.AssertJUnit;
import com.google.gson.Gson;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
public class ArtifactRestUtils extends BaseRestUtils {
private static Logger logger = LoggerFactory.getLogger(ArtifactRestUtils.class.getName());
@@ -68,7 +65,7 @@ public class ArtifactRestUtils extends BaseRestUtils {
// Delete Artifact on rI of the asset
public static RestResponse externalAPIDeleteArtifactOfComponentInstanceOnAsset(Component component, User user, ComponentInstance resourceInstance, String artifactUUID) throws IOException {
Config config = Utils.getConfig();
- String resourceType = null;
+ String resourceType;
String resourceUUID = component.getUUID();
String resourceInstanceName = resourceInstance.getNormalizedName();
@@ -88,7 +85,7 @@ public class ArtifactRestUtils extends BaseRestUtils {
// Delete Artifact of the asset
public static RestResponse externalAPIDeleteArtifactOfTheAsset(Component component, User user, String artifactUUID) throws IOException {
Config config = Utils.getConfig();
- String resourceType = null;
+ String resourceType;
String resourceUUID = component.getUUID();
System.out.println(component.getComponentType());
@@ -110,7 +107,7 @@ public class ArtifactRestUtils extends BaseRestUtils {
// Update Artifact on rI of the asset
public static RestResponse externalAPIUpdateArtifactOfComponentInstanceOnAsset(Component component, User user, ArtifactReqDetails artifactReqDetails, ComponentInstance resourceInstance, String artifactUUID) throws IOException {
Config config = Utils.getConfig();
- String resourceType = null;
+ String resourceType;
String resourceUUID = component.getUUID();
String resourceInstanceName = resourceInstance.getNormalizedName();
@@ -130,7 +127,7 @@ public class ArtifactRestUtils extends BaseRestUtils {
// Update Artifact of the asset
public static RestResponse externalAPIUpdateArtifactOfTheAsset(Component component, User user, ArtifactReqDetails artifactReqDetails, String artifactUUID) throws IOException {
Config config = Utils.getConfig();
- String resourceType = null;
+ String resourceType;
String resourceUUID = component.getUUID();
System.out.println(component.getComponentType());
@@ -150,7 +147,7 @@ public class ArtifactRestUtils extends BaseRestUtils {
// Upload Artifact on rI of the asset
public static RestResponse externalAPIUploadArtifactOfComponentInstanceOnAsset(Component component, User user, ArtifactReqDetails artifactReqDetails, ComponentInstance resourceInstance) throws IOException {
Config config = Utils.getConfig();
- String resourceType = null;
+ String resourceType;
String resourceUUID = component.getUUID();
String resourceInstanceName = resourceInstance.getNormalizedName();
@@ -170,7 +167,7 @@ public class ArtifactRestUtils extends BaseRestUtils {
// Upload Artifact of the asset
public static RestResponse externalAPIUploadArtifactOfTheAsset(Component component, User user, ArtifactReqDetails artifactReqDetails) throws IOException {
Config config = Utils.getConfig();
- String resourceType = null;
+ String resourceType;
String resourceUUID = component.getUUID();
System.out.println(component.getComponentType());
@@ -190,7 +187,7 @@ public class ArtifactRestUtils extends BaseRestUtils {
// Upload Artifact of the asset with invalid checksum
public static RestResponse externalAPIUploadArtifactWithInvalidCheckSumOfComponentInstanceOnAsset(Component component, User user, ArtifactReqDetails artifactReqDetails, ComponentInstance resourceInstance) throws IOException {
Config config = Utils.getConfig();
- String resourceType = null;
+ String resourceType;
String resourceUUID = component.getUUID();
String resourceInstanceName = resourceInstance.getNormalizedName();
@@ -210,7 +207,7 @@ public class ArtifactRestUtils extends BaseRestUtils {
// Upload Artifact of the asset with invalid checksum
public static RestResponse externalAPIUploadArtifactWithInvalidCheckSumOfTheAsset(Component component, User user, ArtifactReqDetails artifactReqDetails) throws IOException {
Config config = Utils.getConfig();
- String resourceType = null;
+ String resourceType;
String resourceUUID = component.getUUID();
System.out.println(component.getComponentType());
@@ -232,7 +229,7 @@ public class ArtifactRestUtils extends BaseRestUtils {
//
public static RestResponse getResourceDeploymentArtifactExternalAPI(String resourceUUID, String artifactUUID,User sdncModifierDetails, String resourceType) throws IOException {
Config config = Utils.getConfig();
- String url = null;
+ String url;
if (resourceType.toUpperCase().equals("SERVICE")) {
url = String.format(Urls.GET_DOWNLOAD_SERVICE_ARTIFACT_OF_ASSET, config.getCatalogBeHost(), config.getCatalogBePort(), resourceUUID, artifactUUID);
@@ -241,11 +238,12 @@ public class ArtifactRestUtils extends BaseRestUtils {
url = String.format(Urls.GET_DOWNLOAD_RESOURCE_ARTIFACT_OF_ASSET, config.getCatalogBeHost(), config.getCatalogBePort(), resourceUUID, artifactUUID);
}
- Map<String, String> headersMap = new HashMap<String,String>();
+ Map<String, String> headersMap = new HashMap<>();
headersMap.put(HttpHeaderEnum.USER_ID.getValue(), sdncModifierDetails.getUserId());
headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
- headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci");
+ headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId);
+ headersMap.put(HttpHeaderEnum.ACCEPT.getValue(),acceptMultipartHeader);
HttpRequest http = new HttpRequest();
@@ -265,7 +263,7 @@ public class ArtifactRestUtils extends BaseRestUtils {
public static RestResponse getComponentInstanceDeploymentArtifactExternalAPI(String resourceUUID, String componentNormalizedName, String artifactUUID,User sdncModifierDetails, String resourceType) throws IOException {
Config config = Utils.getConfig();
- String url = null;
+ String url;
if (resourceType.toLowerCase().equals("service")) {
url = String.format(Urls.GET_DOWNLOAD_SERVICE_ARTIFACT_OF_COMPONENT_INSTANCE, config.getCatalogBeHost(), config.getCatalogBePort(), resourceUUID, componentNormalizedName, artifactUUID);
@@ -274,11 +272,12 @@ public class ArtifactRestUtils extends BaseRestUtils {
url = String.format(Urls.GET_DOWNLOAD_RESOURCE_ARTIFACT_OF_COMPONENT_INSTANCE, config.getCatalogBeHost(), config.getCatalogBePort(), resourceUUID, componentNormalizedName, artifactUUID);
}
- Map<String, String> headersMap = new HashMap<String,String>();
+ Map<String, String> headersMap = new HashMap<>();
headersMap.put(HttpHeaderEnum.USER_ID.getValue(), sdncModifierDetails.getUserId());
headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
- headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci");
+ headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId);
+ headersMap.put(HttpHeaderEnum.ACCEPT.getValue(),acceptMultipartHeader);
HttpRequest http = new HttpRequest();
@@ -443,7 +442,7 @@ public class ArtifactRestUtils extends BaseRestUtils {
public static Map<String, String> getHeadersMap(User sdncModifierDetails) {
- Map<String, String> headersMap = new HashMap<String,String>();
+ Map<String, String> headersMap = new HashMap<>();
headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptJsonHeader);
@@ -602,9 +601,9 @@ public class ArtifactRestUtils extends BaseRestUtils {
public static RestResponse uploadDeploymentArtifact(ArtifactReqDetails artifactDetails, Component component, User sdncModifierDetails) throws IOException {
Config config = Utils.getConfig();
- Map<String, String> additionalHeaders = null;
+ Map<String, String> additionalHeaders;
String checksum = ResponseParser.calculateMD5Header(artifactDetails);
- additionalHeaders = new HashMap<String, String>();
+ additionalHeaders = new HashMap<>();
additionalHeaders.put(HttpHeaderEnum.Content_MD5.getValue(), checksum);
ComponentTypeEnum componentType = component.getComponentType();
@@ -614,26 +613,26 @@ public class ArtifactRestUtils extends BaseRestUtils {
switch (componentType){
case RESOURCE:
- {
- url = String.format(Urls.UPDATE_OR_DELETE_ARTIFACT_OF_SERVICE, config.getCatalogBeHost(),config.getCatalogBePort(), component.getUniqueId(), artifactDetails.getUniqueId());
-
- break;
- }
- case SERVICE: {
-
- break;
- }
-
- case PRODUCT: {
-
- break;
- }
-
- default: {//dummy
- assertTrue("failed on enum selection", false);
-
- break;
- }
+ {
+ url = String.format(Urls.UPDATE_OR_DELETE_ARTIFACT_OF_SERVICE, config.getCatalogBeHost(),config.getCatalogBePort(), component.getUniqueId(), artifactDetails.getUniqueId());
+
+ break;
+ }
+ case SERVICE: {
+
+ break;
+ }
+
+ case PRODUCT: {
+
+ break;
+ }
+
+ default: {//dummy
+ assertTrue("failed on enum selection", false);
+
+ break;
+ }
}
@@ -654,9 +653,9 @@ public class ArtifactRestUtils extends BaseRestUtils {
public static RestResponse uploadArtifact(ArtifactReqDetails artifactDetails, Component component, User sdncModifierDetails) throws IOException {
Config config = Utils.getConfig();
List<String> placeHolderlst = Utils.getListOfResPlaceHoldersDepArtTypes();
- Map<String, String> additionalHeaders = null;
- String checksum = null;
- String url= null;
+ Map<String, String> additionalHeaders;
+ String checksum;
+ String url;
//
//
// if (artifactDetails.getArtifactGroupType() != null
@@ -676,7 +675,7 @@ public class ArtifactRestUtils extends BaseRestUtils {
//
// else {
checksum = ResponseParser.calculateMD5Header(artifactDetails);
- additionalHeaders = new HashMap<String, String>();
+ additionalHeaders = new HashMap<>();
additionalHeaders.put(HttpHeaderEnum.Content_MD5.getValue(), checksum);
url = String.format(Urls.UPLOAD_DELETE_ARTIFACT_OF_COMPONENT, config.getCatalogBeHost(),
config.getCatalogBePort(), ComponentTypeEnum.findParamByType(component.getComponentType()),
@@ -700,13 +699,13 @@ public class ArtifactRestUtils extends BaseRestUtils {
//*************** PRIVATE **************
private static RestResponse deleteInformationalArtifact(User sdncModifierDetails, String url) throws IOException {
- Map<String, String> additionalHeaders = null;
+ Map<String, String> additionalHeaders;
- additionalHeaders = new HashMap<String, String>();
+ additionalHeaders = new HashMap<>();
additionalHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
- additionalHeaders.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci");
+ additionalHeaders.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId);
return sendDelete(url, sdncModifierDetails.getUserId(), additionalHeaders);
@@ -729,12 +728,12 @@ public class ArtifactRestUtils extends BaseRestUtils {
private static RestResponse uploadInformationalArtifact(ArtifactReqDetails artifactDetails, User sdncModifierDetails, String checksum, String url) throws IOException {
Map<String, String> additionalHeaders = null;
if (checksum != null && !checksum.isEmpty()) {
- additionalHeaders = new HashMap<String, String>();
+ additionalHeaders = new HashMap<>();
additionalHeaders.put(HttpHeaderEnum.Content_MD5.getValue(), checksum);
}
additionalHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
- additionalHeaders.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci");
+ additionalHeaders.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId);
Gson gson = new Gson();
// System.out.println("ArtifactDetails: "+ jsonBody);
@@ -749,10 +748,10 @@ public class ArtifactRestUtils extends BaseRestUtils {
}
private static RestResponse addArtifactToInstance(ArtifactReqDetails artifactDetails, User sdncModifierDetails, String checksum, String url) throws IOException {
- Map<String, String> additionalHeaders = null;
- additionalHeaders = new HashMap<String, String>();
+ Map<String, String> additionalHeaders;
+ additionalHeaders = new HashMap<>();
if (checksum != null && !checksum.isEmpty()) {
- additionalHeaders = new HashMap<String, String>();
+ additionalHeaders = new HashMap<>();
additionalHeaders.put(HttpHeaderEnum.Content_MD5.getValue(), checksum);
}
additionalHeaders.put(HttpHeaderEnum.ACCEPT.getValue(), "application/json, text/plain, */*");
@@ -769,8 +768,8 @@ public class ArtifactRestUtils extends BaseRestUtils {
}
private static RestResponse updateDeploymentArtifact(ArtifactDefinition artifactDefinition, User sdncModifierDetails, String url) throws IOException {
- Map<String, String> additionalHeaders = null;
- additionalHeaders = new HashMap<String, String>();
+ Map<String, String> additionalHeaders;
+ additionalHeaders = new HashMap<>();
additionalHeaders.put(HttpHeaderEnum.ACCEPT.getValue(), "application/json, text/plain, */*");
additionalHeaders.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "application/json;charset=UTF-8");
@@ -782,9 +781,9 @@ public class ArtifactRestUtils extends BaseRestUtils {
}
private static RestResponse updateDeploymentArtifact(ArtifactReqDetails artifactDetails, User sdncModifierDetails, String url) throws IOException {
- Map<String, String> additionalHeaders = null;
+ Map<String, String> additionalHeaders;
- additionalHeaders = new HashMap<String, String>();
+ additionalHeaders = new HashMap<>();
additionalHeaders.put(HttpHeaderEnum.ACCEPT.getValue(), "application/json, text/plain, */*");
additionalHeaders.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "application/json;charset=UTF-8");
// additionalHeaders.put(HttpHeaderEnum..getValue(), "application/json;charset=UTF-8");
@@ -805,7 +804,7 @@ public class ArtifactRestUtils extends BaseRestUtils {
private static RestResponse downloadArtifact(String url, User user, Map<String, String> addionalHeaders,boolean addEcompHeader) throws IOException
{
if(addEcompHeader){
- addionalHeaders.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), ecomp);
+ addionalHeaders.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId);
}
return downloadArtifact(url, user, addionalHeaders, acceptOctetStream);
}
@@ -906,29 +905,5 @@ public class ArtifactRestUtils extends BaseRestUtils {
}
-
- public static ArtifactDefinition getArtifactDataFromJson(String json) {
- Gson gson = new Gson();
- JsonObject jsonElement = new JsonObject();
- jsonElement = gson.fromJson(json, jsonElement.getClass());
- ArtifactDefinition artifact = new ArtifactDefinition();
- String payload = null;
- JsonElement artifactPayload = jsonElement.get(Constants.ARTIFACT_PAYLOAD_DATA);
- if (artifactPayload != null && !artifactPayload.isJsonNull()) {
- payload = artifactPayload.getAsString();
- }
- jsonElement.remove(Constants.ARTIFACT_PAYLOAD_DATA);
- artifact = gson.fromJson(jsonElement, ArtifactDefinition.class);
- artifact.setPayloadData(payload);
-
- /*atifact.setArtifactName(UPLOAD_ARTIFACT_NAME);
-artifact.setArtifactDisplayName("configure");
-artifact.setArtifactType("SHELL");
-artifact.setMandatory(false);
-artifact.setDescription("ff");
-artifact.setPayloadData(UPLOAD_ARTIFACT_PAYLOAD);
-artifact.setArtifactLabel("configure");*/
- return artifact;
- }
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AssetRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AssetRestUtils.java
index 4ade9eb16c..13cfb8fb63 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AssetRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AssetRestUtils.java
@@ -31,7 +31,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.UUID;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
@@ -39,7 +38,7 @@ import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
-import org.codehaus.jackson.map.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.openecomp.sdc.be.datatypes.enums.AssetTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
@@ -78,8 +77,6 @@ public class AssetRestUtils extends BaseRestUtils {
static ObjectMapper objectMapper = new ObjectMapper();
static Logger logger = LoggerFactory.getLogger(AssetRestUtils.class.getName());
- static final String contentTypeHeaderData = "application/json";
- static final String acceptHeaderDate = "application/json";
static final String basicAuthentication = "Basic Y2k6MTIzNDU2";
// /sdc/v1/catalog/{services/resources}/{componentUUID}/artifacts/{artifactUUID}
static final String COMPONENT_ARTIFACT_URL = "/sdc/v1/catalog/%s/%s/artifacts/%s";
@@ -93,7 +90,7 @@ public class AssetRestUtils extends BaseRestUtils {
assetType.getValue(), uuid);
HttpGet httpGet = new HttpGet(url);
- httpGet.addHeader(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci");
+ httpGet.addHeader(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId);
httpGet.addHeader(HttpHeaderEnum.AUTHORIZATION.getValue(), basicAuthentication);
logger.debug("Send GET request to get Tosca model: {}", url);
@@ -101,18 +98,27 @@ public class AssetRestUtils extends BaseRestUtils {
return httpclient.execute(httpGet);
}
+ public static File getToscaModelCsarFile(AssetTypeEnum assetType, String uuid) throws IOException {
+ return getToscaModelCsarFile(assetType, uuid, "");
+ }
+
public static File getToscaModelCsarFile(AssetTypeEnum assetType, String uuid, String fileName) throws IOException {
+ File myFile;
Config config = Utils.getConfig();
CloseableHttpClient httpclient = HttpClients.createDefault();
String url = String.format(Urls.GET_TOSCA_MODEL, config.getCatalogBeHost(), config.getCatalogBePort(),
assetType.getValue(), uuid);
HttpGet httpGet = new HttpGet(url);
-
- String csarDir = FileHandling.getCreateDirByName("outputCsar");
- File myFile = new File(csarDir+ File.separator + "tmpCSAR_" + fileName + ".csar");
+
+ if(fileName.isEmpty()) {
+ myFile = new File("tmpCSAR");
+ } else {
+ String csarDir = FileHandling.getCreateDirByName("outputCsar");
+ myFile = new File(csarDir+ File.separator + "tmpCSAR_" + fileName + ".csar");
+ }
- httpGet.addHeader(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci");
+ httpGet.addHeader(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId);
httpGet.addHeader(HttpHeaderEnum.AUTHORIZATION.getValue(), basicAuthentication);
logger.debug("Send GET request to get Tosca model: {}", url);
@@ -127,19 +133,17 @@ public class AssetRestUtils extends BaseRestUtils {
}
return myFile;
}
-
-
-
+
public static RestResponse getRestResponseComponentToscaModel(AssetTypeEnum assetType, String uuid) throws IOException {
Config config = Utils.getConfig();
String url = String.format(Urls.GET_TOSCA_MODEL, config.getCatalogBeHost(), config.getCatalogBePort(),
assetType.getValue(), uuid);
- Map<String, String> headersMap = new HashMap<String,String>();
+ Map<String, String> headersMap = new HashMap<>();
headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
- headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci");
+ headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId);
HttpRequest http = new HttpRequest();
@@ -158,16 +162,16 @@ public class AssetRestUtils extends BaseRestUtils {
public static RestResponse getComponentListByAssetType(boolean isBasicAuthentication, AssetTypeEnum assetType,
String... filterArrayString) throws IOException {
Config config = Utils.getConfig();
- Map<String, String> headersMap = new HashMap<String, String>();
- headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
- headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
+ Map<String, String> headersMap = new HashMap<>();
+ headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData);
+ headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), BaseRestUtils.acceptHeaderData);
if (isBasicAuthentication) {
headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), basicAuthentication);
}
- headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci");
+ headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId);
HttpRequest http = new HttpRequest();
- String url = String.format(Urls.GET_ASSET_LIST, config.getCatalogBeHost(), config.getCatalogBePort(),
+ String url = String.format(Urls.GET_ASSET_LIST, config.getCatalogBeHost(), config.getCatalogBePort(),
assetType.getValue());
if (filterArrayString != null && filterArrayString.length > 0) {
url = buildUrlWithFilter(url, filterArrayString);
@@ -180,11 +184,11 @@ public class AssetRestUtils extends BaseRestUtils {
public static RestResponse getFilteredComponentList(AssetTypeEnum assetType, String query) throws IOException {
Config config = Utils.getConfig();
- Map<String, String> headersMap = new HashMap<String, String>();
- headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
- headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
+ Map<String, String> headersMap = new HashMap<>();
+ headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData);
+ headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), BaseRestUtils.acceptHeaderData);
headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), basicAuthentication);
- headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci");
+ headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId);
HttpRequest http = new HttpRequest();
@@ -217,13 +221,13 @@ public class AssetRestUtils extends BaseRestUtils {
AssetTypeEnum assetType, String uuid) throws IOException {
Config config = Utils.getConfig();
- Map<String, String> headersMap = new HashMap<String, String>();
- headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
- headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
+ Map<String, String> headersMap = new HashMap<>();
+ headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData);
+ headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), BaseRestUtils.acceptHeaderData);
if (isBasicAuthentication) {
headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), basicAuthentication);
}
- headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci");
+ headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId);
HttpRequest http = new HttpRequest();
String url = String.format(Urls.GET_ASSET_METADATA, config.getCatalogBeHost(), config.getCatalogBePort(),
@@ -628,8 +632,5 @@ public class AssetRestUtils extends BaseRestUtils {
}
return null;
}
- private static String getShortUUID() {
- return UUID.randomUUID().toString().split("-")[0];
- }
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AutomationUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AutomationUtils.java
index 2e27907fb5..65ab6c920a 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AutomationUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/AutomationUtils.java
@@ -61,11 +61,19 @@ public class AutomationUtils extends BaseRestUtils {
- public static void createVersionsInfoFile(String filepath, String onboardVersion, String osVersion, String envData, String suiteName)
- throws FileNotFoundException, IOException {
+ public static void createVersionsInfoFile(String filepath, String onboardVersion, String osVersion, String envData, String suiteName) throws IOException {
+ File myFoo = new File(filepath);
+ FileOutputStream fooStream = new FileOutputStream(myFoo, false); // true to append
+ String versions = ("onboardVersion=\""+ onboardVersion+ "\"\n" + "osVersion=\"" + osVersion + "\"\n" + "env=\""+ envData + "\"\n" + "suiteName=\""+ suiteName+ "\"\n");
+ byte[] myBytes = versions.getBytes();
+ fooStream.write(myBytes);
+ fooStream.close();
+ }
+
+ public static void createVersionsInfoFile(String filepath, String onboardVersion, String osVersion, String envData, String suiteName, String reportStartTime) throws IOException {
File myFoo = new File(filepath);
FileOutputStream fooStream = new FileOutputStream(myFoo, false); // true to append
- String versions = ("onboardVesrion=\""+ onboardVersion+ "\"\n" + "osVersion=\"" + osVersion + "\"\n" + "env=\""+ envData + "\"\n" + "suiteName=\""+ suiteName+ "\"\n");
+ String versions = ("onboardVersion=\""+ onboardVersion+ "\"\n" + "osVersion=\"" + osVersion + "\"\n" + "env=\""+ envData + "\"\n" + "suiteName=\""+ suiteName+ "\"\n" + "reportStartTime=\""+ reportStartTime+ "\"\n");
byte[] myBytes = versions.getBytes();
fooStream.write(myBytes);
fooStream.close();
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/BaseRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/BaseRestUtils.java
index 4ea404784a..4ec0353abd 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/BaseRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/BaseRestUtils.java
@@ -45,10 +45,13 @@ public class BaseRestUtils extends BaseValidationUtils {
public static final String acceptHeaderData = "application/json";
public static final String acceptJsonHeader = "application/json";
public static final String acceptOctetHeader = "application/octet-stream";
+ public static final String acceptMultipartHeader = "application/octet-stream";
public static final String authorizationHeader = "Basic " + Base64.encodeBase64String("ci:123456".getBytes());
public static final String acceptOctetStream = "application/octet-stream";
public static final String ecomp = "ecomp";
public static final String authorizationPrefixString = "Basic ";
+ public static final String xEcompInstanceId = "a1bd39f6-d55e-45b2-9207-156216af5cb5";
+ public static final String cacheControlHeader = "no-cache";
public static final String RESOURCE_COMPONENT_TYPE = "resources";
public static final String PRODUCT_COMPONENT_TYPE = "products";
@@ -86,7 +89,7 @@ public class BaseRestUtils extends BaseValidationUtils {
}
protected static Map<String, String> prepareHeadersMap(String userId, String accept) {
- Map<String, String> headersMap = new HashMap<String, String>();
+ Map<String, String> headersMap = new HashMap<>();
if (contentTypeHeaderData != null) {
headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
}
@@ -257,7 +260,7 @@ public class BaseRestUtils extends BaseValidationUtils {
String userCredentials = userName + ":" + password;
encodeBase64 = Base64.encodeBase64(userCredentials.getBytes());
String encodedUserCredentials = authorizationPrefixString + new String(encodeBase64);
- Map<String, String> authorizationHeader = new HashMap<String, String>();
+ Map<String, String> authorizationHeader = new HashMap<>();
authorizationHeader.put(HttpHeaderEnum.AUTHORIZATION.getValue(), encodedUserCredentials);
return authorizationHeader;
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CatalogRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CatalogRestUtils.java
index 449b6beca5..b09ba10df1 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CatalogRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/CatalogRestUtils.java
@@ -67,7 +67,7 @@ public class CatalogRestUtils extends BaseRestUtils {
String url = String.format(Urls.GET_ALL_CATEGORIES_FE, config.getCatalogFeHost(), config.getCatalogFePort(),
BaseRestUtils.RESOURCE_COMPONENT_TYPE);
- Map<String, String> additionalHeaders = new HashMap<String, String>();
+ Map<String, String> additionalHeaders = new HashMap<>();
additionalHeaders.put(HttpHeaderEnum.X_ECOMP_REQUEST_ID_HEADER.getValue(), uuid);
return sendGet(url, UserRoleEnum.DESIGNER.getUserId(), additionalHeaders);
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ComponentInstanceRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ComponentInstanceRestUtils.java
index 1b550e4fff..64b576e3e2 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ComponentInstanceRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ComponentInstanceRestUtils.java
@@ -43,7 +43,7 @@ import org.openecomp.sdc.ci.tests.utils.Utils;
import com.google.gson.Gson;
public class ComponentInstanceRestUtils extends BaseRestUtils {
- public static String acceptHeaderDate = "application/json";
+// public static String acceptHeaderDate = "application/json";
static Config config = Config.instance();
public static Gson gson = new Gson();
@@ -87,7 +87,7 @@ public class ComponentInstanceRestUtils extends BaseRestUtils {
Config config = Utils.getConfig();
- Map<String, String> headersMap = new HashMap<String, String>();
+ Map<String, String> headersMap = new HashMap<>();
headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderData);
headersMap.put(HttpHeaderEnum.USER_ID.getValue(), user.getUserId());
@@ -207,7 +207,7 @@ public class ComponentInstanceRestUtils extends BaseRestUtils {
Config config = Utils.getConfig();
- Map<String, String> headersMap = new HashMap<String, String>();
+ Map<String, String> headersMap = new HashMap<>();
headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderData);
headersMap.put(HttpHeaderEnum.USER_ID.getValue(), user.getUserId());
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ConsumerRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ConsumerRestUtils.java
index 0aadfdbaeb..5e35327305 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ConsumerRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ConsumerRestUtils.java
@@ -20,12 +20,9 @@
package org.openecomp.sdc.ci.tests.utils.rest;
-import static org.testng.AssertJUnit.assertEquals;
-
-import java.util.Map;
-
-import org.codehaus.jackson.map.DeserializationConfig;
-import org.codehaus.jackson.map.ObjectMapper;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
import org.openecomp.sdc.be.datatypes.elements.ConsumerDataDefinition;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.ci.tests.api.Urls;
@@ -34,7 +31,9 @@ import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.Utils;
-import com.google.gson.Gson;
+import java.util.Map;
+
+import static org.testng.AssertJUnit.assertEquals;
public class ConsumerRestUtils extends BaseRestUtils {
@@ -123,9 +122,8 @@ public class ConsumerRestUtils extends BaseRestUtils {
String bodyToParse = restResponse.getResponse();
ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
try {
- mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
ConsumerDataDefinition component = mapper.readValue(bodyToParse, ConsumerDataDefinition.class);
return component;
} catch (Exception e) {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/EcompUserRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/EcompUserRestUtils.java
index 458aa4a91c..9fdab02bb1 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/EcompUserRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/EcompUserRestUtils.java
@@ -44,8 +44,6 @@ public class EcompUserRestUtils extends BaseRestUtils {
static Gson gson = new Gson();
static Logger logger = LoggerFactory.getLogger(EcompUserRestUtils.class.getName());
- static String contentTypeHeaderData = "application/json";
- static String acceptHeaderDate = "application/json";
static String ecompUsername = "12345";
static String ecompPassword = "12345";
@@ -58,9 +56,9 @@ public class EcompUserRestUtils extends BaseRestUtils {
public static RestResponse pushUser(EcompUser ecompUser) throws IOException {
Config config = Utils.getConfig();
- Map<String, String> headersMap = new HashMap<String, String>();
- headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
- headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
+ Map<String, String> headersMap = new HashMap<>();
+ headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData);
+ headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), BaseRestUtils.acceptHeaderData);
headersMap.put(HttpHeaderEnum.ECOMP_USERNAME.getValue(), ecompUsername);
headersMap.put(HttpHeaderEnum.ECOMP_PASSWORD.getValue(), ecompPassword);
@@ -84,9 +82,9 @@ public class EcompUserRestUtils extends BaseRestUtils {
public static RestResponse editUser(String loginId, EcompUser ecompUser) throws IOException {
Config config = Utils.getConfig();
- Map<String, String> headersMap = new HashMap<String, String>();
- headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
- headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
+ Map<String, String> headersMap = new HashMap<>();
+ headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData);
+ headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), BaseRestUtils.acceptHeaderData);
headersMap.put(HttpHeaderEnum.ECOMP_USERNAME.getValue(), ecompUsername);
headersMap.put(HttpHeaderEnum.ECOMP_PASSWORD.getValue(), ecompPassword);
@@ -110,9 +108,9 @@ public class EcompUserRestUtils extends BaseRestUtils {
public static RestResponse getUser(String loginId) throws IOException {
Config config = Utils.getConfig();
- Map<String, String> headersMap = new HashMap<String, String>();
- headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
- headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
+ Map<String, String> headersMap = new HashMap<>();
+ headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData);
+ headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), BaseRestUtils.acceptHeaderData);
headersMap.put(HttpHeaderEnum.ECOMP_USERNAME.getValue(), ecompUsername);
headersMap.put(HttpHeaderEnum.ECOMP_PASSWORD.getValue(), ecompPassword);
@@ -130,9 +128,9 @@ public class EcompUserRestUtils extends BaseRestUtils {
public static RestResponse getAllUsers() throws IOException {
Config config = Utils.getConfig();
- Map<String, String> headersMap = new HashMap<String, String>();
- headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
- headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
+ Map<String, String> headersMap = new HashMap<>();
+ headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData);
+ headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), BaseRestUtils.acceptHeaderData);
headersMap.put(HttpHeaderEnum.ECOMP_USERNAME.getValue(), ecompUsername);
headersMap.put(HttpHeaderEnum.ECOMP_PASSWORD.getValue(), ecompPassword);
@@ -150,9 +148,9 @@ public class EcompUserRestUtils extends BaseRestUtils {
public static RestResponse getAllAvailableRoles() throws IOException {
Config config = Utils.getConfig();
- Map<String, String> headersMap = new HashMap<String, String>();
- headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
- headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
+ Map<String, String> headersMap = new HashMap<>();
+ headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData);
+ headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), BaseRestUtils.acceptHeaderData);
headersMap.put(HttpHeaderEnum.ECOMP_USERNAME.getValue(), ecompUsername);
headersMap.put(HttpHeaderEnum.ECOMP_PASSWORD.getValue(), ecompPassword);
@@ -174,9 +172,9 @@ public class EcompUserRestUtils extends BaseRestUtils {
public static RestResponse pushUserRoles(String loginId, List<EcompRole> roles) throws IOException {
Config config = Utils.getConfig();
- Map<String, String> headersMap = new HashMap<String, String>();
- headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
- headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
+ Map<String, String> headersMap = new HashMap<>();
+ headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData);
+ headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), BaseRestUtils.acceptHeaderData);
headersMap.put(HttpHeaderEnum.ECOMP_USERNAME.getValue(), ecompUsername);
headersMap.put(HttpHeaderEnum.ECOMP_PASSWORD.getValue(), ecompPassword);
@@ -204,9 +202,9 @@ public class EcompUserRestUtils extends BaseRestUtils {
public static RestResponse getUserRoles(String loginId) throws IOException {
Config config = Utils.getConfig();
- Map<String, String> headersMap = new HashMap<String, String>();
- headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
- headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
+ Map<String, String> headersMap = new HashMap<>();
+ headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData);
+ headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), BaseRestUtils.acceptHeaderData);
headersMap.put(HttpHeaderEnum.ECOMP_USERNAME.getValue(), ecompUsername);
headersMap.put(HttpHeaderEnum.ECOMP_PASSWORD.getValue(), ecompPassword);
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/GroupRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/GroupRestUtils.java
index d79c8e002c..f55cdbd035 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/GroupRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/GroupRestUtils.java
@@ -36,7 +36,6 @@ import org.openecomp.sdc.ci.tests.utils.Utils;
import com.google.gson.Gson;
public class GroupRestUtils extends BaseRestUtils {
- public static String acceptHeaderDate = "application/json";
static Config config = Config.instance();
public static Gson gson = new Gson();
@@ -44,7 +43,7 @@ public class GroupRestUtils extends BaseRestUtils {
Config config = Utils.getConfig();
- Map<String, String> headersMap = new HashMap<String, String>();
+ Map<String, String> headersMap = new HashMap<>();
headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderData);
headersMap.put(HttpHeaderEnum.USER_ID.getValue(), user.getUserId());
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ImportRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ImportRestUtils.java
index 0be438470d..40dc060993 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ImportRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ImportRestUtils.java
@@ -48,7 +48,6 @@ import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.codehaus.jettison.json.JSONException;
-import org.openecomp.sdc.be.dao.rest.HttpRestClient;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.ci.tests.api.Urls;
import org.openecomp.sdc.ci.tests.config.Config;
@@ -61,7 +60,7 @@ import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.Utils;
import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
-import org.openecomp.sdc.common.rest.api.RestResponseAsByteArray;
+import org.openecomp.sdc.common.http.client.api.HttpResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -351,7 +350,7 @@ public class ImportRestUtils extends BaseRestUtils {
}
}
- public static RestResponseAsByteArray getCsar(String csarUid, User sdncModifierDetails) throws Exception {
+ public static HttpResponse<byte []> getCsar(String csarUid, User sdncModifierDetails) throws Exception {
Config config = Utils.getConfig();
String url = String.format(Urls.GET_CSAR_USING_SIMULATOR, config.getCatalogBeHost(), config.getCatalogBePort(),
@@ -367,17 +366,11 @@ public class ImportRestUtils extends BaseRestUtils {
// System.out.println(url);
// System.out.println(userBodyJson);
- HttpRestClient httpRestClient = new HttpRestClient();
-
for (Map.Entry<String, String> mapEntry : headersMap.entrySet()) {
downloadCsarHeaders.put(mapEntry.getKey(), mapEntry.getValue());
}
- RestResponseAsByteArray doGetAsByteArray = httpRestClient.doGetAsByteArray(url, downloadCsarHeaders);
- // RestResponse getCsar = http.httpSendGet(url, headersMap);
-
- return doGetAsByteArray;
-
+ return org.openecomp.sdc.common.http.client.api.HttpRequest.getAsByteArray(url, downloadCsarHeaders);
}
private static File getGroupTypeZipFile(String elementName) throws IOException {
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/LifecycleRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/LifecycleRestUtils.java
index 39afff9022..9c0b7a89e0 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/LifecycleRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/LifecycleRestUtils.java
@@ -111,10 +111,10 @@ public class LifecycleRestUtils extends BaseRestUtils {
Config config = Utils.getConfig();
String url = String.format(Urls.POST_EXTERNAL_API_CHANGE_LIFE_CYCLE_OF_ASSET, config.getCatalogBeHost(), config.getCatalogBePort(), assetTypeEnum.getValue(), assetUUID, lifeCycleStatesEnum.getState());
- Map<String, String> additionalHeaders = new HashMap<String, String>();
+ Map<String, String> additionalHeaders = new HashMap<>();
additionalHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
- additionalHeaders.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci");
+ additionalHeaders.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId);
String jsonBody = "{\"userRemarks\": \"" + comment + "\"}";
@@ -361,7 +361,7 @@ public class LifecycleRestUtils extends BaseRestUtils {
}
private static Map<String, String> prepareHeadersMap(User sdncModifierDetails) {
- Map<String, String> headersMap = new HashMap<String, String>();
+ Map<String, String> headersMap = new HashMap<>();
headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderData);
headersMap.put(HttpHeaderEnum.USER_ID.getValue(), sdncModifierDetails.getUserId());
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/PropertyRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/PropertyRestUtils.java
index 33704a5128..d507c2cb23 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/PropertyRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/PropertyRestUtils.java
@@ -20,32 +20,28 @@
package org.openecomp.sdc.ci.tests.utils.rest;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertNull;
-import static org.testng.AssertJUnit.assertTrue;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import com.google.gson.Gson;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.ComponentInstanceInput;
-import org.openecomp.sdc.be.model.ComponentInstanceProperty;
-import org.openecomp.sdc.be.model.PropertyDefinition;
-import org.openecomp.sdc.be.model.Resource;
-import org.openecomp.sdc.be.model.Service;
-import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.*;
import org.openecomp.sdc.ci.tests.api.Urls;
import org.openecomp.sdc.ci.tests.config.Config;
+import org.openecomp.sdc.ci.tests.datatypes.PropertyObject;
+import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
+import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.common.util.GeneralUtility;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.openecomp.sdc.ci.tests.datatypes.PropertyObject;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.testng.AssertJUnit.*;
import com.google.gson.Gson;
@@ -69,6 +65,14 @@ public class PropertyRestUtils extends BaseRestUtils {
return sendPut(url, body, user.getUserId(), acceptHeaderData);
}
+ public static RestResponse updateGroupProperty(Component component, String groupId, String body, User user)
+ throws Exception {
+ Config config = Config.instance();
+
+ String url = String.format(Urls.RESOURCE_GROUP_PROPERTY, config.getCatalogBeHost(), config.getCatalogBePort(), component.getUniqueId(), groupId);
+ return sendPut(url, body, user.getUserId(), acceptHeaderData);
+ }
+
public static RestResponse getProperty(String resourceId, String propertyId, User user) throws Exception {
Config config = Config.instance();
String url = String.format(Urls.GET_PROPERTY, config.getCatalogBeHost(), config.getCatalogBePort(), resourceId,
@@ -337,4 +341,24 @@ public class PropertyRestUtils extends BaseRestUtils {
}
return declareProportiesResponse;
}
+
+ public static RestResponse updateInput(Component componentObject, PropertyObject componentInput, User sdncModifierDetails)
+ throws Exception {
+ Config config = Config.instance();
+ String url = String.format(Urls.UPDATE_INPUT, config.getCatalogBeHost(), config.getCatalogBePort(), componentObject.getUniqueId());
+ String userId = sdncModifierDetails.getUserId();
+ Map<String, String> headersMap = prepareHeadersMap(userId);
+ Gson gson = new Gson();
+ String userBodyJson = gson.toJson(componentInput);
+ String calculateMD5 = GeneralUtility.calculateMD5Base64EncodedByString(userBodyJson);
+ headersMap.put(HttpHeaderEnum.Content_MD5.getValue(), calculateMD5);
+ HttpRequest http = new HttpRequest();
+ // System.out.println(url);
+ // System.out.println(userBodyJson);
+ RestResponse declareProportiesResponse = http.httpSendPost(url, userBodyJson, headersMap);
+ if (declareProportiesResponse.getErrorCode() == STATUS_CODE_GET_SUCCESS) {
+
+ }
+ return declareProportiesResponse;
+ }
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtils.java
index 2f33273319..5f8eeca911 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtils.java
@@ -113,15 +113,12 @@ public class ResourceRestUtils extends BaseRestUtils {
Gson gson = new Gson();
String resourceImportBodyJson = gson.toJson(importReqDetails);
HttpRequest http = new HttpRequest();
- // System.out.println(url);
- // System.out.println(resourceImportBodyJson);
Map<String, String> headersMap = prepareHeadersMap(userId);
if (additionalHeaders != null) {
headersMap.putAll(additionalHeaders);
} else {
- headersMap.put(HttpHeaderEnum.Content_MD5.getValue(),
- ArtifactRestUtils.calculateMD5(resourceImportBodyJson));
+ headersMap.put(HttpHeaderEnum.Content_MD5.getValue(), ArtifactRestUtils.calculateMD5(resourceImportBodyJson));
}
RestResponse createResourceResponse = http.httpSendPost(url, resourceImportBodyJson, headersMap);
@@ -272,7 +269,7 @@ public class ResourceRestUtils extends BaseRestUtils {
Map<String, String> headersMap = prepareHeadersMap(sdncModifierDetails.getUserId());
headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
- headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci");
+ headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId);
return sendGet(url, sdncModifierDetails.getUserId(), headersMap);
@@ -285,7 +282,7 @@ public class ResourceRestUtils extends BaseRestUtils {
Map<String, String> headersMap = prepareHeadersMap(sdncModifierDetails.getUserId());
headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
- headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci");
+ headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId);
return sendGet(url, sdncModifierDetails.getUserId(), headersMap);
@@ -298,7 +295,7 @@ public class ResourceRestUtils extends BaseRestUtils {
Map<String, String> headersMap = prepareHeadersMap(sdncModifierDetails.getUserId());
headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
- headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci");
+ headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId);
return sendGet(url, sdncModifierDetails.getUserId(), headersMap);
@@ -359,9 +356,9 @@ public class ResourceRestUtils extends BaseRestUtils {
HttpRequest http = new HttpRequest();
String url = String.format(Urls.GET_PROPERTY_SCOPES_LIST, config.getCatalogBeHost(), config.getCatalogBePort());
- Map<String, String> headersMap = new HashMap<String, String>();
- headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "application/json");
- headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), "application/json");
+ Map<String, String> headersMap = new HashMap<>();
+ headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData);
+ headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), BaseRestUtils.acceptHeaderData);
headersMap.put(HttpHeaderEnum.USER_ID.getValue(), "cs0008");
return http.httpSendGet(url, headersMap);
@@ -374,10 +371,10 @@ public class ResourceRestUtils extends BaseRestUtils {
HttpRequest http = new HttpRequest();
String url = String.format(Urls.GET_ALL_ARTIFACTS, config.getCatalogBeHost(), config.getCatalogBePort());
- Map<String, String> headersMap = new HashMap<String, String>();
+ Map<String, String> headersMap = new HashMap<>();
- headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "application/json");
- headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), "application/json");
+ headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), acceptJsonHeader);
+ headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptJsonHeader);
headersMap.put(HttpHeaderEnum.USER_ID.getValue(), "cs0008");
return http.httpSendGet(url, headersMap);
@@ -390,9 +387,9 @@ public class ResourceRestUtils extends BaseRestUtils {
HttpRequest http = new HttpRequest();
String url = String.format(Urls.GET_CONFIGURATION, config.getCatalogBeHost(), config.getCatalogBePort());
- Map<String, String> headersMap = new HashMap<String, String>();
- headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "application/json");
- headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), "application/json");
+ Map<String, String> headersMap = new HashMap<>();
+ headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), acceptJsonHeader);
+ headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptJsonHeader);
headersMap.put(HttpHeaderEnum.USER_ID.getValue(), "cs0008");
return http.httpSendGet(url, headersMap);
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtilsExternalAPI.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtilsExternalAPI.java
index d9b8ec3d4b..76d2ededfc 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtilsExternalAPI.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResourceRestUtilsExternalAPI.java
@@ -50,7 +50,7 @@ public class ResourceRestUtilsExternalAPI extends BaseRestUtils {
String calculateMD5 = GeneralUtility.calculateMD5Base64EncodedByString(userBodyJson);
headersMap.put(HttpHeaderEnum.Content_MD5.getValue(), calculateMD5);
headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
- headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), "ci");
+ headersMap.put(HttpHeaderEnum.X_ECOMP_INSTANCE_ID.getValue(), BaseRestUtils.xEcompInstanceId);
headersMap.put(HttpHeaderEnum.USER_ID.getValue(), sdncModifierDetails.getUserId());
HttpRequest http = new HttpRequest();
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java
index 6f83ec9d52..d78a6c9026 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ResponseParser.java
@@ -20,22 +20,16 @@
package org.openecomp.sdc.ci.tests.utils.rest;
-import java.io.IOException;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.google.gson.Gson;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
import org.apache.commons.codec.binary.Base64;
import org.apache.log4j.Logger;
-import org.codehaus.jackson.Version;
-import org.codehaus.jackson.map.DeserializationConfig;
-import org.codehaus.jackson.map.JsonDeserializer;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.module.SimpleModule;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.simple.JSONObject;
@@ -44,12 +38,13 @@ import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.GroupDefinition;
import org.openecomp.sdc.be.model.Product;
import org.openecomp.sdc.be.model.PropertyConstraint;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
-import org.openecomp.sdc.be.model.operations.impl.PropertyOperation.PropertyConstraintJacksonDeserialiser;
+import org.openecomp.sdc.be.model.operations.impl.PropertyOperation.PropertyConstraintJacksonDeserializer;
import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ResourceAssetStructure;
import org.openecomp.sdc.ci.tests.datatypes.ResourceRespJavaObject;
@@ -57,11 +52,16 @@ import org.openecomp.sdc.ci.tests.datatypes.ServiceDistributionStatus;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.Utils;
-import com.google.gson.Gson;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
+import java.io.IOException;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.List;
+import java.util.Map;
public class ResponseParser {
@@ -104,16 +104,25 @@ public class ResponseParser {
public static String getValueFromJsonResponse(String response, String fieldName) {
try {
- JSONObject jsonResp = (JSONObject) JSONValue.parse(response);
- Object fieldValue = jsonResp.get(fieldName);
- return fieldValue.toString();
+// JSONObject jsonResp = (JSONObject) JSONValue.parse(response);
+ String[] split = fieldName.split(":");
+ String fieldValue = response;
+ for(int i=0; i<split.length; i++) {
+ fieldValue = parser(fieldValue, split[i]);
+ }
+ return fieldValue;
} catch (Exception e) {
return null;
}
}
+ private static String parser(String response, String field){
+ JSONObject fieldValue = (JSONObject) JSONValue.parse(response);
+ return fieldValue.get(field).toString();
+ }
+
public static String getUniqueIdFromResponse(RestResponse response) {
return getValueFromJsonResponse(response.getResponse(), UNIQUE_ID);
}
@@ -152,7 +161,7 @@ public class ResponseParser {
JsonObject jObject = jElement.getAsJsonObject();
JsonArray arrayOfObjects = (JsonArray) jObject.get(resourceType);
Gson gson = new Gson();
- Map<String, Object> map = new HashMap<String, Object>();
+ Map<String, Object> map = new HashMap<>();
ResourceRespJavaObject jsonToJavaObject = new ResourceRespJavaObject();
for (int counter = 0; counter < arrayOfObjects.size(); counter++) {
@@ -169,19 +178,19 @@ public class ResponseParser {
}
- public static Resource convertResourceResponseToJavaObject(String response) {
-
- ObjectMapper mapper = new ObjectMapper();
- final SimpleModule module = new SimpleModule("customerSerializationModule",
- new Version(1, 0, 0, "static version"));
- JsonDeserializer<PropertyConstraint> deserializer = new PropertyConstraintJacksonDeserialiser();
- addDeserializer(module, PropertyConstraint.class, deserializer);
+ private static ObjectMapper newObjectMapper() {
+ SimpleModule module = new SimpleModule("customDeserializationModule");
+ module.addDeserializer(PropertyConstraint.class, new PropertyConstraintJacksonDeserializer());
+ return new ObjectMapper()
+ .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
+ .registerModule(module);
+ }
- mapper.registerModule(module);
+ public static Resource convertResourceResponseToJavaObject(String response) {
+ ObjectMapper mapper = newObjectMapper();
Resource resource = null;
try {
-// TODO Andrey L. uncomment line below in case to ignore on unknown properties, not recommended
- mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
resource = mapper.readValue(response, Resource.class);
logger.debug(resource.toString());
@@ -199,15 +208,9 @@ public class ResponseParser {
public static ComponentInstanceProperty convertPropertyResponseToJavaObject(String response) {
- ObjectMapper mapper = new ObjectMapper();
- final SimpleModule module = new SimpleModule("customerSerializationModule", new Version(1, 0, 0, "static version"));
- JsonDeserializer<PropertyConstraint> desrializer = new PropertyConstraintJacksonDeserialiser();
- addDeserializer(module, PropertyConstraint.class, desrializer);
-
- mapper.registerModule(module);
+ ObjectMapper mapper = newObjectMapper();
ComponentInstanceProperty propertyDefinition = null;
try {
- mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
propertyDefinition = mapper.readValue(response, ComponentInstanceProperty.class);
logger.debug(propertyDefinition.toString());
} catch (IOException e) {
@@ -216,6 +219,19 @@ public class ResponseParser {
return propertyDefinition;
}
+ public static GroupDefinition convertPropertyResponseToObject(String response) {
+
+ ObjectMapper mapper = newObjectMapper();
+ GroupDefinition groupDefinition = null;
+ try {
+ groupDefinition = mapper.readValue(response, GroupDefinition.class);
+ logger.debug(groupDefinition.toString());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return groupDefinition;
+ }
+
public static String toJson(Object object) {
Gson gson = new Gson();
return gson.toJson(object);
@@ -225,7 +241,7 @@ public class ResponseParser {
ObjectMapper mapper = new ObjectMapper();
ArtifactDefinition artifactDefinition = null;
try {
- mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
artifactDefinition = mapper.readValue(response, ArtifactDefinition.class);
logger.debug(artifactDefinition.toString());
} catch (IOException e) {
@@ -257,18 +273,10 @@ public class ResponseParser {
public static <T> T parseToObjectUsingMapper(String json, Class<T> clazz) {
// Generic convert
- ObjectMapper mapper = new ObjectMapper();
+ ObjectMapper mapper = newObjectMapper();
T object = null;
- final SimpleModule module = new SimpleModule("customerSerializationModule",
- new Version(1, 0, 0, "static version"));
- JsonDeserializer<PropertyConstraint> desrializer = new PropertyConstraintJacksonDeserialiser();
- addDeserializer(module, PropertyConstraint.class, desrializer);
- mapper.registerModule(module);
- mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
try {
object = mapper.readValue(json, clazz);
- // System.out.println("Class: "+clazz.getSimpleName()+", json:
- // "+json);
} catch (IOException e) {
e.printStackTrace();
}
@@ -286,25 +294,11 @@ public class ResponseParser {
return artifactReqDetails;
}
- public static <T> void addDeserializer(SimpleModule module, Class<T> clazz,
- final JsonDeserializer<T> deserializer) {
- module.addDeserializer(clazz, deserializer);
- }
-
public static Service convertServiceResponseToJavaObject(String response) {
- ObjectMapper mapper = new ObjectMapper();
- final SimpleModule module = new SimpleModule("customerSerializationModule",
- new Version(1, 0, 0, "static version"));
- JsonDeserializer<PropertyConstraint> deserializer = new PropertyConstraintJacksonDeserialiser();
- addDeserializer(module, PropertyConstraint.class, deserializer);
-
- mapper.registerModule(module);
+ ObjectMapper mapper = newObjectMapper();
Service service = null;
try {
-// TODO Andrey L. uncomment line below in case to ignore on unknown properties, not recommended, added by Matvey
- mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
service = mapper.readValue(response, Service.class);
logger.debug(service.toString());
} catch (IOException e) {
@@ -316,18 +310,9 @@ public class ResponseParser {
public static Product convertProductResponseToJavaObject(String response) {
- ObjectMapper mapper = new ObjectMapper();
-
- final SimpleModule module = new SimpleModule("customerSerializationModule",
- new Version(1, 0, 0, "static version"));
- JsonDeserializer<PropertyConstraint> desrializer = new PropertyConstraintJacksonDeserialiser();
- addDeserializer(module, PropertyConstraint.class, desrializer);
-
- mapper.registerModule(module);
-
+ ObjectMapper mapper = newObjectMapper();
Product product = null;
try {
- mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
product = mapper.readValue(response, Product.class);
logger.debug(product.toString());
} catch (IOException e) {
@@ -339,16 +324,9 @@ public class ResponseParser {
public static ComponentInstance convertComponentInstanceResponseToJavaObject(String response) {
- ObjectMapper mapper = new ObjectMapper();
- final SimpleModule module = new SimpleModule("customerSerializationModule",
- new Version(1, 0, 0, "static version"));
- JsonDeserializer<PropertyConstraint> desrializer = new PropertyConstraintJacksonDeserialiser();
- addDeserializer(module, PropertyConstraint.class, desrializer);
-
- mapper.registerModule(module);
+ ObjectMapper mapper = newObjectMapper();
ComponentInstance componentInstance = null;
try {
- mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
componentInstance = mapper.readValue(response, ComponentInstance.class);
logger.debug(componentInstance.toString());
} catch (IOException e) {
@@ -360,7 +338,7 @@ public class ResponseParser {
}
public static List<String> getValuesFromJsonArray(RestResponse message) throws Exception {
- List<String> artifactTypesArrayFromApi = new ArrayList<String>();
+ List<String> artifactTypesArrayFromApi = new ArrayList<>();
org.json.JSONObject responseObject = new org.json.JSONObject(message.getResponse());
JSONArray jArr = responseObject.getJSONArray("artifactTypes");
@@ -392,7 +370,7 @@ public class ResponseParser {
}
public static List<Map<String, Object>> getAuditFromMessage(Map<String, Object> auditingMessage) {
- List<Map<String, Object>> auditList = new ArrayList<Map<String, Object>>();
+ List<Map<String, Object>> auditList = new ArrayList<>();
auditList.add(auditingMessage);
return auditList;
}
@@ -425,8 +403,8 @@ public class ResponseParser {
}
public static List<String> getDerivedListFromJson(RestResponse res) throws JSONException {
- JSONArray listFromJson = getListFromJson(res, "derivedList");
- List<String> lst = new ArrayList<String>();
+ JSONArray listFromJson = getListFromJson(res, "derivedFrom");
+ List<String> lst = new ArrayList<>();
for (int i = 0; i < listFromJson.length(); i++) {
lst.add(listFromJson.getString(i));
}
@@ -440,7 +418,7 @@ public class ResponseParser {
}
public static List<Map<String, Object>> getListOfMapsFromJson(RestResponse res, String field) throws Exception {
- List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
+ List<Map<String, Object>> list = new ArrayList<>();
JSONArray listFromJson = getListFromJson(res, field);
for (int i = 0; i < listFromJson.length(); i++) {
Map<String, Object> convertStringToMap = convertStringToMap(listFromJson.getString(i));
@@ -472,7 +450,7 @@ public class ResponseParser {
// Map<String, ArrayList<Component>> map = new HashMap<String,
// ArrayList<Component>>();
- Map<String, List<Component>> map = new HashMap<String, List<Component>>();
+ Map<String, List<Component>> map = new HashMap<>();
JsonElement jElement = new JsonParser().parse(response);
JsonObject jObject = jElement.getAsJsonObject();
@@ -531,7 +509,7 @@ public class ResponseParser {
public static Map<Long, ServiceDistributionStatus> convertServiceDistributionStatusToObject(String response) throws ParseException {
- Map<Long, ServiceDistributionStatus> serviceDistributionStatusMap = new HashMap<Long, ServiceDistributionStatus>();
+ Map<Long, ServiceDistributionStatus> serviceDistributionStatusMap = new HashMap<>();
ServiceDistributionStatus serviceDistributionStatusObject = null;
JsonElement jElement = new JsonParser().parse(response);
@@ -551,7 +529,7 @@ public class ResponseParser {
public static Map<String, String> getPropertiesNameType(RestResponse restResponse)
throws JSONException {
- Map<String, String> propertiesMap = new HashMap<String, String>();
+ Map<String, String> propertiesMap = new HashMap<>();
JSONArray propertiesList = getListFromJson(restResponse, "properties");
for (int i = 0; i < propertiesList.length() ; i ++){
JSONObject prop = (JSONObject) JSONValue.parse(propertiesList.get(i).toString());
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ServiceRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ServiceRestUtils.java
index 9ba4a906c6..1d8aef6f04 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ServiceRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/ServiceRestUtils.java
@@ -45,9 +45,6 @@ import com.google.gson.Gson;
public class ServiceRestUtils extends BaseRestUtils {
private static Logger logger = LoggerFactory.getLogger(ServiceRestUtils.class.getName());
- private final static String cacheControl = "no-cache";
- private final static String contentTypeHeaderData = "application/json";
- private final static String acceptHeaderDate = "application/json";
// ****** CREATE *******
private static Gson gson = new Gson();
@@ -68,8 +65,7 @@ public class ServiceRestUtils extends BaseRestUtils {
public static RestResponse markServiceToDelete(String resourceId, String userId) throws IOException {
Config config = Utils.getConfig();
- String url = String.format(Urls.DELETE_SERVICE, config.getCatalogBeHost(), config.getCatalogBePort(),
- resourceId);
+ String url = String.format(Urls.DELETE_SERVICE, config.getCatalogBeHost(), config.getCatalogBePort(), resourceId);
RestResponse sendDelete = sendDelete(url, userId);
return sendDelete;
@@ -79,8 +75,7 @@ public class ServiceRestUtils extends BaseRestUtils {
public static RestResponse deleteServiceById(String serviceId, String userId) throws IOException {
Config config = Utils.getConfig();
- String url = String.format(Urls.DELETE_SERVICE, config.getCatalogBeHost(), config.getCatalogBePort(),
- serviceId);
+ String url = String.format(Urls.DELETE_SERVICE, config.getCatalogBeHost(), config.getCatalogBePort(), serviceId);
RestResponse sendDelete = sendDelete(url, userId);
deleteMarkedServices(userId);
return sendDelete;
@@ -177,12 +172,12 @@ public class ServiceRestUtils extends BaseRestUtils {
}
public static Map<String, String> prepareHeadersMap(User sdncModifierDetails, boolean isCached) {
- Map<String, String> headersMap = new HashMap<String, String>();
+ Map<String, String> headersMap = new HashMap<>();
if (isCached)
- headersMap.put(HttpHeaderEnum.CACHE_CONTROL.getValue(), cacheControl);
+ headersMap.put(HttpHeaderEnum.CACHE_CONTROL.getValue(), BaseRestUtils.cacheControlHeader);
- headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
- headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
+ headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData);
+ headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), BaseRestUtils.acceptHeaderData);
headersMap.put(HttpHeaderEnum.USER_ID.getValue(), sdncModifierDetails.getUserId());
return headersMap;
}
@@ -202,7 +197,7 @@ public class ServiceRestUtils extends BaseRestUtils {
String url = String.format(Urls.REJECT_DISTRIBUTION, config.getCatalogBeHost(), config.getCatalogBePort(),
serviceId);
String userBodyJson = gson.toJson(comment);
- return sendPost(url, userBodyJson, userId, acceptHeaderData);
+ return sendPost(url, userBodyJson, userId, BaseRestUtils.acceptHeaderData);
}
@@ -268,9 +263,9 @@ public class ServiceRestUtils extends BaseRestUtils {
String url = String.format(Urls.GET_FOLLWED_LIST, config.getCatalogBeHost(), config.getCatalogBePort());
- Map<String, String> headersMap = new HashMap<String, String>();
- headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "application/json");
- headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), "application/json");
+ Map<String, String> headersMap = new HashMap<>();
+ headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), BaseRestUtils.contentTypeHeaderData);
+ headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), BaseRestUtils.acceptHeaderData);
headersMap.put(HttpHeaderEnum.USER_ID.getValue(), user.getUserId());
RestResponse getResourceNotAbstarctResponse = httpRequest.httpSendGet(url, headersMap);
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/UserRestUtils.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/UserRestUtils.java
index 881e9469dd..5031391fe4 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/UserRestUtils.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/rest/UserRestUtils.java
@@ -171,7 +171,7 @@ public class UserRestUtils extends BaseRestUtils {
Config config = Utils.getConfig();
- Map<String, String> headersMap = new HashMap<String, String>();
+ Map<String, String> headersMap = new HashMap<>();
headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
headersMap.put(HttpHeaderEnum.USER_ID.getValue(), sdncModifierDetails.getUserId());
@@ -189,7 +189,7 @@ public class UserRestUtils extends BaseRestUtils {
Config config = Utils.getConfig();
- Map<String, String> headersMap = new HashMap<String, String>();
+ Map<String, String> headersMap = new HashMap<>();
headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), contentTypeHeaderData);
headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), acceptHeaderDate);
headersMap.put(HttpHeaderEnum.USER_ID.getValue(), sdncModifierDetails.getUserId());