[SDC-29] Amdocs OnBoard 1707 initial commit.
[sdc.git] / openecomp-be / backend / openecomp-sdc-vendor-software-product-manager / src / test / java / org / openecomp / sdc / vendorsoftwareproduct / impl / VendorSoftwareProductManagerImplTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
21 package org.openecomp.sdc.vendorsoftwareproduct.impl;
22
23 import org.apache.commons.lang3.tuple.ImmutablePair;
24 import org.apache.commons.lang3.tuple.Pair;
25 import org.mockito.ArgumentCaptor;
26 import org.mockito.Captor;
27 import org.mockito.InjectMocks;
28 import org.mockito.Mock;
29 import org.mockito.MockitoAnnotations;
30 import org.mockito.Spy;
31 import org.openecomp.core.enrichment.factory.EnrichmentManagerFactory;
32 import org.openecomp.core.enrichment.types.ArtifactType;
33 import org.openecomp.core.factory.impl.AbstractFactoryBase;
34 import org.openecomp.core.model.dao.EnrichedServiceModelDao;
35 import org.openecomp.core.model.dao.ServiceModelDao;
36 import org.openecomp.core.model.types.ServiceElement;
37 import org.openecomp.core.utilities.file.FileContentHandler;
38 import org.openecomp.core.utilities.file.FileUtils;
39 import org.openecomp.sdc.activityLog.ActivityLogManager;
40 import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
41 import org.openecomp.sdc.common.errors.CoreException;
42 import org.openecomp.sdc.common.errors.ErrorCategory;
43 import org.openecomp.sdc.common.errors.ErrorCode;
44 import org.openecomp.sdc.common.errors.Messages;
45 import org.openecomp.sdc.common.errors.ValidationErrorBuilder;
46 import org.openecomp.sdc.healing.api.HealingManager;
47 import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
48 import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition;
49 import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
50 import org.openecomp.sdc.vendorlicense.licenseartifacts.VendorLicenseArtifactsService;
51 import org.openecomp.sdc.vendorsoftwareproduct.MibManager;
52 import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager;
53 import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
54 import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
55 import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDao;
56 import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
57 import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
58 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
59 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo;
60 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity;
61 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
62 import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes;
63 import org.openecomp.sdc.vendorsoftwareproduct.impl.mock.EnrichmentManagerFactoryImpl;
64 import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactGenerator;
65 import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
66 import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
67 import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse;
68 import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo;
69 import org.openecomp.sdc.versioning.VersioningManager;
70 import org.openecomp.sdc.versioning.dao.types.Version;
71 import org.openecomp.sdc.versioning.dao.types.VersionStatus;
72 import org.openecomp.sdc.versioning.errors.EditOnEntityLockedByOtherErrorBuilder;
73 import org.openecomp.sdc.versioning.errors.EntityNotExistErrorBuilder;
74 import org.openecomp.sdc.versioning.types.VersionInfo;
75 import org.openecomp.sdc.versioning.types.VersionableEntityAction;
76 import org.testng.Assert;
77 import org.testng.annotations.BeforeMethod;
78 import org.testng.annotations.Test;
79
80 import java.io.File;
81 import java.io.FileInputStream;
82 import java.io.IOException;
83 import java.io.InputStream;
84 import java.net.URL;
85 import java.nio.ByteBuffer;
86 import java.util.ArrayList;
87 import java.util.Arrays;
88 import java.util.Collections;
89 import java.util.HashMap;
90 import java.util.List;
91 import java.util.Map;
92 import java.util.stream.Collectors;
93 import java.util.zip.ZipEntry;
94 import java.util.zip.ZipInputStream;
95
96 import static org.mockito.Matchers.any;
97 import static org.mockito.Matchers.anyObject;
98 import static org.mockito.Matchers.eq;
99 import static org.mockito.Mockito.doNothing;
100 import static org.mockito.Mockito.doReturn;
101 import static org.mockito.Mockito.doThrow;
102 import static org.mockito.Mockito.never;
103 import static org.mockito.Mockito.verify;
104
105
106 /**
107  * Created by TALIO on 4/23/2016
108  */
109 public class VendorSoftwareProductManagerImplTest {
110   private static final String INVALID_VERSION_MSG = "Invalid requested version.";
111
112   private static String VSP_ID = "vspId";
113   private static String VERSION_ID = "versionId";
114   public static final Version VERSION01 = new Version(0, 1);
115   private static final Version VERSION10 = new Version(1, 0);
116   private static final String USER1 = "vspTestUser1";
117   private static final String USER2 = "vspTestUser2";
118   private static final String USER3 = "vspTestUser3";
119   private static String id006 = null;
120   private static String id007 = null;
121
122   @Mock
123   private VersioningManager versioningManagerMock;
124   @Mock
125   private VendorSoftwareProductDao vendorSoftwareProductDaoMock; // todo get rid of
126   @Mock
127   private OrchestrationTemplateDao orchestrationTemplateDataDaoMock;
128   @Mock
129   private VendorLicenseFacade vendorLicenseFacadeMock;
130   @Mock
131   private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDaoMock;
132   @Mock
133   private EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> enrichedServiceModelDaoMock;
134   @Mock
135   private HealingManager healingManagerMock;
136   @Mock
137   private VendorLicenseArtifactsService licenseArtifactsServiceMock;
138   @Mock
139   private CompositionEntityDataManager compositionEntityDataManagerMock;
140   @Mock
141   private InformationArtifactGenerator informationArtifactGeneratorMock;
142   @Mock
143   private ActivityLogManager activityLogManagerMock;
144   @Mock
145   private PackageInfoDao packageInfoDao;
146   @Mock
147   private VendorSoftwareProductInfoDao vspInfoDaoMock;
148
149
150   @Spy
151   @InjectMocks
152   private VendorSoftwareProductManagerImpl vendorSoftwareProductManager;
153
154   private OrchestrationTemplateCandidateManager candidateManager;
155   private MibManager mibManager;
156
157   @Captor
158   private ArgumentCaptor<ActivityLogEntity> activityLogEntityArg;
159
160   @BeforeMethod
161   public void setUp() throws Exception {
162     MockitoAnnotations.initMocks(this);
163   }
164
165   @Test
166   public void testListWhenNone() {
167     doReturn(new HashMap<>()).when(versioningManagerMock).listEntitiesVersionInfo
168         (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1,
169             VersionableEntityAction.Read);
170     List<VersionedVendorSoftwareProductInfo> vsps =
171         vendorSoftwareProductManager.listVsps(null, USER1);
172     Assert.assertEquals(vsps.size(), 0);
173   }
174
175   @Test
176   public void testList() {
177     String vsp1id = "vsp1_id";
178     String vsp2id = "vsp2_id";
179     Map<String, VersionInfo> vspsTobeReturned = new HashMap<>();
180
181     VersionInfo versionInfo1 = new VersionInfo();
182     versionInfo1.setActiveVersion(VERSION01);
183     vspsTobeReturned.put(vsp1id, versionInfo1);
184
185     VersionInfo versionInfo2 = new VersionInfo();
186     versionInfo2.setActiveVersion(VERSION10);
187     vspsTobeReturned.put(vsp2id, versionInfo2);
188
189     doReturn(vspsTobeReturned).when(versioningManagerMock).listEntitiesVersionInfo
190         (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1,
191             VersionableEntityAction.Read);
192
193     VspDetails vsp1 = new VspDetails(vsp1id, VERSION01);
194     vsp1.setWritetimeMicroSeconds(8L);
195     doReturn(vsp1).when(vspInfoDaoMock)
196         .get(any(VspDetails.class));
197
198     List<VersionedVendorSoftwareProductInfo> vsps =
199         vendorSoftwareProductManager.listVsps(null, USER1);
200     Assert.assertEquals(vsps.size(), 2);
201   }
202
203   @Test
204   public void testListFinalsWhenNone() {
205     String vsp1id = "vsp1_id";
206     String vsp2id = "vsp2_id";
207     Map<String, VersionInfo> vspsTobeReturned = new HashMap<>();
208
209     VersionInfo versionInfo1 = new VersionInfo();
210     versionInfo1.setActiveVersion(VERSION01);
211     vspsTobeReturned.put(vsp1id, versionInfo1);
212
213     VersionInfo versionInfo2 = new VersionInfo();
214     versionInfo2.setActiveVersion(VERSION10);
215     vspsTobeReturned.put(vsp2id, versionInfo2);
216
217     doReturn(vspsTobeReturned).when(versioningManagerMock).listEntitiesVersionInfo
218         (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1,
219             VersionableEntityAction.Read);
220
221     List<VersionedVendorSoftwareProductInfo> vsps =
222         vendorSoftwareProductManager.listVsps(VersionStatus.Final.name(), USER1);
223     Assert.assertEquals(vsps.size(), 0);
224   }
225
226   @Test
227   public void testListFinals() {
228     String vsp1id = "vsp1_id";
229     String vsp2id = "vsp2_id";
230     Map<String, VersionInfo> vspsTobeReturned = new HashMap<>();
231
232     VersionInfo versionInfo1 = new VersionInfo();
233     versionInfo1.setActiveVersion(VERSION01);
234     vspsTobeReturned.put(vsp1id, versionInfo1);
235
236     VersionInfo versionInfo2 = new VersionInfo();
237     versionInfo2.setActiveVersion(new Version(1, 3));
238     versionInfo2.setLatestFinalVersion(VERSION10);
239     vspsTobeReturned.put(vsp2id, versionInfo2);
240
241     doReturn(vspsTobeReturned).when(versioningManagerMock).listEntitiesVersionInfo
242         (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1,
243             VersionableEntityAction.Read);
244
245     VspDetails vsp2 = new VspDetails(vsp2id, VERSION10);
246     vsp2.setWritetimeMicroSeconds(8L);
247     doReturn(vsp2).when(vspInfoDaoMock)
248         .get(any(VspDetails.class));
249
250     List<VersionedVendorSoftwareProductInfo> vsps =
251         vendorSoftwareProductManager.listVsps(VersionStatus.Final.name(), USER1);
252     Assert.assertEquals(vsps.size(), 1);
253   }
254
255   @Test(expectedExceptions = CoreException.class)
256   public void testCreateWithExistingName_negative() {
257     doThrow(new CoreException(
258         new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).build()))
259         .when(vendorSoftwareProductManager).validateUniqueName("Vsp1");
260     VspDetails expectedVsp =
261         createVspDetails(null, null, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon",
262             "category", "subCategory", "123", null);
263
264     vendorSoftwareProductManager.createVsp(expectedVsp, USER1);
265   }
266
267   @Test
268   public void testCreate() {
269     doNothing().when(vendorSoftwareProductManager).validateUniqueName("Vsp1");
270     doNothing().when(vendorSoftwareProductManager).createUniqueName("Vsp1");
271     doReturn(VERSION01).when(versioningManagerMock).create(anyObject(), anyObject(), anyObject());
272     doReturn("{}")
273         .when(vendorSoftwareProductManager).getVspQuestionnaireSchema(anyObject());
274
275     VspDetails vspToCreate =
276         createVspDetails(null, null, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon",
277             "category", "subCategory", "123", null);
278
279     VspDetails vsp = vendorSoftwareProductManager.createVsp(vspToCreate, USER1);
280
281     Assert.assertNotNull(vsp);
282     vspToCreate.setId(vsp.getId());
283     vspToCreate.setVersion(VERSION01);
284     assertVspsEquals(vsp, vspToCreate);
285     verify(activityLogManagerMock).addActionLog(activityLogEntityArg.capture(), eq(USER1));
286     ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
287     Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION01.getMajor()+1));
288     Assert.assertTrue(activityLogEntity.isSuccess());
289   }
290
291   @Test(expectedExceptions = CoreException.class)
292   public void testUpdateWithExistingName_negative() {
293     VersionInfo versionInfo = new VersionInfo();
294     versionInfo.setActiveVersion(VERSION01);
295     doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
296         VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
297         VersionableEntityAction.Write);
298
299     VspDetails existingVsp =
300         createVspDetails(VSP_ID, VERSION01, "Vsp1", "Test-existingVsp", "vendorName", "vlm1Id",
301             "icon", "category", "subCategory", "123", null);
302     VspDetails updatedVsp =
303         createVspDetails(VSP_ID, VERSION01, "Vsp1_updated", "Test-existingVsp", "vendorName",
304             "vlm1Id", "icon", "category", "subCategory", "123", null);
305     doReturn(existingVsp).when(vspInfoDaoMock)
306         .get(any(VspDetails.class));
307     doThrow(new CoreException(
308         new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).build()))
309         .when(vendorSoftwareProductManager)
310         .updateUniqueName(existingVsp.getName(), updatedVsp.getName());
311
312     vendorSoftwareProductManager.updateVsp(updatedVsp, USER1);
313   }
314
315   @Test
316   public void testUpdate() {
317     VersionInfo versionInfo = new VersionInfo();
318     versionInfo.setActiveVersion(VERSION01);
319     doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
320         VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
321         VersionableEntityAction.Write);
322     VspDetails existingVsp =
323         createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon",
324             "category",
325             "subCategory", "456", null);
326     VspDetails updatedVsp =
327         createVspDetails(VSP_ID, VERSION01, "VSP1_updated", null, "vendorName", "vlm1Id", "icon",
328             "category_updated",
329             "subCategory", "456", null);
330     existingVsp.setWritetimeMicroSeconds(8L);
331     doReturn(existingVsp).when(vspInfoDaoMock)
332         .get(any(VspDetails.class));
333     doNothing().when(vendorSoftwareProductManager)
334         .updateUniqueName(existingVsp.getName(), updatedVsp.getName());
335
336     vendorSoftwareProductManager.updateVsp(updatedVsp, USER1);
337
338     verify(vspInfoDaoMock).update(updatedVsp);
339   }
340
341   @Test(expectedExceptions = CoreException.class)
342   public void testGetNonExistingVersion_negative() {
343     Version notExistversion = new Version(43, 8);
344     doReturn(null).when(vspInfoDaoMock).get(any(VspDetails.class));
345     vendorSoftwareProductManager.getVsp(VSP_ID, notExistversion, USER1);
346   }
347
348   @Test
349   public void testGetCheckedOutVersion() {
350     VersionInfo versionInfo = new VersionInfo();
351     versionInfo.setActiveVersion(VERSION01);
352     versionInfo.setStatus(VersionStatus.Locked);
353     versionInfo.setLockingUser(USER1);
354     doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
355         VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
356         VersionableEntityAction.Read);
357
358     VspDetails existingVsp =
359         createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon",
360             "category",
361             "subCategory", "456", null);
362     existingVsp.setWritetimeMicroSeconds(8L);
363     doReturn(existingVsp).when(vspInfoDaoMock).get(any(VspDetails.class));
364
365     VspDetails actualVsp =
366         vendorSoftwareProductManager.getVsp(VSP_ID, VERSION01, USER1);
367
368     assertVspsEquals(actualVsp, existingVsp);
369   }
370
371   @Test
372   public void testGetOldVersion() {
373     VersionInfo versionInfo = new VersionInfo();
374     versionInfo.setActiveVersion(new Version(0, 2));
375     versionInfo.setViewableVersions(Arrays.asList(VERSION01, new Version(0, 2)));
376     versionInfo.setStatus(VersionStatus.Locked);
377     versionInfo.setLockingUser(USER2);
378     doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
379         VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
380         VersionableEntityAction.Read);
381
382     VspDetails existingVsp =
383         createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon",
384             "category",
385             "subCategory", "456", null);
386     existingVsp.setWritetimeMicroSeconds(8L);
387     doReturn(existingVsp)
388         .when(vspInfoDaoMock).get(any(VspDetails.class));
389
390     VspDetails actualVsp =
391         vendorSoftwareProductManager.getVsp(VSP_ID, VERSION01, USER1);
392
393     VspDetails expectedVsp =
394         vspInfoDaoMock
395             .get(new VspDetails(VSP_ID, VERSION01));
396     assertVspsEquals(actualVsp, expectedVsp);
397   }
398
399   @Test
400   public void testCheckin() {
401     doReturn(VERSION01).when(versioningManagerMock)
402         .checkin(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
403             USER1, null);
404     Version version = vendorSoftwareProductManager.checkin(VSP_ID, USER1);
405
406     Assert.assertEquals(version, VERSION01);
407     verify(versioningManagerMock)
408         .checkin(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
409             USER1, null);
410     verify(activityLogManagerMock).addActionLog(activityLogEntityArg.capture(), eq(USER1));
411     ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
412     Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION01.getMajor()+1));
413     Assert.assertTrue(activityLogEntity.isSuccess());
414   }
415
416   @Test
417   public void testCheckout() {
418     doReturn(VERSION01).when(versioningManagerMock)
419         .checkout(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
420             USER1);
421     Version version = vendorSoftwareProductManager.checkout(VSP_ID, USER1);
422
423     Assert.assertEquals(version, VERSION01);
424     verify(versioningManagerMock)
425         .checkout(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
426             USER1);
427
428     verify(activityLogManagerMock).addActionLog(activityLogEntityArg.capture(), eq(USER1));
429     ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
430     Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION01.getMajor()+1));
431     Assert.assertTrue(activityLogEntity.isSuccess());
432   }
433
434
435   @Test
436   public void testUndoCheckout() {
437     Version existingVersion = new Version(0, 2);
438     VersionInfo versionInfo = new VersionInfo();
439     versionInfo.setActiveVersion(existingVersion);
440     doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
441         VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
442         VSP_ID, USER1, VersionableEntityAction.Read);
443
444     doReturn(VERSION01).when(versioningManagerMock).undoCheckout(VendorSoftwareProductConstants
445         .VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1);
446
447     VspDetails vsp = new VspDetails(VSP_ID, existingVersion);
448     vsp.setName("ExistingName");
449     doReturn(vsp).when(vspInfoDaoMock).get(anyObject());
450     doNothing().when(vendorSoftwareProductManager).updateUniqueName(vsp.getName(), vsp.getName());
451
452     Version undoCheckoutVersion = vendorSoftwareProductManager.undoCheckout(VSP_ID, USER1);
453
454     Assert.assertEquals(undoCheckoutVersion, VERSION01);
455   }
456
457
458   @Test
459   public void testSubmitWithMissingData() throws IOException {
460     VersionInfo versionInfo = new VersionInfo();
461     versionInfo.setActiveVersion(VERSION01);
462     doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
463         VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
464         VSP_ID, USER1, VersionableEntityAction.Read);
465
466     VspDetails vsp = new VspDetails(VSP_ID, VERSION01);
467     doReturn(vsp).when(vspInfoDaoMock).get(anyObject());
468
469     ValidationResponse validationResponse = vendorSoftwareProductManager.submit(VSP_ID, USER1);
470     Assert.assertNotNull(validationResponse);
471     Assert.assertFalse(validationResponse.isValid());
472     List<String> errorIds = validationResponse.getVspErrors().stream().map(ErrorCode::id).distinct()
473         .collect(Collectors.toList());
474     Assert.assertTrue(errorIds.contains(ValidationErrorBuilder.FIELD_VALIDATION_ERROR_ERR_ID));
475     Assert.assertTrue(errorIds.contains(VendorSoftwareProductErrorCodes.VSP_INVALID));
476
477     verify(versioningManagerMock, never())
478         .submit(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
479             USER1, null);
480     verify(activityLogManagerMock, never()).addActionLog(any(ActivityLogEntity.class),eq(USER1));
481   }
482
483   // TODO: 3/15/2017 fix and enable
484   //@Test
485   public void testSubmitWithInvalidLicensingData() throws IOException {
486     VersionInfo versionInfo = new VersionInfo();
487     versionInfo.setActiveVersion(VERSION01);
488     doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
489         VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
490         VSP_ID, USER1, VersionableEntityAction.Read);
491
492     VspDetails vsp =
493         createVspDetails(VSP_ID, VERSION01, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon",
494             "category", "subCategory", "licenseAgreementId",
495             Collections.singletonList("featureGroupId"));
496     doReturn(vsp).when(vspInfoDaoMock).get(anyObject());
497     UploadDataEntity uploadData = new UploadDataEntity(VSP_ID, VERSION01);
498     uploadData.setContentData(
499         ByteBuffer.wrap(FileUtils.toByteArray(getFileInputStream("/emptyComposition"))));
500     doReturn(uploadData).when(orchestrationTemplateDataDaoMock)
501         .getOrchestrationTemplate(anyObject(), anyObject());
502     doReturn(new ToscaServiceModel(new FileContentHandler(), new HashMap<>(),
503         "MainServiceTemplate.yaml"))
504         .when(serviceModelDaoMock).getServiceModel(VSP_ID, VERSION01);
505
506     ValidationResponse validationResponse = vendorSoftwareProductManager.submit(VSP_ID, USER1);
507     Assert.assertNotNull(validationResponse);
508     Assert.assertFalse(validationResponse.isValid());
509     Assert.assertNull(validationResponse.getVspErrors());
510     Assert.assertEquals(validationResponse.getLicensingDataErrors(), 1);
511
512     verify(versioningManagerMock, never())
513         .submit(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
514             USER1, null);
515
516     //TODO - check..
517     verify(activityLogManagerMock, never()).addActionLog(any(ActivityLogEntity.class), eq(USER1));
518   }
519
520   // TODO: 3/15/2017 fix and enable
521   //@Test
522   public void testSubmit() throws IOException {
523     mockVersioning(VersionableEntityAction.Read);
524
525     EnrichmentManagerFactory.getInstance();
526     AbstractFactoryBase
527         .registerFactory(EnrichmentManagerFactory.class, EnrichmentManagerFactoryImpl.class);
528
529     VspDetails vsp =
530         createVspDetails(VSP_ID, VERSION01, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon",
531             "category", "subCategory", "123", Collections.singletonList("fg1"));
532     doReturn(vsp).when(vspInfoDaoMock).get(anyObject());
533     UploadDataEntity uploadData = new UploadDataEntity(VSP_ID, VERSION01);
534     uploadData.setContentData(
535         ByteBuffer.wrap(FileUtils.toByteArray(getFileInputStream("/emptyComposition"))));
536     doReturn(uploadData).when(orchestrationTemplateDataDaoMock)
537         .getOrchestrationTemplate(anyObject(), anyObject());
538     doReturn(new ToscaServiceModel(new FileContentHandler(), new HashMap<>(),
539         "MainServiceTemplate.yaml"))
540         .when(serviceModelDaoMock).getServiceModel(VSP_ID, VERSION01);
541
542     ValidationResponse validationResponse = vendorSoftwareProductManager.submit(VSP_ID, USER1);
543     Assert.assertTrue(validationResponse.isValid());
544
545 /*    Assert.assertEquals(vsp2.getVersionInfo().getActiveVersion(), VERSION10);
546     Assert.assertEquals(vsp2.getVersionInfo().getStatus(), VersionStatus.Final);
547     Assert.assertNull(vsp2.getVersionInfo().getLockingUser());*/
548
549     verify(versioningManagerMock)
550         .submit(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
551             USER1, null);
552     verify(activityLogManagerMock).addActionLog(activityLogEntityArg.capture(),eq(USER1));
553     ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
554     Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION10.getMajor()));
555     Assert.assertTrue(activityLogEntity.isSuccess());
556   }
557
558   @Test(expectedExceptions = CoreException.class)
559   public void testCreatePackageOnNonFinalVersion_negative() throws IOException {
560     vendorSoftwareProductManager.createPackage(VSP_ID, VERSION01, USER1);
561   }
562
563   @Test
564   public void testCreatePackage() throws IOException {
565     /*VspDetails vspDetailsMock = new VspDetails("vspId", new Version(1, 0));
566     doReturn(vspDetailsMock).when(vspInfoDaoMock).get(anyObject());*/
567     VersionInfo versionInfo = new VersionInfo();
568     versionInfo.setActiveVersion(VERSION10);
569     doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
570         VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
571         VersionableEntityAction.Read);
572
573     doReturn(new ToscaServiceModel(new FileContentHandler(), new HashMap<>(), "")).when
574         (enrichedServiceModelDaoMock).getServiceModel(VSP_ID, VERSION10);
575
576     VspDetails vsp = new VspDetails(VSP_ID, VERSION10);
577     vsp.setVendorId("vendorId");
578     vsp.setVlmVersion(VERSION10);
579     vsp.setFeatureGroups(Arrays.asList("fg1", "fg2"));
580     doReturn(vsp).when(vspInfoDaoMock).get(any(VspDetails.class));
581
582     doReturn(new FileContentHandler()).when(licenseArtifactsServiceMock)
583         .createLicenseArtifacts(VSP_ID, vsp.getVendorId(), VERSION10, vsp.getFeatureGroups(),
584             USER1);
585
586     PackageInfo packageInfo = vendorSoftwareProductManager.createPackage(VSP_ID, VERSION10, USER1);
587     Assert.assertNotNull(packageInfo.getVspId());
588   }
589
590   // TODO: 3/15/2017 fix and enable
591   //@Test(dependsOnMethods = {"testListFinals"})
592   public void testUploadFileMissingFile() {
593     InputStream zis = getFileInputStream("/vspmanager/zips/missingYml.zip");
594
595     UploadFileResponse uploadFileResponse =
596         candidateManager.upload(VSP_ID, VERSION01, zis, USER1);
597
598     Assert.assertEquals(uploadFileResponse.getErrors().size(), 0);
599   }
600
601   // TODO: 3/15/2017 fix and enable
602   //@Test(dependsOnMethods = {"testUploadFileMissingFile"})
603   public void testUploadNotZipFile() throws IOException {
604     URL url = this.getClass().getResource("/notZipFile");
605
606     try {
607       candidateManager
608           .upload(VSP_ID, VERSION01,
609               url.openStream(), USER1);
610       candidateManager.process(VSP_ID, VERSION01, USER1);
611     } catch (Exception ce) {
612       Assert.assertEquals(ce.getMessage(), Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage());
613     }
614
615     verify(activityLogManagerMock, never()).addActionLog(any(ActivityLogEntity.class),eq(USER1));
616   }
617 /*
618   @Test
619   public void testEnrichModelInSubmit() {
620     UniqueValueUtil
621         .deleteUniqueValue(VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME,
622             "VSP_syb");
623     VspDetails vspDetails = vendorSoftwareProductManager.createVsp(
624         createVspDetails(null, null, "VSP_syb", "Test-vsp_syb", "vendorName", "vlm1Id", "icon",
625             "category", "subCategory", "456", null), USER1);
626     String id = vspDetails.getId();
627
628     //upload file
629     InputStream zis = getFileInputStream("/vspmanager/zips/fullComposition.zip");
630     candidateManager.upload(id, VERSION01, zis, USER1);
631     OrchestrationTemplateActionResponse uploadFileResponse =
632         candidateManager.process(id, VERSION01, USER1);
633
634     //check in
635     vendorSoftwareProductManager.checkin(id, USER1);
636     //submit
637     try {
638       ValidationResponse result = vendorSoftwareProductManager.submit(id, USER1);
639     } catch (IOException exception) {
640       Assert.fail();
641     }
642     VersionedVendorSoftwareProductInfo details =
643         vendorSoftwareProductManager.getVsp(id, null, USER1);
644     Collection<ComponentEntity> components =vendorSoftwareProductManager
645         .listComponents(id, details.getVersionInfo().getActiveVersion(), USER1);
646
647     ToscaServiceModel model =
648         (ToscaServiceModel) EnrichedServiceModelDaoFactory.getInstance().createInterface()
649             .getServiceModel(id, details.getVersionInfo().getActiveVersion());
650
651     Map<String, CapabilityDefinition> capabilities = new HashMap<>();
652     for (ComponentEntity component : components) {
653       model.getServiceTemplates().
654           entrySet().
655           stream().
656           filter(entryValue -> entryValue.getValue() != null &&
657               entryValue.getValue().getNode_types() != null &&
658               entryValue.getValue().
659                   getNode_types().
660                   containsKey(component.getComponentCompositionData().getName())).
661           forEach(entryValue -> entryValue.getValue().getNode_types().
662               values().
663               stream().
664               filter(type -> MapUtils.isNotEmpty(type.getCapabilities())).
665               forEach(type -> type.getCapabilities().
666                   entrySet().
667                   forEach(entry -> addCapability(entryValue.getKey(), capabilities, entry.getKey(),
668                       entry.getValue()))));
669
670     }
671
672     Assert.assertNotNull(capabilities);
673   }
674
675   @Test(dependsOnMethods = {"testCreatePackage"})
676   public void testEnrichedFilesDeletedOnNewUpload() throws IOException {
677     Version activeVersion;
678
679     createPackageFromUpload(VSP_ID, USER1, "/fullComposition");
680     activeVersion = vendorSoftwareProductManager.getVsp(VSP_ID, null, USER1).getVersionInfo()
681         .getActiveVersion();
682
683     List<ServiceArtifact> firstExternalArtifacts = enrichedServiceModelDaoMock
684         .getExternalArtifacts(VSP_ID, activeVersion);
685     ToscaServiceModel firstServiceModel = enrichedServiceModelDaoMock.getServiceModel(VSP_ID,
686         activeVersion);
687
688     createPackageFromUpload(VSP_ID, USER1, "/emptyComposition");
689     activeVersion = vendorSoftwareProductManager.getVsp(VSP_ID, null, USER1).getVersionInfo()
690         .getActiveVersion();
691
692     List<ServiceArtifact> secondExternalArtifacts = enrichedServiceModelDaoMock
693         .getExternalArtifacts(VSP_ID, activeVersion);
694     ToscaServiceModel secondServiceModel = enrichedServiceModelDaoMock.getServiceModel(VSP_ID,
695         activeVersion);
696
697     Assert.assertNotEquals(firstExternalArtifacts, secondExternalArtifacts);
698     Assert.assertNotEquals(firstServiceModel, secondServiceModel);
699
700   }
701
702   @Test(dependsOnMethods = {"testMibsDeletedInCsar"})
703   public void testServiceTemplatesAreDeletedInCsarOnNewUpload() throws IOException {
704     String nestedPath = "Definitions" + File.separator + "nested";
705
706     uploadFileAndProcess(VSP_ID, USER1, "/vspmanager/zips/fullCompositionNested.zip");
707     checkinSubmitCreatePackage(VSP_ID, USER1);
708     List<String> nestedFileNamesServiceTemplates =
709         getWantedFileNamesFromCsar(nestedPath);
710
711     uploadFileAndProcess(VSP_ID, USER1, "/vspmanager/zips/fullComposition.zip");
712     checkinSubmitCreatePackage(VSP_ID, USER1);
713     List<String> emptyNestedNamesList = getWantedFileNamesFromCsar(nestedPath);
714
715     Assert.assertEquals(emptyNestedNamesList.size(), 0);
716     Assert.assertNotEquals(emptyNestedNamesList.size(), nestedFileNamesServiceTemplates.size());
717   }*/
718
719   private List<String> getWantedFileNamesFromCsar(String pathInCsar)
720       throws IOException {
721     File translatedFile = vendorSoftwareProductManager.getTranslatedFile(VSP_ID, VERSION10, USER1);
722
723     return getFileNamesFromFolderInCsar(translatedFile,
724         pathInCsar);
725   }
726
727   private List<String> getFileNamesFromFolderInCsar(File csar, String folderName)
728       throws IOException {
729     List<String> fileNames = new ArrayList<>();
730
731     ZipInputStream zip = new ZipInputStream(new FileInputStream(csar));
732     ZipEntry ze;
733
734     while ((ze = zip.getNextEntry()) != null) {
735       String name = ze.getName();
736       if (name.contains(folderName)) {
737         fileNames.add(name);
738       }
739     }
740
741     return fileNames;
742   }
743
744   private Pair<String, String> uploadMib(String vspId, String user, String filePath,
745                                          String fileName) {
746     List<ComponentEntity> componentEntities = null;
747     //(List<ComponentEntity>) vendorSoftwareProductManager.listComponents(vspId, null, user);
748     mibManager.upload(getFileInputStream(filePath),
749         fileName, vspId,
750         VERSION01, componentEntities.get(0).getId(), ArtifactType.SNMP_POLL, user);
751     //TODO: add validate of addActionLog() func call
752
753     return new ImmutablePair<>(componentEntities.get(0).getId(),
754         componentEntities.get(0).getComponentCompositionData()
755             .getDisplayName());
756   }
757
758   private void createPackageFromUpload(String vspId, String user, String filePath)
759       throws IOException {
760     uploadFileAndProcess(vspId, user, filePath);
761     checkinSubmitCreatePackage(vspId, user);
762   }
763
764   private void uploadFileAndProcess(String vspId, String user, String filePath) {
765     vendorSoftwareProductManager.checkout(vspId, user);
766     candidateManager.upload(vspId, VERSION01, getFileInputStream(filePath), user);
767     candidateManager.process(vspId, VERSION01, user);
768   }
769
770   private void checkinSubmitCreatePackage(String vspId, String user) throws IOException {
771     vendorSoftwareProductManager.checkin(vspId, user);
772     ValidationResponse submitResponse = vendorSoftwareProductManager.submit(vspId, user);
773     Assert.assertTrue(submitResponse.isValid());
774     vendorSoftwareProductManager.createPackage(vspId, VERSION10, user);
775   }
776
777   // TODO: 3/15/2017 fix and enable
778 /*
779
780   public void testUpdatedVSPShouldBeInBeginningOfList() {
781     vendorSoftwareProductManager.updateVsp(new VspDetails(), USER3);
782     assertVSPInWantedLocationInVSPList(id006, 0, USER3);
783
784     InputStream zis = getFileInputStream("/vspmanager/zips/fullComposition.zip");
785     candidateManager.upload(id007, VERSION01, zis, USER3);
786     candidateManager.process(id007, VERSION01, USER3);
787     assertVSPInWantedLocationInVSPList(id007, 0, USER3);
788   }
789
790   @Test(dependsOnMethods = {"testUpdatedVSPShouldBeInBeginningOfList"})
791   public void testVSPInBeginningOfListAfterCheckin() {
792     vendorSoftwareProductManager.checkin(id006, USER3);
793     assertVSPInWantedLocationInVSPList(id006, 0, USER3);
794
795     vendorSoftwareProductManager.checkin(id007, USER3);
796     assertVSPInWantedLocationInVSPList(id007, 0, USER3);
797   }
798
799   @Test(dependsOnMethods = {"testVSPInBeginningOfListAfterCheckin"})
800   public void testVSPInBeginningOfListAfterCheckout() {
801     vendorSoftwareProductManager.checkout(id006, USER3);
802     assertVSPInWantedLocationInVSPList(id006, 0, USER3);
803   }
804
805   @Test(dependsOnMethods = {"testVSPInBeginningOfListAfterCheckout"})
806   public void testVSPInBeginningOfListAfterUndoCheckout() {
807     vendorSoftwareProductManager.checkout(id007, USER3);
808     assertVSPInWantedLocationInVSPList(id007, 0, USER3);
809
810     vendorSoftwareProductManager.undoCheckout(id006, USER3);
811     assertVSPInWantedLocationInVSPList(id006, 0, USER3);
812   }
813
814   @Test(dependsOnMethods = {"testVSPInBeginningOfListAfterUndoCheckout"})
815   public void testVSPInBeginningOfListAfterSubmit() throws IOException {
816     vendorSoftwareProductManager.checkin(id007, USER3);
817     vendorSoftwareProductManager.submit(id007, USER3);
818
819     assertVSPInWantedLocationInVSPList(id007, 0, USER3);
820   }
821 */
822
823   private void testLegalUpload(String vspId, Version version, InputStream upload, String user) {
824     candidateManager.upload(vspId, VERSION01, upload, USER1);
825     candidateManager.process(vspId, VERSION01, user);
826
827     UploadDataEntity uploadData =
828         orchestrationTemplateDataDaoMock.getOrchestrationTemplate(vspId, version);
829     Assert.assertNotNull(uploadData);
830   }
831
832   private void addCapability(String entryValueKey, Map<String, CapabilityDefinition> capabilities,
833                              String key, CapabilityDefinition value) {
834
835     capabilities.put(entryValueKey + "_" + key, value);
836   }
837
838   public InputStream getFileInputStream(String fileName) {
839     URL url = this.getClass().getResource(fileName);
840     try {
841       return url.openStream();
842     } catch (IOException exception) {
843       exception.printStackTrace();
844       return null;
845     }
846   }
847
848   private void assertVSPInWantedLocationInVSPList(String vspId, int location, String user) {
849     List<VersionedVendorSoftwareProductInfo> vspList =
850         vendorSoftwareProductManager.listVsps(null, user);
851     Assert.assertEquals(vspList.get(location).getVspDetails().getId(), vspId);
852   }
853
854
855   //  private void assertInfoArtifactIsInRightPathInCsar(String vspId, String zipFileName)
856 //      throws IOException {
857 //    ZipInputStream inputZipStream = new ZipInputStream(new FileInputStream(new File(zipFileName)));
858 //    boolean isInfoArtifactInZip = false;
859 //
860 //    ZipEntry zipEntry;
861 //    while ((zipEntry = inputZipStream.getNextEntry()) != null) {
862 //      String currentEntryName = zipEntry.getName();
863 //      if(currentEntryName.equals("Artifacts\\Informative\\Guide\\VSP_" +
864 //          vspId + "_Information.txt")){
865 //        isInfoArtifactInZip = true;
866 //        break;
867 //      }
868 //    }
869 //
870 //    Assert.assertTrue(isInfoArtifactInZip);
871 //  }
872   static VspDetails createVspDetails(String id, Version version, String name, String desc,
873                                      String vendorName, String vlm, String icon,
874                                      String category, String subCategory,
875                                      String licenseAgreement, List<String> featureGroups) {
876     VspDetails vspDetails = new VspDetails(id, version);
877     vspDetails.setName(name);
878     vspDetails.setDescription(desc);
879     vspDetails.setIcon(icon);
880     vspDetails.setCategory(category);
881     vspDetails.setSubCategory(subCategory);
882     vspDetails.setVendorName(vendorName);
883     vspDetails.setVendorId(vlm);
884     vspDetails.setVlmVersion(new Version(1, 0));
885     vspDetails.setLicenseAgreement(licenseAgreement);
886     vspDetails.setFeatureGroups(featureGroups);
887     return vspDetails;
888   }
889
890   static void assertVspsEquals(VspDetails actual, VspDetails expected) {
891     Assert.assertEquals(actual.getId(), expected.getId());
892     Assert.assertEquals(actual.getVersion(), expected.getVersion());
893     Assert.assertEquals(actual.getName(), expected.getName());
894     Assert.assertEquals(actual.getDescription(), expected.getDescription());
895     Assert.assertEquals(actual.getIcon(), expected.getIcon());
896     Assert.assertEquals(actual.getCategory(), expected.getCategory());
897     Assert.assertEquals(actual.getSubCategory(), expected.getSubCategory());
898     Assert.assertEquals(actual.getVendorName(), expected.getVendorName());
899     Assert.assertEquals(actual.getVendorId(), expected.getVendorId());
900     Assert.assertEquals(actual.getLicenseAgreement(), expected.getLicenseAgreement());
901     Assert.assertEquals(actual.getFeatureGroups(), expected.getFeatureGroups());
902   }
903
904
905 //    @Test
906 //    public void testDownloadFile() throws IOException {
907 //        VspDetails expectedVsp = VSPCommon.createVspDetails(null, null, String.format("VSP-test-%s", vlm1Id), "Test-vsp", "vendorName", "vlm1Id", "icon", "category", "subCategory", "123", null);
908 //        VspDetails createdVsp = vendorSoftwareProductManager.createVsp(expectedVsp, USER1);
909 //
910 //        id005 = createdVsp.getId();
911 //        Assert.assertNotNull(id005);
912 //        Assert.assertNotNull(createdVsp.getVersion());
913 //
914 //        try (InputStream zipInputStream = new ZipFileUtils().getZipInputStream("/legalUploadWithWarning")) {
915 //
916 //            UploadFileResponse uploadFileResponse = vendorSoftwareProductManager.upload(id005, zipInputStream, USER1);
917 //            vendorSoftwareProductManager.process(id005, USER1);
918 //            Optional<File> fileCandidate = vendorSoftwareProductManager.get(id005, USER1);
919 //
920 //            File latestHeatPackage = fileCandidate.get();
921 //
922 //            zipInputStream.reset();
923 //            byte[] uploaded = IOUtils.toByteArray(zipInputStream);
924 //
925 //            Optional<FileContentHandler> zipContentMap = vendorSoftwareProductManager.getZipContentMap(uploadFileResponse, uploaded);
926 //            FileContentHandler fileContentHandler = new FileContentHandler();
927 //            if(zipContentMap.isPresent()){
928 //                 fileContentHandler = zipContentMap.get();
929 //            }
930 //
931 //            uploaded = IOUtils.toByteArray(fileContentHandler.getFiles().values());
932 //
933 //            byte[] downloaded;
934 //            try (BufferedInputStream fileStream = new BufferedInputStream(new FileInputStream(latestHeatPackage))) {
935 //                downloaded = IOUtils.toByteArray(fileStream);
936 //            }
937 //
938 //            Assert.assertTrue(Arrays.equals(uploaded, downloaded));
939 //        }
940 //    }
941
942   // todo ********************** move to common **************************************
943
944   private void mockVersioning(VersionableEntityAction action) {
945     VersionInfo versionInfo = new VersionInfo();
946     versionInfo.setActiveVersion(VERSION01);
947     doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
948         VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
949         action);
950   }
951
952   private void mockVersioningEntityNotExist(VersionableEntityAction action, String vspId) {
953     doThrow(new CoreException(new EntityNotExistErrorBuilder(
954         VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, vspId).build()))
955         .when(versioningManagerMock).getEntityVersionInfo(
956         VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, vspId, USER1,
957         action);
958   }
959
960   private void MockVersioningEntityLocked(VersionableEntityAction action) {
961     doThrow(new CoreException(new EditOnEntityLockedByOtherErrorBuilder(
962         VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1)
963         .build()))
964         .when(versioningManagerMock).getEntityVersionInfo(
965         VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER2,
966         action);
967   }
968 }