diff options
author | andre.schmid <andre.schmid@est.tech> | 2021-08-18 14:34:33 +0100 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2021-08-26 12:13:58 +0000 |
commit | aea64ba99fa9c9b51112b30aeb0872c4cdb89759 (patch) | |
tree | 8645ba4b820f8615e54ecd053f7232c2fcd7dca9 /integration-tests | |
parent | 5a0703ffad1492ec6b6c78143f63dca83ee030d2 (diff) |
Validate the Resource Model before importing VSP
Validates the Resource Model selected during the Import VSP.
This model must be aligned with one of the models that the
imported VSP relates to.
Fix VSP package retrieval to get the exact version from the
VSP chosen during the Import VSP process.
Introduces a client in the Catalog to retrieve from the
Onboarding backend a VSP information using its Id and
version Id.
Change-Id: Ic8fb52b6daadc0e7203c81a9c15c3e46d5b9fffb
Issue-ID: SDC-3675
Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'integration-tests')
6 files changed, 42 insertions, 158 deletions
diff --git a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/datatypes/ImportReqDetails.java b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/datatypes/ImportReqDetails.java index a42da88a7d..160a338033 100644 --- a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/datatypes/ImportReqDetails.java +++ b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/datatypes/ImportReqDetails.java @@ -106,7 +106,7 @@ public class ImportReqDetails extends ResourceReqDetails { public void setRequirements(String path, String fileName, User user, String derivedFromSource) throws IOException, JSONException { Map<String, Object> requirementsFromFile = getRequirementsMapFromFile(path + File.separator + fileName, - toscaResourceName, "requirements"); + getToscaResourceName(), "requirements"); Map<String, Object> reqs = organizeRequirementsMap(requirementsFromFile); getDerivedReqCap(user, reqs, "requirements", derivedFromSource); this.requirements = reqs; @@ -170,7 +170,7 @@ public class ImportReqDetails extends ResourceReqDetails { public void setCapabilities(String path, String fileName, User user, String derivedFromSource) throws IOException, JSONException { Map<String, Object> capabilitiesFromFile = getCapabilitiesMapFromFile(path + File.separator + fileName, - toscaResourceName, CAPS); + getToscaResourceName(), CAPS); Map<String, Object> caps = organizeCapabilitiesMap(capabilitiesFromFile); getDerivedReqCap(user, caps, CAPS, derivedFromSource); this.capabilities = caps; diff --git a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/datatypes/ResourceReqDetails.java b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/datatypes/ResourceReqDetails.java index d285c0b137..e8705607ed 100644 --- a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/datatypes/ResourceReqDetails.java +++ b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/datatypes/ResourceReqDetails.java @@ -20,32 +20,33 @@ package org.onap.sdc.backend.ci.tests.datatypes; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.Resource; import java.util.List; +@Getter +@Setter +@ToString(callSuper = false) public class ResourceReqDetails extends ComponentReqDetails { - List<String> derivedFrom; - String vendorName; - String vendorRelease; - String componentType = "RESOURCE"; - public String getComponentType() { - return componentType; - } - // Unsettable/unupdatable fields - - Boolean isAbstract; - Boolean isHighestVersion; - String cost; - - String licenseType; - String toscaResourceName; - String resourceVendorModelNumber; - - private String resourceType = ResourceTypeEnum.VFC.toString(); // Default - // value + private List<String> derivedFrom; + private String vendorName; + private String vendorRelease; + @Setter(AccessLevel.NONE) + private String componentType = "RESOURCE"; + private String csarVersionId; + private Boolean isAbstract; + private Boolean isHighestVersion; + private String cost; + private String licenseType; + private String toscaResourceName; + private String resourceVendorModelNumber; + private String resourceType = ResourceTypeEnum.VFC.toString(); public ResourceReqDetails() { super(); @@ -154,92 +155,4 @@ public class ResourceReqDetails extends ComponentReqDetails { this.toscaResourceName = resourceName; } - public String getResourceVendorModelNumber() { - return resourceVendorModelNumber; - } - - public void setResourceVendorModelNumber(String resourceVendorModelNumber) { - this.resourceVendorModelNumber = resourceVendorModelNumber; - } - public String getToscaResourceName() { - return toscaResourceName; - } - - public void setToscaResourceName(String toscaResourceName) { - this.toscaResourceName = toscaResourceName; - } - - public List<String> getDerivedFrom() { - return derivedFrom; - } - - public void setDerivedFrom(List<String> derivedFrom) { - this.derivedFrom = derivedFrom; - } - - public String getVendorName() { - return vendorName; - } - - public void setVendorName(String vendorName) { - this.vendorName = vendorName; - } - - public String getVendorRelease() { - return vendorRelease; - } - - public void setVendorRelease(String vendorRelease) { - this.vendorRelease = vendorRelease; - } - - public String getCost() { - return cost; - } - - public void setCost(String cost) { - this.cost = cost; - } - - public String getLicenseType() { - return licenseType; - } - - public void setLicenseType(String licenseType) { - this.licenseType = licenseType; - } - - // Unupdatable fields - to check that they are not updated - public void setIsAbstract(Boolean isAbstract) { - this.isAbstract = isAbstract; - } - - public void setIsHighestVersion(Boolean isHighestVersion) { - this.isHighestVersion = isHighestVersion; - } - - public Boolean getIsAbstract() { - return isAbstract; - } - - public Boolean getIsHighestVersion() { - return isHighestVersion; - } - - public String getResourceType() { - return resourceType; - } - - public void setResourceType(String resourceType) { - this.resourceType = resourceType; - } - - @Override - public String toString() { - return "ResourceReqDetails [name=" + name + ", derivedFrom=" + derivedFrom + ", vendorName=" + vendorName - + ", vendorRelease=" + vendorRelease + ", version=" + version + ", isAbstract=" + isAbstract - + ", isHighestVersion=" + isHighestVersion + ", cost=" + cost + ", licenseType=" + licenseType - + ", resourceType=" + resourceType + "]"; - } - -} +}
\ No newline at end of file diff --git a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/datatypes/VendorSoftwareProductObject.java b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/datatypes/VendorSoftwareProductObject.java index 4aa30ec2ec..69f59c8ee0 100644 --- a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/datatypes/VendorSoftwareProductObject.java +++ b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/datatypes/VendorSoftwareProductObject.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,14 +20,22 @@ package org.onap.sdc.backend.ci.tests.datatypes; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(callSuper = false) +@NoArgsConstructor public class VendorSoftwareProductObject extends VendorSoftwareProductObjectReqDetails { private String vspId; private String componentId; private String attContact; private String version; - - public VendorSoftwareProductObject(){super();} + private String versionId; public VendorSoftwareProductObject(String vspId, String componentId, String attContact, String version) { this.vspId = vspId; @@ -44,45 +52,4 @@ public class VendorSoftwareProductObject extends VendorSoftwareProductObjectReqD this.version = version; } - public String getVspId() { - return vspId; - } - - public void setVspId(String vspId) { - this.vspId = vspId; - } - - public String getComponentId() { - return componentId; - } - - public void setComponentId(String componentId) { - this.componentId = componentId; - } - - public String getAttContact() { - return attContact; - } - - public void setAttContact(String attContact) { - this.attContact = attContact; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - @Override - public String toString() { - return "VendorSoftwareProductObject{" + - "vspId='" + vspId + '\'' + - ", componentId='" + componentId + '\'' + - ", attContact='" + attContact + '\'' + - ", version='" + version + '\'' + - '}'; - } } diff --git a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/AtomicOperationUtils.java b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/AtomicOperationUtils.java index 9c73275316..11e56cce5b 100644 --- a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/AtomicOperationUtils.java +++ b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/AtomicOperationUtils.java @@ -142,13 +142,16 @@ public final class AtomicOperationUtils { } } - public static Either<Resource, RestResponse> createResourceByResourceDetails(ResourceReqDetails resourceDetails, UserRoleEnum userRole, Boolean validateState) { + public static Either<Resource, RestResponse> createResourceByResourceDetails(final ResourceReqDetails resourceDetails, + final UserRoleEnum userRole, + final Boolean validateState) { try { User defaultUser = ElementFactory.getDefaultUser(userRole); RestResponse resourceResp = ResourceRestUtils.createResource(resourceDetails, defaultUser); if (validateState) { - assertTrue("Create resource failed with error: " + resourceResp.getResponse(),resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED); + assertEquals("Create resource failed with error: " + resourceResp.getResponse(), + ResourceRestUtils.STATUS_CODE_CREATED, (int) resourceResp.getErrorCode()); } if (resourceResp.getErrorCode() == ResourceRestUtils.STATUS_CODE_CREATED) { diff --git a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/OnboardingUtillViaApis.java b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/OnboardingUtillViaApis.java index 6c6ba0dbbe..197daba4c0 100644 --- a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/OnboardingUtillViaApis.java +++ b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/OnboardingUtillViaApis.java @@ -143,6 +143,7 @@ public class OnboardingUtillViaApis { tags.add(vendorSoftwareProductObject.getName()); resourceDetails.setCsarUUID(vendorSoftwareProductObject.getVspId()); resourceDetails.setCsarVersion(vendorSoftwareProductObject.getVersion()); + resourceDetails.setCsarVersionId(vendorSoftwareProductObject.getVersionId()); resourceDetails.setName(vendorSoftwareProductObject.getName()); resourceDetails.setTags(tags); resourceDetails.setDescription(vendorSoftwareProductObject.getDescription()); diff --git a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/VendorSoftwareProductRestUtils.java b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/VendorSoftwareProductRestUtils.java index 1eea8f320d..d9f2b904e0 100644 --- a/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/VendorSoftwareProductRestUtils.java +++ b/integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/VendorSoftwareProductRestUtils.java @@ -362,8 +362,8 @@ public class VendorSoftwareProductRestUtils { RestResponse response = http.httpSendPost(url, body, headersMap); vendorSoftwareProductObject.setVspId(ResponseParser.getValueFromJsonResponse(response.getResponse(), "itemId")); + vendorSoftwareProductObject.setVersionId(ResponseParser.getValueFromJsonResponse(response.getResponse(), "version:id")); vendorSoftwareProductObject.setComponentId(ResponseParser.getValueFromJsonResponse(response.getResponse(), "version:id")); -// vendorSoftwareProductObject.setVersion(ResponseParser.getValueFromJsonResponse(response.getResponse(), "version:name")); vendorSoftwareProductObject.setAttContact(user.getUserId()); return new Pair<>(response, vendorSoftwareProductObject); |