summaryrefslogtreecommitdiffstats
path: root/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/utils/general/OnboardingUtils.java
blob: dc38d4006409e0eecbee9fe880eb706c31744f05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
/*-
 * ============LICENSE_START=======================================================
 * SDC
 * ================================================================================
 * Copyright (C) 2017 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.openecomp.sdc.ci.tests.utils.general;

import static org.testng.AssertJUnit.assertEquals;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.nio.file.FileSystems;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.simple.JSONArray;
import org.json.simple.JSONValue;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
import org.openecomp.sdc.ci.tests.api.Urls;
import org.openecomp.sdc.ci.tests.config.Config;
import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers;
import org.openecomp.sdc.ci.tests.datatypes.LicensingData;
import org.openecomp.sdc.ci.tests.datatypes.LicensingVersion;
import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject;
import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObjectReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.enums.CvfcTypeEnum;
import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
import org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest;
import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
import org.openecomp.sdc.ci.tests.utils.Utils;
import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;

import com.aventstack.extentreports.Status;
import com.clearspring.analytics.util.Pair;
import com.google.gson.Gson;

public class OnboardingUtils {

	/**
	 * excluded VNF file list
	 */
	protected static List<String> exludeVnfList =
//			new ArrayList<String>();

			Arrays.asList(

//			new VNFs
					"Vhss-epc-rdm3-lab-vf-0921-v2.0-MOBILITY-10-20.zip", "Apndns-1710-vf-v3.0-10-20.zip",
					"HeatCandidate_2017-09-22_01-48_55Name_2016-182-asbg-nsbg-tsbg-v1.0-(VOIP).zip", "HeatCandidate_2017-09-22_01-47_55Name_2016-182-asbg-nsbg-tsbg-v7.0-(VOIP).zip",
					"Efmc-dbe-nin-v24.0-VOIP-10-20.zip", "VF_LMSP_v5-062317-V3.0-(Mobility).zip", "base_bwks_nfm_volume-236262502.zip",

//			newest failed VNFs
					"HeatCandidate_2017-09-20_15-07_66Name_2016-20-visbc1vf-v4.0-(VOIP).zip",
					"HeatCandidate_2017-09-20_15-06_66Name_2016-20-visbc1vf-v6.0-(VOIP).zip", "1-Vf-zrdm5bpxtc02-092017-(MOBILITY)_v3.0.zip",
					"1-2017-491-4vshaken-HTTP-CM-vf-(VOIP)_v2.0.zip"

			);

	/**
	 * additional files to exludeVnfList files for tosca parser tests
	 */
	protected static List<String> exludeVnfListForToscaParser = //new ArrayList<String>();
	Arrays.asList("1-Vvig-062017-(MOBILITY)_v5.1.zip",
			"HeatCandidate_2017-09-22_01-43_57Name_2017389vtsbc4vf-v1.0-(VOIP).zip",
			"1-Mvm-sbc-1710-092017-(MOBILITY)_v7.0.zip",
			"1-2017-492-5vshaken-SIP-AS-vf-(VOIP)_v2.0.zip",
			"HeatCandidate_2017-09-20_13-37_70Name_2017-491-4vshaken-HTTP-CM-vf-v1.0-(VOIP)_10202017.zip", "1-201712-488-adiod-vpe-(Layer-0-3)_v2.0.zip",
			"2017-502.zip",
			"1-2017-505-urlb-vhepe-(Layer-0-3)_v2.0.zip",
			"2017-376_vMOG_11_1.zip",
			"HeatCandidate_2017-09-22_00-55_62Name_2017-491-6vshaken-http-cm-vf-v1.0-(VOIP).zip", "HeatCandidate_2017-09-22_01-30_60Name_Vdbe-vsp-15.1x49-d50.3-v3.0-(VOIP).zip",
			"HeatCandidate_2017-09-22_01-35_59Name_2017-418-afx-v1.0.zip",
			"1-2017-488-adiod-vpe-(Layer-0-3)_v-5.0.zip",
			"HeatCandidate_2017-09-22_01-42_57Name_2017389vtsbc4vf-v10.0-(VOIP).zip",
			"HeatCandidate_2017-09-20_13-47_68Name_2017-492-5vshaken-SIP-AS-vf-v1.0-(VOIP)_10202017.zip", "1-2016-20-visbc3vf-(VOIP)_v2.1.zip",
			"1-2017-404_vUSP_vCCF_AIC3.0-(VOIP)_v6.0.zip", "1-2017389vtsbc4vf-(VOIP)_v11.0.zip",
			"HeatCandidate_2017-09-22_01-32_60Name_Vdbe-vsp-15.1x49-d50.3-v1.0-(VOIP).zip", "1-2017-418-afx-v1.1.zip");
	
	public OnboardingUtils() {
	}

	public static Pair<String, Map<String, String>> createVendorSoftwareProduct(ResourceReqDetails resourceReqDetails, String heatFileName, String filepath, User user, AmdocsLicenseMembers amdocsLicenseMembers, Map<CvfcTypeEnum, String> cvfcArtifacts)
			throws Exception {

		Pair<String, Map<String, String>> pair = createVSP(resourceReqDetails, heatFileName, filepath, user, amdocsLicenseMembers);
		String vspid = pair.right.get("vspId");
		if(cvfcArtifacts != null && ! cvfcArtifacts.isEmpty()){
			OnboardingUtils.addCvfcArtifacts(cvfcArtifacts, vspid, user, null);

		}
		prepareVspForUse(user, vspid, "0.1");
		return pair;
	}

	public static Pair<String, Map<String, String>> createVendorSoftwareProduct(ResourceReqDetails resourceReqDetails, String heatFileName, String filepath, User user, AmdocsLicenseMembers amdocsLicenseMembers)
			throws Exception {

		Map<CvfcTypeEnum, String> cvfcArtifacts = new HashMap<>();
		return createVendorSoftwareProduct(resourceReqDetails, heatFileName, filepath, user, amdocsLicenseMembers, cvfcArtifacts);
	}

