1 package org.openecomp.sdc.vendorlicense.impl;
3 import org.junit.After;
4 import org.junit.Before;
7 import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
8 import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
9 import org.openecomp.sdc.vendorlicense.dao.*;
10 import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
11 import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
12 import org.openecomp.sdc.versioning.VersioningManager;
13 import org.openecomp.sdc.versioning.dao.types.Version;
15 import static org.mockito.Matchers.any;
16 import static org.mockito.Mockito.*;
20 * Created by ayalaben on 7/19/2017
22 public class VendorLicenseModelTest {
24 private static final String USER1 = "TestUser1";
25 private static final String USER2 = "TestUser2";
27 private static String vlm1_id = "vlm1_id";
28 private static String vlm2_id = "vlm2_id";
29 private static String la1_id = "la1_id";
30 private static String la2_id = "la2_id";
31 private static String fg1_id = "fg1_id";
32 private static String fg2_id = "fg2_id";
33 public static final Version VERSION01 = new Version(0, 1);
34 private static final Version VERSION10 = new Version(1, 0);
37 private VersioningManager versioningManagerMcok;
39 private VendorLicenseFacade vendorLicenseFacadeMcok;
41 private VendorLicenseModelDao vendorLicenseModelDaoMcok;
43 private LicenseAgreementDao licenseAgreementDaoMcok;
45 private FeatureGroupDao featureGroupDaoMcok;
47 private EntitlementPoolDao entitlementPoolDaoMcok;
49 private LicenseKeyGroupDao licenseKeyGroupDaoMcok;
51 private LimitDao limitDaoMcok;
55 private VendorLicenseManagerImpl vendorLicenseManager;
59 private ArgumentCaptor<ActivityLogEntity> activityLogEntityArg;
63 public void setUp() throws Exception {
64 MockitoAnnotations.initMocks(this);
68 public void tearDown(){
69 vendorLicenseManager = null;
73 public void testValidate() {
75 vendorLicenseManager.validate(vlm1_id, null);
76 verify(vendorLicenseFacadeMcok).validate(vlm1_id, null);
80 public void testCreate() {
81 VendorLicenseModelEntity vlmEntity = new VendorLicenseModelEntity(vlm1_id, VERSION01);
83 vendorLicenseManager.createVendorLicenseModel(vlmEntity);
85 verify(vendorLicenseModelDaoMcok).create(vlmEntity);
89 public void testUpdate() {
91 VendorLicenseModelEntity existingVlm = new VendorLicenseModelEntity();
92 existingVlm.setVersion(VERSION01);
93 existingVlm.setId(vlm1_id);
94 existingVlm.setIconRef("icon");
95 existingVlm.setVendorName("VLM1");
96 existingVlm.setDescription("decription");
98 doReturn("VLM1").when(vendorLicenseModelDaoMcok).get(existingVlm);
100 VendorLicenseModelEntity updatedVlm = new VendorLicenseModelEntity();
101 updatedVlm.setVersion(VERSION01);
102 updatedVlm.setId(vlm1_id);
103 updatedVlm.setIconRef("icon");
104 updatedVlm.setVendorName("VLM1_updated");
105 updatedVlm.setDescription("decription");
107 doNothing().when(vendorLicenseManager)
108 .updateUniqueName(VendorLicenseConstants.UniqueValues.VENDOR_NAME,
109 existingVlm.getVendorName(), updatedVlm.getVendorName());
111 doReturn(existingVlm).when(vendorLicenseModelDaoMcok).get(any(VendorLicenseModelEntity.class));
113 vendorLicenseManager.updateVendorLicenseModel(updatedVlm);
115 verify(vendorLicenseModelDaoMcok).update(updatedVlm);
119 public void testGetVendorLicenseModel() {
120 vendorLicenseManager.getVendorLicenseModel(vlm1_id, VERSION01);
121 verify(vendorLicenseFacadeMcok).getVendorLicenseModel(vlm1_id, VERSION01);
124 @Test(expected = UnsupportedOperationException.class)
125 public void testDeleteVLMUnsupportedOperation() {
126 vendorLicenseManager.deleteVendorLicenseModel(vlm1_id, null); // TODO: 8/13/2017
130 // @Test(expectedExceptions = CoreException.class)
131 // public void testGetNonExistingVersion_negative() {
132 // Version notExistversion = new Version(43, 8);
133 // doReturn(null).when(vspInfoDaoMock).get(any(VspDetails.class));
134 // vendorSoftwareProductManager.getVsp(VSP_ID, notExistversion);