Replaced all tabs with spaces in java and pom.xml
[so.git] / bpmn / MSOCommonBPMN / src / test / java / org / onap / so / BuildingBlockTestDataSetup.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;
21
22 import static org.mockito.Mockito.doReturn;
23 import static org.mockito.Mockito.mock;
24 import java.util.ArrayList;
25 import java.util.HashMap;
26 import java.util.List;
27 import java.util.Map;
28 import java.util.UUID;
29 import org.assertj.core.util.Arrays;
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.CloudRegion;
38 import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
39 import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
40 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
41 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
42 import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
43 import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
44 import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness;
45 import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity;
46 import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform;
47 import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
48 import org.onap.so.bpmn.servicedecomposition.bbobjects.Project;
49 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
50 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy;
51 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription;
52 import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
53 import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
54 import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding;
55 import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBondingLink;
56 import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
57 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
58 import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
59 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
60 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters;
61 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoConfiguration;
62 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf;
63 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork;
64 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
65 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
66 import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
67 import org.onap.so.client.exception.BBObjectNotFoundException;
68 import org.onap.so.bpmn.servicedecomposition.bbobjects.AllottedResource;
69 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoAllottedResource;
70 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceProxy;
71
72 public class BuildingBlockTestDataSetup {
73     private int collectionCounter;
74     private int configurationCounter;
75     private int customerCounter;
76     private int genericVnfCounter;
77     private int instanceGroupCounter;
78     private int l3NetworkCounter;
79     private int owningEntityCounter;
80     private int pnfCounter;
81     private int projectCounter;
82     private int serviceInstanceCounter;
83     private int serviceProxyCounter;
84     private int serviceSubscriptionCounter;
85     private int vfModuleCounter;
86     private int volumeGroupCounter;
87     private int vpnBindingCounter;
88     private int vpnBondingLinkCounter;
89
90     protected BuildingBlockExecution execution;
91
92     protected GeneralBuildingBlock gBBInput;
93
94     protected HashMap<ResourceKey, String> lookupKeyMap;
95
96     protected ExtractPojosForBB extractPojosForBB = new ExtractPojosForBB();
97
98     @Rule
99     public ExpectedException expectedException = ExpectedException.none();
100
101     protected DelegateExecution delegateExecution;
102
103     @Before
104     public void buildingBlockTestDataSetupBefore() {
105         collectionCounter = 0;
106         configurationCounter = 0;
107         customerCounter = 0;
108         genericVnfCounter = 0;
109         instanceGroupCounter = 0;
110         l3NetworkCounter = 0;
111         owningEntityCounter = 0;
112         pnfCounter = 0;
113         projectCounter = 0;
114         serviceInstanceCounter = 0;
115         serviceProxyCounter = 0;
116         serviceSubscriptionCounter = 0;
117         vfModuleCounter = 0;
118         volumeGroupCounter = 0;
119         vpnBindingCounter = 0;
120         vpnBondingLinkCounter = 0;
121
122         execution = new DelegateExecutionImpl(new ExecutionImpl());
123         execution.setVariable("testProcessKey", "testProcessKeyValue");
124
125         gBBInput = new GeneralBuildingBlock();
126         execution.setVariable("gBBInput", gBBInput);
127
128         lookupKeyMap = new HashMap<ResourceKey, String>();
129         execution.setVariable("lookupKeyMap", lookupKeyMap);
130
131         ExecutionImpl mockExecutionImpl = mock(ExecutionImpl.class);
132         doReturn("test").when(mockExecutionImpl).getProcessInstanceId();
133
134         ExecutionImpl executionImpl = new ExecutionImpl();
135         executionImpl.setProcessInstance(mockExecutionImpl);
136
137         delegateExecution = (DelegateExecution) executionImpl;
138         delegateExecution.setVariable("testProcessKey", "testProcessKeyValue");
139     }
140
141     public Map<String, String> buildUserInput() {
142         Map<String, String> userInput = new HashMap<>();
143         userInput.put("testUserInputKey", "testUserInputValue");
144
145         return userInput;
146     }
147
148     public Map<String, String> setUserInput() {
149         Map<String, String> userInput = buildUserInput();
150
151         gBBInput.setUserInput(userInput);
152
153         return userInput;
154     }
155
156     public RequestContext buildRequestContext() {
157         RequestContext requestContext = new RequestContext();
158         requestContext.setMsoRequestId(UUID.randomUUID().toString());
159         requestContext.setProductFamilyId("testProductFamilyId");
160         requestContext.setRequestorId("testRequestorId");
161
162         requestContext.setUserParams(new HashMap<>());
163
164         Map<String, Object> dataMap = new HashMap<>();
165         dataMap.put("vpnId", "testVpnId");
166         dataMap.put("vpnRegion", "testVpnRegion");
167         dataMap.put("vpnRt", "testVpnRt");
168         dataMap.put("vpnName", "vpnName");
169         ArrayList<String> vpnRegions = new ArrayList<String>();
170         vpnRegions.add("USA");
171         vpnRegions.add("EMEA");
172         vpnRegions.add("APAC");
173         dataMap.put("vpnRegion", vpnRegions);
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("testProjectName" + 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         serviceInstance.setModelInfoServiceInstance(modelInfoServiceInstance);
309
310         serviceInstance.setProject(buildProject());
311
312         serviceInstance.setOwningEntity(buildOwningEntity());
313
314         serviceInstance.setCollection(buildCollection());
315
316         serviceInstance.getConfigurations().add(buildConfiguration());
317
318         return serviceInstance;
319     }
320
321     public ServiceInstance setServiceInstance() {
322         ServiceInstance serviceInstance = buildServiceInstance();
323
324         if (gBBInput.getCustomer() == null) {
325             gBBInput.setCustomer(buildCustomer());
326         }
327         gBBInput.getCustomer().getServiceSubscription().getServiceInstances().add(serviceInstance);
328         lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstance.getServiceInstanceId());
329
330         return serviceInstance;
331     }
332
333     public Customer setCustomer() {
334         if (gBBInput.getCustomer() != null)
335             return gBBInput.getCustomer();
336         Customer customer = new Customer();
337         customer.setGlobalCustomerId("testGlobalCustomerId");
338         customer.setSubscriberType("testSubscriberType");
339
340         customer.setServiceSubscription(buildServiceSubscription());
341
342         gBBInput.setCustomer(customer);
343
344         return customer;
345     }
346
347     public Collection setCollection() {
348         Collection collection = new Collection();
349         collection.setId("testId");
350
351         ServiceInstance serviceInstance = null;
352
353         try {
354             serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
355         } catch (BBObjectNotFoundException e) {
356             serviceInstance = setServiceInstance();
357         }
358
359         serviceInstance.setCollection(collection);
360
361         return collection;
362     }
363
364     public InstanceGroup setInstanceGroup() {
365         InstanceGroup instanceGroup = new InstanceGroup();
366         instanceGroup.setId("testId");
367         instanceGroup.setInstanceGroupFunction("testInstanceGroupFunction");
368
369         Collection collection = null;
370
371         try {
372             ServiceInstance serviceInstance =
373                     extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
374             collection = serviceInstance.getCollection();
375
376             if (collection == null) {
377                 collection = setCollection();
378             }
379         } catch (BBObjectNotFoundException e) {
380             collection = setCollection();
381         }
382
383         collection.setInstanceGroup(instanceGroup);
384
385         return instanceGroup;
386     }
387
388     public VpnBinding buildVpnBinding() {
389         vpnBindingCounter++;
390
391         VpnBinding vpnBinding = new VpnBinding();
392         vpnBinding.setVpnId("testVpnId" + vpnBindingCounter);
393         vpnBinding.setVpnName("testVpnName" + vpnBindingCounter);
394         vpnBinding.setCustomerVpnId("testCustomerVpnId" + vpnBindingCounter);
395
396         return vpnBinding;
397     }
398
399     public VpnBinding setVpnBinding() {
400         VpnBinding vpnBinding = buildVpnBinding();
401
402         Customer customer = gBBInput.getCustomer();
403
404         if (customer == null) {
405             customer = buildCustomer();
406         }
407
408         customer.getVpnBindings().add(vpnBinding);
409         lookupKeyMap.put(ResourceKey.VPN_ID, vpnBinding.getVpnId());
410
411         return vpnBinding;
412     }
413
414     public InstanceGroup buildInstanceGroup() {
415         instanceGroupCounter++;
416
417         InstanceGroup instanceGroup = new InstanceGroup();
418         instanceGroup.setId("testId" + instanceGroupCounter);
419         instanceGroup.setInstanceGroupFunction("testInstanceGroupFunction" + instanceGroupCounter);
420
421         return instanceGroup;
422     }
423
424     public L3Network buildL3Network() {
425         l3NetworkCounter++;
426
427         L3Network network = new L3Network();
428         network.setNetworkId("testNetworkId" + l3NetworkCounter);
429         network.setNetworkName("testNetworkName" + l3NetworkCounter);
430         network.setNetworkType("testNetworkType" + l3NetworkCounter);
431
432         ModelInfoNetwork modelInfoNetwork = new ModelInfoNetwork();
433         modelInfoNetwork.setModelInvariantUUID("testModelInvariantUUID" + l3NetworkCounter);
434         modelInfoNetwork.setModelName("testModelName" + l3NetworkCounter);
435         modelInfoNetwork.setModelVersion("testModelVersion" + l3NetworkCounter);
436         modelInfoNetwork.setModelUUID("testModelUUID" + l3NetworkCounter);
437         network.setModelInfoNetwork(modelInfoNetwork);
438
439         return network;
440     }
441
442     public L3Network setL3Network() {
443         L3Network network = buildL3Network();
444
445         ServiceInstance serviceInstance = null;
446
447         try {
448             serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
449         } catch (BBObjectNotFoundException e) {
450             serviceInstance = setServiceInstance();
451         }
452
453         serviceInstance.getNetworks().add(network);
454         lookupKeyMap.put(ResourceKey.NETWORK_ID, network.getNetworkId());
455
456         return network;
457     }
458
459     public GenericVnf buildGenericVnf() {
460         genericVnfCounter++;
461
462         GenericVnf genericVnf = new GenericVnf();
463         genericVnf.setVnfId("testVnfId" + genericVnfCounter);
464         genericVnf.setVnfName("testVnfName" + genericVnfCounter);
465         genericVnf.setVnfType("testVnfType" + genericVnfCounter);
466
467         Platform platform = new Platform();
468         platform.setPlatformName("testPlatformName");
469         genericVnf.setPlatform(platform);
470
471         LineOfBusiness lob = new LineOfBusiness();
472         lob.setLineOfBusinessName("testLineOfBusinessName");
473         genericVnf.setLineOfBusiness(lob);
474
475         ModelInfoGenericVnf modelInfoGenericVnf = new ModelInfoGenericVnf();
476         modelInfoGenericVnf.setModelName("testModelName" + genericVnfCounter);
477         modelInfoGenericVnf.setModelCustomizationUuid("testModelCustomizationUUID" + genericVnfCounter);
478         modelInfoGenericVnf.setModelInvariantUuid("testModelInvariantUUID" + genericVnfCounter);
479         modelInfoGenericVnf.setModelVersion("testModelVersion" + genericVnfCounter);
480         modelInfoGenericVnf.setModelUuid("testModelUUID" + genericVnfCounter);
481         modelInfoGenericVnf.setModelInstanceName("testModelInstanceName" + genericVnfCounter);
482         genericVnf.setModelInfoGenericVnf(modelInfoGenericVnf);
483
484         return genericVnf;
485     }
486
487     public GenericVnf setGenericVnf() {
488         GenericVnf genericVnf = buildGenericVnf();
489
490         ServiceInstance serviceInstance = null;
491
492         try {
493             serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
494         } catch (BBObjectNotFoundException e) {
495             serviceInstance = setServiceInstance();
496         }
497
498         serviceInstance.getVnfs().add(genericVnf);
499         lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, genericVnf.getVnfId());
500
501         return genericVnf;
502     }
503
504     public VfModule buildVfModule() {
505         vfModuleCounter++;
506
507         VfModule vfModule = new VfModule();
508         vfModule.setVfModuleId("testVfModuleId" + vfModuleCounter);
509         vfModule.setVfModuleName("testVfModuleName" + vfModuleCounter);
510
511         ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
512         modelInfoVfModule.setModelInvariantUUID("testModelInvariantUUID" + vfModuleCounter);
513         modelInfoVfModule.setModelVersion("testModelVersion" + vfModuleCounter);
514         modelInfoVfModule.setModelUUID("testModelUUID" + vfModuleCounter);
515         modelInfoVfModule.setModelName("testModelName" + vfModuleCounter);
516         modelInfoVfModule.setModelCustomizationUUID("testModelCustomizationUUID" + vfModuleCounter);
517         vfModule.setModelInfoVfModule(modelInfoVfModule);
518
519         return vfModule;
520     }
521
522     public VfModule setVfModule() {
523         VfModule vfModule = buildVfModule();
524
525         GenericVnf genericVnf = null;
526
527         try {
528             genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
529         } catch (BBObjectNotFoundException e) {
530             genericVnf = setGenericVnf();
531         }
532
533         genericVnf.getVfModules().add(vfModule);
534         lookupKeyMap.put(ResourceKey.VF_MODULE_ID, vfModule.getVfModuleId());
535
536         return vfModule;
537     }
538
539     public VolumeGroup buildVolumeGroup() {
540         volumeGroupCounter++;
541
542         VolumeGroup volumeGroup = new VolumeGroup();
543         volumeGroup.setVolumeGroupId("testVolumeGroupId" + volumeGroupCounter);
544         volumeGroup.setVolumeGroupName("testVolumeGroupName" + volumeGroupCounter);
545         volumeGroup.setHeatStackId("testHeatStackId" + volumeGroupCounter);
546
547         return volumeGroup;
548     }
549
550     public VolumeGroup setVolumeGroup() {
551         VolumeGroup volumeGroup = buildVolumeGroup();
552
553         GenericVnf genericVnf = null;
554
555         try {
556             genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
557         } catch (BBObjectNotFoundException e) {
558             genericVnf = setGenericVnf();
559         }
560
561         genericVnf.getVolumeGroups().add(volumeGroup);
562         lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, volumeGroup.getVolumeGroupId());
563
564         return volumeGroup;
565     }
566
567     public Pnf buildPnf() {
568         pnfCounter++;
569
570         Pnf pnf = new Pnf();
571         pnf.setPnfId("testPnfId" + pnfCounter);
572         pnf.setPnfName("testPnfName" + pnfCounter);
573
574         return pnf;
575     }
576
577     public ServiceProxy buildServiceProxy() {
578         serviceProxyCounter++;
579
580         ServiceProxy serviceProxy = new ServiceProxy();
581         serviceProxy.setServiceInstance(buildServiceInstance());
582         serviceProxy.getServiceInstance().getVnfs().add(buildGenericVnf());
583
584         Pnf primaryPnf = buildPnf();
585         primaryPnf.setRole("Primary");
586         serviceProxy.getServiceInstance().getPnfs().add(primaryPnf);
587
588         Pnf secondaryPnf = buildPnf();
589         secondaryPnf.setRole("Secondary");
590         serviceProxy.getServiceInstance().getPnfs().add(secondaryPnf);
591
592         return serviceProxy;
593     }
594
595     public VpnBondingLink buildVpnBondingLink() {
596         vpnBondingLinkCounter++;
597
598         VpnBondingLink vpnBondingLink = new VpnBondingLink();
599         vpnBondingLink.setVpnBondingLinkId("testVpnBondingLinkId" + vpnBondingLinkCounter);
600
601         Configuration vnrConfiguration = buildConfiguration();
602         vnrConfiguration.setNetwork(buildL3Network());
603         vpnBondingLink.setVnrConfiguration(vnrConfiguration);
604
605         vpnBondingLink.setVrfConfiguration(buildConfiguration());
606
607         vpnBondingLink.setInfrastructureServiceProxy(buildServiceProxy());
608
609         vpnBondingLink.setTransportServiceProxy(buildServiceProxy());
610
611         return vpnBondingLink;
612     }
613
614     public VpnBondingLink setVpnBondingLink() {
615         VpnBondingLink vpnBondingLink = buildVpnBondingLink();
616
617         ServiceInstance serviceInstance = null;
618
619         try {
620             serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
621         } catch (BBObjectNotFoundException e) {
622             serviceInstance = setServiceInstance();
623         }
624
625         serviceInstance.getVpnBondingLinks().add(vpnBondingLink);
626         lookupKeyMap.put(ResourceKey.VPN_BONDING_LINK_ID, vpnBondingLink.getVpnBondingLinkId());
627
628
629         return vpnBondingLink;
630     }
631
632     public Customer setAvpnCustomer() {
633         Customer customer = buildCustomer();
634
635         gBBInput.setCustomer(customer);
636
637         return customer;
638     }
639
640     public ServiceProxy setServiceProxy(String uniqueIdentifier, String type) {
641         ServiceProxy serviceProxy = new ServiceProxy();
642         serviceProxy.setId("testProxyId" + uniqueIdentifier);
643         serviceProxy.setType(type);
644
645         ModelInfoServiceProxy modelInfo = new ModelInfoServiceProxy();
646         modelInfo.setModelInvariantUuid("testProxyModelInvariantUuid" + uniqueIdentifier);
647         modelInfo.setModelName("testProxyModelName" + uniqueIdentifier);
648         modelInfo.setModelUuid("testProxyModelUuid" + uniqueIdentifier);
649         modelInfo.setModelVersion("testProxyModelVersion" + uniqueIdentifier);
650         modelInfo.setModelInstanceName("testProxyInstanceName" + uniqueIdentifier);
651
652         serviceProxy.setModelInfoServiceProxy(modelInfo);
653
654         return serviceProxy;
655     }
656
657     public AllottedResource setAllottedResource(String uniqueIdentifier) {
658         AllottedResource ar = new AllottedResource();
659         ar.setId("testAllottedResourceId" + uniqueIdentifier);
660
661         ModelInfoAllottedResource modelInfo = new ModelInfoAllottedResource();
662         modelInfo.setModelInvariantUuid("testAllottedModelInvariantUuid" + uniqueIdentifier);
663         modelInfo.setModelName("testAllottedModelName" + uniqueIdentifier);
664         modelInfo.setModelUuid("testAllottedModelUuid" + uniqueIdentifier);
665         modelInfo.setModelVersion("testAllottedModelVersion" + uniqueIdentifier);
666         modelInfo.setModelInstanceName("testAllottedInstanceName" + uniqueIdentifier);
667
668         ar.setModelInfoAllottedResource(modelInfo);
669
670         return ar;
671     }
672
673     public Configuration setConfiguration() {
674         Configuration config = new Configuration();
675         config.setConfigurationId("testConfigurationId");
676         ModelInfoConfiguration modelInfoConfig = new ModelInfoConfiguration();
677         modelInfoConfig.setModelCustomizationId("modelCustomizationId");
678         modelInfoConfig.setModelVersionId("modelVersionId");
679         modelInfoConfig.setModelInvariantId("modelInvariantId");
680         modelInfoConfig.setPolicyName("policyName");
681         config.setModelInfoConfiguration(modelInfoConfig);
682
683         List<Configuration> configurations = new ArrayList<>();
684         configurations.add(config);
685         ServiceInstance serviceInstance = new ServiceInstance();
686         try {
687             serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
688         } catch (BBObjectNotFoundException e) {
689             serviceInstance = setServiceInstance();
690         }
691         lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, "testConfigurationId");
692         serviceInstance.setConfigurations(configurations);
693         return config;
694     }
695 }