//	duplicate function
	public static void prepareVspForUse(User user, String vspid, String vspVersion) throws Exception {

		RestResponse checkin = OnboardingUtils.checkinVendorSoftwareProduct(vspid, user, vspVersion);
		assertEquals("did not succeed to checking new VSP", 200, checkin.getErrorCode().intValue());

		RestResponse submit = OnboardingUtils.submitVendorSoftwareProduct(vspid, user, vspVersion);
		assertEquals("did not succeed to submit new VSP", 200, submit.getErrorCode().intValue());

		RestResponse createPackage = OnboardingUtils.createPackageOfVendorSoftwareProduct(vspid, user, vspVersion);
		assertEquals("did not succeed to create package of new VSP ", 200, createPackage.getErrorCode().intValue());

//		ComponentBaseTest.getExtendTest().log(Status.INFO, "Succeeded in creating the vendor software product");
	}

	public static VendorSoftwareProductObject createAndFillVendorSoftwareProduct(ResourceReqDetails resourceReqDetails, String heatFileName, String filePath, User user, AmdocsLicenseMembers amdocsLicenseMembers, Map<CvfcTypeEnum, String> cvfcArtifacts)
			throws Exception {

		Pair<String, Map<String, String>> createVendorSoftwareProduct = OnboardingUtils.createVendorSoftwareProduct(resourceReqDetails, heatFileName, filePath, user, amdocsLicenseMembers, cvfcArtifacts);
		VendorSoftwareProductObject vendorSoftwareProductObject = fillVendorSoftwareProductObjectWithMetaData(heatFileName, createVendorSoftwareProduct);
		return vendorSoftwareProductObject;

	}

	public static void updateVendorLicense(AmdocsLicenseMembers amdocsLicenseMembers, User user, String vlmVersion) throws Exception {

		RestResponse checkoutVendorLicense = checkoutVendorLicense(amdocsLicenseMembers.getVendorId(), user, vlmVersion);
		assertEquals("did not succeed to checkout vendor license", 200, checkoutVendorLicense.getErrorCode().intValue());

		RestResponse checkinVendorLicense = checkinVendorLicense(amdocsLicenseMembers.getVendorId(), user, vlmVersion);
		assertEquals("did not succeed to checkin vendor license", 200, checkinVendorLicense.getErrorCode().intValue());

		RestResponse submitVendorLicense = submitVendorLicense(amdocsLicenseMembers.getVendorId(), user, vlmVersion);
		assertEquals("did not succeed to submit vendor license", 200, submitVendorLicense.getErrorCode().intValue());

		if(ComponentBaseTest.getExtendTest() != null){
			ComponentBaseTest.getExtendTest().log(Status.INFO, "Succeeded in updating the vendor license");
		}
	}

	public static Pair<String, Map<String, String>> createVSP(ResourceReqDetails resourceReqDetails, String heatFileName, String filepath, User user, AmdocsLicenseMembers amdocsLicenseMembers) throws Exception {
		String vspName = handleFilename(heatFileName);

		if(ComponentBaseTest.getExtendTest() != null){
			ComponentBaseTest.getExtendTest().log(Status.INFO, "Starting to create the vendor software product");
		}

		Pair<RestResponse, Map<String, String>> createNewVspPair = createNewVendorSoftwareProduct(resourceReqDetails, vspName, amdocsLicenseMembers, user);
		RestResponse createNewVendorSoftwareProduct = createNewVspPair.left;
		assertEquals("did not succeed to create new VSP", 200,createNewVendorSoftwareProduct.getErrorCode().intValue());
		String vspid = ResponseParser.getValueFromJsonResponse(createNewVendorSoftwareProduct.getResponse(), "vspId");
		String componentId = ResponseParser.getValueFromJsonResponse(createNewVendorSoftwareProduct.getResponse(), "componentId");

		Map<String, String> vspMeta = createNewVspPair.right;
		Map<String, String> vspObject = new HashMap<String, String>();
		Iterator<String> iterator = vspMeta.keySet().iterator();
		while(iterator.hasNext()){
			Object key = iterator.next();
			Object value = vspMeta.get(key);
			vspObject.put(key.toString(), value.toString());
		}
		vspObject.put("vspId", vspid);
		vspObject.put("componentId", componentId);
		vspObject.put("vendorName", amdocsLicenseMembers.getVendorLicenseName());
		vspObject.put("attContact", user.getUserId());

		RestResponse uploadHeatPackage = uploadHeatPackage(filepath, heatFileName, vspid, user, "0.1");
		assertEquals("did not succeed to upload HEAT package", 200, uploadHeatPackage.getErrorCode().intValue());

		RestResponse validateUpload = validateUpload(vspid, user, "0.1");
		assertEquals("did not succeed to validate upload process, reason: " + validateUpload.getResponse(), 200, validateUpload.getErrorCode().intValue());

		Pair<String, Map<String, String>> pair = new Pair<String, Map<String, String>>(vspName, vspObject);

		return pair;
	}

	public static void updateVspWithVfcArtifacts(String filepath, String vspId, String updatedSnmpPoll, String updatedSnmpTrap, String componentId, User user, String vspVersion) throws Exception{
		RestResponse checkout = checkoutVendorSoftwareProduct(vspId, user, vspVersion);
		assertEquals("did not succeed to checkout new VSP", 200, checkout.getErrorCode().intValue());
//		ExtentTestActions.log(Status.INFO, "Deleting SNMP POLL");
		deleteArtifactByType(componentId, vspId, user, CvfcTypeEnum.SNMP_POLL);
//		ExtentTestActions.log(Status.INFO, "Deleting SNMP TRAP");
		deleteArtifactByType(componentId, vspId, user, CvfcTypeEnum.SNMP_TRAP);
		addVFCArtifacts(filepath, updatedSnmpPoll, updatedSnmpTrap, vspId, user, componentId);
		prepareVspForUse(user, vspId, vspVersion);
	}

	private static RestResponse deleteArtifactByType(String componentId, String vspId, User user, CvfcTypeEnum snmpType) throws Exception
	{
		Config config = Utils.getConfig();
		String url = String.format(Urls.DELETE_AMDOCS_ARTIFACT_BY_TYPE, config.getCatalogBeHost(),config.getCatalogBePort(), vspId, componentId, snmpType.getValue());
		String userId = user.getUserId();
		Map<String, String> headersMap = prepareHeadersMap(userId);

		HttpRequest http = new HttpRequest();
		RestResponse response = http.httpSendDelete(url, headersMap);
		return response;
	}

