Replaced all tabs with spaces in java and pom.xml
[so.git] / bpmn / so-bpmn-tasks / src / test / java / org / onap / so / bpmn / common / data / TestDataSetup.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 package org.onap.so.bpmn.common.data;
21
22 import static org.mockito.Mockito.doReturn;
23 import static org.mockito.Mockito.mock;
24 import java.util.ArrayList;
25 import java.util.Arrays;
26 import java.util.HashMap;
27 import java.util.List;
28 import java.util.Map;
29 import java.util.UUID;
30 import org.camunda.bpm.engine.delegate.DelegateExecution;
31 import org.camunda.bpm.engine.impl.pvm.runtime.ExecutionImpl;
32 import org.junit.Before;
33 import org.junit.Rule;
34 import org.junit.rules.ExpectedException;
35 import org.onap.so.bpmn.common.BuildingBlockExecution;
36 import org.onap.so.bpmn.common.DelegateExecutionImpl;
37 import org.onap.so.bpmn.servicedecomposition.bbobjects.AllottedResource;
38 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
39 import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
40 import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
41 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
42 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
43 import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
44 import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
45 import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness;
46 import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy;
47 import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity;
48 import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform;
49 import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
50 import org.onap.so.bpmn.servicedecomposition.bbobjects.Project;
51 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
52 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy;
53 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription;
54 import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet;
55 import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
56 import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
57 import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding;
58 import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBondingLink;
59 import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
60 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
61 import org.onap.so.bpmn.servicedecomposition.generalobjects.License;
62 import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
63 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
64 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters;
65 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoAllottedResource;
66 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration;
67 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
68 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork;
69 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
70 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceProxy;
71 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
72 import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
73 import org.onap.so.client.exception.BBObjectNotFoundException;
74 import org.onap.so.db.catalog.beans.OrchestrationStatus;
75
76 public class TestDataSetup {
77     private int collectionCounter;
78     private int configurationCounter;
79     private int customerCounter;
80     private int genericVnfCounter;
81     private int instanceGroupCounter;
82     private int l3NetworkCounter;
83     private int owningEntityCounter;
84     private int pnfCounter;
85     private int projectCounter;
86     private int serviceInstanceCounter;
87     private int serviceProxyCounter;
88     private int serviceSubscriptionCounter;
89     private int vfModuleCounter;
90     private int volumeGroupCounter;
91     private int vpnBindingCounter;
92     private int vpnBondingLinkCounter;
93
94     protected BuildingBlockExecution execution;
95
96     protected GeneralBuildingBlock gBBInput;
97
98     protected HashMap<ResourceKey, String> lookupKeyMap;
99
100     protected ExtractPojosForBB extractPojosForBB = new ExtractPojosForBB();
101
102     @Rule
103     public ExpectedException expectedException = ExpectedException.none();
104
105     protected DelegateExecution delegateExecution;
106
107     @Before
108     public void buildingBlockTestDataSetupBefore() {
109         collectionCounter = 0;
110         configurationCounter = 0;
111         customerCounter = 0;
112         genericVnfCounter = 0;
113         instanceGroupCounter = 0;
114         l3NetworkCounter = 0;
115         owningEntityCounter = 0;
116         pnfCounter = 0;
117         projectCounter = 0;
118         serviceInstanceCounter = 0;
119         serviceProxyCounter = 0;
120         serviceSubscriptionCounter = 0;
121         vfModuleCounter = 0;
122         volumeGroupCounter = 0;
123         vpnBindingCounter = 0;
124         vpnBondingLinkCounter = 0;
125
126         execution = new DelegateExecutionImpl(new ExecutionImpl());
127         execution.setVariable("testProcessKey", "testProcessKeyValue");
128
129         gBBInput = new GeneralBuildingBlock();
130         execution.setVariable("gBBInput", gBBInput);
131
132         lookupKeyMap = new HashMap<ResourceKey, String>();
133         execution.setVariable("lookupKeyMap", lookupKeyMap);
134
135         ExecutionImpl mockExecutionImpl = mock(ExecutionImpl.class);
136         doReturn("test").when(mockExecutionImpl).getProcessInstanceId();
137
138         ExecutionImpl executionImpl = new ExecutionImpl();
139         executionImpl.setProcessInstance(mockExecutionImpl);
140
141         delegateExecution = (DelegateExecution) executionImpl;
142         delegateExecution.setVariable("testProcessKey", "testProcessKeyValue");
143     }
144
145     public Map<String, String> buildUserInput() {
146         Map<String, String> userInput = new HashMap<>();
147         userInput.put("testUserInputKey", "testUserInputValue");
148
149         return userInput;
150     }
151
152     public Map<String, String> setUserInput() {
153         Map<String, String> userInput = buildUserInput();
154
155         gBBInput.setUserInput(userInput);
156
157         return userInput;
158     }
159
160     public RequestContext buildRequestContext() {
161         RequestContext requestContext = new RequestContext();
162         requestContext.setMsoRequestId(UUID.randomUUID().toString());
163         requestContext.setProductFamilyId("testProductFamilyId");
164         requestContext.setRequestorId("testRequestorId");
165
166         requestContext.setUserParams(new HashMap<>());
167
168         Map<String, Object> dataMap = new HashMap<>();
169         dataMap.put("vpnId", "testVpnId");
170         dataMap.put("vpnRegion", "testVpnRegion");
171         dataMap.put("vpnRt", "testVpnRt");
172         dataMap.put("vpnName", "vpnName");
173         dataMap.put("vpnRegion", Arrays.asList(new String[] {"USA", "EMEA", "APAC"}));
174
175         HashMap<String, Object> userParams = new HashMap<>();
176         userParams.put("vpnData", dataMap);
177
178         List<Map<String, Object>> userParamsList = new ArrayList<>();
179         userParamsList.add(userParams);
180
181         RequestParameters requestParameters = new RequestParameters();
182         requestParameters.setUserParams(userParamsList);
183         requestContext.setRequestParameters(requestParameters);
184
185         return requestContext;
186     }
187
188     public RequestContext setRequestContext() {
189         RequestContext requestContext = buildRequestContext();
190
191         gBBInput.setRequestContext(requestContext);
192
193         return requestContext;
194     }
195
196     public CloudRegion buildCloudRegion() {
197         CloudRegion cloudRegion = new CloudRegion();
198         cloudRegion.setLcpCloudRegionId("testLcpCloudRegionId");
199         cloudRegion.setTenantId("testTenantId");
200         cloudRegion.setCloudOwner("testCloudOwner");
201
202         return cloudRegion;
203     }
204
205     public CloudRegion setCloudRegion() {
206         CloudRegion cloudRegion = buildCloudRegion();
207
208         gBBInput.setCloudRegion(cloudRegion);
209
210         return cloudRegion;
211     }
212
213     public OrchestrationContext buildOrchestrationContext() {
214         OrchestrationContext orchestrationContext = new OrchestrationContext();
215
216         return orchestrationContext;
217     }
218
219     public OrchestrationContext setOrchestrationContext() {
220         OrchestrationContext orchestrationContext = buildOrchestrationContext();
221
222         gBBInput.setOrchContext(orchestrationContext);
223
224         return orchestrationContext;
225     }
226
227     public Collection buildCollection() {
228         collectionCounter++;
229
230         Collection collection = new Collection();
231         collection.setId("testId" + collectionCounter);
232         collection.setInstanceGroup(buildInstanceGroup());
233
234         return collection;
235     }
236
237     public Configuration buildConfiguration() {
238         configurationCounter++;
239
240         Configuration configuration = new Configuration();
241         configuration.setConfigurationId("testConfigurationId" + configurationCounter);
242         configuration.setConfigurationName("testConfigurationName" + configurationCounter);
243
244         ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration();
245         modelInfoConfiguration.setModelVersionId("testModelVersionId" + configurationCounter);
246         modelInfoConfiguration.setModelInvariantId("testModelInvariantId" + configurationCounter);
247         modelInfoConfiguration.setModelCustomizationId("testModelCustomizationId" + configurationCounter);
248
249         configuration.setModelInfoConfiguration(modelInfoConfiguration);
250
251         return configuration;
252     }
253
254     public OwningEntity buildOwningEntity() {
255         owningEntityCounter++;
256
257         OwningEntity owningEntity = new OwningEntity();
258         owningEntity.setOwningEntityId("testOwningEntityId" + owningEntityCounter);
259         owningEntity.setOwningEntityName("testOwningEntityName" + owningEntityCounter);
260
261         return owningEntity;
262     }
263
264     public Project buildProject() {
265         projectCounter++;
266
267         Project project = new Project();
268         project.setProjectName("testProjectName1 , testProjectName2      , testProjectName3" + projectCounter);
269
270         return project;
271     }
272
273     public ServiceSubscription buildServiceSubscription() {
274         serviceSubscriptionCounter++;
275
276         ServiceSubscription serviceSubscription = new ServiceSubscription();
277         serviceSubscription.setTempUbSubAccountId("testTempUbSubAccountId" + serviceSubscriptionCounter);
278         serviceSubscription.setServiceType("testServiceType" + serviceSubscriptionCounter);
279
280         return serviceSubscription;
281     }
282
283     public Customer buildCustomer() {
284         customerCounter++;
285
286         Customer customer = new Customer();
287         customer.setGlobalCustomerId("testGlobalCustomerId" + customerCounter);
288         customer.setSubscriberType("testSubscriberType" + customerCounter);
289
290         customer.setServiceSubscription(buildServiceSubscription());
291
292         return customer;
293     }
294
295     public ServiceInstance buildServiceInstance() {
296         serviceInstanceCounter++;
297
298         ServiceInstance serviceInstance = new ServiceInstance();
299         serviceInstance.setServiceInstanceId("testServiceInstanceId" + serviceInstanceCounter);
300         serviceInstance.setServiceInstanceName("testServiceInstanceName" + serviceInstanceCounter);
301
302         ModelInfoServiceInstance modelInfoServiceInstance = new ModelInfoServiceInstance();
303         modelInfoServiceInstance.setModelInvariantUuid("testModelInvariantUUID" + serviceInstanceCounter);
304         modelInfoServiceInstance.setModelUuid("testModelUUID" + serviceInstanceCounter);
305         modelInfoServiceInstance.setModelVersion("testModelVersion" + serviceInstanceCounter);
306         modelInfoServiceInstance.setModelName("testModelName" + serviceInstanceCounter);
307         modelInfoServiceInstance.setServiceType("testServiceType" + serviceInstanceCounter);
308         modelInfoServiceInstance.setServiceRole("testServiceRole" + serviceInstanceCounter);
309         serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
310
311         serviceInstance.setProject(buildProject());
312
313         serviceInstance.setOwningEntity(buildOwningEntity());
314
315         serviceInstance.setCollection(buildCollection());
316
317         serviceInstance.getConfigurations().add(buildConfiguration());
318
319         return serviceInstance;
320     }
321
322     public ServiceInstance setServiceInstance() {
323         ServiceInstance serviceInstance = buildServiceInstance();
324
325         if (gBBInput.getCustomer() == null) {
326             gBBInput.setCustomer(buildCustomer());
327         }
328         gBBInput.getCustomer().getServiceSubscription().getServiceInstances().add(serviceInstance);
329         lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstance.getServiceInstanceId());
330
331         return serviceInstance;
332     }
333
334     public Customer setCustomer() {
335         if (gBBInput.getCustomer() != null)
336             return gBBInput.getCustomer();
337         Customer customer = new Customer();
338         customer.setGlobalCustomerId("testGlobalCustomerId");
339         customer.setSubscriberType("testSubscriberType");
340
341         customer.setServiceSubscription(buildServiceSubscription());
342
343         gBBInput.setCustomer(customer);
344
345         return customer;
346     }
347
348     public Collection setCollection() {
349         Collection collection = new Collection();
350         collection.setId("testId");
351
352         ServiceInstance serviceInstance = null;
353
354         try {
355             serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
356         } catch (BBObjectNotFoundException e) {
357             serviceInstance = setServiceInstance();
358         }
359
360         serviceInstance.setCollection(collection);
361
362         return collection;
363     }
364
365     public InstanceGroup setInstanceGroup() {
366         InstanceGroup instanceGroup = new InstanceGroup();
367         instanceGroup.setId("testId");
368         instanceGroup.setInstanceGroupFunction("testInstanceGroupFunction");
369
370         Collection collection = null;
371
372         try {
373             ServiceInstance serviceInstance =
374                     extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
375             collection = serviceInstance.getCollection();
376
377             if (collection == null) {
378                 collection = setCollection();
379             }
380         } catch (BBObjectNotFoundException e) {
381             collection = setCollection();
382         }
383
384         collection.setInstanceGroup(instanceGroup);
385
386
387         return instanceGroup;
388     }
389
390     public InstanceGroup setInstanceGroupVnf() {
391         InstanceGroup instanceGroup = buildInstanceGroup();
392
393         ServiceInstance serviceInstance = null;
394
395         try {
396             serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
397         } catch (BBObjectNotFoundException e) {
398             serviceInstance = setServiceInstance();
399         }
400
401         serviceInstance.getInstanceGroups().add(instanceGroup);
402         lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, instanceGroup.getId());
403
404         return instanceGroup;
405     }
406
407     public VpnBinding buildVpnBinding() {
408         vpnBindingCounter++;
409
410         VpnBinding vpnBinding = new VpnBinding();
411         vpnBinding.setVpnId("testVpnId" + vpnBindingCounter);
412         vpnBinding.setVpnName("testVpnName" + vpnBindingCounter);
413         vpnBinding.setCustomerVpnId("testCustomerVpnId" + vpnBindingCounter);
414
415         return vpnBinding;
416     }
417
418     public VpnBinding setVpnBinding() {
419         VpnBinding vpnBinding = buildVpnBinding();
420
421         Customer customer = gBBInput.getCustomer();
422
423         if (customer == null) {
424             customer = buildCustomer();
425         }
426
427         customer.getVpnBindings().add(vpnBinding);
428         lookupKeyMap.put(ResourceKey.VPN_ID, vpnBinding.getVpnId());
429
430         return vpnBinding;
431     }
432
433     public InstanceGroup buildInstanceGroup() {
434         instanceGroupCounter++;
435
436         InstanceGroup instanceGroup = new InstanceGroup();
437         instanceGroup.setId("testId" + instanceGroupCounter);
438         instanceGroup.setInstanceGroupFunction("testInstanceGroupFunction" + instanceGroupCounter);
439
440         return instanceGroup;
441     }
442
443     public L3Network buildL3Network() {
444         l3NetworkCounter++;
445
446         L3Network network = new L3Network();
447         network.setNetworkId("testNetworkId" + l3NetworkCounter);
448         network.setNetworkName("testNetworkName" + l3NetworkCounter);
449         network.setNetworkType("testNetworkType" + l3NetworkCounter);
450
451         ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
452         modelInfoNetwork.setModelInvariantUUID("testModelInvariantUUID" + l3NetworkCounter);
453         modelInfoNetwork.setModelName("testModelName" + l3NetworkCounter);
454         modelInfoNetwork.setModelVersion("testModelVersion" + l3NetworkCounter);
455         modelInfoNetwork.setModelUUID("testModelUUID" + l3NetworkCounter);
456         network.setModelInfoNetwork(modelInfoNetwork);
457
458         return network;
459     }
460
461     public L3Network setL3Network() {
462         L3Network network = buildL3Network();
463
464         ServiceInstance serviceInstance = null;
465
466         try {
467             serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
468         } catch (BBObjectNotFoundException e) {
469             serviceInstance = setServiceInstance();
470         }
471
472         serviceInstance.getNetworks().add(network);
473         lookupKeyMap.put(ResourceKey.NETWORK_ID, network.getNetworkId());
474
475         return network;
476     }
477
478     public GenericVnf buildGenericVnf() {
479         genericVnfCounter++;
480
481         GenericVnf genericVnf = new GenericVnf();
482         genericVnf.setVnfId("testVnfId" + genericVnfCounter);
483         genericVnf.setVnfName("testVnfName" + genericVnfCounter);
484         genericVnf.setVnfType("testVnfType" + genericVnfCounter);
485         genericVnf.setIpv4OamAddress("10.222.22.2");
486
487         Platform platform = new Platform();
488         platform.setPlatformName(" testPlatformName, testPlatformName2   ,   testPlatformName3   , testPlatformName4");
489         genericVnf.setPlatform(platform);
490
491         LineOfBusiness lob = new LineOfBusiness();
492         lob.setLineOfBusinessName(
493                 "  testLineOfBusinessName   , testLineOfBusinessName2,    testLineOfBusinessName3,   testLineOfBusinessName4");
494         genericVnf.setLineOfBusiness(lob);
495
496         ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
497         modelInfoGenericVnf.setModelName("testModelName" + genericVnfCounter);
498         modelInfoGenericVnf.setModelCustomizationUuid("testModelCustomizationUUID" + genericVnfCounter);
499         modelInfoGenericVnf.setModelInvariantUuid("testModelInvariantUUID" + genericVnfCounter);
500         modelInfoGenericVnf.setModelVersion("testModelVersion" + genericVnfCounter);
501         modelInfoGenericVnf.setModelUuid("testModelUUID" + genericVnfCounter);
502         modelInfoGenericVnf.setModelInstanceName("testInstanceName" + genericVnfCounter);
503
504         genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf);
505
506         License license = new License();
507         List<String> array = new ArrayList<String>();
508         array.add("testPoolUuid");
509         license.setEntitlementPoolUuids(array);
510         genericVnf.setLicense(license);
511
512         return genericVnf;
513     }
514
515     public GenericVnf setGenericVnf() {
516         GenericVnf genericVnf = buildGenericVnf();
517
518         ServiceInstance serviceInstance = null;
519
520         try {
521             serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
522         } catch (BBObjectNotFoundException e) {
523             serviceInstance = setServiceInstance();
524         }
525
526         serviceInstance.getVnfs().add(genericVnf);
527         lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, genericVnf.getVnfId());
528
529         return genericVnf;
530     }
531
532     public VfModule buildVfModule() {
533         vfModuleCounter++;
534
535         VfModule vfModule = new VfModule();
536         vfModule.setVfModuleId("testVfModuleId" + vfModuleCounter);
537         vfModule.setVfModuleName("testVfModuleName" + vfModuleCounter);
538         vfModule.setModuleIndex(0);
539         ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
540         modelInfoVfModule.setModelInvariantUUID("testModelInvariantUUID" + vfModuleCounter);
541         modelInfoVfModule.setModelVersion("testModelVersion" + vfModuleCounter);
542         modelInfoVfModule.setModelUUID("testModelUUID" + vfModuleCounter);
543         modelInfoVfModule.setModelName("testModelName" + vfModuleCounter);
544         modelInfoVfModule.setModelCustomizationUUID("testModelCustomizationUUID" + vfModuleCounter);
545         vfModule.setModelInfoVfModule(modelInfoVfModule);
546
547         return vfModule;
548     }
549
550     public VfModule setVfModule() {
551         return setVfModule(true);
552     }
553
554     public VfModule setVfModule(boolean addToGenericVnf) {
555         VfModule vfModule = buildVfModule();
556
557         GenericVnf genericVnf = null;
558
559         try {
560             genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
561         } catch (BBObjectNotFoundException e) {
562             genericVnf = setGenericVnf();
563         }
564
565         if (addToGenericVnf) {
566             genericVnf.getVfModules().add(vfModule);
567         }
568         lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModule.getVfModuleId());
569
570         return vfModule;
571     }
572
573     public VolumeGroup buildVolumeGroup() {
574         volumeGroupCounter++;
575
576         VolumeGroup volumeGroup = new VolumeGroup();
577         volumeGroup.setVolumeGroupId("testVolumeGroupId" + volumeGroupCounter);
578         volumeGroup.setVolumeGroupName("testVolumeGroupName" + volumeGroupCounter);
579         volumeGroup.setHeatStackId("testHeatStackId" + volumeGroupCounter);
580
581         return volumeGroup;
582     }
583
584     public VolumeGroup setVolumeGroup() {
585         VolumeGroup volumeGroup = buildVolumeGroup();
586
587         GenericVnf genericVnf = null;
588
589         try {
590             genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
591         } catch (BBObjectNotFoundException e) {
592             genericVnf = setGenericVnf();
593         }
594
595         genericVnf.getVolumeGroups().add(volumeGroup);
596         lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroup.getVolumeGroupId());
597
598         return volumeGroup;
599     }
600
601     public Pnf buildPnf() {
602         pnfCounter++;
603
604         Pnf pnf = new Pnf();
605         pnf.setPnfId("testPnfId" + pnfCounter);
606         pnf.setPnfName("testPnfName" + pnfCounter);
607
608         return pnf;
609     }
610
611     public ServiceProxy buildServiceProxy() {
612         serviceProxyCounter++;
613
614         ServiceProxy serviceProxy = new ServiceProxy();
615         serviceProxy.setServiceInstance(buildServiceInstance());
616         serviceProxy.getServiceInstance().getVnfs().add(buildGenericVnf());
617
618         Pnf primaryPnf = buildPnf();
619         primaryPnf.setRole("Primary");
620         serviceProxy.getServiceInstance().getPnfs().add(primaryPnf);
621
622         Pnf secondaryPnf = buildPnf();
623         secondaryPnf.setRole("Secondary");
624         serviceProxy.getServiceInstance().getPnfs().add(secondaryPnf);
625
626         return serviceProxy;
627     }
628
629     public VpnBondingLink buildVpnBondingLink() {
630         vpnBondingLinkCounter++;
631
632         VpnBondingLink vpnBondingLink = new VpnBondingLink();
633         vpnBondingLink.setVpnBondingLinkId("testVpnBondingLinkId" + vpnBondingLinkCounter);
634
635         Configuration vnrConfiguration = buildConfiguration();
636         vnrConfiguration.setNetwork(buildL3Network());
637         vpnBondingLink.setVnrConfiguration(vnrConfiguration);
638
639         vpnBondingLink.setVrfConfiguration(buildConfiguration());
640
641         vpnBondingLink.setInfrastructureServiceProxy(buildServiceProxy());
642
643         vpnBondingLink.setTransportServiceProxy(buildServiceProxy());
644
645         return vpnBondingLink;
646     }
647
648     public VpnBondingLink setVpnBondingLink() {
649         VpnBondingLink vpnBondingLink = buildVpnBondingLink();
650
651         ServiceInstance serviceInstance = null;
652
653         try {
654             serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
655         } catch (BBObjectNotFoundException e) {
656             serviceInstance = setServiceInstance();
657         }
658
659         serviceInstance.getVpnBondingLinks().add(vpnBondingLink);
660         lookupKeyMap.put(ResourceKey.VPN_BONDING_LINK_ID, vpnBondingLink.getVpnBondingLinkId());
661
662
663         return vpnBondingLink;
664     }
665
666     public Customer setAvpnCustomer() {
667         Customer customer = buildCustomer();
668
669         gBBInput.setCustomer(customer);
670
671         return customer;
672     }
673
674     public ServiceProxy setServiceProxy(String uniqueIdentifier, String type) {
675         ServiceProxy serviceProxy = new ServiceProxy();
676         serviceProxy.setId("testProxyId" + uniqueIdentifier);
677         serviceProxy.setType(type);
678
679         ModelInfoServiceProxy modelInfo = new ModelInfoServiceProxy();
680         modelInfo.setModelInvariantUuid("testProxyModelInvariantUuid" + uniqueIdentifier);
681         modelInfo.setModelName("testProxyModelName" + uniqueIdentifier);
682         modelInfo.setModelUuid("testProxyModelUuid" + uniqueIdentifier);
683         modelInfo.setModelVersion("testProxyModelVersion" + uniqueIdentifier);
684         modelInfo.setModelInstanceName("testProxyInstanceName" + uniqueIdentifier);
685
686         serviceProxy.setModelInfoServiceProxy(modelInfo);
687
688         return serviceProxy;
689     }
690
691     public AllottedResource setAllottedResource(String uniqueIdentifier) {
692         AllottedResource ar = new AllottedResource();
693         ar.setId("testAllottedResourceId" + uniqueIdentifier);
694
695         ModelInfoAllottedResource modelInfo = new ModelInfoAllottedResource();
696         modelInfo.setModelInvariantUuid("testAllottedModelInvariantUuid" + uniqueIdentifier);
697         modelInfo.setModelName("testAllottedModelName" + uniqueIdentifier);
698         modelInfo.setModelUuid("testAllottedModelUuid" + uniqueIdentifier);
699         modelInfo.setModelVersion("testAllottedModelVersion" + uniqueIdentifier);
700         modelInfo.setModelInstanceName("testAllottedModelInstanceName" + uniqueIdentifier);
701
702         ar.setModelInfoAllottedResource(modelInfo);
703
704         return ar;
705     }
706
707     public Configuration setConfiguration() {
708         Configuration config = new Configuration();
709         config.setConfigurationId("testConfigurationId");
710         List<Configuration> configurations = new ArrayList<>();
711         configurations.add(config);
712         ServiceInstance serviceInstance = new ServiceInstance();
713         try {
714             serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
715         } catch (BBObjectNotFoundException e) {
716             serviceInstance = setServiceInstance();
717         }
718         lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "testConfigurationId");
719         serviceInstance.setConfigurations(configurations);
720         return config;
721     }
722
723     public Subnet buildSubnet() {
724         Subnet subnet = new Subnet();
725         subnet.setSubnetId("testSubnetId");
726         subnet.setOrchestrationStatus(OrchestrationStatus.PENDING);
727         subnet.setNeutronSubnetId("testNeutronSubnetId");
728         return subnet;
729     }
730
731     public NetworkPolicy buildNetworkPolicy() {
732         NetworkPolicy networkPolicy = new NetworkPolicy();
733         networkPolicy.setNetworkPolicyId("testNetworkPolicyId");
734         networkPolicy.setNetworkPolicyFqdn("testNetworkPolicyFqdn");
735         networkPolicy.setHeatStackId("testHeatStackId");
736         return networkPolicy;
737     }
738 }