import com.google.common.base.MoreObjects;
+import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
private String type;
+ private String version;
+
private String description;
private String category;
private List<TemplateInput> inputs;
+ private List<ServiceTemplateInput> nestedTemplates;
+
public ServiceTemplateInput(
String invariantUUID,
String uuid,
String name,
String type,
+ String version,
String description,
String category,
String subcategory,
this.uuid = uuid;
this.name = name;
this.type = type;
+ this.version = version;
this.description = description;
this.category = category;
this.subcategory = subcategory;
this.inputs = inputs;
+ this.nestedTemplates = new ArrayList<>();
}
public String getInvariantUUID() {
return type;
}
+ public String getVersion() {
+ return version;
+ }
+
public String getDescription() {
return description;
}
return inputs;
}
+ public List<ServiceTemplateInput> getNestedTemplates() {
+ return nestedTemplates;
+ }
+
+ public void addNestedTemplate(ServiceTemplateInput template) {
+ this.nestedTemplates.add(template);
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
Objects.equals(uuid, that.uuid) &&
Objects.equals(name, that.name) &&
Objects.equals(type, that.type) &&
+ Objects.equals(version, that.version) &&
Objects.equals(description, that.description) &&
Objects.equals(category, that.category) &&
Objects.equals(subcategory, that.subcategory) &&
- Objects.equals(inputs, that.inputs);
+ Objects.equals(inputs, that.inputs) &&
+ Objects.equals(nestedTemplates, that.nestedTemplates);
}
@Override
public int hashCode() {
- return Objects.hash(invariantUUID, uuid, name, type, description, category, subcategory, inputs);
+ return Objects.hash(invariantUUID, uuid, name, type, version, description, category, subcategory, inputs, nestedTemplates);
}
@Override
.add("uuid", uuid)
.add("name", name)
.add("type", type)
+ .add("version", version)
.add("description", description)
.add("category", category)
.add("subcategory", subcategory)
.add("inputs", inputs)
+ .add("nestedTemplates", nestedTemplates)
.toString();
}
}
+++ /dev/null
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * 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.
- */
-package org.onap.usecaseui.server.bean.lcm;
-
-import com.google.common.base.MoreObjects;
-import org.onap.usecaseui.server.service.lcm.domain.aai.bean.VimInfo;
-
-import java.util.List;
-import java.util.Objects;
-
-public class ServiceTemplateInputRsp {
-
- private List<ServiceTemplateInput> serviceTemplateInput;
-
- private List<VimInfo> vimInfos;
-
- public ServiceTemplateInputRsp(List<ServiceTemplateInput> serviceTemplateInput, List<VimInfo> vimInfos) {
- this.serviceTemplateInput = serviceTemplateInput;
- this.vimInfos = vimInfos;
- }
-
- public List<ServiceTemplateInput> getServiceTemplateInput() {
- return serviceTemplateInput;
- }
-
- public List<VimInfo> getVimInfos() {
- return vimInfos;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- ServiceTemplateInputRsp that = (ServiceTemplateInputRsp) o;
- return Objects.equals(serviceTemplateInput, that.serviceTemplateInput) &&
- Objects.equals(vimInfos, that.vimInfos);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(serviceTemplateInput, vimInfos);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("serviceTemplateInput", serviceTemplateInput)
- .add("vimInfos", vimInfos)
- .toString();
- }
-}
*/
package org.onap.usecaseui.server.bean.lcm;
-import org.onap.usecaseui.server.service.lcm.domain.aai.bean.VimInfo;
import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.SDCServiceTemplate;
import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.Vnf;
private List<Vnf> vnfPackages;
- private List<VimInfo> vimInfos;
-
- public VfNsPackageInfo(List<SDCServiceTemplate> nsPackage, List<Vnf> vnfPackages, List<VimInfo> vimInfos) {
+ public VfNsPackageInfo(List<SDCServiceTemplate> nsPackage, List<Vnf> vnfPackages) {
this.nsPackage = nsPackage;
this.vnfPackages = vnfPackages;
- this.vimInfos = vimInfos;
}
public List<SDCServiceTemplate> getNsPackage() {
return vnfPackages;
}
- public List<VimInfo> getVimInfos() {
- return vimInfos;
- }
-
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
VfNsPackageInfo that = (VfNsPackageInfo) o;
return Objects.equals(nsPackage, that.nsPackage) &&
- Objects.equals(vnfPackages, that.vnfPackages) &&
- Objects.equals(vimInfos, that.vimInfos);
+ Objects.equals(vnfPackages, that.vnfPackages);
}
@Override
public int hashCode() {
- return Objects.hash(nsPackage, vnfPackages, vimInfos);
+ return Objects.hash(nsPackage, vnfPackages);
}
}
import org.onap.usecaseui.server.service.lcm.CustomerService;
import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAICustomer;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAIServiceSubscription;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
}
@ResponseBody
- @RequestMapping(value = {"/lcm/customers"}, method = RequestMethod.GET , produces = "application/json")
+ @RequestMapping(value = {"/onapapi/uui-lcm/v1/customers"}, method = RequestMethod.GET , produces = "application/json")
public List<AAICustomer> getCustomers(){
return customerService.listCustomer();
}
+
+ @ResponseBody
+ @RequestMapping(value = {"/onapapi/uui-lcm/v1/customers/{customerId}/service-subscriptions"}, method = RequestMethod.GET , produces = "application/json")
+ public List<AAIServiceSubscription> getServiceSubscriptions(@PathVariable(value="customerId") String customerId){
+ return customerService.listServiceSubscriptions(customerId);
+ }
}
}
@ResponseBody
- @RequestMapping(value = {"/lcm/vf-ns-packages"}, method = RequestMethod.GET , produces = "application/json")
+ @RequestMapping(value = {"/onapapi/uui-lcm/v1/vf-ns-packages"}, method = RequestMethod.GET , produces = "application/json")
public VfNsPackageInfo retrievePackageInfo(){
return packageDistributionService.retrievePackageInfo();
}
@ResponseBody
- @RequestMapping(value = {"/lcm/ns-packages"}, method = RequestMethod.POST , produces = "application/json")
+ @RequestMapping(value = {"/onapapi/uui-lcm/v1/ns-packages"}, method = RequestMethod.POST , produces = "application/json")
public DistributionResult distributeNsPackage(@RequestBody Csar csar){
return packageDistributionService.postNsPackage(csar);
}
@ResponseBody
- @RequestMapping(value = {"/lcm/vf-packages"}, method = RequestMethod.POST , produces = "application/json")
+ @RequestMapping(value = {"/onapapi/uui-lcm/v1/vf-packages"}, method = RequestMethod.POST , produces = "application/json")
public Job distributeVfPackage(@RequestBody Csar csar){
return packageDistributionService.postVfPackage(csar);
}
@ResponseBody
- @RequestMapping(value = {"/lcm/jobs/{jobId}"}, method = RequestMethod.POST , produces = "application/json")
+ @RequestMapping(value = {"/onapapi/uui-lcm/v1/jobs/{jobId}"}, method = RequestMethod.POST , produces = "application/json")
public JobStatus getJobStatus(@PathVariable(value="jobId") String jobId){
return packageDistributionService.getJobStatus(jobId);
}
}
@ResponseBody
- @RequestMapping(value = {"/lcm/service-instances"}, method = RequestMethod.GET , produces = "application/json")
+ @RequestMapping(value = {"/onapapi/uui-lcm/v1/service-instances"}, method = RequestMethod.GET , produces = "application/json")
public List<ServiceInstance> listServiceInstances(HttpServletRequest request){
String customerId = request.getParameter("customerId");
String serviceType = request.getParameter("serviceType");
}
@ResponseBody
- @RequestMapping(value = {"/lcm/services"}, method = RequestMethod.POST , produces = "application/json")
+ @RequestMapping(value = {"/onapapi/uui-lcm/v1/services/"}, method = RequestMethod.POST , produces = "application/json")
public ServiceOperation instantiateService(@RequestBody ServiceInstantiationRequest request){
return serviceLcmService.instantiateService(request);
}
@ResponseBody
- @RequestMapping(value = {"/lcm/services/{serviceId}/operations/{operationId}"}, method = RequestMethod.GET , produces = "application/json")
+ @RequestMapping(value = {"/onapapi/uui-lcm/v1/services/{serviceId}/operations/{operationId}"}, method = RequestMethod.GET , produces = "application/json")
public OperationProgressInformation queryOperationProgress(@PathVariable(value="serviceId") String serviceId, @PathVariable(value="operationId") String operationId){
return serviceLcmService.queryOperationProgress(serviceId, operationId);
}
@ResponseBody
- @RequestMapping(value = {"/lcm/services/{serviceId}"}, method = RequestMethod.DELETE , produces = "application/json")
+ @RequestMapping(value = {"/onapapi/uui-lcm/v1/services/{serviceId}"}, method = RequestMethod.DELETE , produces = "application/json")
public ServiceOperation terminateService(@PathVariable(value = "serviceId") String serviceId){
return serviceLcmService.terminateService(serviceId);
}
*/
package org.onap.usecaseui.server.controller.lcm;
-import org.onap.usecaseui.server.bean.lcm.ServiceTemplateInputRsp;
+import org.onap.usecaseui.server.bean.lcm.ServiceTemplateInput;
import org.onap.usecaseui.server.service.lcm.ServiceTemplateService;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.VimInfo;
import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.SDCServiceTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
@ResponseBody
- @RequestMapping(value = {"/lcm/service-templates"}, method = RequestMethod.GET , produces = "application/json")
+ @RequestMapping(value = {"/onapapi/uui-lcm/v1/service-templates"}, method = RequestMethod.GET , produces = "application/json")
public List<SDCServiceTemplate> getServiceTemplates(){
return serviceTemplateService.listDistributedServiceTemplate();
}
@ResponseBody
- @RequestMapping(value = {"/lcm/service-templates/service-template/{uuid}"}, method = RequestMethod.GET , produces = "application/json")
- public ServiceTemplateInputRsp getServiceTemplateInput(@PathVariable("uuid") String uuid, @RequestParam("toscaModelPath") String toscaModelPath){
+ @RequestMapping(value = {"/onapapi/uui-lcm/v1/service-templates/{uuid}"}, method = RequestMethod.GET , produces = "application/json")
+ public ServiceTemplateInput getServiceTemplateInput(@PathVariable("uuid") String uuid, @RequestParam("toscaModelPath") String toscaModelPath){
return serviceTemplateService.fetchServiceTemplateInput(uuid, toscaModelPath);
}
+
+ @ResponseBody
+ @RequestMapping(value = {"/onapapi/uui-lcm/v1/locations/"}, method = RequestMethod.GET , produces = "application/json")
+ public List<VimInfo> getLocations(){
+ return serviceTemplateService.listVim();
+ }
}
package org.onap.usecaseui.server.service.lcm;
import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAICustomer;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAIServiceSubscription;
import java.util.List;
public interface CustomerService {
List<AAICustomer> listCustomer();
+ List<AAIServiceSubscription> listServiceSubscriptions(String customerId);
}
*/
package org.onap.usecaseui.server.service.lcm;
-import org.onap.usecaseui.server.bean.lcm.ServiceTemplateInputRsp;
+import org.onap.usecaseui.server.bean.lcm.ServiceTemplateInput;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.VimInfo;
import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.SDCServiceTemplate;
import java.util.List;
List<SDCServiceTemplate> listDistributedServiceTemplate();
- ServiceTemplateInputRsp fetchServiceTemplateInput(String uuid, String toscaModelPath);
+ ServiceTemplateInput fetchServiceTemplateInput(String uuid, String toscaModelPath);
+
+ List<VimInfo> listVim();
}
\ No newline at end of file
package org.onap.usecaseui.server.service.lcm.domain.aai;
import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAICustomer;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAIServiceSubscription;
import org.onap.usecaseui.server.service.lcm.domain.aai.bean.ServiceInstance;
import org.onap.usecaseui.server.service.lcm.domain.aai.bean.VimInfo;
import retrofit2.Call;
})
@GET("/cloud-infrastructure/cloud-regions")
Call<List<VimInfo>> listVimInfo();
+
+ @Headers({
+ "X-TransactionId: 7777",
+ "X-FromAppId: uui",
+ "Authorization: QUFJOkFBSQ=="
+ })
+ @GET("/api/aai-business/v11/customers/customer/{global-customer-id}/service-subscriptions")
+ Call<List<AAIServiceSubscription>> listServiceSubscriptions(@Path("global-customer-id") String customerId);
}
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onap.usecaseui.server.bean.lcm;
+package org.onap.usecaseui.server.service.lcm.domain.aai.bean;
-public class ServiceTemplate {
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class AAIServiceSubscription {
+
+ private String serviceType;
+
+ @JsonCreator
+ public AAIServiceSubscription(@JsonProperty("service-type") String serviceType) {
+ this.serviceType = serviceType;
+ }
+
+ @JsonProperty("service-type")
+ public String getServiceType() {
+ return serviceType;
+ }
}
private String name;
+ private String version;
+
private String toscaModelURL;
private String category;
@JsonProperty String uuid,
@JsonProperty String invariantUUID,
@JsonProperty String name,
+ @JsonProperty String version,
@JsonProperty String toscaModelURL,
@JsonProperty String category) {
this.uuid = uuid;
this.invariantUUID = invariantUUID;
this.name = name;
+ this.version = version;
this.toscaModelURL = toscaModelURL;
this.category = category;
}
return name;
}
+ public String getVersion() {
+ return version;
+ }
+
public String getToscaModelURL() {
return toscaModelURL;
}
return Objects.equals(uuid, that.uuid) &&
Objects.equals(invariantUUID, that.invariantUUID) &&
Objects.equals(name, that.name) &&
+ Objects.equals(version, that.version) &&
Objects.equals(toscaModelURL, that.toscaModelURL) &&
Objects.equals(category, that.category);
}
@Override
public int hashCode() {
- return Objects.hash(uuid, invariantUUID, name, toscaModelURL, category);
+ return Objects.hash(uuid, invariantUUID, name, version, toscaModelURL, category);
}
}
import org.onap.usecaseui.server.service.lcm.CustomerService;
import org.onap.usecaseui.server.service.lcm.domain.aai.AAIService;
import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAICustomer;
+import org.onap.usecaseui.server.service.lcm.domain.aai.bean.AAIServiceSubscription;
import org.onap.usecaseui.server.service.lcm.domain.aai.exceptions.AAIException;
import org.onap.usecaseui.server.util.RestfulServices;
import org.slf4j.Logger;
throw new AAIException("AAI is not available.", e);
}
}
+
+ @Override
+ public List<AAIServiceSubscription> listServiceSubscriptions(String customerId) {
+ try {
+ return this.aaiService.listServiceSubscriptions(customerId).execute().body();
+ } catch (IOException e) {
+ logger.error("list customers occur exception");
+ throw new AAIException("AAI is not available.", e);
+ }
+ }
}
import org.onap.usecaseui.server.bean.lcm.VfNsPackageInfo;
import org.onap.usecaseui.server.service.lcm.PackageDistributionService;
-import org.onap.usecaseui.server.service.lcm.domain.aai.AAIService;
-import org.onap.usecaseui.server.service.lcm.domain.aai.bean.VimInfo;
import org.onap.usecaseui.server.service.lcm.domain.sdc.SDCCatalogService;
import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.SDCServiceTemplate;
import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.Vnf;
private SDCCatalogService sdcCatalogService;
- private AAIService aaiService;
-
private VfcService vfcService;
public DefaultPackageDistributionService() {
- this(create(SDCCatalogService.class), create(AAIService.class), create(VfcService.class));
+ this(create(SDCCatalogService.class), create(VfcService.class));
}
- public DefaultPackageDistributionService(SDCCatalogService sdcCatalogService, AAIService aaiService, VfcService vfcService) {
+ public DefaultPackageDistributionService(SDCCatalogService sdcCatalogService, VfcService vfcService) {
this.sdcCatalogService = sdcCatalogService;
- this.aaiService = aaiService;
this.vfcService = vfcService;
}
try {
List<SDCServiceTemplate> nsTemplate = sdcCatalogService.listServices(CATEGORY_NS, DISTRIBUTION_STATUS_DISTRIBUTED).execute().body();
List<Vnf> vnf = sdcCatalogService.listResources(RESOURCETYPE_VF, DISTRIBUTION_STATUS_DISTRIBUTED).execute().body();
- List<VimInfo> vim = aaiService.listVimInfo().execute().body();
- return new VfNsPackageInfo(nsTemplate, vnf, vim);
+ return new VfNsPackageInfo(nsTemplate, vnf);
} catch (IOException e) {
throw new SDCCatalogException("SDC Service is not available!", e);
}
import com.google.common.io.Files;
import okhttp3.ResponseBody;
import org.onap.usecaseui.server.bean.lcm.ServiceTemplateInput;
-import org.onap.usecaseui.server.bean.lcm.ServiceTemplateInputRsp;
import org.onap.usecaseui.server.bean.lcm.TemplateInput;
import org.onap.usecaseui.server.service.lcm.ServiceTemplateService;
import org.onap.usecaseui.server.service.lcm.domain.aai.AAIService;
import org.onap.usecaseui.server.service.lcm.domain.aai.bean.VimInfo;
+import org.onap.usecaseui.server.service.lcm.domain.aai.exceptions.AAIException;
import org.onap.usecaseui.server.service.lcm.domain.sdc.SDCCatalogService;
import org.onap.usecaseui.server.service.lcm.domain.sdc.bean.SDCServiceTemplate;
import org.onap.usecaseui.server.service.lcm.domain.sdc.exceptions.SDCCatalogException;
}
@Override
- public ServiceTemplateInputRsp fetchServiceTemplateInput(String uuid, String toscaModelPath) {
+ public ServiceTemplateInput fetchServiceTemplateInput(String uuid, String toscaModelPath) {
+ return fetchServiceTemplate(uuid, toscaModelPath);
+ }
+
+ private ServiceTemplateInput fetchServiceTemplate(String uuid, String toscaModelPath) {
String rootPath = "http://localhost";// get from msb
String templateUrl = String.format("%s/%s", rootPath, toscaModelPath);
String toPath = String.format("temp/%s.csar", uuid);
try {
downloadFile(templateUrl, toPath);
- List<ServiceTemplateInput> serviceTemplateInputs = new ArrayList<>();
- serviceTemplateInputs = extractInputs(toPath, serviceTemplateInputs);
- List<VimInfo> vimInfo = aaiService.listVimInfo().execute().body();
- return new ServiceTemplateInputRsp(serviceTemplateInputs, vimInfo);
+ return extractTemplate(toPath);
} catch (IOException e) {
throw new SDCCatalogException("download csar file failed!", e);
} catch (JToscaException e) {
}
}
- private List<ServiceTemplateInput> extractInputs(String toPath, List<ServiceTemplateInput> serviceTemplateInputs) throws JToscaException, IOException {
+ private ServiceTemplateInput extractTemplate(String toPath) throws JToscaException, IOException {
ToscaTemplate tosca = translateToToscaTemplate(toPath);
ServiceTemplateInput serviceTemplateInput = fetchServiceTemplateInput(tosca);
- serviceTemplateInputs.add(serviceTemplateInput);
for (NodeTemplate nodeTemplate : tosca.getNodeTemplates()) {
String nodeUUID = nodeTemplate.getMetaData().getValue("UUID");
SDCServiceTemplate template = sdcCatalog.getService(nodeUUID).execute().body();
if (toscaModelURL == null) {
continue;
}
- String savePath = String.format("temp/%s.csar", nodeUUID);
- downloadFile(toscaModelURL, savePath);
- extractInputs(savePath, serviceTemplateInputs);
+ ServiceTemplateInput nodeService = fetchServiceTemplate(nodeUUID, toscaModelURL);
+ serviceTemplateInput.addNestedTemplate(nodeService);
}
- return serviceTemplateInputs;
+ return serviceTemplateInput;
}
+// private List<ServiceTemplateInput> extractInputs(String toPath, List<ServiceTemplateInput> serviceTemplateInputs) throws JToscaException, IOException {
+// ToscaTemplate tosca = translateToToscaTemplate(toPath);
+// ServiceTemplateInput serviceTemplateInput = fetchServiceTemplateInput(tosca);
+// serviceTemplateInputs.add(serviceTemplateInput);
+// for (NodeTemplate nodeTemplate : tosca.getNodeTemplates()) {
+// String nodeUUID = nodeTemplate.getMetaData().getValue("UUID");
+// SDCServiceTemplate template = sdcCatalog.getService(nodeUUID).execute().body();
+// String toscaModelURL = template.getToscaModelURL();
+// if (toscaModelURL == null) {
+// continue;
+// }
+// String savePath = String.format("temp/%s.csar", nodeUUID);
+// downloadFile(toscaModelURL, savePath);
+// extractInputs(savePath, serviceTemplateInputs);
+// }
+// return serviceTemplateInputs;
+// }
+
protected ToscaTemplate translateToToscaTemplate(String toPath) throws JToscaException {
return new ToscaTemplate(toPath,null,true,null,true);
}
String uuid = tosca.getMetaData().getValue("UUID");
String name = tosca.getMetaData().getValue("name");
String type = tosca.getMetaData().getValue("type");
+ String version = tosca.getMetaData().getValue("version");
+ if (version == null) {
+ version = "";
+ }
String description = tosca.getMetaData().getValue("description");
String category = tosca.getMetaData().getValue("category");
String subcategory = tosca.getMetaData().getValue("subcategory");
uuid,
name,
type,
+ version,
description,
category,
subcategory,
templateInputs);
}
+
+ @Override
+ public List<VimInfo> listVim() {
+ try {
+ return aaiService.listVimInfo().execute().body();
+ } catch (IOException e) {
+ logger.error("Visit AAI occur exception");
+ throw new AAIException("AAI is not available.", e);
+ }
+ }
}
@Test
public void itCanRetrievePackageFromSDCAndAAI() {
- List<SDCServiceTemplate> serviceTemplate = Collections.singletonList(new SDCServiceTemplate("1", "1", "service", "", ""));
+ List<SDCServiceTemplate> serviceTemplate = Collections.singletonList(new SDCServiceTemplate("1", "1", "service", "V1","", ""));
List<Vnf> vnf = Collections.singletonList(new Vnf("2","2","vnf"));
SDCCatalogService sdcService = newSDCService(serviceTemplate, vnf);
List<VimInfo> vim = Collections.singletonList(new VimInfo("owner", "regionId"));
AAIService aaiService = newAAIService(vim);
- PackageDistributionService service = new DefaultPackageDistributionService(sdcService,aaiService, null);
+ PackageDistributionService service = new DefaultPackageDistributionService(sdcService, null);
- Assert.assertThat(service.retrievePackageInfo(), equalTo(new VfNsPackageInfo(serviceTemplate, vnf, vim)));
+ Assert.assertThat(service.retrievePackageInfo(), equalTo(new VfNsPackageInfo(serviceTemplate, vnf)));
}
private AAIService newAAIService(List<VimInfo> vim) {
List<VimInfo> vim = Collections.singletonList(new VimInfo("owner", "regionId"));
AAIService aaiService = newAAIService(vim);
- PackageDistributionService service = new DefaultPackageDistributionService(sdcService,aaiService, null);
+ PackageDistributionService service = new DefaultPackageDistributionService(sdcService, null);
service.retrievePackageInfo();
}
Csar csar = new Csar();
DistributionResult result = new DistributionResult("status", "description", "errorcode");
when(vfcService.distributeNsPackage(csar)).thenReturn(successfulCall(result));
- PackageDistributionService service = new DefaultPackageDistributionService(null, null, vfcService);
+ PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
Assert.assertSame(result, service.postNsPackage(csar));
}
VfcService vfcService = mock(VfcService.class);
Csar csar = new Csar();
when(vfcService.distributeNsPackage(csar)).thenReturn(failedCall("VFC is not available!"));
- PackageDistributionService service = new DefaultPackageDistributionService(null, null, vfcService);
+ PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.postNsPackage(csar);
}
Csar csar = new Csar();
Job job = new Job();
when(vfcService.distributeVnfPackage(csar)).thenReturn(successfulCall(job));
- PackageDistributionService service = new DefaultPackageDistributionService(null, null, vfcService);
+ PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
Assert.assertSame(job, service.postVfPackage(csar));
}
VfcService vfcService = mock(VfcService.class);
Csar csar = new Csar();
when(vfcService.distributeVnfPackage(csar)).thenReturn(failedCall("VFC is not available!"));
- PackageDistributionService service = new DefaultPackageDistributionService(null, null, vfcService);
+ PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.postVfPackage(csar);
}
String jobId = "1";
JobStatus jobStatus = new JobStatus();
when(vfcService.getJobStatus(jobId)).thenReturn(successfulCall(jobStatus));
- PackageDistributionService service = new DefaultPackageDistributionService(null, null, vfcService);
+ PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
Assert.assertSame(jobStatus, service.getJobStatus(jobId));
}
VfcService vfcService = mock(VfcService.class);
String jobId = "1";
when(vfcService.getJobStatus(jobId)).thenReturn(failedCall("VFC is not available!"));
- PackageDistributionService service = new DefaultPackageDistributionService(null, null, vfcService);
+ PackageDistributionService service = new DefaultPackageDistributionService(null, vfcService);
service.getJobStatus(jobId);
}
}
\ No newline at end of file
import org.junit.Assert;
import org.junit.Test;
import org.onap.usecaseui.server.bean.lcm.ServiceTemplateInput;
-import org.onap.usecaseui.server.bean.lcm.ServiceTemplateInputRsp;
import org.onap.usecaseui.server.bean.lcm.TemplateInput;
import org.onap.usecaseui.server.service.lcm.ServiceTemplateService;
import org.onap.usecaseui.server.service.lcm.domain.aai.AAIService;
@Test
public void itCanListDistributedServiceTemplate() {
- List<SDCServiceTemplate> templates = Collections.singletonList(new SDCServiceTemplate("uuid", "uuid", "name", "url", "category"));
+ List<SDCServiceTemplate> templates = Collections.singletonList(new SDCServiceTemplate("uuid", "uuid", "name", "V1","url", "category"));
SDCCatalogService sdcService = mock(SDCCatalogService.class);
when(sdcService.listServices(CATEGORY_E2E_SERVICE, DISTRIBUTION_STATUS_DISTRIBUTED)).thenReturn(successfulCall(templates));
ServiceTemplateService service = newServiceTemplateService(uuid, nodeUUID, sdcService, aaiService);
- Assert.assertThat(service.fetchServiceTemplateInput(uuid, modelPath), equalTo(new ServiceTemplateInputRsp(expectedServiceInputs(uuid, nodeUUID),vim)));
+ Assert.assertThat(service.fetchServiceTemplateInput(uuid, modelPath), equalTo(expectedServiceInputs(uuid, nodeUUID)));
}
private DefaultServiceTemplateService newServiceTemplateService(String uuid, String nodeUUID, SDCCatalogService sdcService, AAIService aaiService) {
private SDCCatalogService newSdcCatalogService(String nodeUUID) throws IOException {
SDCCatalogService sdcService = mock(SDCCatalogService.class);
- when(sdcService.getService(nodeUUID)).thenReturn(successfulCall(new SDCServiceTemplate(nodeUUID, nodeUUID, "node", "nodeModelUrl", "service")));
+ when(sdcService.getService(nodeUUID)).thenReturn(successfulCall(new SDCServiceTemplate(nodeUUID, nodeUUID, "node", "V1", "nodeModelUrl", "service")));
return sdcService;
}
- private List<ServiceTemplateInput> expectedServiceInputs(String uuid, String nodeUUID) {
+ private ServiceTemplateInput expectedServiceInputs(String uuid, String nodeUUID) {
ServiceTemplateInput e2eServiceTemplateInput = new ServiceTemplateInput(
- uuid, uuid, "VoLTE", "service", "VoLTE", "service", "", Collections.EMPTY_LIST);
+ uuid, uuid, "VoLTE", "service","", "VoLTE", "service", "", Collections.EMPTY_LIST);
TemplateInput templateInput = new TemplateInput("field_name","field_type", "field_description", "true", "field_default");
ServiceTemplateInput nodeTemplateInput = new ServiceTemplateInput(
- nodeUUID, nodeUUID, "", "", "", "service", "", Collections.singletonList(templateInput));
- return Arrays.asList(e2eServiceTemplateInput, nodeTemplateInput);
+ nodeUUID, nodeUUID, "", "", "","", "service", "", Collections.singletonList(templateInput));
+ e2eServiceTemplateInput.addNestedTemplate(nodeTemplateInput);
+ return e2eServiceTemplateInput;
}
private ToscaTemplate e2eToscaTemplate(String nodeUUID) {