//	duplicated method
	public static String updateVendorSoftwareProduct(String vspId, String HeatFileName, String filepath, User user, String vspVersion)
		throws Exception, Throwable {
		String vspName = OnboardingUtils.handleFilename(HeatFileName);
		ComponentBaseTest.getExtendTest().log(Status.INFO, "Starting to update the vendor software product");

		RestResponse checkout = OnboardingUtils.checkoutVendorSoftwareProduct(vspId, user, vspVersion);
		assertEquals("did not succeed to checkout new VSP", 200, checkout.getErrorCode().intValue());

		RestResponse uploadHeatPackage = OnboardingUtils.uploadHeatPackage(filepath, HeatFileName, vspId, user, vspVersion);
		assertEquals("did not succeed to upload HEAT package", 200, uploadHeatPackage.getErrorCode().intValue());

		RestResponse validateUpload = OnboardingUtils.validateUpload(vspId, user, vspVersion);
		assertEquals("did not succeed to validate upload process", 200, validateUpload.getErrorCode().intValue());

		RestResponse checkin = OnboardingUtils.checkinVendorSoftwareProduct(vspId, user, vspVersion);
		assertEquals("did not succeed to checking VSP", 200, checkin.getErrorCode().intValue());

		RestResponse submit = OnboardingUtils.submitVendorSoftwareProduct(vspId, user, vspVersion);
		assertEquals("did not succeed to submit VSP", 200, submit.getErrorCode().intValue());

		RestResponse createPackage = OnboardingUtils.createPackageOfVendorSoftwareProduct(vspId, user, vspVersion);
		assertEquals("did not succeed to update package of VSP ", 200, createPackage.getErrorCode().intValue());

		ComponentBaseTest.getExtendTest().log(Status.INFO, "Succeeded in updating the vendor software product");

		return vspName;
	}

	public static void updateVendorSoftwareProductToNextVersion(VendorSoftwareProductObject vendorSoftwareProductObject, String toVspVersion, User user)
			throws Exception, Throwable {

		RestResponse checkout = checkoutVendorSoftwareProduct(vendorSoftwareProductObject.getVspId(), user, vendorSoftwareProductObject.getVersion());
		assertEquals("did not succeed to checkout new VSP", 200, checkout.getErrorCode().intValue());

		RestResponse checkin = checkinVendorSoftwareProduct(vendorSoftwareProductObject.getVspId(), user, vendorSoftwareProductObject.getVersion());
		assertEquals("did not succeed to checking VSP", 200, checkin.getErrorCode().intValue());

		RestResponse submit = submitVendorSoftwareProduct(vendorSoftwareProductObject.getVspId(), user, vendorSoftwareProductObject.getVersion());
		assertEquals("did not succeed to submit VSP", 200, submit.getErrorCode().intValue());

		vendorSoftwareProductObject.setVersion(toVspVersion);
	}

	public static String handleFilename(String heatFileName) {
		final String namePrefix = "ciVFOnboarded-";
		final String nameSuffix = "-" + getShortUUID();

		String subHeatFileName = heatFileName.substring(0, heatFileName.lastIndexOf("."));

		if ((namePrefix + subHeatFileName + nameSuffix).length() >= 50) {
			subHeatFileName = subHeatFileName.substring(0, 50 - namePrefix.length() - nameSuffix.length());
		}

		if (subHeatFileName.contains("(") || subHeatFileName.contains(")")) {
			subHeatFileName = subHeatFileName.replace("(", "-");
			subHeatFileName = subHeatFileName.replace(")", "-");
		}

		String vnfName = namePrefix + subHeatFileName + nameSuffix;
		return vnfName;
	}
	
	public static String addVFCArtifacts(String filepath, String snmpPoll, String snmpTrap, String vspid, User user, String vspComponentId) throws Exception{
		vspComponentId = (vspComponentId == null) ? getVSPComponentId(vspid, user) : vspComponentId;
		if (vspComponentId != null){
			if (snmpPoll != null){
//				ExtentTestActions.log(Status.INFO, "Adding VFC artifact of type SNMP POLL with the file " + snmpPoll);
				RestResponse uploadSnmpPollArtifact = uploadSnmpPollArtifact(filepath, snmpPoll, vspid, user, vspComponentId);
				assertEquals("Did not succeed to add SNMP POLL", 200, uploadSnmpPollArtifact.getErrorCode().intValue());
			}
			if (snmpTrap != null){
//				ExtentTestActions.log(Status.INFO, "Adding VFC artifact of type SNMP TRAP with the file " + snmpTrap);
				RestResponse uploadSnmpTrapArtifact = uploadSnmpTrapArtifact(filepath, snmpTrap, vspid, user, vspComponentId);
				assertEquals("Did not succeed to add SNMP TRAP", 200, uploadSnmpTrapArtifact.getErrorCode().intValue());
			}
		}
		
		return vspComponentId;
	}

	public static String addCvfcArtifacts(Map<CvfcTypeEnum, String> componentVfcArtifacts, String vspid, User user, String vspComponentId) throws Exception{
		vspComponentId = (vspComponentId == null) ? getVSPComponentId(vspid, user) : vspComponentId;
		if (vspComponentId != null){
			for(Map.Entry<CvfcTypeEnum, String> entry : componentVfcArtifacts.entrySet()){
//				ExtentTestActions.log(Status.INFO, "Adding VFC artifact of type " + entry.getKey().getValue() + " with the file " + entry.getValue());
				RestResponse uploadSnmpPollArtifact = uploadCvfcArtifact(entry.getValue(), entry.getKey().getValue(), vspid, user, vspComponentId);
				assertEquals("Did not succeed to add " + entry.getKey().getValue(), BaseRestUtils.STATUS_CODE_SUCCESS, uploadSnmpPollArtifact.getErrorCode().intValue());
			}
		}
		return vspComponentId;
	}

	public static String addVFCArtifacts(String filepath, String snmpPoll, String snmpTrap, String vspid, User user) throws Exception{
		return addVFCArtifacts(filepath, snmpPoll, snmpTrap, vspid, user, null);
	}

	public static RestResponse uploadCvfcArtifact(String filepath, String cvfcType, String vspid, User user, String vspComponentId) throws FileNotFoundException, IOException, ClientProtocolException {
		Config config = Utils.getConfig();
		String snmpPollUrl = String.format(Urls.UPLOAD_AMDOCS_ARTIFACT, config.getCatalogBeHost(),config.getCatalogBePort(), vspid, vspComponentId, cvfcType);
		return uploadFile(filepath, null, snmpPollUrl, user);
	}


	private static RestResponse uploadSnmpPollArtifact(String filepath, String zipArtifact, String vspid, User user,
													   String vspComponentId) throws FileNotFoundException, IOException, ClientProtocolException {
		Config config = Utils.getConfig();
		String snmpPollUrl = String.format(Urls.UPLOAD_SNMP_POLL_ARTIFACT, config.getCatalogBeHost(),config.getCatalogBePort(), vspid, vspComponentId);
		return uploadFile(filepath, zipArtifact, snmpPollUrl, user);
	}

	private static RestResponse uploadSnmpTrapArtifact(String filepath, String zipArtifact, String vspid, User user,
													   String vspComponentId) throws FileNotFoundException, IOException, ClientProtocolException {
		Config config = Utils.getConfig();
		String snmpTrapUrl = String.format(Urls.UPLOAD_SNMP_POLL_ARTIFACT, config.getCatalogBeHost(),config.getCatalogBePort(), vspid, vspComponentId);
		return uploadFile(filepath, zipArtifact, snmpTrapUrl, user);
	}
	
	private static RestResponse deleteSnmpArtifact(String componentId, String vspId, User user, SnmpTypeEnum snmpType) throws Exception
	{
		Config config = Utils.getConfig();
		String url = String.format("http://%s:%s/onboarding-api/v1.0/vendor-software-products/%s/versions/0.1/components/%s/monitors/%s", 
				config.getCatalogBeHost(),config.getCatalogBePort(), vspId, componentId, snmpType.getValue());
		String userId = user.getUserId();

		Map<String, String> headersMap = prepareHeadersMap(userId);

		HttpRequest http = new HttpRequest();
		RestResponse response = http.httpSendDelete(url, headersMap);
		return response;
	}

	private static String getVSPComponentId(String vspid, User user) throws Exception, JSONException {
		RestResponse components = getVSPComponents(vspid, user);
		String response = components.getResponse();
		Map<String, Object> responseMap = (Map<String, Object>) JSONValue.parse(response);
		JSONArray results = (JSONArray)responseMap.get("results");
		for (Object res : results){
			Map<String, Object> compMap= (Map<String, Object>) JSONValue.parse(res.toString());
			String componentId = compMap.get("id").toString();
			return componentId;
		}
		return null;
	}

	private static RestResponse getVSPComponents(String vspid, User user) throws Exception{
		Config config = Utils.getConfig();
		String url = String.format(Urls.GET_VSP_COMPONENTS, config.getCatalogBeHost(),config.getCatalogBePort(), vspid);
		String userId = user.getUserId();

		Map<String, String> headersMap = prepareHeadersMap(userId);

		HttpRequest http = new HttpRequest();
		RestResponse response = http.httpSendGet(url, headersMap);
		return response;
	}

	private static RestResponse getVLMComponentByVersion(String vlmId, String vlmVersion, User user) throws Exception{
		Config config = Utils.getConfig();
		String url = String.format(Urls.GET_VLM_COMPONENT_BY_VERSION, config.getCatalogBeHost(),config.getCatalogBePort(), vlmId,vlmVersion);
		String userId = user.getUserId();

		Map<String, String> headersMap = prepareHeadersMap(userId);

		HttpRequest http = new HttpRequest();
		RestResponse response = http.httpSendGet(url, headersMap);
		return response;
	}

	public static boolean validateVspExist(String vspId, String vspVersion, User user) throws Exception {
		RestResponse restResponse = getVSPComponentByVersion(vspId, vspVersion, user);
		assertEquals(String.format("Vsp version not updated, reponse message: %s", restResponse.getResponse()),restResponse.getErrorCode().intValue(),200);
		return (restResponse.getErrorCode()==200);
	}

	public static boolean validateVlmExist(String vlmId, String vlmVersion, User user) throws Exception {
		RestResponse restResponse = getVLMComponentByVersion(vlmId, vlmVersion, user);
		assertEquals(String.format("VLM version not updated, reponse code message: %s", restResponse.getResponse()),restResponse.getErrorCode().intValue(),200);
		return (restResponse.getErrorCode()==200);
	}


	private static RestResponse getVSPComponentByVersion(String vspId, String vspVersion, User user) throws Exception{
		Config config = Utils.getConfig();
		String url = String.format(Urls.GET_VSP_COMPONENT_BY_VERSION, config.getCatalogBeHost(),config.getCatalogBePort(), vspId,vspVersion);
		String userId = user.getUserId();

		Map<String, String> headersMap = prepareHeadersMap(userId);

		HttpRequest http = new HttpRequest();
		RestResponse response = http.httpSendGet(url, headersMap);
		return response;
	}

