diff options
Diffstat (limited to 'adapters')
19 files changed, 506 insertions, 424 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntry.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntry.java index 8cacf8526a..47ba076e0e 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntry.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntry.java @@ -132,14 +132,14 @@ public class MsoHeatEnvironmentEntry { } public boolean hasResources() { - if (this.resources != null && this.resources.size() > 0) { + if (this.resources != null && !this.resources.isEmpty()) { return true; } return false; } public boolean hasParameters() { - if (this.parameters != null && this.parameters.size() > 0) { + if (this.parameters != null && !this.parameters.isEmpty()) { return true; } return false; @@ -147,7 +147,7 @@ public class MsoHeatEnvironmentEntry { public boolean containsParameter(String paramName) { boolean contains = false; - if (this.parameters == null || this.parameters.size() < 1) { + if (this.parameters == null || this.parameters.isEmpty()) { return false; } if (this.parameters.contains(new MsoHeatEnvironmentParameter(paramName))) { @@ -246,22 +246,4 @@ public class MsoHeatEnvironmentEntry { sb.append(this.rawEntry.substring(indexOf)); return sb; } - - public void setHPAParameters(StringBuilder hpasb) { - try { - MsoYamlEditorWithEnvt yaml = new MsoYamlEditorWithEnvt(hpasb.toString().getBytes()); - Set<MsoHeatEnvironmentParameter> hpaParams = yaml.getParameterListFromEnvt(); - for (MsoHeatEnvironmentParameter hpaparam : hpaParams) { - for (MsoHeatEnvironmentParameter param : this.parameters) { - if (param.getName() == hpaparam.getName()) { - param.setValue(hpaparam.getValue()); - } - } - } - } catch (Exception e) { - logger.debug("Exception:", e); - this.errorString = e.getMessage(); - // e.printStackTrace(); - } - } } diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java index 49ba336e3f..c75aa9a67e 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java @@ -22,10 +22,6 @@ package org.onap.so.openstack.utils; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.woorea.openstack.heat.model.CreateStackParam; -import com.woorea.openstack.heat.model.Stack; import java.net.MalformedURLException; import java.net.URL; import java.util.HashMap; @@ -52,7 +48,6 @@ import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.HeatStatus; import org.onap.so.openstack.beans.StackInfo; import org.onap.so.openstack.exceptions.MsoAdapterException; -import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; import org.onap.so.openstack.exceptions.MsoException; import org.onap.so.openstack.exceptions.MsoOpenstackException; import org.onap.so.openstack.mappers.StackInfoMapper; @@ -62,7 +57,11 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableSet; +import com.woorea.openstack.heat.model.CreateStackParam; +import com.woorea.openstack.heat.model.Stack; @Component public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { @@ -299,7 +298,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { responseBody = getQueryBody((java.io.InputStream) response.getEntity()); if (responseBody != null) { if (logger.isDebugEnabled()) { - logger.debug("Multicloud Create Response Body: " + responseBody.toString()); + logger.debug("Multicloud Create Response Body: {}", responseBody); } Stack workloadStack = getWorkloadStack(responseBody.getWorkloadStatusReason()); if (workloadStack != null && !responseBody.getWorkloadStatus().equals("GET_FAILED") @@ -354,7 +353,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { } } if (workloadStack != null) - logger.debug("Multicloud getWorkloadStack() returning Stack Object: {} ", workloadStack.toString()); + logger.debug("Multicloud getWorkloadStack() returning Stack Object: {} ", workloadStack); return workloadStack; } @@ -457,8 +456,8 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { Response response = multicloudClient.post(multicloudRequest); if (response.getStatus() != Response.Status.ACCEPTED.getStatusCode()) { if (logger.isDebugEnabled()) - logger.debug( - "Multicloud AAI update request failed: " + response.getStatus() + response.getStatusInfo()); + logger.debug("Multicloud AAI update request failed: {} {}", response.getStatus(), + response.getStatusInfo()); return; } @@ -470,14 +469,14 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { Integer.parseInt(this.environment.getProperty(createPollIntervalProp, CREATE_POLL_INTERVAL_DEFAULT)); int pollTimeout = (timeoutMinutes * 60) + updatePollInterval; boolean updateTimedOut = false; - logger.debug("updatePollInterval=" + updatePollInterval + ", pollTimeout=" + pollTimeout); + logger.debug("updatePollInterval={}, pollTimeout={}", updatePollInterval, pollTimeout); StackInfo stackInfo = null; while (true) { try { stackInfo = queryStack(cloudSiteId, cloudOwner, tenantId, workloadId); if (logger.isDebugEnabled()) - logger.debug(stackInfo.getStatus() + " (" + workloadId + ")"); + logger.debug("{} ({})", stackInfo.getStatus(), workloadId); if (HeatStatus.UPDATING.equals(stackInfo.getStatus())) { if (pollTimeout <= 0) { @@ -494,7 +493,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { pollTimeout -= updatePollInterval; if (logger.isDebugEnabled()) - logger.debug("pollTimeout remaining: " + pollTimeout); + logger.debug("pollTimeout remaining: {}", pollTimeout); } else { break; } @@ -508,15 +507,14 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { if (updateTimedOut) { if (logger.isDebugEnabled()) logger.debug("Multicloud AAI update request failed: {} {}", response.getStatus(), - response.getStatusInfo().toString()); + response.getStatusInfo()); } else if (!HeatStatus.UPDATED.equals(stackInfo.getStatus())) { if (logger.isDebugEnabled()) logger.debug("Multicloud AAI update request failed: {} {}", response.getStatus(), - response.getStatusInfo().toString()); + response.getStatusInfo()); } else { if (logger.isDebugEnabled()) - logger.debug("Multicloud AAI update successful: {} {}", response.getStatus(), - response.getStatusInfo().toString()); + logger.debug("Multicloud AAI update successful: {} {}", response.getStatus(), response.getStatusInfo()); } } @@ -543,12 +541,12 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { int deletePollTimeout = pollTimeout; boolean createTimedOut = false; StringBuilder stackErrorStatusReason = new StringBuilder(""); - logger.debug("createPollInterval=" + createPollInterval + ", pollTimeout=" + pollTimeout); + logger.debug("createPollInterval={}, pollTimeout={} ", createPollInterval, pollTimeout); while (true) { try { stackInfo = queryStack(cloudSiteId, cloudOwner, tenantId, instanceId); - logger.debug(stackInfo.getStatus() + " (" + instanceId + ")"); + logger.debug("{} ({})", stackInfo.getStatus(), instanceId); if (HeatStatus.BUILDING.equals(stackInfo.getStatus())) { // Stack creation is still running. @@ -567,7 +565,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { sleep(createPollInterval * 1000L); pollTimeout -= createPollInterval; - logger.debug("pollTimeout remaining: " + pollTimeout); + logger.debug("pollTimeout remaining: {}", pollTimeout); } else { // save off the status & reason msg before we attempt delete stackErrorStatusReason @@ -596,7 +594,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { while (!deleted) { try { StackInfo queryInfo = queryStack(cloudSiteId, cloudOwner, tenantId, instanceId); - logger.debug("Deleting " + instanceId + ", status: " + queryInfo.getStatus()); + logger.debug("Deleting {}, status: {}", instanceId, queryInfo.getStatus()); if (HeatStatus.DELETING.equals(queryInfo.getStatus())) { if (deletePollTimeout <= 0) { logger.error(String.format("%s %s %s %s %s %s %s %s %d %s", @@ -610,7 +608,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { deletePollTimeout -= deletePollInterval; } } else if (HeatStatus.NOTFOUND.equals(queryInfo.getStatus())) { - logger.debug("DELETE_COMPLETE for " + instanceId); + logger.debug("DELETE_COMPLETE for {}", instanceId); deleted = true; continue; } else { @@ -664,7 +662,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { while (!deleted) { try { StackInfo queryInfo = queryStack(cloudSiteId, cloudOwner, tenantId, instanceId); - logger.debug("Deleting " + instanceId + ", status: " + queryInfo.getStatus()); + logger.debug("Deleting {}, status: {}", instanceId, queryInfo.getStatus()); if (HeatStatus.DELETING.equals(queryInfo.getStatus())) { if (deletePollTimeout <= 0) { logger.error(String.format("%s %s %s %s %s %s %s %s %d %s", @@ -678,7 +676,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { deletePollTimeout -= deletePollInterval; } } else if (HeatStatus.NOTFOUND.equals(queryInfo.getStatus())) { - logger.debug("DELETE_COMPLETE for " + instanceId); + logger.debug("DELETE_COMPLETE for {}", instanceId); deleted = true; continue; } else { @@ -730,7 +728,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { } else { // Get initial status, since it will have been null after the create. stackInfo = queryStack(cloudSiteId, cloudOwner, tenantId, instanceId); - logger.debug("Multicloud stack query status is: " + stackInfo.getStatus()); + logger.debug("Multicloud stack query status is: {}", stackInfo.getStatus()); } return stackInfo; } @@ -769,7 +767,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { try { return new ObjectMapper().readerFor(MulticloudCreateResponse.class).readValue(body); } catch (Exception e) { - logger.debug("Exception retrieving multicloud vfModule POST response body " + e); + logger.debug("Exception retrieving multicloud vfModule POST response body ", e); } return null; } @@ -786,7 +784,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { try { return new ObjectMapper().readerFor(MulticloudQueryResponse.class).readValue(body); } catch (Exception e) { - logger.debug("Exception retrieving multicloud workload query response body " + e); + logger.debug("Exception retrieving multicloud workload query response body ", e); } return null; } @@ -828,14 +826,11 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { client.addAdditionalHeader("Project", tenantId); } } catch (MalformedURLException e) { - logger.debug( - String.format("Encountered malformed URL error getting multicloud rest client %s", e.getMessage())); + logger.debug("Encountered malformed URL error getting multicloud rest client ", e); } catch (IllegalArgumentException e) { - logger.debug( - String.format("Encountered illegal argument getting multicloud rest client %s", e.getMessage())); + logger.debug("Encountered illegal argument getting multicloud rest client ", e); } catch (UriBuilderException e) { - logger.debug( - String.format("Encountered URI builder error getting multicloud rest client %s", e.getMessage())); + logger.debug("Encountered URI builder error getting multicloud rest client ", e); } return client; } @@ -989,7 +984,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin { // There are lots of HeatStatus values, so this is a bit long... HeatStatus heatStatus = stackInfo.getStatus(); String statusMessage = stackInfo.getStatusMessage(); - logger.debug("HeatStatus = " + heatStatus + " msg = " + statusMessage); + logger.debug("HeatStatus = {} msg = {}", heatStatus, statusMessage); if (logger.isDebugEnabled()) { logger.debug(String.format("Stack Status: %s", heatStatus.toString())); diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java index 069c6c7c5b..44fc620b07 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java @@ -130,13 +130,13 @@ public class MsoNeutronUtils extends MsoCommonUtils { network.setAdminStateUp(true); if (type == NetworkType.PROVIDER) { - if (provider != null && vlans != null && vlans.size() > 0) { + if (provider != null && vlans != null && !vlans.isEmpty()) { network.setProviderPhysicalNetwork(provider); network.setProviderNetworkType("vlan"); network.setProviderSegmentationId(vlans.get(0)); } } else if (type == NetworkType.MULTI_PROVIDER) { - if (provider != null && vlans != null && vlans.size() > 0) { + if (provider != null && vlans != null && !vlans.isEmpty()) { List<Segment> segments = new ArrayList<>(vlans.size()); for (int vlan : vlans) { Segment segment = new Segment(); diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java index ad37b39f30..c575304ade 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java @@ -40,7 +40,7 @@ public class MulticloudQueryResponse implements Serializable { @JsonProperty("workload_status") private String workloadStatus; @JsonProperty("workload_status_reason") - private JsonNode workloadStatusReason; + private transient JsonNode workloadStatusReason; @JsonCreator public MulticloudQueryResponse(@JsonProperty("template_type") String templateType, diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java index 79aad1ad1a..b43447f5c4 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/JerseyConfiguration.java @@ -25,6 +25,7 @@ import javax.ws.rs.ApplicationPath; import org.glassfish.jersey.server.ResourceConfig; import org.onap.so.adapters.catalogdb.rest.CatalogDbAdapterRest; import org.onap.so.adapters.catalogdb.rest.ServiceRestImpl; +import org.onap.so.adapters.catalogdb.rest.VnfRestImpl; import org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging; import org.springframework.context.annotation.Configuration; import io.swagger.jaxrs.config.BeanConfig; @@ -42,6 +43,7 @@ public class JerseyConfiguration extends ResourceConfig { register(SwaggerSerializers.class); register(JaxRsFilterLogging.class); register(ServiceRestImpl.class); + register(VnfRestImpl.class); BeanConfig beanConfig = new BeanConfig(); beanConfig.setVersion("1.0.2"); beanConfig.setSchemes(new String[] {"https"}); diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogEntityNotFoundException.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogEntityNotFoundException.java new file mode 100644 index 0000000000..f8a7ba6da4 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogEntityNotFoundException.java @@ -0,0 +1,14 @@ +package org.onap.so.adapters.catalogdb.rest; + +public class CatalogEntityNotFoundException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = -300157844846680791L; + + public CatalogEntityNotFoundException(String errorMessage) { + super(errorMessage); + } + +} diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogEntityNotFoundExceptionMapper.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogEntityNotFoundExceptionMapper.java new file mode 100644 index 0000000000..c42eaabea7 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogEntityNotFoundExceptionMapper.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.catalogdb.rest; + +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; +import javax.ws.rs.ext.Provider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@Provider +public class CatalogEntityNotFoundExceptionMapper implements ExceptionMapper<CatalogEntityNotFoundException> { + + private static final Logger logger = LoggerFactory.getLogger(CatalogEntityNotFoundExceptionMapper.class); + + @Override + public Response toResponse(CatalogEntityNotFoundException e) { + return Response.status(Response.Status.NOT_FOUND).entity(e).build(); + } +} diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceMapper.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceMapper.java index dd18767762..e74663dbba 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceMapper.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceMapper.java @@ -22,9 +22,11 @@ package org.onap.so.adapters.catalogdb.rest; import java.util.ArrayList; import java.util.List; +import org.onap.so.db.catalog.beans.CvnfcCustomization; import org.onap.so.db.catalog.beans.HeatEnvironment; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; +import org.onap.so.rest.catalog.beans.Cvnfc; import org.onap.so.rest.catalog.beans.Service; import org.onap.so.rest.catalog.beans.VfModule; import org.onap.so.rest.catalog.beans.Vnf; @@ -39,16 +41,23 @@ public class ServiceMapper { public Service mapService(org.onap.so.db.catalog.beans.Service service, int depth) { Service restService = new Service(); - restService.setCategory(service.getCategory()); + if (service.getCategory() != null) { + restService.setCategory(service.getCategory()); + } restService.setCreated(service.getCreated()); restService.setDescription(service.getDescription()); - restService.setDistrobutionStatus(service.getDistrobutionStatus()); + + if (service.getDistrobutionStatus() != null) { + restService.setDistrobutionStatus(service.getDistrobutionStatus()); + } restService.setEnvironmentContext(service.getEnvironmentContext()); restService.setModelInvariantId(service.getModelInvariantUUID()); restService.setModelName(service.getModelName()); restService.setModelVersionId(service.getModelUUID()); restService.setModelVersion(service.getModelVersion()); - restService.setServiceRole(service.getServiceRole()); + if (service.getServiceRole() != null) { + restService.setServiceRole(service.getServiceRole()); + } restService.setServiceType(service.getServiceType()); restService.setWorkloadContext(service.getWorkloadContext()); if (depth > 0) @@ -63,7 +72,7 @@ public class ServiceMapper { return vnfs; } - private Vnf mapVnf(org.onap.so.db.catalog.beans.VnfResourceCustomization vnfResourceCustomization, int depth) { + protected Vnf mapVnf(org.onap.so.db.catalog.beans.VnfResourceCustomization vnfResourceCustomization, int depth) { Vnf vnf = new Vnf(); vnf.setAvailabilityZoneMaxCount(vnfResourceCustomization.getAvailabilityZoneMaxCount()); vnf.setCategory(vnfResourceCustomization.getVnfResources().getCategory()); @@ -81,9 +90,12 @@ public class ServiceMapper { vnf.setNfFunction(vnfResourceCustomization.getNfFunction()); vnf.setNfNamingCode(vnfResourceCustomization.getNfNamingCode()); vnf.setNfRole(vnfResourceCustomization.getNfRole()); + vnf.setNfType(vnfResourceCustomization.getNfType()); + vnf.setNfDataValid(vnfResourceCustomization.getNfDataValid()); vnf.setOrchestrationMode(vnfResourceCustomization.getVnfResources().getOrchestrationMode()); vnf.setSubCategory(vnfResourceCustomization.getVnfResources().getSubCategory()); vnf.setToscaNodeType(vnfResourceCustomization.getVnfResources().getToscaNodeType()); + if (depth > 1) { vnf.setVfModule(mapVfModules(vnfResourceCustomization, depth)); } @@ -93,11 +105,11 @@ public class ServiceMapper { private List<VfModule> mapVfModules(VnfResourceCustomization vnfResourceCustomization, int depth) { List<VfModule> vfModules = new ArrayList<>(); vnfResourceCustomization.getVfModuleCustomizations().parallelStream() - .forEach(vfModule -> vfModules.add(mapVfModule(vfModule))); + .forEach(vfModule -> vfModules.add(mapVfModule(vfModule, depth))); return vfModules; } - private VfModule mapVfModule(VfModuleCustomization vfModuleCust) { + private VfModule mapVfModule(VfModuleCustomization vfModuleCust, int depth) { VfModule vfModule = new VfModule(); vfModule.setAvailabilityZoneCount(vfModuleCust.getAvailabilityZoneCount()); vfModule.setCreated(vfModuleCust.getCreated()); @@ -113,9 +125,34 @@ public class ServiceMapper { vfModule.setModelName(vfModuleCust.getVfModule().getModelName()); vfModule.setModelVersionId(vfModuleCust.getVfModule().getModelUUID()); vfModule.setModelVersion(vfModuleCust.getVfModule().getModelVersion()); + if (depth > 3) { + vfModule.setVnfc(mapCvnfcs(vfModuleCust)); + } return vfModule; } + private List<Cvnfc> mapCvnfcs(VfModuleCustomization vfModuleCustomization) { + List<Cvnfc> cvnfcs = new ArrayList<>(); + vfModuleCustomization.getCvnfcCustomization().parallelStream() + .forEach(cvnfcCust -> cvnfcs.add(mapCvnfcCus(cvnfcCust))); + return cvnfcs; + } + + private Cvnfc mapCvnfcCus(CvnfcCustomization cvnfcCust) { + Cvnfc cvnfc = new Cvnfc(); + cvnfc.setCreated(cvnfcCust.getCreated()); + cvnfc.setDescription(cvnfcCust.getDescription()); + cvnfc.setModelCustomizationId(cvnfcCust.getModelCustomizationUUID()); + cvnfc.setModelInstanceName(cvnfcCust.getModelInstanceName()); + cvnfc.setModelInvariantId(cvnfcCust.getModelInvariantUUID()); + cvnfc.setModelName(cvnfcCust.getModelName()); + cvnfc.setModelVersion(cvnfcCust.getModelVersion()); + cvnfc.setModelVersionId(cvnfcCust.getModelUUID()); + cvnfc.setNfcFunction(cvnfcCust.getNfcFunction()); + cvnfc.setNfcNamingCode(cvnfcCust.getNfcNamingCode()); + return cvnfc; + } + private boolean getIsVolumeGroup(VfModuleCustomization vfModuleCust) { boolean isVolumeGroup = false; HeatEnvironment envt = vfModuleCust.getVolumeHeatEnv(); diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceRestImpl.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceRestImpl.java index 520de4d38c..6f556edfa1 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceRestImpl.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/ServiceRestImpl.java @@ -38,7 +38,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; -@Api(value = "/v1/services", tags = "model") +@Api(value = "/v1", tags = "model") @Path("/v1/services") @Component public class ServiceRestImpl { @@ -49,18 +49,21 @@ public class ServiceRestImpl { @Autowired private ServiceMapper serviceMapper; + @GET @Path("/{modelUUID}") @Produces({MediaType.APPLICATION_JSON}) @Transactional(readOnly = true) public Service findService(@PathParam("modelUUID") String modelUUID, @QueryParam("depth") int depth) { org.onap.so.db.catalog.beans.Service service = serviceRepo.findOneByModelUUID(modelUUID); + if (service == null) { + new CatalogEntityNotFoundException("Unable to find Service " + modelUUID); + } return serviceMapper.mapService(service, depth); } @GET - @ApiOperation(value = "Find Service Models", response = Service.class, responseContainer = "List", - notes = "If no query parameters are sent an empty list will be returned") + @ApiOperation(value = "Find Service Models", response = Service.class, responseContainer = "List") @Produces({MediaType.APPLICATION_JSON}) @Transactional(readOnly = true) public List<Service> queryServices( @@ -74,6 +77,8 @@ public class ServiceRestImpl { serviceFromDB = serviceRepo.findByModelNameAndDistrobutionStatus(modelName, distributionStatus); } else if (!Strings.isNullOrEmpty(modelName)) { serviceFromDB = serviceRepo.findByModelName(modelName); + } else { + serviceFromDB = serviceRepo.findAll(); } serviceFromDB.stream().forEach(serviceDB -> services.add(serviceMapper.mapService(serviceDB, depth))); return services; diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/VnfMapper.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/VnfMapper.java new file mode 100644 index 0000000000..52a8ccb5a7 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/VnfMapper.java @@ -0,0 +1,37 @@ +package org.onap.so.adapters.catalogdb.rest; + +import org.onap.so.db.catalog.beans.VnfResource; +import org.onap.so.db.catalog.beans.VnfResourceCustomization; +import org.onap.so.rest.catalog.beans.Vnf; +import org.springframework.stereotype.Component; +import com.google.common.base.Strings; + +@Component +public class VnfMapper { + + public VnfResourceCustomization mapVnf(VnfResourceCustomization vnfCust, Vnf vnf) { + + vnfCust.setAvailabilityZoneMaxCount(vnf.getAvailabilityZoneMaxCount()); + vnfCust.setMaxInstances(vnf.getMaxInstances()); + vnfCust.setMinInstances(vnf.getMinInstances()); + vnfCust.setModelCustomizationUUID(vnf.getModelCustomizationId()); + vnfCust.setModelInstanceName(vnf.getModelInstanceName()); + vnfCust.setMultiStageDesign(vnf.getMultiStageDesign()); + vnfCust.setNfDataValid(vnf.getNfDataValid()); + vnfCust.setNfFunction(Strings.nullToEmpty(vnf.getNfFunction())); + vnfCust.setNfNamingCode(Strings.nullToEmpty(vnf.getNfNamingCode())); + vnfCust.setNfRole(Strings.nullToEmpty(vnf.getNfRole())); + vnfCust.setNfType(Strings.nullToEmpty(vnf.getNfType())); + + VnfResource vnfRes = vnfCust.getVnfResources(); + vnfRes.setOrchestrationMode(Strings.nullToEmpty(vnfRes.getOrchestrationMode())); + vnfRes.setSubCategory(Strings.nullToEmpty(vnfRes.getSubCategory())); + vnfRes.setToscaNodeType(Strings.nullToEmpty(vnfRes.getToscaNodeType())); + vnfRes.setModelInvariantUUID(vnfRes.getModelInvariantId()); + vnfRes.setModelName(vnfRes.getModelName()); + vnfRes.setModelUUID(vnfRes.getModelUUID()); + vnfRes.setModelVersion(vnfRes.getModelVersion()); + return vnfCust; + } + +} diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/VnfRestImpl.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/VnfRestImpl.java new file mode 100644 index 0000000000..4353526872 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/VnfRestImpl.java @@ -0,0 +1,107 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.catalogdb.rest; + +import java.util.List; +import java.util.stream.Collectors; +import javax.ws.rs.GET; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import org.onap.so.db.catalog.beans.VnfResourceCustomization; +import org.onap.so.db.catalog.data.repository.ServiceRepository; +import org.onap.so.db.catalog.data.repository.VnfCustomizationRepository; +import org.onap.so.rest.catalog.beans.Vnf; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + +@Api(value = "/v1/services/{modelUUID}/vnfs", tags = "model") +@Path("/v1/services/{modelUUID}/vnfs") +@Component +public class VnfRestImpl { + + @Autowired + private ServiceRepository serviceRepo; + + @Autowired + private ServiceMapper serviceMapper; + + @Autowired + private VnfMapper vnfMapper; + + @Autowired + private VnfCustomizationRepository vnfCustRepo; + + @GET + @ApiOperation(value = "Find a VNF model contained within a service", response = Vnf.class) + @Path("/{modelCustomizationUUID}") + @Produces({MediaType.APPLICATION_JSON}) + @Transactional(readOnly = true) + public Vnf findService(@PathParam("modelUUID") String serviceModelUUID, + @PathParam("modelCustomizationUUID") String modelCustomizationUUID, @QueryParam("depth") int depth) { + org.onap.so.db.catalog.beans.Service service = serviceRepo.findOneByModelUUID(serviceModelUUID); + if (service.getVnfCustomizations() == null || service.getVnfCustomizations().isEmpty()) { + throw new WebApplicationException("Vnf Not Found", 404); + } + List<VnfResourceCustomization> vnfCustom = service.getVnfCustomizations().stream() + .filter(vnfCust -> vnfCust.getModelCustomizationUUID().equals(modelCustomizationUUID)) + .collect(Collectors.toList()); + if (vnfCustom.isEmpty() || vnfCustom == null) { + return null; + } else if (vnfCustom.size() > 1) { + throw new RuntimeException( + "More than one Vnf model returned with model Customization UUID: " + modelCustomizationUUID); + } + return serviceMapper.mapVnf(vnfCustom.get(0), depth); + } + + @PUT + @ApiOperation(value = "Update a VNF model contained within a service", response = Vnf.class) + @Path("/{modelCustomizationUUID}") + @Produces({MediaType.APPLICATION_JSON}) + @Transactional + public Response findService(@PathParam("modelUUID") String serviceModelUUID, + @PathParam("modelCustomizationUUID") String modelCustomizationUUID, Vnf vnf) { + org.onap.so.db.catalog.beans.Service service = serviceRepo.findOneByModelUUID(serviceModelUUID); + List<VnfResourceCustomization> vnfCustom = service.getVnfCustomizations().stream() + .filter(vnfCust -> vnfCust.getModelCustomizationUUID().equals(modelCustomizationUUID)) + .collect(Collectors.toList()); + if (vnfCustom.isEmpty() || vnfCustom == null) { + throw new RuntimeException("No Vnf Found"); + } else if (vnfCustom.size() > 1) { + throw new RuntimeException( + "More than one Vnf model returned with model Customization UUID: " + modelCustomizationUUID); + } + VnfResourceCustomization vnfCust = vnfMapper.mapVnf(vnfCustom.get(0), vnf); + vnfCustRepo.save(vnfCust); + return Response.ok().build(); + } + +} + diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V6.2__AddNfValidData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V6.2__AddNfValidData.sql new file mode 100644 index 0000000000..93dde1341e --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V6.2__AddNfValidData.sql @@ -0,0 +1,5 @@ +USE catalogdb; + +ALTER TABLE vnf_resource_customization +ADD IF NOT EXISTS NF_DATA_VALID tinyint(1) DEFAULT 0; + diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/ServiceMapperTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/ServiceMapperTest.java index 8decd77656..d46fd9c7ba 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/ServiceMapperTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/ServiceMapperTest.java @@ -67,6 +67,7 @@ public class ServiceMapperTest { testService.setModelVersion("modelVersion"); testService.setServiceType("serviceType"); testService.setServiceRole("serviceRole"); + testService.getVnfCustomizations().add(getTestVnfCustomization()); return testService; } diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java index a955a2c3ce..f82c7acd38 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java @@ -22,15 +22,14 @@ package org.onap.so.db.catalog.client; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import java.util.List; import java.util.UUID; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.onap.so.adapters.catalogdb.CatalogDBApplication; import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest; import org.onap.so.db.catalog.beans.AuthenticationType; import org.onap.so.db.catalog.beans.CloudIdentity; @@ -56,10 +55,7 @@ import org.onap.so.db.catalog.beans.macro.NorthBoundRequest; import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.web.server.LocalServerPort; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { @@ -74,6 +70,8 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { @Autowired CatalogDbClientPortChanger client; + + @Before public void initialize() { client.wiremockPort = String.valueOf(port); @@ -88,7 +86,7 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { public void testGetRainyDayHandler_Regex() { RainyDayHandlerStatus rainyDayHandlerStatus = client.getRainyDayHandlerStatus("AssignServiceInstanceBB", "*", "*", "*", "*", "The Flavor ID (nd.c6r16d20) could not be found.", "*"); - Assert.assertEquals("Rollback", rainyDayHandlerStatus.getPolicy()); + assertEquals("Rollback", rainyDayHandlerStatus.getPolicy()); } @Test @@ -97,105 +95,105 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { "*", "*", "*", "resources.lba_0_dmz_vmi_0: Unknown id: Error: oper 1 url /fqname-to-id body {\"fq_name\": [\"zrdm6bvota05-dmz_sec_group\"], \"type\": \"security-group\"} response Name ['zrdm6bvota05-dmz_sec_group'] not found", "*"); - Assert.assertEquals("Rollback", rainyDayHandlerStatus.getPolicy()); + assertEquals("Rollback", rainyDayHandlerStatus.getPolicy()); } @Test public void testGetCloudSiteHappyPath() throws Exception { CloudSite cloudSite = client.getCloudSite(MTN13); - Assert.assertNotNull(cloudSite); - Assert.assertNotNull(cloudSite.getIdentityService()); - Assert.assertEquals("MDT13", cloudSite.getClli()); - Assert.assertEquals("mtn13", cloudSite.getRegionId()); - Assert.assertEquals("MTN13", cloudSite.getIdentityServiceId()); + assertNotNull(cloudSite); + assertNotNull(cloudSite.getIdentityService()); + assertEquals("MDT13", cloudSite.getClli()); + assertEquals("mtn13", cloudSite.getRegionId()); + assertEquals("MTN13", cloudSite.getIdentityServiceId()); } @Test public void testGetCloudSiteNotFound() throws Exception { CloudSite cloudSite = client.getCloudSite(UUID.randomUUID().toString()); - Assert.assertNull(cloudSite); + assertNull(cloudSite); } @Test public void testGetCloudifyManagerHappyPath() throws Exception { CloudifyManager cloudifyManager = client.getCloudifyManager("mtn13"); - Assert.assertNotNull(cloudifyManager); - Assert.assertEquals("http://localhost:28090/v2.0", cloudifyManager.getCloudifyUrl()); + assertNotNull(cloudifyManager); + assertEquals("http://localhost:28090/v2.0", cloudifyManager.getCloudifyUrl()); } @Test public void testGetCloudifyManagerNotFound() throws Exception { CloudifyManager cloudifyManager = client.getCloudifyManager(UUID.randomUUID().toString()); - Assert.assertNull(cloudifyManager); + assertNull(cloudifyManager); } @Test public void testGetCloudSiteByClliAndAicVersionHappyPath() throws Exception { CloudSite cloudSite = client.getCloudSiteByClliAndAicVersion("MDT13", "2.5"); - Assert.assertNotNull(cloudSite); + assertNotNull(cloudSite); } @Test public void testGetCloudSiteByClliAndAicVersionNotFound() throws Exception { CloudSite cloudSite = client.getCloudSiteByClliAndAicVersion("MDT13", "232496239746328"); - Assert.assertNull(cloudSite); + assertNull(cloudSite); } @Test public void testGetServiceByID() throws Exception { Service serviceByID = client.getServiceByID("5df8b6de-2083-11e7-93ae-92361f002671"); - Assert.assertNotNull(serviceByID); - Assert.assertEquals("MSOTADevInfra_vSAMP10a_Service", serviceByID.getModelName()); - Assert.assertEquals("NA", serviceByID.getServiceType()); - Assert.assertEquals("NA", serviceByID.getServiceRole()); + assertNotNull(serviceByID); + assertEquals("MSOTADevInfra_vSAMP10a_Service", serviceByID.getModelName()); + assertEquals("NA", serviceByID.getServiceType()); + assertEquals("NA", serviceByID.getServiceRole()); } @Test public void testGetServiceByIDNotFound() throws Exception { Service serviceByID = client.getServiceByID(UUID.randomUUID().toString()); - Assert.assertNull(serviceByID); + assertNull(serviceByID); } @Test public void testGetVfModuleByModelUUID() throws Exception { VfModule vfModule = client.getVfModuleByModelUUID("20c4431c-246d-11e7-93ae-92361f002671"); - Assert.assertNotNull(vfModule); - Assert.assertNotNull(vfModule.getVfModuleCustomization()); - Assert.assertEquals("78ca26d0-246d-11e7-93ae-92361f002671", vfModule.getModelInvariantUUID()); - Assert.assertEquals("vSAMP10aDEV::base::module-0", vfModule.getModelName()); + assertNotNull(vfModule); + assertNotNull(vfModule.getVfModuleCustomization()); + assertEquals("78ca26d0-246d-11e7-93ae-92361f002671", vfModule.getModelInvariantUUID()); + assertEquals("vSAMP10aDEV::base::module-0", vfModule.getModelName()); } @Test public void testGetVfModuleByModelUUIDNotFound() throws Exception { VfModule vfModule = client.getVfModuleByModelUUID(UUID.randomUUID().toString()); - Assert.assertNull(vfModule); + assertNull(vfModule); } @Test public void testGetVnfResourceByModelUUID() throws Exception { VnfResource vnfResource = client.getVnfResourceByModelUUID("ff2ae348-214a-11e7-93ae-92361f002671"); - Assert.assertNotNull(vnfResource); - Assert.assertEquals("vSAMP10a", vnfResource.getModelName()); + assertNotNull(vnfResource); + assertEquals("vSAMP10a", vnfResource.getModelName()); } @Test public void testGetVnfResourceByModelUUIDNotFound() throws Exception { VnfResource vnfResource = client.getVnfResourceByModelUUID(UUID.randomUUID().toString()); - Assert.assertNull(vnfResource); + assertNull(vnfResource); } @Test public void testGetVnfResourceCustomizationByModelCustomizationUUID() { VnfResourceCustomization vnfResourceCustomization = client.getVnfResourceCustomizationByModelCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002671"); - Assert.assertNotNull(vnfResourceCustomization); - Assert.assertEquals("vSAMP", vnfResourceCustomization.getNfRole()); - Assert.assertNotNull(vnfResourceCustomization.getModelCustomizationUUID()); - Assert.assertNotNull(vnfResourceCustomization.getVnfResources()); - Assert.assertNotNull(vnfResourceCustomization.getVfModuleCustomizations()); - Assert.assertEquals("vSAMP10a", vnfResourceCustomization.getVnfResources().getModelName()); + assertNotNull(vnfResourceCustomization); + assertEquals("vSAMP", vnfResourceCustomization.getNfRole()); + assertNotNull(vnfResourceCustomization.getModelCustomizationUUID()); + assertNotNull(vnfResourceCustomization.getVnfResources()); + assertNotNull(vnfResourceCustomization.getVfModuleCustomizations()); + assertEquals("vSAMP10a", vnfResourceCustomization.getVnfResources().getModelName()); assertTrue("skip post instantiation configuration", vnfResourceCustomization.isSkipPostInstConf()); } @@ -203,15 +201,15 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { public void testGetVnfResourceCustomizationByModelCustomizationUUINotFound() { VnfResourceCustomization vnfResourceCustomization = client.getVnfResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString()); - Assert.assertNull(vnfResourceCustomization); + assertNull(vnfResourceCustomization); } @Test public void testGetInstanceGroupByModelUUID() { InstanceGroup instanceGroup = client.getInstanceGroupByModelUUID("0c8692ef-b9c0-435d-a738-edf31e71f38b"); - Assert.assertNotNull(instanceGroup); - Assert.assertEquals("network_collection_resource_1806..NetworkCollection..0", instanceGroup.getModelName()); - Assert.assertEquals("org.openecomp.resource.cr.NetworkCollectionResource1806", + assertNotNull(instanceGroup); + assertEquals("network_collection_resource_1806..NetworkCollection..0", instanceGroup.getModelName()); + assertEquals("org.openecomp.resource.cr.NetworkCollectionResource1806", instanceGroup.getToscaNodeType().toString()); } @@ -219,33 +217,33 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { public void testGetVfModuleCustomizationByModelCuztomizationUUID() { VfModuleCustomization vfModuleCustomization = client.getVfModuleCustomizationByModelCuztomizationUUID("cb82ffd8-252a-11e7-93ae-92361f002671"); - Assert.assertNotNull(vfModuleCustomization); - Assert.assertNotNull(vfModuleCustomization.getModelCustomizationUUID()); - Assert.assertEquals("base", vfModuleCustomization.getLabel()); + assertNotNull(vfModuleCustomization); + assertNotNull(vfModuleCustomization.getModelCustomizationUUID()); + assertEquals("base", vfModuleCustomization.getLabel()); } @Test public void testGetVfModuleCustomizationByModelCuztomizationUUIDNotFound() { VfModuleCustomization vfModuleCustomization = client.getVfModuleCustomizationByModelCuztomizationUUID(UUID.randomUUID().toString()); - Assert.assertNull(vfModuleCustomization); + assertNull(vfModuleCustomization); } @Test public void testGetNetworkResourceCustomizationByModelCustomizationUUID() { NetworkResourceCustomization networkResourceCustomization = client.getNetworkResourceCustomizationByModelCustomizationUUID("3bdbb104-476c-483e-9f8b-c095b3d308ac"); - Assert.assertNotNull(networkResourceCustomization); - Assert.assertNotNull(networkResourceCustomization.getModelCustomizationUUID()); - Assert.assertEquals("CONTRAIL30_GNDIRECT 9", networkResourceCustomization.getModelInstanceName()); - Assert.assertNotNull(networkResourceCustomization.getNetworkResource()); + assertNotNull(networkResourceCustomization); + assertNotNull(networkResourceCustomization.getModelCustomizationUUID()); + assertEquals("CONTRAIL30_GNDIRECT 9", networkResourceCustomization.getModelInstanceName()); + assertNotNull(networkResourceCustomization.getNetworkResource()); } @Test public void testGetNetworkResourceCustomizationByModelCustomizationUUIDNotFound() { NetworkResourceCustomization networkResourceCustomization = client.getNetworkResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString()); - Assert.assertNull(networkResourceCustomization); + assertNull(networkResourceCustomization); } @Test @@ -253,10 +251,10 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { VfModuleCustomization vfModuleCustomization = client.getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID( "cb82ffd8-252a-11e7-93ae-92361f002672", "20c4431c-246d-11e7-93ae-92361f002672"); - Assert.assertNotNull(vfModuleCustomization); - Assert.assertNotNull(vfModuleCustomization.getModelCustomizationUUID()); - Assert.assertNotNull(vfModuleCustomization.getVfModule()); - Assert.assertEquals("base", vfModuleCustomization.getLabel()); + assertNotNull(vfModuleCustomization); + assertNotNull(vfModuleCustomization.getModelCustomizationUUID()); + assertNotNull(vfModuleCustomization.getVfModule()); + assertEquals("base", vfModuleCustomization.getLabel()); } @Test @@ -264,44 +262,43 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { VfModuleCustomization vfModuleCustomization = client.getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID( "cb82ffd8-252a-11e7-93ae-92361f002672", UUID.randomUUID().toString()); - Assert.assertNull(vfModuleCustomization); + assertNull(vfModuleCustomization); } @Test public void testGetFirstByServiceModelUUIDAndAction() { ServiceRecipe serviceRecipe = client.getFirstByServiceModelUUIDAndAction("4694a55f-58b3-4f17-92a5-796d6f5ffd0d", "createInstance"); - Assert.assertNotNull(serviceRecipe); - Assert.assertNotNull(serviceRecipe.getServiceModelUUID()); - Assert.assertNotNull(serviceRecipe.getAction()); - Assert.assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance", - serviceRecipe.getOrchestrationUri()); - Assert.assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription()); + assertNotNull(serviceRecipe); + assertNotNull(serviceRecipe.getServiceModelUUID()); + assertNotNull(serviceRecipe.getAction()); + assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance", serviceRecipe.getOrchestrationUri()); + assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription()); } @Test public void testGetFirstByServiceModelUUIDAndActionNotFound() { ServiceRecipe serviceRecipe = client.getFirstByServiceModelUUIDAndAction("5df8b6de-2083-11e7-93ae-92361f002671", UUID.randomUUID().toString()); - Assert.assertNull(serviceRecipe); + assertNull(serviceRecipe); } @Test public void testGetFirstVnfResourceByModelInvariantUUIDAndModelVersion() { VnfResource vnfResource = client .getFirstVnfResourceByModelInvariantUUIDAndModelVersion("2fff5b20-214b-11e7-93ae-92361f002671", "2.0"); - Assert.assertNotNull(vnfResource); - Assert.assertNotNull(vnfResource.getModelInvariantId()); - Assert.assertNotNull(vnfResource.getModelVersion()); - Assert.assertNotNull(vnfResource.getHeatTemplates()); - Assert.assertEquals("vSAMP10a", vnfResource.getModelName()); + assertNotNull(vnfResource); + assertNotNull(vnfResource.getModelInvariantId()); + assertNotNull(vnfResource.getModelVersion()); + assertNotNull(vnfResource.getHeatTemplates()); + assertEquals("vSAMP10a", vnfResource.getModelName()); } @Test public void testGetFirstVnfResourceByModelInvariantUUIDAndModelVersionNotFound() { VnfResource vnfResource = client.getFirstVnfResourceByModelInvariantUUIDAndModelVersion( "2fff5b20-214b-11e7-93ae-92361f002671", UUID.randomUUID().toString()); - Assert.assertNull(vnfResource); + assertNull(vnfResource); } @Test @@ -310,29 +307,28 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { vnfr.setModelUUID("ff2ae348-214a-11e7-93ae-92361f002671"); VnfResourceCustomization firstVnfResourceCustomizationByModelInstanceNameAndVnfResources = client.getFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources("vSAMP10a 1", vnfr); - Assert.assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources); - Assert.assertEquals("vSAMP", firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getNfRole()); - Assert.assertEquals("vSAMP10a 1", + assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources); + assertEquals("vSAMP", firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getNfRole()); + assertEquals("vSAMP10a 1", firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getModelInstanceName()); - Assert.assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVnfResources()); - Assert.assertNotNull( - firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVfModuleCustomizations()); + assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVnfResources()); + assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVfModuleCustomizations()); } @Test public void testGetFirstVnfRecipeByNfRoleAndAction() { VnfRecipe vnfRecipe = client.getFirstVnfRecipeByNfRoleAndAction("GR-API-DEFAULT", "createInstance"); - Assert.assertNotNull(vnfRecipe); - Assert.assertNotNull(vnfRecipe.getNfRole()); - Assert.assertNotNull(vnfRecipe.getAction()); - Assert.assertEquals("Gr api recipe to create vnf", vnfRecipe.getDescription()); - Assert.assertEquals("/mso/async/services/WorkflowActionBB", vnfRecipe.getOrchestrationUri()); + assertNotNull(vnfRecipe); + assertNotNull(vnfRecipe.getNfRole()); + assertNotNull(vnfRecipe.getAction()); + assertEquals("Gr api recipe to create vnf", vnfRecipe.getDescription()); + assertEquals("/mso/async/services/WorkflowActionBB", vnfRecipe.getOrchestrationUri()); } @Test public void testGetFirstVnfRecipeByNfRoleAndActionNotFound() { VnfRecipe vnfRecipe = client.getFirstVnfRecipeByNfRoleAndAction(UUID.randomUUID().toString(), "createInstance"); - Assert.assertNull(vnfRecipe); + assertNull(vnfRecipe); } @Test @@ -340,12 +336,12 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { VnfComponentsRecipe vnfComponentsRecipe = client.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction( "20c4431c-246d-11e7-93ae-92361f002671", "volumeGroup", "createInstance"); - Assert.assertNotNull(vnfComponentsRecipe); - Assert.assertNotNull(vnfComponentsRecipe.getAction()); - Assert.assertNotNull(vnfComponentsRecipe.getVfModuleModelUUID()); - Assert.assertNotNull(vnfComponentsRecipe.getVnfComponentType()); - Assert.assertEquals("Gr api recipe to create volume-group", vnfComponentsRecipe.getDescription()); - Assert.assertEquals("/mso/async/services/WorkflowActionBB", vnfComponentsRecipe.getOrchestrationUri()); + assertNotNull(vnfComponentsRecipe); + assertNotNull(vnfComponentsRecipe.getAction()); + assertNotNull(vnfComponentsRecipe.getVfModuleModelUUID()); + assertNotNull(vnfComponentsRecipe.getVnfComponentType()); + assertEquals("Gr api recipe to create volume-group", vnfComponentsRecipe.getDescription()); + assertEquals("/mso/async/services/WorkflowActionBB", vnfComponentsRecipe.getOrchestrationUri()); } @@ -355,80 +351,79 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { VnfComponentsRecipe vnfComponentsRecipe = client.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction( UUID.randomUUID().toString(), "volumeGroup", "createInstance"); - Assert.assertNull(vnfComponentsRecipe); + assertNull(vnfComponentsRecipe); } @Test public void testGetFirstVnfComponentsRecipeByVnfComponentTypeAndAction() { VnfComponentsRecipe vnfComponentsRecipe = client.getFirstVnfComponentsRecipeByVnfComponentTypeAndAction("volumeGroup", "createInstance"); - Assert.assertNotNull(vnfComponentsRecipe); - Assert.assertNotNull(vnfComponentsRecipe.getAction()); - Assert.assertNotNull(vnfComponentsRecipe.getVnfComponentType()); - Assert.assertEquals("VID_DEFAULT recipe t", vnfComponentsRecipe.getDescription()); - Assert.assertEquals("/mso/async/services/CreateVfModuleVolumeInfraV1", - vnfComponentsRecipe.getOrchestrationUri()); + assertNotNull(vnfComponentsRecipe); + assertNotNull(vnfComponentsRecipe.getAction()); + assertNotNull(vnfComponentsRecipe.getVnfComponentType()); + assertEquals("VID_DEFAULT recipe t", vnfComponentsRecipe.getDescription()); + assertEquals("/mso/async/services/CreateVfModuleVolumeInfraV1", vnfComponentsRecipe.getOrchestrationUri()); } @Test public void testGetServiceByModelVersionAndModelInvariantUUID() { Service service = client.getServiceByModelVersionAndModelInvariantUUID("2.0", "9647dfc4-2083-11e7-93ae-92361f002671"); - Assert.assertNotNull(service); - Assert.assertNotNull(service.getModelVersion()); - Assert.assertNotNull(service.getModelInvariantUUID()); - Assert.assertEquals("MSOTADevInfra_vSAMP10a_Service", service.getModelName()); - Assert.assertEquals("NA", service.getServiceRole()); + assertNotNull(service); + assertNotNull(service.getModelVersion()); + assertNotNull(service.getModelInvariantUUID()); + assertEquals("MSOTADevInfra_vSAMP10a_Service", service.getModelName()); + assertEquals("NA", service.getServiceRole()); } @Test public void testGetServiceByModelVersionAndModelInvariantUUIDNotFound() { Service service = client.getServiceByModelVersionAndModelInvariantUUID("2.0", UUID.randomUUID().toString()); - Assert.assertNull(service); + assertNull(service); } @Test public void testGetVfModuleByModelInvariantUUIDAndModelVersion() { VfModule vfModule = client.getVfModuleByModelInvariantUUIDAndModelVersion("78ca26d0-246d-11e7-93ae-92361f002671", "2"); - Assert.assertNotNull(vfModule); - Assert.assertNotNull(vfModule.getModelVersion()); - Assert.assertNotNull(vfModule.getModelInvariantUUID()); - Assert.assertEquals("vSAMP10aDEV::base::module-0", vfModule.getModelName()); - Assert.assertEquals("vSAMP10a DEV Base", vfModule.getDescription()); + assertNotNull(vfModule); + assertNotNull(vfModule.getModelVersion()); + assertNotNull(vfModule.getModelInvariantUUID()); + assertEquals("vSAMP10aDEV::base::module-0", vfModule.getModelName()); + assertEquals("vSAMP10a DEV Base", vfModule.getDescription()); } @Test public void testGetVfModuleByModelInvariantUUIDAndModelVersionNotFound() { VfModule vfModule = client.getVfModuleByModelInvariantUUIDAndModelVersion(UUID.randomUUID().toString(), "2"); - Assert.assertNull(vfModule); + assertNull(vfModule); } @Test public void testGetServiceByModelInvariantUUIDOrderByModelVersionDesc() { List<Service> serviceList = client.getServiceByModelInvariantUUIDOrderByModelVersionDesc("9647dfc4-2083-11e7-93ae-92361f002671"); - Assert.assertFalse(serviceList.isEmpty()); - Assert.assertEquals(2, serviceList.size()); + assertFalse(serviceList.isEmpty()); + assertEquals(2, serviceList.size()); Service service = serviceList.get(0); - Assert.assertEquals("2.0", service.getModelVersion()); + assertEquals("2.0", service.getModelVersion()); } @Test public void testGetServiceByModelInvariantUUIDOrderByModelVersionDescNotFound() { List<Service> serviceList = client.getServiceByModelInvariantUUIDOrderByModelVersionDesc(UUID.randomUUID().toString()); - Assert.assertTrue(serviceList.isEmpty()); + assertTrue(serviceList.isEmpty()); } @Test public void testGetVfModuleByModelInvariantUUIDOrderByModelVersionDesc() { List<VfModule> moduleList = client.getVfModuleByModelInvariantUUIDOrderByModelVersionDesc("78ca26d0-246d-11e7-93ae-92361f002671"); - Assert.assertFalse(moduleList.isEmpty()); - Assert.assertEquals(2, moduleList.size()); + assertFalse(moduleList.isEmpty()); + assertEquals(2, moduleList.size()); VfModule module = moduleList.get(0); - Assert.assertEquals("vSAMP10a DEV Base", module.getDescription()); + assertEquals("vSAMP10a DEV Base", module.getDescription()); } @Test @@ -454,20 +449,20 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { cloudSite.setIdentityService(cloudIdentity); localClient.postCloudSite(cloudSite); CloudSite getCloudSite = this.client.getCloudSite("MTN6"); - Assert.assertNotNull(getCloudSite); - Assert.assertNotNull(getCloudSite.getIdentityService()); - Assert.assertEquals("TESTCLLI", getCloudSite.getClli()); - Assert.assertEquals("regionId", getCloudSite.getRegionId()); - Assert.assertEquals("RANDOMID", getCloudSite.getIdentityServiceId()); + assertNotNull(getCloudSite); + assertNotNull(getCloudSite.getIdentityService()); + assertEquals("TESTCLLI", getCloudSite.getClli()); + assertEquals("regionId", getCloudSite.getRegionId()); + assertEquals("RANDOMID", getCloudSite.getIdentityServiceId()); } @Test public void testGetHomingInstance() { HomingInstance homingInstance = client.getHomingInstance("5df8b6de-2083-11e7-93ae-92361f232671"); - Assert.assertNotNull(homingInstance); - Assert.assertNotNull(homingInstance.getCloudOwner()); - Assert.assertNotNull(homingInstance.getCloudRegionId()); - Assert.assertNotNull(homingInstance.getOofDirectives()); + assertNotNull(homingInstance); + assertNotNull(homingInstance.getCloudOwner()); + assertNotNull(homingInstance.getCloudRegionId()); + assertNotNull(homingInstance.getOofDirectives()); } @Test @@ -491,43 +486,43 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { + "\"id\": \"vsink\"\n" + "}\n" + "]\n" + "}"); localClient.postHomingInstance(homingInstance); HomingInstance getHomingInstance = this.client.getHomingInstance("5df8d6be-2083-11e7-93ae-92361f232671"); - Assert.assertNotNull(getHomingInstance); - Assert.assertNotNull(getHomingInstance.getCloudRegionId()); - Assert.assertNotNull(getHomingInstance.getCloudOwner()); - Assert.assertEquals("CloudOwner-1", getHomingInstance.getCloudOwner()); - Assert.assertEquals("CloudRegionOne", getHomingInstance.getCloudRegionId()); + assertNotNull(getHomingInstance); + assertNotNull(getHomingInstance.getCloudRegionId()); + assertNotNull(getHomingInstance.getCloudOwner()); + assertEquals("CloudOwner-1", getHomingInstance.getCloudOwner()); + assertEquals("CloudRegionOne", getHomingInstance.getCloudRegionId()); } @Test public void testGetServiceByModelName() { Service service = client.getServiceByModelName("MSOTADevInfra_Test_Service"); - Assert.assertNotNull(service); - Assert.assertNotNull(service.getModelVersion()); - Assert.assertNotNull(service.getModelInvariantUUID()); - Assert.assertEquals("MSOTADevInfra_Test_Service", service.getModelName()); - Assert.assertEquals("NA", service.getServiceRole()); + assertNotNull(service); + assertNotNull(service.getModelVersion()); + assertNotNull(service.getModelInvariantUUID()); + assertEquals("MSOTADevInfra_Test_Service", service.getModelName()); + assertEquals("NA", service.getServiceRole()); } @Test public void testGetServiceByModelNameNotFound() { Service service = client.getServiceByModelName("Not_Found"); - Assert.assertNull(service); + assertNull(service); } @Test public void testGetServiceByModelUUID() { Service service = client.getServiceByModelUUID("5df8b6de-2083-11e7-93ae-92361f002679"); - Assert.assertNotNull(service); - Assert.assertNotNull(service.getModelVersion()); - Assert.assertNotNull(service.getModelInvariantUUID()); - Assert.assertEquals("5df8b6de-2083-11e7-93ae-92361f002679", service.getModelUUID()); - Assert.assertEquals("NA", service.getServiceRole()); + assertNotNull(service); + assertNotNull(service.getModelVersion()); + assertNotNull(service.getModelInvariantUUID()); + assertEquals("5df8b6de-2083-11e7-93ae-92361f002679", service.getModelUUID()); + assertEquals("NA", service.getServiceRole()); } @Test public void testGetServiceByModelUUIDNotFound() { Service service = client.getServiceByModelUUID("Not_Found"); - Assert.assertNull(service); + assertNull(service); } @Test @@ -539,53 +534,52 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { northBoundRequest.setCloudOwner("my-custom-cloud-owner"); client.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner("createService", "service", true, "my-custom-cloud-owner"); - Assert.assertNotNull(northBoundRequest); - Assert.assertEquals("createService", northBoundRequest.getAction()); - Assert.assertEquals("service", northBoundRequest.getRequestScope()); - Assert.assertEquals(true, northBoundRequest.getIsAlacarte()); - Assert.assertEquals("my-custom-cloud-owner", northBoundRequest.getCloudOwner()); + assertNotNull(northBoundRequest); + assertEquals("createService", northBoundRequest.getAction()); + assertEquals("service", northBoundRequest.getRequestScope()); + assertEquals(true, northBoundRequest.getIsAlacarte()); + assertEquals("my-custom-cloud-owner", northBoundRequest.getCloudOwner()); } @Test public void testFindServiceRecipeByActionAndServiceModelUUID() { ServiceRecipe serviceRecipe = client.findServiceRecipeByActionAndServiceModelUUID("createInstance", "4694a55f-58b3-4f17-92a5-796d6f5ffd0d"); - Assert.assertNotNull(serviceRecipe); - Assert.assertNotNull(serviceRecipe.getServiceModelUUID()); - Assert.assertNotNull(serviceRecipe.getAction()); - Assert.assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance", - serviceRecipe.getOrchestrationUri()); - Assert.assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription()); + assertNotNull(serviceRecipe); + assertNotNull(serviceRecipe.getServiceModelUUID()); + assertNotNull(serviceRecipe.getAction()); + assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance", serviceRecipe.getOrchestrationUri()); + assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription()); } @Test public void testFindServiceRecipeByActionAndServiceModelUUIDNotFound() { ServiceRecipe serviceRecipe = client.findServiceRecipeByActionAndServiceModelUUID("not_found", "5df8b6de-2083-11e7-93ae-test"); - Assert.assertNull(serviceRecipe); + assertNull(serviceRecipe); } @Test public void testFindExternalToInternalServiceByServiceName() { ExternalServiceToInternalService externalServiceToInternalService = client.findExternalToInternalServiceByServiceName("MySpecialServiceName"); - Assert.assertNotNull(externalServiceToInternalService); - Assert.assertNotNull(externalServiceToInternalService.getServiceName()); - Assert.assertNotNull(externalServiceToInternalService.getServiceModelUUID()); - Assert.assertEquals("MySpecialServiceName", externalServiceToInternalService.getServiceName()); + assertNotNull(externalServiceToInternalService); + assertNotNull(externalServiceToInternalService.getServiceName()); + assertNotNull(externalServiceToInternalService.getServiceModelUUID()); + assertEquals("MySpecialServiceName", externalServiceToInternalService.getServiceName()); } @Test public void testFindExternalToInternalServiceByServiceNameNotFound() { ExternalServiceToInternalService externalServiceToInternalService = client.findExternalToInternalServiceByServiceName("Not_Found"); - Assert.assertNull(externalServiceToInternalService); + assertNull(externalServiceToInternalService); } @Test public void getPnfResourceByModelUUID_validUuid_expectedOutput() { PnfResource pnfResource = client.getPnfResourceByModelUUID("ff2ae348-214a-11e7-93ae-92361f002680"); - Assert.assertNotNull(pnfResource); + assertNotNull(pnfResource); assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID()); assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680", pnfResource.getModelInvariantUUID()); @@ -596,7 +590,7 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { @Test public void getPnfResourceByModelUUID_invalidUuid_NullOutput() { PnfResource pnfResource = client.getPnfResourceByModelUUID(UUID.randomUUID().toString()); - Assert.assertNull(pnfResource); + assertNull(pnfResource); } @Test @@ -620,7 +614,7 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { public void getPnfResourceCustomizationByModelCustomizationUUID_invalidUuid_nullOutput() { PnfResourceCustomization pnfResourceCustomization = client.getPnfResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString()); - Assert.assertNull(pnfResourceCustomization); + assertNull(pnfResourceCustomization); } @Test @@ -651,6 +645,53 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { } @Test + public void testGetServiceTopologyById() throws Exception { + org.onap.so.rest.catalog.beans.Service serviceByID = + client.getServiceModelInformation("5df8b6de-2083-11e7-93ae-92361f002671", "2"); + assertNotNull(serviceByID); + assertEquals("MSOTADevInfra_vSAMP10a_Service", serviceByID.getModelName()); + assertEquals("NA", serviceByID.getServiceType()); + assertEquals("NA", serviceByID.getServiceRole()); + } + + @Test + public void testGetServices() throws Exception { + List<org.onap.so.rest.catalog.beans.Service> services = client.getServices(); + assertEquals(false, services.isEmpty()); + } + + @Test + public void testVnf() throws Exception { + org.onap.so.rest.catalog.beans.Vnf vnf = client.getVnfModelInformation("5df8b6de-2083-11e7-93ae-92361f002671", + "68dc9a92-214c-11e7-93ae-92361f002671", "0"); + assertNotNull(vnf); + assertEquals("vSAMP10a", vnf.getModelName()); + assertEquals(false, vnf.getNfDataValid()); + assertEquals("vSAMP", vnf.getNfFunction()); + assertEquals("vSAMP", vnf.getNfNamingCode()); + assertEquals("vSAMP", vnf.getNfRole()); + assertEquals("vSAMP", vnf.getNfType()); + + vnf.setNfDataValid(true); + vnf.setNfFunction("nfFunction"); + vnf.setNfRole("nfRole"); + vnf.setNfType("nfType"); + vnf.setNfNamingCode("nfNamingCode"); + + client.updateVnf("5df8b6de-2083-11e7-93ae-92361f002671", vnf); + vnf = client.getVnfModelInformation("5df8b6de-2083-11e7-93ae-92361f002671", + "68dc9a92-214c-11e7-93ae-92361f002671", "0"); + assertEquals("vSAMP10a", vnf.getModelName()); + assertEquals(true, vnf.getNfDataValid()); + assertEquals("nfFunction", vnf.getNfFunction()); + assertEquals("nfNamingCode", vnf.getNfNamingCode()); + assertEquals("nfRole", vnf.getNfRole()); + assertEquals("nfType", vnf.getNfType()); + + + } + + @Test public void getWorkflowByArtifactUUID_validUuid_expectedOutput() { Workflow workflow = client.findWorkflowByArtifactUUID("5b0c4322-643d-4c9f-b184-4516049e99b1"); assertEquals("artifactName", "testingWorkflow.bpmn", workflow.getArtifactName()); @@ -659,7 +700,7 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { @Test public void getWorkflowByArtifactUUID_invalidUuid_nullOutput() { Workflow workflow = client.findWorkflowByArtifactUUID(UUID.randomUUID().toString()); - Assert.assertNull(workflow); + assertNull(workflow); } @Test @@ -674,7 +715,7 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { @Test public void getWorkflowByModelUUID_invalidUuid_nullOutput() { Workflow workflow = client.findWorkflowByArtifactUUID(UUID.randomUUID().toString()); - Assert.assertNull(workflow); + assertNull(workflow); } @Test @@ -689,7 +730,7 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { @Test public void getWorkflowBySource_invalidSource_nullOutput() { List<Workflow> workflow = client.findWorkflowBySource("abc"); - Assert.assertNull(workflow); + assertNull(workflow); } } diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/ExpectedService.json b/adapters/mso-catalog-db-adapter/src/test/resources/ExpectedService.json index cc5145f0e3..2dc83c8963 100644 --- a/adapters/mso-catalog-db-adapter/src/test/resources/ExpectedService.json +++ b/adapters/mso-catalog-db-adapter/src/test/resources/ExpectedService.json @@ -23,6 +23,7 @@ "toscaNodeType": "toscaNodeType", "nfFunction": "nfFunction", "nfRole": "nfRole", + "nfType": "nfType", "nfNamingCode": "nfNamingCode", "multiStageDesign": "multiStageDesign", "orchestrationMode": "orchestrationMode", diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java index 4c115271f0..153de2fb12 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java @@ -842,8 +842,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } else { String error = String.format( "Network Type:%s Version_Min:%s Version_Max:%s not supported on Cloud:%s with AIC_Version:%s", - networkType, networkType, networkResource.getAicVersionMin(), networkResource.getAicVersionMax(), - cloudSiteId, cloudSite.getCloudVersion()); + networkType, networkResource.getAicVersionMin(), networkResource.getAicVersionMax(), cloudSiteId, + cloudSite.getCloudVersion()); logger.error(LoggingAnchor.THREE, MessageEnum.RA_CONFIG_EXC, ErrorCode.DataError.getValue(), error); throw new NetworkException(error, MsoExceptionCategory.USERDATA); } @@ -1477,13 +1477,19 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } if (subnet.getAllocationPools() != null) { - curR = curR + " allocation_pools:\n"; + StringBuilder tempBuf = new StringBuilder(); + tempBuf.append(curR); + tempBuf.append(" allocation_pools:\n"); for (Pool pool : subnet.getAllocationPools()) { if (!commonUtils.isNullOrEmpty(pool.getStart()) && !commonUtils.isNullOrEmpty(pool.getEnd())) { - curR = curR + " - start: " + pool.getStart() + "\n"; - curR = curR + " end: " + pool.getEnd() + "\n"; + tempBuf.append(" - start: "); + tempBuf.append(pool.getStart()); + tempBuf.append("\n end: "); + tempBuf.append(pool.getEnd()); + tempBuf.append("\n"); } } + curR = tempBuf.toString(); } resourcesBuf.append(curR); @@ -1492,7 +1498,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { curO = curO.replace("%subnetId%", subnet.getSubnetId()); outputsBuf.append(curO); - } // append resources and outputs in heatTemplate logger.debug("Tempate initial:{}", heatTemplate); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/CSAR.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/CSAR.java deleted file mode 100644 index 7786b872ef..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/CSAR.java +++ /dev/null @@ -1,189 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.vnf; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.List; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; -import org.onap.so.adapters.vdu.VduArtifact; -import org.onap.so.adapters.vdu.VduArtifact.ArtifactType; -import org.onap.so.adapters.vdu.VduModelInfo; -import org.onap.so.adapters.vnf.exceptions.VnfException; -import com.google.common.io.Files; - -/** - * The purpose of this class is to create a CSAR byte array from Vdu inputs for the purpose of forwarding to a TOSCA - * orchestrator. - * - * @author DeWayne - * - */ -public class CSAR { - private static final String MANIFEST_FILENAME = "MANIFEST.MF"; - private VduModelInfo vduModel; - - public CSAR(VduModelInfo model) { - this.vduModel = model; - } - - /** - * Creates a byte array representation of a CSAR corresponding to the VduBlueprint arg in the constructor. - * - * @return - * @throws VnfException - */ - public byte[] create() { - File dir = Files.createTempDir(); - - /** - * Create subdir - */ - File metadir = new File(dir.getAbsolutePath() + "/TOSCA-Metadata"); - if (!metadir.mkdir()) { - throw new RuntimeException("CSAR TOSCA-Metadata directory create failed"); - } - - /** - * Organize model info for consumption - */ - VduArtifact mainTemplate = null; - List<VduArtifact> extraFiles = new ArrayList<>(); - for (VduArtifact artifact : vduModel.getArtifacts()) { - if (artifact.getType() == ArtifactType.MAIN_TEMPLATE) { - mainTemplate = artifact; - } else { - extraFiles.add(artifact); - } - } - - if (mainTemplate == null) { // make a dummy to avoid null pointers - mainTemplate = new VduArtifact("", new byte[0], null); - } - - /** - * Write template files - */ - try (OutputStream ofs = new FileOutputStream(new File(dir, mainTemplate.getName())); - PrintStream mfstream = - new PrintStream(new File(metadir.getAbsolutePath() + '/' + MANIFEST_FILENAME));) { - ofs.write(mainTemplate.getContent()); - - /** - * Write other files - */ - if (!extraFiles.isEmpty()) { - for (VduArtifact artifact : extraFiles) { - try (OutputStream out = new FileOutputStream(new File(dir, artifact.getName()));) { - out.write(artifact.getContent()); - } - } - } - - - /** - * Create manifest - */ - mfstream.println("TOSCA-Meta-File-Version: 1.0"); - mfstream.println("CSAR-Version: 1.1"); - mfstream.println("Created-by: ONAP"); - mfstream.println("Entry-Definitions: " + mainTemplate.getName()); - - /** - * ZIP it up - */ - ByteArrayOutputStream zipbytes = new ByteArrayOutputStream(); - ZipOutputStream zos = new ZipOutputStream(zipbytes); - compressTree(zos, "", dir, dir); - zos.close(); - return zipbytes.toByteArray(); - - } catch (Exception e) { - throw new RuntimeException("Failed to create CSAR: " + e.getMessage()); - } finally { - /** - * Clean up tmpdir - */ - deleteDirectory(dir); - } - } - - /** - * Private methods - */ - - /** - * Compresses (ZIPs) a directory tree - * - * @param dir - * @throws IOException - */ - private void compressTree(ZipOutputStream zos, String path, File basedir, File dir) throws IOException { - if (!dir.isDirectory()) - return; - - for (File f : dir.listFiles()) { - if (f.isDirectory()) { - String newpath = path + f.getName() + '/'; - ZipEntry entry = new ZipEntry(newpath); - zos.putNextEntry(entry); - zos.closeEntry(); - compressTree(zos, newpath, basedir, f); - } else { - ZipEntry ze = new ZipEntry( - f.getAbsolutePath().substring(basedir.getAbsolutePath().length() + 1).replaceAll("\\\\", "/")); - zos.putNextEntry(ze); - // read the file and write to ZipOutputStream - try (FileInputStream fis = new FileInputStream(f);) { - byte[] buffer = new byte[1024]; - int len; - while ((len = fis.read(buffer)) > 0) { - zos.write(buffer, 0, len); - } - } - zos.closeEntry(); - } - } - } - - private boolean deleteDirectory(File directory) { - if (directory.exists()) { - File[] files = directory.listFiles(); - if (null != files) { - for (int i = 0; i < files.length; i++) { - if (files[i].isDirectory()) { - deleteDirectory(files[i]); - } else { - files[i].delete(); - } - } - } - } - return (directory.delete()); - } -} diff --git a/adapters/mso-openstack-adapters/src/test/resources/schema.sql b/adapters/mso-openstack-adapters/src/test/resources/schema.sql index 7b3ffd7d30..9406bc445d 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/schema.sql +++ b/adapters/mso-openstack-adapters/src/test/resources/schema.sql @@ -1109,6 +1109,7 @@ CREATE TABLE `vnf_resource_customization` ( `CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `VNF_RESOURCE_MODEL_UUID` varchar(200) NOT NULL, `SERVICE_MODEL_UUID` varchar(200) NOT NULL, + `NF_DATA_VALID` tinyint(1) DEFAULT '0', `VNFCINSTANCEGROUP_ORDER` varchar(200) default NULL, PRIMARY KEY (`ID`), UNIQUE KEY `UK_vnf_resource_customization` (`MODEL_CUSTOMIZATION_UUID`,`SERVICE_MODEL_UUID`), diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/WebSecurityConfigImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/WebSecurityConfigImpl.java index f45d5a0219..792002354b 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/WebSecurityConfigImpl.java +++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/WebSecurityConfigImpl.java @@ -40,7 +40,7 @@ public class WebSecurityConfigImpl extends WebSecurityConfig { @Override protected void configure(final HttpSecurity http) throws Exception { - if (clientAuth.equalsIgnoreCase("need")) { + if (("need").equalsIgnoreCase(clientAuth)) { http.csrf().disable().authorizeRequests().anyRequest().permitAll(); } else { http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll() |