aboutsummaryrefslogtreecommitdiffstats
path: root/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src
diff options
context:
space:
mode:
authorwaqas.ikram <waqas.ikram@est.tech>2021-01-29 15:24:07 +0000
committerwaqas.ikram <waqas.ikram@est.tech>2021-01-29 15:53:24 +0000
commit87a7fca8a3db019e191447526b3e291514aa0725 (patch)
treec0bcc15d55556eb7889c56fadcb3a56f4ba636a1 /plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src
parent93a3060d58c058e5588d249adcf53d968c8e5593 (diff)
Adding endpoints to SDC simulator
for ETSI NFVO NS LCM Usecase Change-Id: I1a626dce2a24364a81076e4a860a9b658edf2d59 Issue-ID: INT-1839 Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
Diffstat (limited to 'plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src')
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/controller/CatalogController.java46
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/Artifact.java234
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/AssetInfo.java (renamed from plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/ResourceArtifact.java)65
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/AssetType.java31
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/Metadata.java104
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/Resource.java198
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/ResourceAssetInfo.java81
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/ServiceAssetInfo.java82
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/providers/AssetProvider.java (renamed from plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/providers/ResourceProvider.java)14
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/providers/AssetProviderImpl.java274
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/providers/ResourceProviderImpl.java174
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/utils/Constants.java6
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/RESOURCES/73522444-e8e9-49c1-be29-d355800aa349.csar (renamed from plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/73522444-e8e9-49c1-be29-d355800aa349.csar)bin117247 -> 117247 bytes
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/RESOURCES/73522444-e8e9-49c1-be29-d355800aa349.json116
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/SERVICES/9bb8c882-44a1-4b67-a12c-5a998e18d6ba.csar (renamed from plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/ba1c0c0e-9fb8-4b83-97bb-5e9af1e73393.csar)bin116913 -> 147743 bytes
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/SERVICES/9bb8c882-44a1-4b67-a12c-5a998e18d6ba.json62
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/default_csar_file.csarbin3982 -> 0 bytes
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdcsimulator/controller/CatalogControllerTest.java80
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdcsimulator/providers/AssetProviderImplTest.java (renamed from plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdcsimulator/providers/ResourceProviderImplTest.java)33
19 files changed, 1351 insertions, 249 deletions
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/controller/CatalogController.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/controller/CatalogController.java
index eff63b84..f22bcf69 100644
--- a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/controller/CatalogController.java
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/controller/CatalogController.java
@@ -22,7 +22,9 @@ package org.onap.so.sdcsimulator.controller;
import static org.onap.so.sdcsimulator.utils.Constants.CATALOG_URL;
import java.util.Optional;
import javax.ws.rs.core.MediaType;
-import org.onap.so.sdcsimulator.providers.ResourceProvider;
+import org.onap.so.sdcsimulator.models.AssetType;
+import org.onap.so.sdcsimulator.models.Metadata;
+import org.onap.so.sdcsimulator.providers.AssetProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -42,23 +44,23 @@ import org.springframework.web.bind.annotation.RequestMapping;
public class CatalogController {
private static final Logger LOGGER = LoggerFactory.getLogger(CatalogController.class);
- private ResourceProvider resourceProvider;
+ private AssetProvider resourceProvider;
@Autowired
- public CatalogController(final ResourceProvider resourceProvider) {
+ public CatalogController(final AssetProvider resourceProvider) {
this.resourceProvider = resourceProvider;
}
@GetMapping(value = "/resources", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public ResponseEntity<?> getResources() {
LOGGER.info("Running getResources ...");
- return ResponseEntity.ok().body(resourceProvider.getResource());
+ return ResponseEntity.ok().body(resourceProvider.getAssetInfo(AssetType.RESOURCES));
}
@GetMapping(value = "/resources/{csarId}/toscaModel", produces = MediaType.APPLICATION_OCTET_STREAM)
public ResponseEntity<byte[]> getCsar(@PathVariable("csarId") final String csarId) {
LOGGER.info("Running getCsar for {} ...", csarId);
- final Optional<byte[]> resource = resourceProvider.getResource(csarId);
+ final Optional<byte[]> resource = resourceProvider.getAsset(csarId, AssetType.RESOURCES);
if (resource.isPresent()) {
return new ResponseEntity<>(resource.get(), HttpStatus.OK);
}
@@ -67,4 +69,38 @@ public class CatalogController {
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
+ @GetMapping(value = "/resources/{csarId}/metadata",
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<Metadata> getResourceMetadata(@PathVariable("csarId") final String csarId) {
+ LOGGER.info("Running getResourceMetadata for {} ...", csarId);
+ final Optional<Metadata> resource = resourceProvider.getMetadata(csarId, AssetType.RESOURCES);
+ if (resource.isPresent()) {
+ return new ResponseEntity<>(resource.get(), HttpStatus.OK);
+ }
+ LOGGER.error("Unable to find metadata for csarId: {}", csarId);
+
+ return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+
+
+ @GetMapping(value = "/services", produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<?> getServices() {
+ LOGGER.info("Running getServices ...");
+ return ResponseEntity.ok().body(resourceProvider.getAssetInfo(AssetType.SERVICES));
+ }
+
+ @GetMapping(value = "/services/{csarId}/metadata",
+ produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+ public ResponseEntity<Metadata> getServiceMetadata(@PathVariable("csarId") final String csarId) {
+ LOGGER.info("Running getServiceMetadata for {} ...", csarId);
+ final Optional<Metadata> resource = resourceProvider.getMetadata(csarId, AssetType.SERVICES);
+ if (resource.isPresent()) {
+ return new ResponseEntity<>(resource.get(), HttpStatus.OK);
+ }
+ LOGGER.error("Unable to find metadata for csarId: {}", csarId);
+
+ return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+
+
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/Artifact.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/Artifact.java
new file mode 100644
index 00000000..51bd18b1
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/Artifact.java
@@ -0,0 +1,234 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.sdcsimulator.models;
+
+import java.io.Serializable;
+import org.springframework.util.ObjectUtils;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ *
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public class Artifact implements Serializable {
+
+ private static final long serialVersionUID = 4106531921550274666L;
+
+ @JsonProperty("artifactName")
+ private String artifactName;
+
+ @JsonProperty("artifactType")
+ private String artifactType;
+
+ @JsonProperty("artifactURL")
+ private String artifactUrl;
+
+ @JsonProperty("artifactDescription")
+ private String artifactDescription;
+
+ @JsonProperty("artifactChecksum")
+ private String artifactChecksum;
+
+ @JsonProperty("artifactUUID")
+ private String artifactUuid;
+
+ @JsonProperty("artifactVersion")
+ private String artifactVersion;
+
+ @JsonProperty("artifactLabel")
+ private String artifactLabel;
+
+ @JsonProperty("artifactGroupType")
+ private String artifactGroupType;
+
+ public String getArtifactName() {
+ return artifactName;
+ }
+
+ public void setArtifactName(final String artifactName) {
+ this.artifactName = artifactName;
+ }
+
+ public Artifact artifactName(final String artifactName) {
+ this.artifactName = artifactName;
+ return this;
+ }
+
+ public String getArtifactType() {
+ return artifactType;
+ }
+
+ public void setArtifactType(final String artifactType) {
+ this.artifactType = artifactType;
+ }
+
+ public Artifact artifactType(final String artifactType) {
+ this.artifactType = artifactType;
+ return this;
+ }
+
+ public String getArtifactUrl() {
+ return artifactUrl;
+ }
+
+ public void setArtifactUrl(final String artifactUrl) {
+ this.artifactUrl = artifactUrl;
+ }
+
+ public Artifact artifactUrl(final String artifactURL) {
+ this.artifactUrl = artifactURL;
+ return this;
+ }
+
+ public String getArtifactDescription() {
+ return artifactDescription;
+ }
+
+ public void setArtifactDescription(final String artifactDescription) {
+ this.artifactDescription = artifactDescription;
+ }
+
+ public Artifact artifactDescription(final String artifactDescription) {
+ this.artifactDescription = artifactDescription;
+ return this;
+ }
+
+ public String getArtifactChecksum() {
+ return artifactChecksum;
+ }
+
+ public void setArtifactChecksum(final String artifactChecksum) {
+ this.artifactChecksum = artifactChecksum;
+ }
+
+ public Artifact artifactChecksum(final String artifactChecksum) {
+ this.artifactChecksum = artifactChecksum;
+ return this;
+ }
+
+ public String getArtifactUuid() {
+ return artifactUuid;
+ }
+
+ public void setArtifactUuid(final String artifactUuid) {
+ this.artifactUuid = artifactUuid;
+ }
+
+ public Artifact artifactUuid(final String artifactUuid) {
+ this.artifactUuid = artifactUuid;
+ return this;
+ }
+
+ public String getArtifactVersion() {
+ return artifactVersion;
+ }
+
+ public void setArtifactVersion(final String artifactVersion) {
+ this.artifactVersion = artifactVersion;
+ }
+
+ public Artifact artifactVersion(final String artifactVersion) {
+ this.artifactVersion = artifactVersion;
+ return this;
+ }
+
+ public String getArtifactLabel() {
+ return artifactLabel;
+ }
+
+ public void setArtifactLabel(final String artifactLabel) {
+ this.artifactLabel = artifactLabel;
+ }
+
+ public Artifact artifactLabel(final String artifactLabel) {
+ this.artifactLabel = artifactLabel;
+ return this;
+ }
+
+ public String getArtifactGroupType() {
+ return artifactGroupType;
+ }
+
+ public void setArtifactGroupType(final String artifactGroupType) {
+ this.artifactGroupType = artifactGroupType;
+ }
+
+ public Artifact artifactGroupType(final String artifactGroupType) {
+ this.artifactGroupType = artifactGroupType;
+ return this;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((artifactChecksum == null) ? 0 : artifactChecksum.hashCode());
+ result = prime * result + ((artifactDescription == null) ? 0 : artifactDescription.hashCode());
+ result = prime * result + ((artifactGroupType == null) ? 0 : artifactGroupType.hashCode());
+ result = prime * result + ((artifactLabel == null) ? 0 : artifactLabel.hashCode());
+ result = prime * result + ((artifactName == null) ? 0 : artifactName.hashCode());
+ result = prime * result + ((artifactType == null) ? 0 : artifactType.hashCode());
+ result = prime * result + ((artifactUrl == null) ? 0 : artifactUrl.hashCode());
+ result = prime * result + ((artifactUuid == null) ? 0 : artifactUuid.hashCode());
+ result = prime * result + ((artifactVersion == null) ? 0 : artifactVersion.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj instanceof AssetInfo) {
+ final Artifact other = (Artifact) obj;
+ return ObjectUtils.nullSafeEquals(artifactChecksum, other.artifactChecksum)
+ && ObjectUtils.nullSafeEquals(artifactDescription, other.artifactDescription)
+ && ObjectUtils.nullSafeEquals(artifactGroupType, other.artifactGroupType)
+ && ObjectUtils.nullSafeEquals(artifactLabel, other.artifactLabel)
+ && ObjectUtils.nullSafeEquals(artifactGroupType, other.artifactGroupType)
+ && ObjectUtils.nullSafeEquals(artifactName, other.artifactName)
+ && ObjectUtils.nullSafeEquals(artifactType, other.artifactType)
+ && ObjectUtils.nullSafeEquals(artifactUrl, other.artifactUrl)
+ && ObjectUtils.nullSafeEquals(artifactUuid, other.artifactUuid)
+ && ObjectUtils.nullSafeEquals(artifactVersion, other.artifactVersion);
+
+
+ }
+ return false;
+
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("class Artifact {\n");
+ sb.append(" artifactName: ").append(artifactName).append("\n");
+ sb.append(" artifactType: ").append(artifactType).append("\n");
+ sb.append(" artifactURL: ").append(artifactUrl).append("\n");
+ sb.append(" artifactDescription: ").append(artifactDescription).append("\n");
+ sb.append(" artifactChecksum: ").append(artifactChecksum).append("\n");
+ sb.append(" artifactUUID: ").append(artifactUuid).append("\n");
+ sb.append(" artifactVersion: ").append(artifactVersion).append("\n");
+ sb.append(" artifactLabel: ").append(artifactLabel).append("\n");
+ sb.append(" artifactGroupType: ").append(artifactGroupType).append("\n");
+
+ sb.append("}");
+ return sb.toString();
+
+ }
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/ResourceArtifact.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/AssetInfo.java
index 0b9e6cf1..39055cf5 100644
--- a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/ResourceArtifact.java
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/AssetInfo.java
@@ -27,7 +27,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
* @author Waqas Ikram (waqas.ikram@est.tech)
*
*/
-public class ResourceArtifact implements Serializable {
+public class AssetInfo implements Serializable {
private static final long serialVersionUID = 3967660000071162759L;
@@ -49,9 +49,6 @@ public class ResourceArtifact implements Serializable {
@JsonProperty("category")
private String category;
- @JsonProperty("subCategory")
- private String subCategory;
-
@JsonProperty("resourceType")
private String resourceType;
@@ -61,6 +58,9 @@ public class ResourceArtifact implements Serializable {
@JsonProperty("lastUpdaterUserId")
private String lastUpdaterUserId;
+ @JsonProperty("toscaResourceName")
+ private String toscaResourceName;
+
public String getUuid() {
return uuid;
}
@@ -69,7 +69,7 @@ public class ResourceArtifact implements Serializable {
this.uuid = uuid;
}
- public ResourceArtifact uuid(final String uuid) {
+ public AssetInfo uuid(final String uuid) {
this.uuid = uuid;
return this;
}
@@ -82,7 +82,7 @@ public class ResourceArtifact implements Serializable {
this.invariantUuid = invariantUuid;
}
- public ResourceArtifact invariantUuid(final String invariantUuid) {
+ public AssetInfo invariantUuid(final String invariantUuid) {
this.invariantUuid = invariantUuid;
return this;
}
@@ -95,7 +95,7 @@ public class ResourceArtifact implements Serializable {
this.name = name;
}
- public ResourceArtifact name(final String name) {
+ public AssetInfo name(final String name) {
this.name = name;
return this;
}
@@ -108,7 +108,7 @@ public class ResourceArtifact implements Serializable {
this.version = version;
}
- public ResourceArtifact version(final String version) {
+ public AssetInfo version(final String version) {
this.version = version;
return this;
}
@@ -121,7 +121,7 @@ public class ResourceArtifact implements Serializable {
this.toscaModelUrl = toscaModelUrl;
}
- public ResourceArtifact toscaModelUrl(final String toscaModelUrl) {
+ public AssetInfo toscaModelUrl(final String toscaModelUrl) {
this.toscaModelUrl = toscaModelUrl;
return this;
}
@@ -134,24 +134,11 @@ public class ResourceArtifact implements Serializable {
this.category = category;
}
- public ResourceArtifact category(final String category) {
+ public AssetInfo category(final String category) {
this.category = category;
return this;
}
- public String getSubCategory() {
- return subCategory;
- }
-
- public void setSubCategory(final String subCategory) {
- this.subCategory = subCategory;
- }
-
- public ResourceArtifact subCategory(final String subCategory) {
- this.subCategory = subCategory;
- return this;
- }
-
public String getResourceType() {
return resourceType;
}
@@ -160,7 +147,7 @@ public class ResourceArtifact implements Serializable {
this.resourceType = resourceType;
}
- public ResourceArtifact resourceType(final String resourceType) {
+ public AssetInfo resourceType(final String resourceType) {
this.resourceType = resourceType;
return this;
}
@@ -173,7 +160,7 @@ public class ResourceArtifact implements Serializable {
this.lifecycleState = lifecycleState;
}
- public ResourceArtifact lifecycleState(final String lifecycleState) {
+ public AssetInfo lifecycleState(final String lifecycleState) {
this.lifecycleState = lifecycleState;
return this;
}
@@ -186,11 +173,24 @@ public class ResourceArtifact implements Serializable {
this.lastUpdaterUserId = lastUpdaterUserId;
}
- public ResourceArtifact lastUpdaterUserId(final String lastUpdaterUserId) {
+ public AssetInfo lastUpdaterUserId(final String lastUpdaterUserId) {
this.lastUpdaterUserId = lastUpdaterUserId;
return this;
}
+ public String getToscaResourceName() {
+ return toscaResourceName;
+ }
+
+ public void setToscaResourceName(final String toscaResourceName) {
+ this.toscaResourceName = toscaResourceName;
+ }
+
+ public AssetInfo toscaResourceName(final String toscaResourceName) {
+ this.toscaResourceName = toscaResourceName;
+ return this;
+ }
+
@Override
public int hashCode() {
final int prime = 31;
@@ -201,27 +201,27 @@ public class ResourceArtifact implements Serializable {
result = prime * result + ((lifecycleState == null) ? 0 : lifecycleState.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((resourceType == null) ? 0 : resourceType.hashCode());
- result = prime * result + ((subCategory == null) ? 0 : subCategory.hashCode());
result = prime * result + ((toscaModelUrl == null) ? 0 : toscaModelUrl.hashCode());
result = prime * result + ((uuid == null) ? 0 : uuid.hashCode());
result = prime * result + ((version == null) ? 0 : version.hashCode());
+
return result;
}
@Override
public boolean equals(final Object obj) {
- if (obj instanceof ResourceArtifact) {
- final ResourceArtifact other = (ResourceArtifact) obj;
+ if (obj instanceof AssetInfo) {
+ final AssetInfo other = (AssetInfo) obj;
return ObjectUtils.nullSafeEquals(category, other.category)
&& ObjectUtils.nullSafeEquals(invariantUuid, other.invariantUuid)
&& ObjectUtils.nullSafeEquals(lastUpdaterUserId, other.lastUpdaterUserId)
&& ObjectUtils.nullSafeEquals(lifecycleState, other.lifecycleState)
&& ObjectUtils.nullSafeEquals(name, other.name)
&& ObjectUtils.nullSafeEquals(resourceType, other.resourceType)
- && ObjectUtils.nullSafeEquals(subCategory, other.subCategory)
&& ObjectUtils.nullSafeEquals(toscaModelUrl, other.toscaModelUrl)
&& ObjectUtils.nullSafeEquals(uuid, other.uuid)
&& ObjectUtils.nullSafeEquals(version, other.version);
+
}
return false;
}
@@ -229,15 +229,16 @@ public class ResourceArtifact implements Serializable {
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
- sb.append("class ResourceArtifact {\n");
+ sb.append("class AssetInfo {\n");
sb.append(" uuid: ").append(uuid).append("\n");
sb.append(" invariantUuid: ").append(invariantUuid).append("\n");
sb.append(" name: ").append(name).append("\n");
sb.append(" version: ").append(version).append("\n");
sb.append(" toscaModelUrl: ").append(toscaModelUrl).append("\n");
sb.append(" category: ").append(category).append("\n");
- sb.append(" subCategory: ").append(subCategory).append("\n");
+ sb.append(" lifecycleState: ").append(lifecycleState).append("\n");
sb.append(" lastUpdaterUserId: ").append(lastUpdaterUserId).append("\n");
+
sb.append("}");
return sb.toString();
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/AssetType.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/AssetType.java
new file mode 100644
index 00000000..749a714f
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/AssetType.java
@@ -0,0 +1,31 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.sdcsimulator.models;
+
+ /**
+ *
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public enum AssetType {
+
+ RESOURCES, SERVICES;
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/Metadata.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/Metadata.java
new file mode 100644
index 00000000..4836fc16
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/Metadata.java
@@ -0,0 +1,104 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.sdcsimulator.models;
+
+import java.util.HashSet;
+import java.util.Set;
+import org.springframework.util.ObjectUtils;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ *
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public class Metadata extends AssetInfo {
+
+ private static final long serialVersionUID = 2754071491333890698L;
+
+ @JsonProperty("resources")
+ private Set<Resource> resources = new HashSet<>();
+
+ @JsonProperty("artifacts")
+ private Set<Artifact> artifacts = new HashSet<>();
+
+
+ public Set<Resource> getResources() {
+ return resources;
+ }
+
+ public void setResources(final Set<Resource> resources) {
+ this.resources = resources;
+ }
+
+ public Metadata resources(final Set<Resource> resources) {
+ this.resources = resources;
+ return this;
+ }
+
+ public Set<Artifact> getArtifacts() {
+ return artifacts;
+ }
+
+ public void setArtifacts(final Set<Artifact> artifacts) {
+ this.artifacts = artifacts;
+ }
+
+ public Metadata artifacts(Set<Artifact> artifacts) {
+ this.artifacts = artifacts;
+ return this;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + super.hashCode();
+ result = prime * result + ((resources == null) ? 0 : resources.hashCode());
+ result = prime * result + ((artifacts == null) ? 0 : artifacts.hashCode());
+
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj instanceof Metadata) {
+ final Metadata other = (Metadata) obj;
+ return super.equals(obj) && ObjectUtils.nullSafeEquals(resources, other.resources)
+ && ObjectUtils.nullSafeEquals(artifacts, other.artifacts);
+
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append(super.toString());
+ sb.deleteCharAt(sb.length() - 1);
+ sb.append(" resources: ").append(resources).append("\n");
+ sb.append(" artifacts: ").append(artifacts).append("\n");
+
+ sb.append("}");
+ return sb.toString();
+ }
+
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/Resource.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/Resource.java
new file mode 100644
index 00000000..6eb3734b
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/Resource.java
@@ -0,0 +1,198 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.sdcsimulator.models;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+import org.springframework.util.ObjectUtils;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ *
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public class Resource implements Serializable {
+
+ private static final long serialVersionUID = -8014206400770867160L;
+
+ @JsonProperty("resourceInstanceName")
+ private String resourceInstanceName;
+
+ @JsonProperty("resourceName")
+ private String resourceName;
+
+ @JsonProperty("resourceInvariantUUID")
+ private String resourceInvariantUuid;
+
+ @JsonProperty("resourceVersion")
+ private String resourceVersion;
+
+ @JsonProperty("resoucreType")
+ private String resourceType;
+
+ @JsonProperty("resourceUUID")
+ private String resourceUuid;
+
+ @JsonProperty("artifacts")
+ private Set<Artifact> artifacts = new HashSet<>();
+
+ public String getResourceInstanceName() {
+ return resourceInstanceName;
+ }
+
+ public void setResourceInstanceName(final String resourceInstanceName) {
+ this.resourceInstanceName = resourceInstanceName;
+ }
+
+ public Resource resourceInstanceName(final String resourceInstanceName) {
+ this.resourceInstanceName = resourceInstanceName;
+ return this;
+ }
+
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ public void setResourceName(final String resourceName) {
+ this.resourceName = resourceName;
+ }
+
+ public Resource resourceName(final String resourceName) {
+ this.resourceName = resourceName;
+ return this;
+ }
+
+ public String getResourceInvariantUuid() {
+ return resourceInvariantUuid;
+ }
+
+ public void setResourceInvariantUuid(final String resourceInvariantUuid) {
+ this.resourceInvariantUuid = resourceInvariantUuid;
+ }
+
+ public Resource resourceInvariantUuid(final String resourceInvariantUuid) {
+ this.resourceInvariantUuid = resourceInvariantUuid;
+ return this;
+ }
+
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ public void setResourceVersion(final String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ public Resource resourceVersion(final String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ return this;
+ }
+
+ public String getResourceType() {
+ return resourceType;
+ }
+
+ public void setResourceType(final String resourceType) {
+ this.resourceType = resourceType;
+ }
+
+ public Resource resourceType(final String resourceType) {
+ this.resourceType = resourceType;
+ return this;
+ }
+
+ public String getResourceUuid() {
+ return resourceUuid;
+ }
+
+ public void setResourceUuid(final String resourceUuid) {
+ this.resourceUuid = resourceUuid;
+ }
+
+ public Resource resourceUUID(final String resourceUuid) {
+ this.resourceUuid = resourceUuid;
+ return this;
+ }
+
+ public Set<Artifact> getArtifacts() {
+ return artifacts;
+ }
+
+ public void setArtifacts(final Set<Artifact> artifacts) {
+ this.artifacts = artifacts;
+ }
+
+ public Resource artifacts(final Set<Artifact> artifacts) {
+ this.artifacts = artifacts;
+ return this;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((artifacts == null) ? 0 : artifacts.hashCode());
+ result = prime * result + ((resourceType == null) ? 0 : resourceType.hashCode());
+ result = prime * result + ((resourceInstanceName == null) ? 0 : resourceInstanceName.hashCode());
+ result = prime * result + ((resourceInvariantUuid == null) ? 0 : resourceInvariantUuid.hashCode());
+ result = prime * result + ((resourceName == null) ? 0 : resourceName.hashCode());
+ result = prime * result + ((resourceUuid == null) ? 0 : resourceUuid.hashCode());
+ result = prime * result + ((resourceVersion == null) ? 0 : resourceVersion.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj instanceof Resource) {
+ final Resource other = (Resource) obj;
+ return ObjectUtils.nullSafeEquals(resourceInstanceName, other.resourceInstanceName)
+ && ObjectUtils.nullSafeEquals(resourceName, other.resourceName)
+ && ObjectUtils.nullSafeEquals(resourceInvariantUuid, other.resourceInvariantUuid)
+ && ObjectUtils.nullSafeEquals(resourceVersion, other.resourceVersion)
+ && ObjectUtils.nullSafeEquals(resourceType, other.resourceType)
+ && ObjectUtils.nullSafeEquals(resourceUuid, other.resourceUuid)
+ && ObjectUtils.nullSafeEquals(artifacts, other.artifacts);
+ }
+ return false;
+
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("class Resource {\n");
+ sb.append(" resourceInstanceName: ").append(resourceInstanceName).append("\n");
+ sb.append(" resourceName: ").append(resourceName).append("\n");
+ sb.append(" resourceInvariantUuid: ").append(resourceInvariantUuid).append("\n");
+ sb.append(" resourceVersion: ").append(resourceVersion).append("\n");
+ sb.append(" resourceType: ").append(resourceType).append("\n");
+ sb.append(" resourceUuid: ").append(resourceUuid).append("\n");
+ sb.append(" artifacts: ").append(artifacts).append("\n");
+
+ sb.append("}");
+ return sb.toString();
+
+ }
+
+
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/ResourceAssetInfo.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/ResourceAssetInfo.java
new file mode 100644
index 00000000..352070a7
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/ResourceAssetInfo.java
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.sdcsimulator.models;
+
+import org.springframework.util.ObjectUtils;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ *
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public class ResourceAssetInfo extends AssetInfo {
+
+ private static final long serialVersionUID = -6812049917047990700L;
+
+ @JsonProperty("subCategory")
+ private String subCategory;
+
+ public String getSubCategory() {
+ return subCategory;
+ }
+
+ public void setSubCategory(final String subCategory) {
+ this.subCategory = subCategory;
+ }
+
+ public ResourceAssetInfo subCategory(final String subCategory) {
+ this.subCategory = subCategory;
+ return this;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + super.hashCode();
+ result = prime * result + ((subCategory == null) ? 0 : subCategory.hashCode());
+
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj instanceof ResourceAssetInfo) {
+ final ResourceAssetInfo other = (ResourceAssetInfo) obj;
+ return super.equals(obj) && ObjectUtils.nullSafeEquals(subCategory, other.subCategory);
+
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append(super.toString());
+ sb.deleteCharAt(sb.length() - 1);
+ sb.append(" subCategory: ").append(subCategory).append("\n");
+
+ sb.append("}");
+ return sb.toString();
+ }
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/ServiceAssetInfo.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/ServiceAssetInfo.java
new file mode 100644
index 00000000..f1fa2bc9
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/models/ServiceAssetInfo.java
@@ -0,0 +1,82 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.sdcsimulator.models;
+
+import org.springframework.util.ObjectUtils;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ *
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public class ServiceAssetInfo extends AssetInfo {
+
+ private static final long serialVersionUID = 1487426510731947767L;
+
+ @JsonProperty("distributionStatus")
+ private String distributionStatus;
+
+ public String getDistributionStatus() {
+ return distributionStatus;
+ }
+
+ public void setDistributionStatus(final String distributionStatus) {
+ this.distributionStatus = distributionStatus;
+ }
+
+ public ServiceAssetInfo distributionStatus(final String distributionStatus) {
+ this.distributionStatus = distributionStatus;
+ return this;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + super.hashCode();
+ result = prime * result + ((distributionStatus == null) ? 0 : distributionStatus.hashCode());
+
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (obj instanceof ServiceAssetInfo) {
+ final ServiceAssetInfo other = (ServiceAssetInfo) obj;
+ return super.equals(obj) && ObjectUtils.nullSafeEquals(distributionStatus, other.distributionStatus);
+
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append(super.toString());
+ sb.deleteCharAt(sb.length() - 1);
+ sb.append(" distributionStatus: ").append(distributionStatus).append("\n");
+
+ sb.append("}");
+ return sb.toString();
+ }
+
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/providers/ResourceProvider.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/providers/AssetProvider.java
index 48353a7c..3ea077d4 100644
--- a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/providers/ResourceProvider.java
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/providers/AssetProvider.java
@@ -22,15 +22,21 @@ package org.onap.so.sdcsimulator.providers;
import java.util.Optional;
import java.util.Set;
-import org.onap.so.sdcsimulator.models.ResourceArtifact;
+import org.onap.so.sdcsimulator.models.AssetInfo;
+import org.onap.so.sdcsimulator.models.AssetType;
+import org.onap.so.sdcsimulator.models.Metadata;
/**
* @author Eoin Hanan (eoin.hanan@est.tech)
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
*/
-public interface ResourceProvider {
+public interface AssetProvider {
- Optional<byte[]> getResource(final String csarId);
+ Optional<byte[]> getAsset(final String csarId, final AssetType assetType);
- Set<ResourceArtifact> getResource();
+ Set<AssetInfo> getAssetInfo(final AssetType assetType);
+
+ Optional<Metadata> getMetadata(final String csarId, final AssetType assetType);
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/providers/AssetProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/providers/AssetProviderImpl.java
new file mode 100644
index 00000000..d2614029
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/providers/AssetProviderImpl.java
@@ -0,0 +1,274 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.sdcsimulator.providers;
+
+import static org.onap.so.sdcsimulator.utils.Constants.CATALOG_URL;
+import static org.onap.so.sdcsimulator.utils.Constants.DOT_CSAR;
+import static org.onap.so.sdcsimulator.utils.Constants.DOT_JSON;
+import static org.onap.so.sdcsimulator.utils.Constants.FORWARD_SLASH;
+import static org.onap.so.sdcsimulator.utils.Constants.MAIN_RESOURCE_FOLDER;
+import static org.onap.so.sdcsimulator.utils.Constants.WILD_CARD_REGEX;
+import static org.springframework.core.io.support.ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.DirectoryStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashSet;
+import java.util.Optional;
+import java.util.Set;
+import org.onap.so.sdcsimulator.models.AssetInfo;
+import org.onap.so.sdcsimulator.models.AssetType;
+import org.onap.so.sdcsimulator.models.Metadata;
+import org.onap.so.sdcsimulator.models.ResourceAssetInfo;
+import org.onap.so.sdcsimulator.models.ServiceAssetInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.support.ResourcePatternResolver;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StreamUtils;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ */
+@Service
+public class AssetProviderImpl implements AssetProvider {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(AssetProvider.class);
+
+ private final ObjectMapper mapper =
+ new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);;
+
+ private final String resourceLocation;
+
+ private final ResourcePatternResolver resourcePatternResolver;
+
+ @Autowired
+ public AssetProviderImpl(@Value("${sdc.resource.location:/app/csars/}") final String resourceLocation,
+ final ResourcePatternResolver resourcePatternResolver) {
+ this.resourceLocation = resourceLocation;
+ this.resourcePatternResolver = resourcePatternResolver;
+ }
+
+ @Override
+ public Optional<byte[]> getAsset(final String csarId, final AssetType assetType) {
+ try {
+ final Optional<InputStream> optionalInputStream = getInputStream(csarId, assetType);
+ if (optionalInputStream.isPresent()) {
+ return Optional.of(StreamUtils.copyToByteArray(optionalInputStream.get()));
+ }
+ } catch (final IOException ioException) {
+ LOGGER.warn("Unable to create file stream ...", ioException);
+ }
+
+ return Optional.empty();
+ }
+
+ @Override
+ public Set<AssetInfo> getAssetInfo(final AssetType assetType) {
+ final Set<AssetInfo> result = new HashSet<>();
+
+ final Path dir = Paths.get(resourceLocation).resolve(assetType.toString());
+ if (Files.exists(dir)) {
+ try (final DirectoryStream<Path> stream = Files.newDirectoryStream(dir, WILD_CARD_REGEX + DOT_CSAR)) {
+ for (final Path entry : stream) {
+ final String filename = getFilenameWithoutExtension(entry);
+ result.add(getAssetInfo(assetType, filename, entry));
+ }
+ } catch (final IOException ioException) {
+ LOGGER.error("Unable to find assetInfo on filesystem", ioException);
+ }
+ }
+
+ try {
+ final String classPathdir = MAIN_RESOURCE_FOLDER + assetType.toString() + FORWARD_SLASH;
+ final String csarFileLocationPattern = CLASSPATH_ALL_URL_PREFIX + classPathdir + WILD_CARD_REGEX + DOT_CSAR;
+ final Resource[] resources = resourcePatternResolver.getResources(csarFileLocationPattern);
+ if (resources != null) {
+
+ for (final Resource resource : resources) {
+ final String filename = getFilenameWithoutExtension(resource.getFilename());
+ result.add(getAssetInfo(assetType, filename, resource));
+ }
+ }
+
+ } catch (final IOException ioException) {
+ LOGGER.error("Unable to find assetInfo in classpath", ioException);
+ }
+
+ return result;
+ }
+
+ @Override
+ public Optional<Metadata> getMetadata(final String csarId, final AssetType assetType) {
+ final Path dir = Paths.get(resourceLocation).resolve(assetType.toString());
+ final Path metadataFilePath = dir.resolve(csarId + DOT_JSON);
+ try {
+ if (Files.exists(metadataFilePath)) {
+ LOGGER.info("Found metadata file on file system using path: {}", metadataFilePath);
+
+ return Optional.of(mapper.readValue(metadataFilePath.toFile(), Metadata.class));
+
+ }
+ } catch (final IOException ioException) {
+ LOGGER.error("Unable to find metadata file on filesystem", ioException);
+ }
+
+
+ try {
+ final String path = MAIN_RESOURCE_FOLDER + assetType.toString() + FORWARD_SLASH + csarId + DOT_JSON;
+ LOGGER.warn("Couldn't find metadata file on file system '{}', will search it in classpath", path);
+ final ClassPathResource classPathResource = getClassPathResource(path);
+ if (classPathResource.exists()) {
+ LOGGER.info("Found metadata file in classpath using path: {}", path);
+ return Optional.of(mapper.readValue(classPathResource.getInputStream(), Metadata.class));
+ }
+ } catch (final IOException ioException) {
+ LOGGER.error("Unable to find metadata file in classpath", ioException);
+ }
+ LOGGER.error("Couldn't find metadata file in classpath ....");
+ return Optional.empty();
+ }
+
+ private AssetInfo getAssetInfo(final AssetType assetType, final String filename, final Resource resource)
+ throws IOException {
+ final Resource jsonResource = resource.createRelative(filename + DOT_JSON);
+
+ if (jsonResource != null && jsonResource.exists()) {
+ final AssetInfo assetInfo = getJsonAssetInfo(assetType, jsonResource);
+ assetInfo.setUuid(filename);
+ assetInfo.setToscaModelUrl(getToscaModelUrl(filename, assetType));
+ LOGGER.info("Found AssetInfo file in classpath: {}", assetInfo);
+ return assetInfo;
+
+ }
+
+ final AssetInfo assetInfo = getAssetInfo(filename, assetType);
+ LOGGER.info("Returning AssetInfo: {}", assetInfo);
+ return assetInfo;
+
+ }
+
+ private AssetInfo getAssetInfo(final AssetType assetType, final String filename, final Path entry)
+ throws IOException {
+ final Path assetJsonFilePath = entry.getParent().resolve(filename + DOT_JSON);
+ if (Files.exists(assetJsonFilePath)) {
+ final AssetInfo assetInfo = getJsonAssetInfo(assetType, assetJsonFilePath.toFile());
+ assetInfo.setUuid(filename);
+ assetInfo.setToscaModelUrl(getToscaModelUrl(filename, assetType));
+ LOGGER.info("Found AssetInfo file on file system: {}", assetInfo);
+ return assetInfo;
+
+ }
+ final AssetInfo assetInfo = getAssetInfo(filename, assetType);
+ LOGGER.info("Returning AssetInfo: {}", assetInfo);
+ return assetInfo;
+ }
+
+
+ private AssetInfo getJsonAssetInfo(final AssetType assetType, final Resource jsonResource) throws IOException {
+ if (AssetType.RESOURCES.equals(assetType)) {
+ return mapper.readValue(jsonResource.getInputStream(), ResourceAssetInfo.class);
+ }
+
+ if (AssetType.SERVICES.equals(assetType)) {
+ return mapper.readValue(jsonResource.getInputStream(), ServiceAssetInfo.class);
+ }
+
+ return mapper.readValue(jsonResource.getInputStream(), AssetInfo.class);
+ }
+
+
+ private AssetInfo getJsonAssetInfo(final AssetType assetType, final File file) throws IOException {
+ if (AssetType.RESOURCES.equals(assetType)) {
+ return mapper.readValue(file, ResourceAssetInfo.class);
+ }
+
+ if (AssetType.SERVICES.equals(assetType)) {
+ return mapper.readValue(file, ServiceAssetInfo.class);
+ }
+
+ return mapper.readValue(file, AssetInfo.class);
+ }
+
+ private AssetInfo getAssetInfo(final String filename, final AssetType assetType) {
+ return getAssetInfoObject(assetType).uuid(filename).invariantUuid(filename).name(filename).version("1.0")
+ .toscaModelUrl(getToscaModelUrl(filename, assetType)).category("Generic").lifecycleState("CERTIFIED")
+ .lastUpdaterUserId("SDC_SIMULATOR");
+ }
+
+ private AssetInfo getAssetInfoObject(final AssetType assetType) {
+ if (AssetType.RESOURCES.equals(assetType)) {
+ return new ResourceAssetInfo().subCategory("Network Service");
+ }
+
+ if (AssetType.SERVICES.equals(assetType)) {
+ return new ServiceAssetInfo().distributionStatus("DISTRIBUTED");
+ }
+
+ return new AssetInfo();
+ }
+
+ private String getToscaModelUrl(final String filename, final AssetType assetType) {
+ return CATALOG_URL + FORWARD_SLASH + assetType.toString().toLowerCase() + FORWARD_SLASH + filename
+ + "/toscaModel";
+ }
+
+ private String getFilenameWithoutExtension(final String filename) {
+ return filename.substring(0, filename.lastIndexOf('.'));
+ }
+
+ private String getFilenameWithoutExtension(final Path file) {
+ return getFilenameWithoutExtension(file.getFileName().toString());
+ }
+
+ private Optional<InputStream> getInputStream(final String csarId, final AssetType assetType) throws IOException {
+ final Path filePath = Paths.get(resourceLocation, csarId + DOT_CSAR);
+ if (Files.exists(filePath)) {
+ LOGGER.info("Found csar on file system using path: {}", filePath);
+ return Optional.of(Files.newInputStream(filePath));
+ }
+ LOGGER.warn("Couldn't find file on file system '{}', will search it in classpath", filePath);
+
+ final String path = MAIN_RESOURCE_FOLDER + assetType.toString() + FORWARD_SLASH + csarId + DOT_CSAR;
+ final ClassPathResource classPathResource = getClassPathResource(path);
+ if (classPathResource.exists()) {
+ LOGGER.info("Found csar in classpath using path: {}", path);
+ return Optional.of(classPathResource.getInputStream());
+ }
+
+ LOGGER.error("Couldn't find csar in classpath ....");
+ return Optional.empty();
+ }
+
+ private ClassPathResource getClassPathResource(final String path) {
+ return new ClassPathResource(path, this.getClass());
+ }
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/providers/ResourceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/providers/ResourceProviderImpl.java
deleted file mode 100644
index eacc9d5c..00000000
--- a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/providers/ResourceProviderImpl.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.sdcsimulator.providers;
-
-import static org.onap.so.sdcsimulator.utils.Constants.CATALOG_URL;
-import static org.onap.so.sdcsimulator.utils.Constants.DOT_CSAR;
-import static org.onap.so.sdcsimulator.utils.Constants.MAIN_RESOURCE_FOLDER;
-import static org.onap.so.sdcsimulator.utils.Constants.WILD_CARD_REGEX;
-import static org.springframework.core.io.support.ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.DirectoryStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.HashSet;
-import java.util.Optional;
-import java.util.Set;
-import org.onap.so.sdcsimulator.models.ResourceArtifact;
-import org.onap.so.sdcsimulator.utils.Constants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.support.ResourcePatternResolver;
-import org.springframework.stereotype.Service;
-import org.springframework.util.StreamUtils;
-
-/**
- * @author Eoin Hanan (eoin.hanan@est.tech)
- */
-@Service
-public class ResourceProviderImpl implements ResourceProvider {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ResourceProvider.class);
-
- private final String resourceLocation;
-
- private final ResourcePatternResolver resourcePatternResolver;
-
- @Autowired
- public ResourceProviderImpl(@Value("${sdc.resource.location:/app/csars/}") final String resourceLocation,
- final ResourcePatternResolver resourcePatternResolver) {
- this.resourceLocation = resourceLocation;
- this.resourcePatternResolver = resourcePatternResolver;
- }
-
- @Override
- public Optional<byte[]> getResource(final String csarId) {
- try {
- final Optional<InputStream> optionalInputStream = getInputStream(csarId);
- if (optionalInputStream.isPresent()) {
- return Optional.of(StreamUtils.copyToByteArray(optionalInputStream.get()));
- }
- } catch (final IOException ioException) {
- LOGGER.warn("Unable to create file stream ...", ioException);
- }
-
- return Optional.empty();
- }
-
- @Override
- public Set<ResourceArtifact> getResource() {
- final Set<ResourceArtifact> result = new HashSet<>();
-
- final Path dir = Paths.get(resourceLocation);
- if (Files.exists(dir)) {
- try (final DirectoryStream<Path> stream = Files.newDirectoryStream(dir, WILD_CARD_REGEX + DOT_CSAR)) {
- for (final Path entry : stream) {
- final String filename = getFilenameWithoutExtension(entry);
- final ResourceArtifact artifact = getResourceArtifact(filename);
- result.add(artifact);
- LOGGER.info("Found resource on file system: {}", artifact);
-
-
- }
- } catch (final IOException ioException) {
- LOGGER.error("Unable to find resources on filesystem", ioException);
- }
- }
-
- try {
- final String csarFileLocationPattern =
- CLASSPATH_ALL_URL_PREFIX + MAIN_RESOURCE_FOLDER + WILD_CARD_REGEX + DOT_CSAR;
- final Resource[] resources = resourcePatternResolver.getResources(csarFileLocationPattern);
- if (resources != null) {
-
- for (final Resource resource : resources) {
- final ResourceArtifact artifact =
- getResourceArtifact(getFilenameWithoutExtension(resource.getFilename()));
- result.add(artifact);
- LOGGER.info("Found resource in classpath: {}", artifact);
- }
- }
-
- } catch (final IOException ioException) {
- LOGGER.error("Unable to find resources in classpath", ioException);
- }
-
- return result;
- }
-
- private ResourceArtifact getResourceArtifact(final String filename) {
- return new ResourceArtifact().uuid(filename).invariantUuid(filename).name(filename).version("1.0")
- .toscaModelUrl(CATALOG_URL + "/resources/" + filename + "/toscaModel").category("Generic")
- .subCategory("Network Service").resourceType("VF").lifecycleState("CERTIFIED")
- .lastUpdaterUserId("SDC_SIMULATOR");
- }
-
- private String getFilenameWithoutExtension(final String filename) {
- return filename.substring(0, filename.lastIndexOf('.'));
- }
-
- private String getFilenameWithoutExtension(final Path file) {
- return getFilenameWithoutExtension(file.getFileName().toString());
- }
-
- private Optional<InputStream> getInputStream(final String csarId) throws IOException {
- final Path filePath = Paths.get(resourceLocation, csarId + DOT_CSAR);
- if (Files.exists(filePath)) {
- LOGGER.info("Found resource in on file system using path: {}", filePath);
- return Optional.of(Files.newInputStream(filePath));
- }
- LOGGER.warn("Couldn't find file on file system '{}', will search it in classpath", filePath);
-
- final String path = MAIN_RESOURCE_FOLDER + csarId + DOT_CSAR;
- ClassPathResource classPathResource = getClassPathResource(path);
- if (classPathResource.exists()) {
- LOGGER.info("Found resource in classpath using path: {}", path);
- return Optional.of(classPathResource.getInputStream());
- }
-
- LOGGER.warn("Couldn't find file on file system '{}', will return default csar", filePath);
- classPathResource = getClassPathResource(getDefaultCsarPath());
- if (classPathResource.exists()) {
- LOGGER.info("Found default csar in classpath");
- return Optional.of(classPathResource.getInputStream());
- }
-
- LOGGER.error("Couldn't find default csar in classpath ....");
- return Optional.empty();
- }
-
- private ClassPathResource getClassPathResource(final String path) {
- return new ClassPathResource(path, this.getClass());
- }
-
- /*
- * Used in test
- */
- String getDefaultCsarPath() {
- return Constants.DEFAULT_CSAR_PATH;
- }
-}
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/utils/Constants.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/utils/Constants.java
index 3ddb5bee..4822b4fc 100644
--- a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/utils/Constants.java
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdcsimulator/utils/Constants.java
@@ -33,17 +33,15 @@ public class Constants {
public static final String HEALTHY = "healthy";
- public static final String DEFAULT_CSAR_NAME = "default_csar_file";
-
public static final String DOT = ".";
public static final String WILD_CARD_REGEX = "*";
public static final String DOT_CSAR = DOT + "csar";
- public static final String DEFAULT_CSAR_NAME_WITH_EXT = DEFAULT_CSAR_NAME + DOT_CSAR;
+ public static final String DOT_JSON = DOT + "json";
- public static final String DEFAULT_CSAR_PATH = MAIN_RESOURCE_FOLDER + DEFAULT_CSAR_NAME_WITH_EXT;
+ public static final String FORWARD_SLASH = "/";
private Constants() {}
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/73522444-e8e9-49c1-be29-d355800aa349.csar b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/RESOURCES/73522444-e8e9-49c1-be29-d355800aa349.csar
index db8f12d8..db8f12d8 100644
--- a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/73522444-e8e9-49c1-be29-d355800aa349.csar
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/RESOURCES/73522444-e8e9-49c1-be29-d355800aa349.csar
Binary files differ
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/RESOURCES/73522444-e8e9-49c1-be29-d355800aa349.json b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/RESOURCES/73522444-e8e9-49c1-be29-d355800aa349.json
new file mode 100644
index 00000000..1ca1e7d4
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/RESOURCES/73522444-e8e9-49c1-be29-d355800aa349.json
@@ -0,0 +1,116 @@
+{
+ "uuid": "73522444-e8e9-49c1-be29-d355800aa349",
+ "invariantUUID": "037f7b1b-5c62-44c1-b806-f92fe8970171",
+ "name": "EtsiVnfCSIT3",
+ "version": "1.0",
+ "toscaModelURL": "/sdc/v1/catalog/resources/73522444-e8e9-49c1-be29-d355800aa349/toscaModel",
+ "category": "Generic",
+ "subCategory": "Network Service",
+ "resourceType": "VF",
+ "lifecycleState": "CERTIFIED",
+ "lastUpdaterUserId": "cs0008",
+ "lastUpdaterFullName": "Carlos Santana",
+ "toscaResourceName": "org.openecomp.resource.vf.Etsivnfcsit3",
+ "resources": [
+ {
+ "resourceInstanceName": "Cp_vgw_mux_gw_private_net",
+ "resourceName": "VDU Cp",
+ "resourceInvariantUUID": "3e4b8692-e6b1-44e9-90b1-6c5f1abf469c",
+ "resourceVersion": "1.0",
+ "resoucreType": "CP",
+ "resourceUUID": "72b9cd47-e8b7-4033-bb1a-fa30e45e3233"
+ },
+ {
+ "resourceInstanceName": "Cp_vgw_onap_private",
+ "resourceName": "VDU Cp",
+ "resourceInvariantUUID": "3e4b8692-e6b1-44e9-90b1-6c5f1abf469c",
+ "resourceVersion": "1.0",
+ "resoucreType": "CP",
+ "resourceUUID": "72b9cd47-e8b7-4033-bb1a-fa30e45e3233"
+ },
+ {
+ "resourceInstanceName": "LLU_VNF",
+ "resourceName": "VNF",
+ "resourceInvariantUUID": "a85aa428-cdb6-4e96-b873-0c20bfd22cac",
+ "resourceVersion": "1.0",
+ "resoucreType": "VFC",
+ "resourceUUID": "bbe67a58-6fd6-4849-abdf-f6a73dbdd594"
+ },
+ {
+ "resourceInstanceName": "VDU_vgw_0",
+ "resourceName": "VDU Compute",
+ "resourceInvariantUUID": "d211a1fd-ae0d-4b33-9076-76defafa7adc",
+ "resourceVersion": "1.0",
+ "resoucreType": "VFC",
+ "resourceUUID": "5dcd4cc9-2db5-49aa-a51a-a0eb4124df4c"
+ },
+ {
+ "resourceInstanceName": "VL_mux_gw_private_net",
+ "resourceName": "VnfVirtualLink",
+ "resourceInvariantUUID": "a9351632-8045-4422-bda6-fdbf4c472b2b",
+ "resourceVersion": "1.0",
+ "resoucreType": "VL",
+ "resourceUUID": "22ba6824-e467-4f6a-87df-ccc8bee01fe4"
+ },
+ {
+ "resourceInstanceName": "Cp_vgw_cpe_public",
+ "resourceName": "VDU Cp",
+ "resourceInvariantUUID": "3e4b8692-e6b1-44e9-90b1-6c5f1abf469c",
+ "resourceVersion": "1.0",
+ "resoucreType": "CP",
+ "resourceUUID": "72b9cd47-e8b7-4033-bb1a-fa30e45e3233"
+ },
+ {
+ "resourceInstanceName": "Cp_vgw_public",
+ "resourceName": "VDU Cp",
+ "resourceInvariantUUID": "3e4b8692-e6b1-44e9-90b1-6c5f1abf469c",
+ "resourceVersion": "1.0",
+ "resoucreType": "CP",
+ "resourceUUID": "72b9cd47-e8b7-4033-bb1a-fa30e45e3233"
+ },
+ {
+ "resourceInstanceName": "VL_cpe_public",
+ "resourceName": "VnfVirtualLink",
+ "resourceInvariantUUID": "a9351632-8045-4422-bda6-fdbf4c472b2b",
+ "resourceVersion": "1.0",
+ "resoucreType": "VL",
+ "resourceUUID": "22ba6824-e467-4f6a-87df-ccc8bee01fe4"
+ }
+ ],
+ "artifacts": [
+ {
+ "artifactName": "vf-license-model.xml",
+ "artifactType": "VF_LICENSE",
+ "artifactURL": "/sdc/v1/catalog/resources/73522444-e8e9-49c1-be29-d355800aa349/artifacts/3e964c48-c539-41b6-b504-52905fbe1f93",
+ "artifactDescription": "VF license file",
+ "artifactChecksum": "MDAwOTQ0NWYzNzMzYjJmYjBlODc2ODUyY2MzOTIyMjQ=",
+ "artifactUUID": "3e964c48-c539-41b6-b504-52905fbe1f93",
+ "artifactVersion": "1",
+ "artifactLabel": "vflicense",
+ "artifactGroupType": "DEPLOYMENT"
+ },
+ {
+ "artifactName": "vgw6.csar",
+ "artifactType": "ETSI_PACKAGE",
+ "artifactURL": "/sdc/v1/catalog/resources/73522444-e8e9-49c1-be29-d355800aa349/artifacts/0737049a-204d-4009-932a-57a48119f5eb",
+ "artifactDescription": "Artifact created from csar",
+ "artifactChecksum": "ZjAyYjhmYzJkY2ExZjMyYzk1ZjlmNjk0YzkzNDNhY2Y=",
+ "artifactUUID": "0737049a-204d-4009-932a-57a48119f5eb",
+ "artifactVersion": "1",
+ "artifactLabel": "vgw6csar",
+ "artifactGroupType": "DEPLOYMENT"
+ },
+ {
+ "artifactName": "vendor-license-model.xml",
+ "artifactType": "VENDOR_LICENSE",
+ "artifactURL": "/sdc/v1/catalog/resources/73522444-e8e9-49c1-be29-d355800aa349/artifacts/f17c8eed-cf1f-44cd-a2b3-2caee9c34b17",
+ "artifactDescription": " Vendor license file",
+ "artifactChecksum": "NzY2ZGUzODNkNWEwNjM1MjRiMjNiNDY1ZWNkNWQyOTg=",
+ "artifactUUID": "f17c8eed-cf1f-44cd-a2b3-2caee9c34b17",
+ "artifactVersion": "1",
+ "artifactLabel": "vendorlicense",
+ "artifactGroupType": "DEPLOYMENT"
+ }
+ ],
+ "description": "test"
+} \ No newline at end of file
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/ba1c0c0e-9fb8-4b83-97bb-5e9af1e73393.csar b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/SERVICES/9bb8c882-44a1-4b67-a12c-5a998e18d6ba.csar
index 4e0400fa..6504cb1a 100644
--- a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/ba1c0c0e-9fb8-4b83-97bb-5e9af1e73393.csar
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/SERVICES/9bb8c882-44a1-4b67-a12c-5a998e18d6ba.csar
Binary files differ
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/SERVICES/9bb8c882-44a1-4b67-a12c-5a998e18d6ba.json b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/SERVICES/9bb8c882-44a1-4b67-a12c-5a998e18d6ba.json
new file mode 100644
index 00000000..7c742382
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/SERVICES/9bb8c882-44a1-4b67-a12c-5a998e18d6ba.json
@@ -0,0 +1,62 @@
+{
+ "uuid": "9bb8c882-44a1-4b67-a12c-5a998e18d6ba",
+ "invariantUUID": "388a89d0-3d3d-47f8-8621-32b7b12975d4",
+ "name": "EtsiNsServiceCSIT1",
+ "version": "1.0",
+ "toscaModelURL": "/sdc/v1/catalog/services/9bb8c882-44a1-4b67-a12c-5a998e18d6ba/toscaModel",
+ "category": "ETSI Network Service",
+ "lifecycleState": "CERTIFIED",
+ "lastUpdaterUserId": "cs0008",
+ "distributionStatus": "DISTRIBUTED",
+ "lastUpdaterFullName": "Carlos Santana",
+ "resources": [{
+ "resourceInstanceName": "EtsiVnfCSIT3 0",
+ "resourceName": "EtsiVnfCSIT3",
+ "resourceInvariantUUID": "037f7b1b-5c62-44c1-b806-f92fe8970171",
+ "resourceVersion": "1.0",
+ "resoucreType": "VF",
+ "resourceUUID": "73522444-e8e9-49c1-be29-d355800aa349",
+ "artifacts": [{
+ "artifactName": "vf-license-model.xml",
+ "artifactType": "VF_LICENSE",
+ "artifactURL": "/sdc/v1/catalog/services/9bb8c882-44a1-4b67-a12c-5a998e18d6ba/resourceInstances/etsivnfcsit30/artifacts/3e964c48-c539-41b6-b504-52905fbe1f93",
+ "artifactDescription": "VF license file",
+ "artifactChecksum": "MDAwOTQ0NWYzNzMzYjJmYjBlODc2ODUyY2MzOTIyMjQ=",
+ "artifactUUID": "3e964c48-c539-41b6-b504-52905fbe1f93",
+ "artifactVersion": "1",
+ "artifactLabel": "vflicense",
+ "artifactGroupType": "DEPLOYMENT"
+ }, {
+ "artifactName": "vgw6.csar",
+ "artifactType": "ETSI_PACKAGE",
+ "artifactURL": "/sdc/v1/catalog/services/9bb8c882-44a1-4b67-a12c-5a998e18d6ba/resourceInstances/etsivnfcsit30/artifacts/0737049a-204d-4009-932a-57a48119f5eb",
+ "artifactDescription": "Artifact created from csar",
+ "artifactChecksum": "ZjAyYjhmYzJkY2ExZjMyYzk1ZjlmNjk0YzkzNDNhY2Y=",
+ "artifactUUID": "0737049a-204d-4009-932a-57a48119f5eb",
+ "artifactVersion": "1",
+ "artifactLabel": "vgw6csar",
+ "artifactGroupType": "DEPLOYMENT"
+ }, {
+ "artifactName": "vendor-license-model.xml",
+ "artifactType": "VENDOR_LICENSE",
+ "artifactURL": "/sdc/v1/catalog/services/9bb8c882-44a1-4b67-a12c-5a998e18d6ba/resourceInstances/etsivnfcsit30/artifacts/f17c8eed-cf1f-44cd-a2b3-2caee9c34b17",
+ "artifactDescription": " Vendor license file",
+ "artifactChecksum": "NzY2ZGUzODNkNWEwNjM1MjRiMjNiNDY1ZWNkNWQyOTg=",
+ "artifactUUID": "f17c8eed-cf1f-44cd-a2b3-2caee9c34b17",
+ "artifactVersion": "1",
+ "artifactLabel": "vendorlicense",
+ "artifactGroupType": "DEPLOYMENT"
+ }]
+ }],
+ "artifacts": [{
+ "artifactName": "ns.csar",
+ "artifactType": "OTHER",
+ "artifactURL": "/sdc/v1/catalog/services/9bb8c882-44a1-4b67-a12c-5a998e18d6ba/artifacts/a6b88549-cf1f-4c08-9088-c5e3067db1c9",
+ "artifactDescription": "ns",
+ "artifactChecksum": "ODBmYmU0MDRkZWIxNGVkY2NjODkxMGE4MmZlMTNmOGU=",
+ "artifactUUID": "a6b88549-cf1f-4c08-9088-c5e3067db1c9",
+ "artifactVersion": "1",
+ "artifactLabel": "ns",
+ "artifactGroupType": "DEPLOYMENT"
+ }]
+} \ No newline at end of file
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/default_csar_file.csar b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/default_csar_file.csar
deleted file mode 100644
index 63b70ec6..00000000
--- a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/csar/default_csar_file.csar
+++ /dev/null
Binary files differ
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdcsimulator/controller/CatalogControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdcsimulator/controller/CatalogControllerTest.java
index e63a7f90..d7ae74bb 100644
--- a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdcsimulator/controller/CatalogControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdcsimulator/controller/CatalogControllerTest.java
@@ -23,13 +23,13 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.Base64;
-import java.util.Optional;
import java.util.Set;
+import java.util.UUID;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Mockito;
-import org.onap.so.sdcsimulator.models.ResourceArtifact;
-import org.onap.so.sdcsimulator.providers.ResourceProvider;
+import org.onap.so.sdcsimulator.models.Metadata;
+import org.onap.so.sdcsimulator.models.ResourceAssetInfo;
+import org.onap.so.sdcsimulator.models.ServiceAssetInfo;
import org.onap.so.sdcsimulator.utils.Constants;
import org.onap.so.simulator.model.UserCredentials;
import org.springframework.beans.factory.annotation.Autowired;
@@ -58,6 +58,10 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@Configuration
public class CatalogControllerTest {
+ private static final String SERVICE_ID = "9bb8c882-44a1-4b67-a12c-5a998e18d6ba";
+
+ private static final String RESOURCE_ID = "73522444-e8e9-49c1-be29-d355800aa349";
+
private static final String PASSWORD = "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U";
@LocalServerPort
@@ -72,42 +76,90 @@ public class CatalogControllerTest {
@Test
public void test_getCsar_validCsarId_matchContent() {
- final String url = getBaseUrl() + "/resources/" + Constants.DEFAULT_CSAR_NAME + "/toscaModel";
+ final String url = getBaseUrl() + "/resources/" + RESOURCE_ID + "/toscaModel";
final ResponseEntity<byte[]> response =
restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(getHttpHeaders()), byte[].class);
assertEquals(HttpStatus.OK, response.getStatusCode());
assertTrue(response.hasBody());
- assertEquals(3982, response.getBody().length);
+ assertEquals(117247, response.getBody().length);
}
@Test
public void test_getResources_validResourcesFromClassPath() {
- final ResponseEntity<Set<ResourceArtifact>> response =
+ final ResponseEntity<Set<ResourceAssetInfo>> response =
restTemplate.exchange(getBaseUrl() + "/resources", HttpMethod.GET, new HttpEntity<>(getHttpHeaders()),
- new ParameterizedTypeReference<Set<ResourceArtifact>>() {});
+ new ParameterizedTypeReference<Set<ResourceAssetInfo>>() {});
assertEquals(HttpStatus.OK, response.getStatusCode());
assertTrue(response.hasBody());
- assertEquals(3, response.getBody().size());
+ assertEquals(1, response.getBody().size());
}
@Test
- public void test_getCsar_invalidCsar_internalServerError() {
- final ResourceProvider mockedResourceProvider = Mockito.mock(ResourceProvider.class);
- Mockito.when(mockedResourceProvider.getResource(Mockito.anyString())).thenReturn(Optional.empty());
- final CatalogController objUnderTest = new CatalogController(mockedResourceProvider);
+ public void test_getServices_validServicesFromClassPath() {
+
+ final ResponseEntity<Set<ServiceAssetInfo>> response =
+ restTemplate.exchange(getBaseUrl() + "/services", HttpMethod.GET, new HttpEntity<>(getHttpHeaders()),
+ new ParameterizedTypeReference<Set<ServiceAssetInfo>>() {});
+
+ assertEquals(HttpStatus.OK, response.getStatusCode());
+ assertTrue(response.hasBody());
+ assertEquals(1, response.getBody().size());
+
+ }
+
+ @Test
+ public void test_getResourceCsar_invalidCsar_internalServerError() {
+ final String url = getBaseUrl() + "/resources/" + UUID.randomUUID().toString() + "/toscaModel";
+
+ final ResponseEntity<byte[]> response =
+ restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(getHttpHeaders()), byte[].class);
- final ResponseEntity<byte[]> response = objUnderTest.getCsar(Constants.DEFAULT_CSAR_NAME);
assertFalse(response.hasBody());
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode());
}
+ @Test
+ public void test_getResourceMetadata_validMetadataFileInClasspath_matchContent() {
+
+ final String url = getBaseUrl() + "/resources/" + RESOURCE_ID + "/metadata";
+
+ final ResponseEntity<Metadata> response =
+ restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(getHttpHeaders()), Metadata.class);
+
+
+ assertEquals(HttpStatus.OK, response.getStatusCode());
+ assertTrue(response.hasBody());
+ final Metadata actual = response.getBody();
+ assertEquals(8, actual.getResources().size());
+ assertEquals(3, actual.getArtifacts().size());
+
+ }
+
+ @Test
+ public void test_getServiceMetadata_validMetadataFileInClasspath_matchContent() {
+
+ final String url = getBaseUrl() + "/services/" + SERVICE_ID + "/metadata";
+
+ final ResponseEntity<Metadata> response =
+ restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(getHttpHeaders()), Metadata.class);
+
+
+ assertEquals(HttpStatus.OK, response.getStatusCode());
+ assertTrue(response.hasBody());
+ final Metadata actual = response.getBody();
+ assertEquals(1, actual.getResources().size());
+ assertEquals(1, actual.getArtifacts().size());
+
+ }
+
+
private String getBaseUrl() {
return "http://localhost:" + port + Constants.CATALOG_URL;
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdcsimulator/providers/ResourceProviderImplTest.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdcsimulator/providers/AssetProviderImplTest.java
index c132184c..293d70d2 100644
--- a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdcsimulator/providers/ResourceProviderImplTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdcsimulator/providers/AssetProviderImplTest.java
@@ -22,6 +22,10 @@ package org.onap.so.sdcsimulator.providers;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertFalse;
+import static org.onap.so.sdcsimulator.models.AssetType.RESOURCES;
+import static org.onap.so.sdcsimulator.utils.Constants.DOT_CSAR;
+import static org.onap.so.sdcsimulator.utils.Constants.FORWARD_SLASH;
+import static org.onap.so.sdcsimulator.utils.Constants.MAIN_RESOURCE_FOLDER;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
@@ -30,7 +34,6 @@ import java.util.UUID;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
-import org.onap.so.sdcsimulator.utils.Constants;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.util.StreamUtils;
@@ -39,7 +42,9 @@ import org.springframework.util.StreamUtils;
* @author Waqas Ikram (waqas.ikram@est.tech)
* @author Eoin Hanan (eoin.hanan@est.tech)
*/
-public class ResourceProviderImplTest {
+public class AssetProviderImplTest {
+
+ private static final String VNF_RESOURCE_ID = "73522444-e8e9-49c1-be29-d355800aa349";
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@@ -51,38 +56,34 @@ public class ResourceProviderImplTest {
@Test
public void test_getResource_withValidPath_matchContent() throws IOException {
- final File folder = temporaryFolder.newFolder();
+ final File folder = temporaryFolder.newFolder(RESOURCES.toString());
final String uuid = UUID.randomUUID().toString();
- final Path file = Files.createFile(folder.toPath().resolve(uuid + Constants.DOT_CSAR));
+ final Path file = Files.createFile(folder.toPath().resolve(uuid + DOT_CSAR));
Files.write(file, DUMMY_CONTENT.getBytes());
- final ResourceProviderImpl objUnderTest = new ResourceProviderImpl(folder.getPath(), resourcePatternResolver);
+ final AssetProviderImpl objUnderTest = new AssetProviderImpl(folder.getPath(), resourcePatternResolver);
- assertArrayEquals(DUMMY_CONTENT.getBytes(), objUnderTest.getResource(uuid).get());
+ assertArrayEquals(DUMMY_CONTENT.getBytes(), objUnderTest.getAsset(uuid, RESOURCES).get());
}
@Test
public void test_getResource_withoutValidPath_matchContent() throws IOException {
- final ClassPathResource classPathResource = new ClassPathResource(Constants.DEFAULT_CSAR_PATH, this.getClass());
+ final String validCsarPath = MAIN_RESOURCE_FOLDER + RESOURCES + FORWARD_SLASH + VNF_RESOURCE_ID + DOT_CSAR;
+ final ClassPathResource classPathResource = new ClassPathResource(validCsarPath, this.getClass());
final byte[] expectedResult = StreamUtils.copyToByteArray(classPathResource.getInputStream());
- final ResourceProviderImpl objUnderTest = new ResourceProviderImpl("", resourcePatternResolver);
+ final AssetProviderImpl objUnderTest = new AssetProviderImpl("", resourcePatternResolver);
- assertArrayEquals(expectedResult, objUnderTest.getResource(Constants.DEFAULT_CSAR_NAME).get());
+ assertArrayEquals(expectedResult, objUnderTest.getAsset(VNF_RESOURCE_ID, RESOURCES).get());
}
@Test
public void test_getResource_unbleToReadFileFromClasspath_emptyOptional() throws IOException {
- final ResourceProviderImpl objUnderTest = new ResourceProviderImpl("", resourcePatternResolver) {
- @Override
- String getDefaultCsarPath() {
- return "/some/dummy/path";
- }
- };
- assertFalse(objUnderTest.getResource(UUID.randomUUID().toString()).isPresent());
+ final AssetProviderImpl objUnderTest = new AssetProviderImpl("", resourcePatternResolver);
+ assertFalse(objUnderTest.getAsset(UUID.randomUUID().toString(), RESOURCES).isPresent());
}
}