//	Duplicate method
	public static AmdocsLicenseMembers createVendorLicense(User user) throws Exception {
		
		AmdocsLicenseMembers amdocsLicenseMembers;
//		ComponentBaseTest.getExtendTest().log(Status.INFO, "Starting to create the vendor license");
		String vendorLicenseName = "ciLicense" + OnboardingUtils.getShortUUID();
		RestResponse vendorLicenseResponse = OnboardingUtils.createVendorLicenseModels_1(vendorLicenseName, user);
		assertEquals("did not succeed to create vendor license model", 200, vendorLicenseResponse.getErrorCode().intValue());
		String vendorId = ResponseParser.getValueFromJsonResponse(vendorLicenseResponse.getResponse(), "value");

		RestResponse vendorKeyGroupsResponse = OnboardingUtils.createVendorKeyGroups_2(vendorId, user);
		assertEquals("did not succeed to create vendor key groups", 200, vendorKeyGroupsResponse.getErrorCode().intValue());
		String keyGroupId = ResponseParser.getValueFromJsonResponse(vendorKeyGroupsResponse.getResponse(), "value");

		RestResponse vendorEntitlementPool = OnboardingUtils.createVendorEntitlementPool_3(vendorId, user);
		assertEquals("did not succeed to create vendor entitlement pool", 200, vendorEntitlementPool.getErrorCode().intValue());
		String entitlementPoolId = ResponseParser.getValueFromJsonResponse(vendorEntitlementPool.getResponse(), "value");

		RestResponse vendorLicenseFeatureGroups = OnboardingUtils.createVendorLicenseFeatureGroups_4(vendorId, keyGroupId, entitlementPoolId, user);
		assertEquals("did not succeed to create vendor license feature groups", 200, vendorLicenseFeatureGroups.getErrorCode().intValue());
		String featureGroupId = ResponseParser.getValueFromJsonResponse(vendorLicenseFeatureGroups.getResponse(), "value");

		RestResponse vendorLicenseAgreement = OnboardingUtils.createVendorLicenseAgreement_5(vendorId, featureGroupId, user);
		assertEquals("did not succeed to create vendor license agreement", 200, vendorLicenseAgreement.getErrorCode().intValue());
		String vendorLicenseAgreementId = ResponseParser.getValueFromJsonResponse(vendorLicenseAgreement.getResponse(), "value");

		RestResponse checkinVendorLicense = OnboardingUtils.checkinVendorLicense(vendorId, user, "0.1");
		assertEquals("did not succeed to checkin vendor license", 200, checkinVendorLicense.getErrorCode().intValue());

		RestResponse submitVendorLicense = OnboardingUtils.submitVendorLicense(vendorId, user, "0.1");
		assertEquals("did not succeed to submit vendor license", 200, submitVendorLicense.getErrorCode().intValue());

//		ComponentBaseTest.getExtendTest().log(Status.INFO, "Succeeded in creating the vendor license");

		amdocsLicenseMembers = new AmdocsLicenseMembers(vendorId, vendorLicenseName, vendorLicenseAgreementId, featureGroupId);
		amdocsLicenseMembers.setVersion("1.0"); // Once object created and submitted, his initial version is 1.0

		return amdocsLicenseMembers;
	}

	public static String getShortUUID() {
		return UUID.randomUUID().toString().split("-")[0];
	}

	private static RestResponse actionOnComponent(String vspid, String action, String onboardComponent, User user, String componentVersion)
			throws Exception {
		Config config = Utils.getConfig();
		String url = String.format(Urls.ACTION_ON_COMPONENT, config.getCatalogBeHost(), config.getCatalogBePort(), onboardComponent, vspid, componentVersion);
		String userId = user.getUserId();

		JSONObject jObject = new JSONObject();
		jObject.put("action", action);

		Map<String, String> headersMap = prepareHeadersMap(userId);

		HttpRequest http = new HttpRequest();
		RestResponse response = http.httpSendPut(url, jObject.toString(), headersMap);
		return response;
	}


		public static RestResponse checkinVendorLicense(String vspid, User user, String vlmVersion) throws Exception {
		return actionOnComponent(vspid, "Checkin", "vendor-license-models", user, vlmVersion);
	}

	public static RestResponse checkoutVendorLicense(String vspid, User user, String vlmVersion) throws Exception {
		return actionOnComponent(vspid, "Checkout", "vendor-license-models", user, vlmVersion);
	}

	public static RestResponse submitVendorLicense(String vspid, User user, String vlmVersion) throws Exception {
		return actionOnComponent(vspid, "Submit", "vendor-license-models", user, vlmVersion);
	}

	public static RestResponse createVendorLicenseModels_1(String name, User user) throws Exception {
		Config config = Utils.getConfig();
		String url = String.format(Urls.CREATE_VENDOR_LISENCE_MODELS, config.getCatalogBeHost(),
				config.getCatalogBePort());
		String userId = user.getUserId();

		JSONObject jObject = new JSONObject();
		jObject.put("vendorName", name);
		jObject.put("description", "new vendor license model");
		jObject.put("iconRef", "icon");

		Map<String, String> headersMap = prepareHeadersMap(userId);

		HttpRequest http = new HttpRequest();
		RestResponse response = http.httpSendPost(url, jObject.toString(), headersMap);
		return response;

	}

	public static RestResponse createVendorLicenseAgreement_5(String vspid, String featureGroupId, User user)
			throws Exception {
		Config config = Utils.getConfig();
		String url = String.format(Urls.CREATE_VENDOR_LISENCE_AGREEMENT, config.getCatalogBeHost(), config.getCatalogBePort(), vspid);
		String userId = user.getUserId();

		JSONObject licenseTermpObject = new JSONObject();
		licenseTermpObject.put("choice", "Fixed_Term");
		licenseTermpObject.put("other", "");

		JSONObject jObjectBody = new JSONObject();
		jObjectBody.put("name", "abc");
		jObjectBody.put("description", "new vendor license agreement");
		jObjectBody.put("requirementsAndConstrains", "abc");
		jObjectBody.put("licenseTerm", licenseTermpObject);
		jObjectBody.put("addedFeatureGroupsIds", Arrays.asList(featureGroupId).toArray());

		Map<String, String> headersMap = prepareHeadersMap(userId);

		HttpRequest http = new HttpRequest();
		RestResponse response = http.httpSendPost(url, jObjectBody.toString(), headersMap);
		return response;
	}

	public static RestResponse createVendorLicenseFeatureGroups_4(String vspid, String licenseKeyGroupId,
																  String entitlementPoolId, User user) throws Exception {
		Config config = Utils.getConfig();
		String url = String.format(Urls.CREATE_VENDOR_LISENCE_FEATURE_GROUPS, config.getCatalogBeHost(), config.getCatalogBePort(), vspid);
		String userId = user.getUserId();

		JSONObject jObject = new JSONObject();
		jObject.put("name", "xyz");
		jObject.put("description", "new vendor license feature groups");
		jObject.put("partNumber", "123abc456");
		jObject.put("manufacturerReferenceNumber", "5");
		jObject.put("addedLicenseKeyGroupsIds", Arrays.asList(licenseKeyGroupId).toArray());
		jObject.put("addedEntitlementPoolsIds", Arrays.asList(entitlementPoolId).toArray());

		Map<String, String> headersMap = prepareHeadersMap(userId);

		HttpRequest http = new HttpRequest();
		RestResponse response = http.httpSendPost(url, jObject.toString(), headersMap);
		return response;

	}

	public static RestResponse createVendorEntitlementPool_3(String vspid, User user) throws Exception {
		Config config = Utils.getConfig();
		String url = String.format(Urls.CREATE_VENDOR_LISENCE_ENTITLEMENT_POOL, config.getCatalogBeHost(), config.getCatalogBePort(), vspid);
		String userId = user.getUserId();

		JSONObject jEntitlementMetricObject = new JSONObject();
		jEntitlementMetricObject.put("choice", "CPU");
		jEntitlementMetricObject.put("other", "");

		JSONObject jAggregationFunctionObject = new JSONObject();
		jAggregationFunctionObject.put("choice", "Peak");
		jAggregationFunctionObject.put("other", "");

		JSONObject jOperationalScope = new JSONObject();
		jOperationalScope.put("choices", Arrays.asList("Availability_Zone").toArray());
		jOperationalScope.put("other", "");

		JSONObject jTimeObject = new JSONObject();
		jTimeObject.put("choice", "Hour");
		jTimeObject.put("other", "");

		JSONObject jObjectBody = new JSONObject();
		jObjectBody.put("name", "def"+ getShortUUID());
		jObjectBody.put("description", "new vendor license entitlement pool");
		jObjectBody.put("thresholdValue", "23");
		jObjectBody.put("thresholdUnits", "Absolute");
		jObjectBody.put("entitlementMetric", jEntitlementMetricObject);
		jObjectBody.put("increments", "abcd");
		jObjectBody.put("aggregationFunction", jAggregationFunctionObject);
		jObjectBody.put("operationalScope", jOperationalScope);
		jObjectBody.put("time", jTimeObject);
		jObjectBody.put("manufacturerReferenceNumber", "123aaa");

		Map<String, String> headersMap = prepareHeadersMap(userId);

		HttpRequest http = new HttpRequest();
		RestResponse response = http.httpSendPost(url, jObjectBody.toString(), headersMap);
		return response;
	}

	public static RestResponse createVendorKeyGroups_2(String vspid, User user) throws Exception {
		Config config = Utils.getConfig();
		String url = String.format(Urls.CREATE_VENDOR_LISENCE_KEY_GROUPS, config.getCatalogBeHost(), config.getCatalogBePort(), vspid);
		String userId = user.getUserId();

		JSONObject jOperationalScope = new JSONObject();
		jOperationalScope.put("choices", Arrays.asList("Tenant").toArray());
		jOperationalScope.put("other", "");

		JSONObject jObjectBody = new JSONObject();
		jObjectBody.put("name", "keyGroup" + getShortUUID());
		jObjectBody.put("description", "new vendor license key group");
		jObjectBody.put("operationalScope", jOperationalScope);
		jObjectBody.put("type", "Universal");

		Map<String, String> headersMap = prepareHeadersMap(userId);

		HttpRequest http = new HttpRequest();
		RestResponse response = http.httpSendPost(url, jObjectBody.toString(), headersMap);
		return response;
	}

	public static Pair<RestResponse, Map<String, String>> createNewVendorSoftwareProduct(ResourceReqDetails resourceReqDetails, String vspName, AmdocsLicenseMembers amdocsLicenseMembers, User user) throws Exception {
		Map<String, String> vspMetadta = new HashMap<String, String>();

		Config config = Utils.getConfig();
		String url = String.format(Urls.CREATE_VENDOR_SOFTWARE_PRODUCT, config.getCatalogBeHost(), config.getCatalogBePort());
		String userId = user.getUserId();
		VendorSoftwareProductObject vendorSoftwareProductObject = new VendorSoftwareProductObject();
		LicensingData licensingData = new LicensingData(amdocsLicenseMembers.getVendorLicenseAgreementId(), Arrays.asList(amdocsLicenseMembers.getFeatureGroupId()));
		LicensingVersion licensingVersion = new LicensingVersion("1.0", "1.0");
		ResourceCategoryEnum resourceCategoryEnum = ResourceCategoryEnum.findEnumNameByValues(resourceReqDetails.getCategories().get(0).getName(), resourceReqDetails.getCategories().get(0).getSubcategories().get(0).getName());

		vendorSoftwareProductObject.setLicensingVersion(licensingVersion);

		vendorSoftwareProductObject.setName(vspName);
		vendorSoftwareProductObject.setDescription(resourceReqDetails.getDescription());
		vendorSoftwareProductObject.setCategory(resourceCategoryEnum.getCategoryUniqeId());
		vendorSoftwareProductObject.setSubCategory(resourceCategoryEnum.getSubCategoryUniqeId());
		vendorSoftwareProductObject.setOnboardingMethod("NetworkPackage");
		vendorSoftwareProductObject.setVendorName(amdocsLicenseMembers.getVendorLicenseName());
		vendorSoftwareProductObject.setVendorId(amdocsLicenseMembers.getVendorId());
		vendorSoftwareProductObject.setIcon("icon");
		vendorSoftwareProductObject.setLicensingData(licensingData);

		vspMetadta.put("description", resourceReqDetails.getDescription());
		vspMetadta.put("category", resourceCategoryEnum.getCategory());
		vspMetadta.put("subCategory", resourceCategoryEnum.getSubCategory());

		Map<String, String> headersMap = prepareHeadersMap(userId);
		HttpRequest http = new HttpRequest();
		Gson gson = new Gson();
		String body = gson.toJson(vendorSoftwareProductObject);

		RestResponse response = http.httpSendPost(url, body, headersMap);
		return new Pair<RestResponse, Map<String, String>>(response, vspMetadta);
	}

	public static RestResponse validateUpload(String vspid, User user, String vspVersion) throws Exception {
		Config config = Utils.getConfig();
		String url = String.format(Urls.VALIDATE_UPLOAD, config.getCatalogBeHost(), config.getCatalogBePort(), vspid,vspVersion);

		String userId = user.getUserId();

		Map<String, String> headersMap = prepareHeadersMap(userId);
		HttpRequest http = new HttpRequest();

		String body =null;

		RestResponse response = http.httpSendPut(url, body, headersMap);

		return response;
	}

	public static RestResponse uploadHeatPackage(String filepath, String filename, String vspid, User user, String vspVersion) throws Exception {
		Config config = Utils.getConfig();
		String url = String.format(Urls.UPLOAD_HEAT_PACKAGE, config.getCatalogBeHost(), config.getCatalogBePort(), vspid, vspVersion);
		return uploadFile(filepath, filename, url, user);
	}

	private static RestResponse uploadFile(String filepath, String filename, String url, User user)
			throws FileNotFoundException, IOException, ClientProtocolException {
		CloseableHttpResponse response = null;

		MultipartEntityBuilder mpBuilder = MultipartEntityBuilder.create();
		mpBuilder.addPart("upload", new FileBody(getTestZipFile(filepath, filename)));

		Map<String, String> headersMap = prepareHeadersMap(user.getUserId());
		headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "multipart/form-data");

		CloseableHttpClient client = HttpClients.createDefault();
		try {
			HttpPost httpPost = new HttpPost(url);
			RestResponse restResponse = new RestResponse();

			Iterator<String> iterator = headersMap.keySet().iterator();
			while (iterator.hasNext()) {
				String key = iterator.next();
				String value = headersMap.get(key);
				httpPost.addHeader(key, value);
			}
			httpPost.setEntity(mpBuilder.build());
			response = client.execute(httpPost);
			HttpEntity entity = response.getEntity();
			String responseBody = null;
			if (entity != null) {
				InputStream instream = entity.getContent();
				try {
					StringWriter writer = new StringWriter();
					IOUtils.copy(instream, writer);
					responseBody = writer.toString();
				} finally {
					instream.close();
				}
			}

			restResponse.setErrorCode(response.getStatusLine().getStatusCode());
			restResponse.setResponse(responseBody);

			return restResponse;

		} finally {
			closeResponse(response);
			closeHttpClient(client);

		}
	}

	private static void closeResponse(CloseableHttpResponse response) {
		try {
			if (response != null) {
				response.close();
			}
		} catch (IOException e) {
			System.out.println(String.format("failed to close client or response: %s", e.getMessage()));
		}
	}

	private static void closeHttpClient(CloseableHttpClient client) {
		try {
			if (client != null) {
				client.close();
			}
		} catch (IOException e) {
			System.out.println(String.format("failed to close client or response: %s", e.getMessage()));
		}
	}

//	private static File getTestZipFile(String filepath, String filename) throws IOException {
//		Config config = Utils.getConfig();
//		String sourceDir = config.getImportResourceTestsConfigDir();
//		java.nio.file.Path filePath = FileSystems.getDefault().getPath(filepath + File.separator + filename);
//		return filePath.toFile();
//	}

	private static File getTestZipFile(String filepath, String filename) throws IOException {
		Config config = Utils.getConfig();
		String sourceDir = config.getImportResourceTestsConfigDir();
		java.nio.file.Path filePath;
		if(filename == null){
			filePath = FileSystems.getDefault().getPath(filepath);
		}else{
			filePath = FileSystems.getDefault().getPath(filepath + File.separator + filename);
		}
		return filePath.toFile();
	}

	public static RestResponse checkinVendorSoftwareProduct(String vspid, User user, String vspVersion) throws Exception {
		return actionOnComponent(vspid, "Checkin", "vendor-software-products", user, vspVersion);
	}

	public static RestResponse checkoutVendorSoftwareProduct(String vspid, User user, String vspVersion) throws Exception {
		return actionOnComponent(vspid, "Checkout", "vendor-software-products", user, vspVersion);
	}

	public static RestResponse submitVendorSoftwareProduct(String vspid, User user, String vspVersion) throws Exception {
		return actionOnComponent(vspid, "Submit", "vendor-software-products", user, vspVersion);
	}

	public static RestResponse createPackageOfVendorSoftwareProduct(String vspid, User user, String vspVersion) throws Exception {
		return actionOnComponent(vspid, "Create_Package", "vendor-software-products", user, vspVersion);
	}

	protected static Map<String, String> prepareHeadersMap(String userId) {
		Map<String, String> headersMap = new HashMap<String, String>();
		headersMap.put(HttpHeaderEnum.CONTENT_TYPE.getValue(), "application/json");
		headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), "application/json");
		headersMap.put(HttpHeaderEnum.USER_ID.getValue(), userId);
		return headersMap;
	}

	public static VendorSoftwareProductObject updateVSPWithNewVLMParameters(VendorSoftwareProductObject vendorSoftwareProductObject,
																			AmdocsLicenseMembers amdocsLicenseMembers, User user, String vspCurrentVersion, String vspNextVersion) throws Exception {

		LicensingVersion licensingVersion = new LicensingVersion(amdocsLicenseMembers.getLicenseVersionId(),amdocsLicenseMembers.getLicenseVersionId());
		LicensingData licensingData = new LicensingData(amdocsLicenseMembers.getVendorLicenseAgreementId(), Arrays.asList(amdocsLicenseMembers.getFeatureGroupId()));
		vendorSoftwareProductObject.setVendorId(amdocsLicenseMembers.getVendorId());
		vendorSoftwareProductObject.setVendorName(amdocsLicenseMembers.getVendorLicenseName());
		vendorSoftwareProductObject.setLicensingVersion(licensingVersion);
		vendorSoftwareProductObject.setLicensingData(licensingData);

		VendorSoftwareProductObjectReqDetails vendorSoftwareProductObjectReqDetails = new VendorSoftwareProductObjectReqDetails(
				vendorSoftwareProductObject.getName(),
				vendorSoftwareProductObject.getDescription(),
				vendorSoftwareProductObject.getCategory(),
				vendorSoftwareProductObject.getSubCategory(),
				vendorSoftwareProductObject.getVendorId(),
				vendorSoftwareProductObject.getVendorName(),
				licensingVersion,
				licensingData,
				vendorSoftwareProductObject.getOnboardingMethod(),
				vendorSoftwareProductObject.getNetworkPackageName(),
				vendorSoftwareProductObject.getOnboardingOrigin());

		Gson gson = new Gson();
		String json = gson.toJson(vendorSoftwareProductObjectReqDetails);

		RestResponse checkout = checkoutVendorSoftwareProduct(vendorSoftwareProductObject.getVspId(), user, "1.0");
		assertEquals("did not succeed to checkout new VSP", 200, checkout.getErrorCode().intValue());

		Config config = Utils.getConfig();
		String url = String.format(Urls.UPDATE_VSP, config.getCatalogBeHost(), config.getCatalogBePort(), vendorSoftwareProductObject.getVspId(), vspCurrentVersion);
		String userId = user.getUserId();

		Map<String, String> headersMap = prepareHeadersMap(userId);
		HttpRequest http = new HttpRequest();

		RestResponse response = http.httpSendPut(url, json, headersMap);

		RestResponse checkin = checkinVendorSoftwareProduct(vendorSoftwareProductObject.getVspId(), user, vspCurrentVersion);
		assertEquals("did not succeed to checking VSP", 200, checkin.getErrorCode().intValue());

		RestResponse submit = submitVendorSoftwareProduct(vendorSoftwareProductObject.getVspId(), user, vspCurrentVersion);
		assertEquals("did not succeed to submit VSP", 200, submit.getErrorCode().intValue());

		vendorSoftwareProductObject.setVersion(vspNextVersion);

		return vendorSoftwareProductObject;
	}

//	private static void importUpdateVSP(Pair<String, Map<String, String>> vsp, boolean isUpdate) throws Exception{
//		String vspName = vsp.left;
//		Map<String, String> vspMetadata = vsp.right;
//		boolean vspFound = HomePage.searchForVSP(vspName);
//
//		if (vspFound){
//
//			List<WebElement> elemenetsFromTable = HomePage.getElemenetsFromTable();
////			WebDriverWait wait = new WebDriverWait(GeneralUIUtils.getDriver(), 30);
////			WebElement findElement = wait.until(ExpectedConditions.visibilityOf(elemenetsFromTable.get(1)));
////			findElement.click();
//			elemenetsFromTable.get(1).click();
//			GeneralUIUtils.waitForLoader();
//
//			if (isUpdate){
//				GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ImportVfRepository.UPDATE_VSP.getValue());
//
//			}
//			else{
//				GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ImportVfRepository.IMPORT_VSP.getValue());
//			}
//
//			String lifeCycleState = ResourceGeneralPage.getLifeCycleState();
//			boolean needCheckout = lifeCycleState.equals(LifeCycleStateEnum.CHECKIN.getValue()) || lifeCycleState.equals(LifeCycleStateEnum.CERTIFIED.getValue());
//			if (needCheckout)
//			{
//				try {
//					ResourceGeneralPage.clickCheckoutButton();
//					Assert.assertTrue(ResourceGeneralPage.getLifeCycleState().equals(LifeCycleStateEnum.CHECKOUT.getValue()), "Did not succeed to checkout");
//
//				} catch (Exception e) {
//					ExtentTestActions.log(Status.ERROR, "Did not succeed to checkout");
//					e.printStackTrace();
//				}
//				GeneralUIUtils.waitForLoader();
//			}
//
//			//Metadata verification
//			VfVerificator.verifyOnboardedVnfMetadata(vspName, vspMetadata);
//
//			ExtentTestActions.log(Status.INFO, "Clicking create/update VNF");
//			String duration = GeneralUIUtils.getActionDuration(() -> waitUntilVnfCreated());
//		    ExtentTestActions.log(Status.INFO, "Succeeded in importing/updating " + vspName, duration);
//		}
//		else{
//			Assert.fail("Did not find VSP named " + vspName);
//		}
//	}

//	private static void waitUntilVnfCreated() {
//		GeneralUIUtils.clickOnElementByTestIdWithoutWait(DataTestIdEnum.GeneralElementsEnum.CREATE_BUTTON.getValue());
//		GeneralUIUtils.waitForLoader(60*10);
//		GeneralUIUtils.waitForAngular();
//		GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.GeneralElementsEnum.CHECKIN_BUTTON.getValue());
//	}
//
//	public static void updateVSP(Pair<String, Map<String, String>> vsp) throws Exception{
//		ExtentTestActions.log(Status.INFO, "Updating VSP " + vsp.left);
//		importUpdateVSP(vsp, true);
//	}
//
//	public static void importVSP(Pair<String, Map<String, String>> vsp) throws Exception{
//		ExtentTestActions.log(Status.INFO, "Importing VSP " + vsp.left);
//		importUpdateVSP(vsp, false);
//	}
//
//	public static void updateVnfAndValidate(String filepath, Pair<String, Map<String, String>> vsp, String updatedVnfFile, User user) throws Exception, Throwable {
//		ExtentTestActions.log(Status.INFO, String.format("Going to update the VNF with %s......", updatedVnfFile));
//		System.out.println(String.format("Going to update the VNF with %s......", updatedVnfFile));
//
//		Map<String, String> vspMap = vsp.right;
//		String vspId = vspMap.get("vspId");
//
//		updateVendorSoftwareProduct(vspId, updatedVnfFile, filepath, user);
//		HomePage.showVspRepository();
//		updateVSP(vsp);
//		ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
//		DeploymentArtifactPage.verifyArtifactsExistInTable(filepath, updatedVnfFile);
//	}
//
//	public static Pair<String, Map<String, String>> onboardAndValidate(String filepath, String vnfFile, User user) throws Exception {
//		ExtentTestActions.log(Status.INFO, String.format("Going to onboard the VNF %s", vnfFile));
//		System.out.println(String.format("Going to onboard the VNF %s", vnfFile));
//
//		AmdocsLicenseMembers amdocsLicenseMembers = createVendorLicense(user);
//		Pair<String, Map<String, String>> createVendorSoftwareProduct = createVendorSoftwareProduct(vnfFile, filepath, user, amdocsLicenseMembers);
//		String vspName = createVendorSoftwareProduct.left;
//
//		DownloadManager.downloadCsarByNameFromVSPRepository(vspName, createVendorSoftwareProduct.right.get("vspId"));
//		File latestFilefromDir = FileHandling.getLastModifiedFileNameFromDir();
//
//		ExtentTestActions.log(Status.INFO, String.format("Searching for onboarded %s", vnfFile));
//		HomePage.showVspRepository();
//		ExtentTestActions.log(Status.INFO,String.format("Going to import %s", vnfFile.substring(0, vnfFile.indexOf("."))));
//		importVSP(createVendorSoftwareProduct);
//
//		ResourceGeneralPage.getLeftMenu().moveToDeploymentArtifactScreen();
//
//		// Verify deployment artifacts
//		Map<String, Object> combinedMap = ArtifactFromCsar.combineHeatArtifacstWithFolderArtifacsToMap(latestFilefromDir.getAbsolutePath());
//
//		LinkedList<HeatMetaFirstLevelDefinition> deploymentArtifacts = ((LinkedList<HeatMetaFirstLevelDefinition>) combinedMap.get("Deployment"));
//		ArtifactsCorrelationManager.addVNFartifactDetails(vspName, deploymentArtifacts);
//
//		List<String> heatEnvFilesFromCSAR = deploymentArtifacts.stream().filter(e -> e.getType().equals("HEAT_ENV")).
//																		 map(e -> e.getFileName()).
//																		 collect(Collectors.toList());
//
//		validateDeploymentArtifactsVersion(deploymentArtifacts, heatEnvFilesFromCSAR);
//
//		DeploymentArtifactPage.verifyArtifactsExistInTable(filepath, vnfFile);
//		return createVendorSoftwareProduct;
//	}
//
//	public static void validateDeploymentArtifactsVersion(LinkedList<HeatMetaFirstLevelDefinition> deploymentArtifacts,
//			List<String> heatEnvFilesFromCSAR) {
//		String artifactVersion;
//		String artifactName;
//
//		for(HeatMetaFirstLevelDefinition deploymentArtifact: deploymentArtifacts) {
//			artifactVersion = "1";
//
//			if(deploymentArtifact.getType().equals("HEAT_ENV")) {
//				continue;
//			} else if(deploymentArtifact.getFileName().contains(".")) {
//				artifactName = deploymentArtifact.getFileName().trim().substring(0, deploymentArtifact.getFileName().lastIndexOf("."));
//			} else {
//				artifactName = deploymentArtifact.getFileName().trim();
//			}
//
//			if (heatEnvFilesFromCSAR.contains(artifactName + ".env")){
//				artifactVersion = "2";
//			}
//			ArtifactUIUtils.validateArtifactNameVersionType(artifactName, artifactVersion, deploymentArtifact.getType());
//		}
//	}
	
	
	/**
	 * @return
	 * The method returns VNF names list from Files directory under sdc-vnfs repository
	 */
	public static List<String> getVnfNamesFileList() {
		String filepath = FileHandling.getVnfRepositoryPath();
		List<String> fileNamesFromFolder = FileHandling.getZipFileNamesFromFolder(filepath);
		fileNamesFromFolder.removeAll(exludeVnfList);
		return fileNamesFromFolder;
	}

	/**
	 * @return
	 * The method returns VNF names list from Files directory under sdc-vnfs repository excluding zip files that known as failed in tosca parser
	 */
	public static List<String> getVnfNamesFileListExcludeToscaParserFailure() {
		List<String> fileNamesFromFolder = getVnfNamesFileList();
		fileNamesFromFolder.removeAll(exludeVnfListForToscaParser);
		return fileNamesFromFolder;
	}

	public static VendorSoftwareProductObject fillVendorSoftwareProductObjectWithMetaData(String vnfFile, Pair<String, Map<String, String>> createVendorSoftwareProduct) {
		VendorSoftwareProductObject vendorSoftwareProductObject = new VendorSoftwareProductObject();
		Map<String, String> map = createVendorSoftwareProduct.right;
		vendorSoftwareProductObject.setAttContact(map.get("attContact"));
		vendorSoftwareProductObject.setCategory(map.get("category"));
		vendorSoftwareProductObject.setComponentId(map.get("componentId"));
		vendorSoftwareProductObject.setDescription(map.get("description"));
		vendorSoftwareProductObject.setSubCategory(map.get("subCategory"));
		vendorSoftwareProductObject.setVendorName(map.get("vendorName"));
		vendorSoftwareProductObject.setVspId(map.get("vspId"));
		vendorSoftwareProductObject.setName(createVendorSoftwareProduct.left);
		String[] arrFileNameAndExtension = vnfFile.split("\\.");
		vendorSoftwareProductObject.setOnboardingMethod("NetworkPackage");
		vendorSoftwareProductObject.setNetworkPackageName(arrFileNameAndExtension[0]);
		vendorSoftwareProductObject.setOnboardingOrigin(arrFileNameAndExtension[1]);

		return vendorSoftwareProductObject;
	}

	public static void updateVendorSoftwareProductToNextVersion(VendorSoftwareProductObject vendorSoftwareProductObject, String toVspVersion, User user, String filepath, String heatFileName)
			throws Exception, Throwable {

		RestResponse checkout = checkoutVendorSoftwareProduct(vendorSoftwareProductObject.getVspId(), user, vendorSoftwareProductObject.getVersion());
		assertEquals("did not succeed to checkout new VSP", 200, checkout.getErrorCode().intValue());

		RestResponse uploadHeatPackage = uploadHeatPackage(filepath, heatFileName, vendorSoftwareProductObject.getVspId(), user, "1.1");
		assertEquals("did not succeed to upload HEAT package", 200, uploadHeatPackage.getErrorCode().intValue());

		RestResponse validateUpload = validateUpload(vendorSoftwareProductObject.getVspId(), user, "1.1");
		assertEquals("did not succeed to validate upload process, reason: " + validateUpload.getResponse(), 200, validateUpload.getErrorCode().intValue());

		prepareVspForUse(user,vendorSoftwareProductObject.getVspId(),toVspVersion);

		vendorSoftwareProductObject.setVersion(toVspVersion);
	}

	public static Object[][] filterObjectArrWithExcludedVnfs(Object[][] objectArr)
	{
		Object[][] filteredArObject = new Object[objectArr.length][];

		int index = 0;

		for (int i = 0; i < objectArr.length ; i++) {

			String vnfSourceFile = (String) objectArr[i][0];
			String vnfUpdateFile = (String) objectArr[i][1];

			if(!exludeVnfList.contains(vnfSourceFile) && !exludeVnfList.contains(vnfUpdateFile))
			{
				filteredArObject[index] = new Object[]{vnfSourceFile , vnfUpdateFile };
				index++;
			}
		}

		return filteredArObject;
	}
}