04f7c794bcd74fcdb7e75ff21cb0d969cd021e75
[sdc.git] /
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
22 package org.openecomp.sdc.vendorlicense;
23
24 import org.mockito.InjectMocks;
25 import org.mockito.Mock;
26 import org.mockito.MockitoAnnotations;
27 import org.mockito.Spy;
28 import org.openecomp.sdc.common.errors.CoreException;
29 import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao;
30 import org.openecomp.sdc.vendorlicense.dao.LimitDao;
31 import org.openecomp.sdc.vendorlicense.dao.types.*;
32 import org.openecomp.sdc.vendorlicense.errors.VendorLicenseErrorCodes;
33 import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
34 import org.openecomp.sdc.vendorlicense.impl.VendorLicenseManagerImpl;
35 import org.openecomp.sdc.versioning.dao.types.Version;
36 import org.openecomp.sdc.versioning.errors.VersioningErrorCodes;
37 import org.openecomp.sdc.versioning.types.VersionInfo;
38 import org.testng.Assert;
39 import org.testng.annotations.BeforeMethod;
40 import org.testng.annotations.Test;
41
42 import java.lang.reflect.Field;
43 import java.lang.reflect.Modifier;
44 import java.util.ArrayList;
45 import java.time.LocalDate;
46 import java.time.format.DateTimeFormatter;
47 import java.util.Collection;
48 import java.util.Collections;
49 import java.util.HashSet;
50 import java.util.Set;
51
52 import static org.mockito.Matchers.anyObject;
53 import static org.mockito.Mockito.doReturn;
54 import static org.mockito.Mockito.verify;
55
56 public class LicenseKeyGroupTest {
57
58     //JUnit Test Cases using Mockito
59     private  final String USER = "lkgTestUser";
60     private  final String LKG_NAME = "LKG name";
61     private  final String LT_NAME = "LT name";
62     private final String LKG1_NAME = "LKG1 name";
63     private final String USER1 = "user1";
64
65     @Mock
66     private VendorLicenseFacade vendorLicenseFacade;
67
68     @Mock
69     private LicenseKeyGroupDao licenseKeyGroupDao;
70     @Mock
71     private LimitDao limitDao;
72
73     @InjectMocks
74     @Spy
75     private VendorLicenseManagerImpl vendorLicenseManagerImpl;
76
77     @BeforeMethod
78     public void setUp() throws Exception {
79         MockitoAnnotations.initMocks(this);
80     }
81
82     private LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyType type, Set<OperationalScope> operationalScopeChoices,
83                                                             String operationalScopeOther)
84     {
85         LicenseKeyGroupEntity licenseKeyGroupEntity = new LicenseKeyGroupEntity();
86         licenseKeyGroupEntity.setType(type);
87         licenseKeyGroupEntity.setOperationalScope(
88                 new MultiChoiceOrOther<>(operationalScopeChoices, operationalScopeOther));
89         return licenseKeyGroupEntity;
90     }
91
92     @Test
93     public void deleteLicenseKeyGroupTest() {
94         Set<OperationalScope> opScopeChoices;
95         opScopeChoices = new HashSet<>();
96         opScopeChoices.add(OperationalScope.Core);
97         opScopeChoices.add(OperationalScope.CPU);
98         opScopeChoices.add(OperationalScope.Network_Wide);
99
100         LicenseKeyGroupEntity licenseKeyGroup =
101                 createLicenseKeyGroup(LicenseKeyType.Unique, opScopeChoices, null);
102
103         VersionInfo info = new VersionInfo();
104         Version version = new Version();
105         info.getViewableVersions().add(version);
106         info.setActiveVersion(version);
107         doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
108
109         LimitEntity limitEntity = LimitTest.createLimitEntity(LT_NAME,LimitType.Vendor,"string",version,
110                 EntitlementMetric.Core,AggregationFunction.Average,10,EntitlementTime.Hour);
111
112         ArrayList<LimitEntity> limitEntityList = new ArrayList();
113         limitEntityList.add(limitEntity);
114
115         doReturn(licenseKeyGroup).when(licenseKeyGroupDao).get(anyObject());
116         doReturn(limitEntityList).when(vendorLicenseFacade).listLimits(anyObject(), anyObject(), anyObject(), anyObject());
117         doReturn(true).when(limitDao).isLimitPresent(anyObject());
118         doReturn(limitEntity).when(limitDao).get(anyObject());
119         try {
120             Field limitField = VendorLicenseManagerImpl.class.getDeclaredField("limitDao");
121             limitField.setAccessible(true);
122             Field modifiersField = Field.class.getDeclaredField("modifiers");
123             modifiersField.setAccessible(true);
124             modifiersField.setInt(limitField, limitField.getModifiers() & ~Modifier.FINAL);
125             limitField.set(null, limitDao);
126
127             Field lkgField = VendorLicenseManagerImpl.class.getDeclaredField("licenseKeyGroupDao");
128             lkgField.setAccessible(true);
129             modifiersField = Field.class.getDeclaredField("modifiers");
130             modifiersField.setAccessible(true);
131             modifiersField.setInt(lkgField, lkgField.getModifiers() & ~Modifier.FINAL);
132             lkgField.set(null, licenseKeyGroupDao);
133         } catch(NoSuchFieldException | IllegalAccessException e)
134         {
135             Assert.fail();
136         }
137
138         vendorLicenseManagerImpl.deleteLicenseKeyGroup(licenseKeyGroup, USER);
139
140         verify(limitDao).delete(anyObject());
141     }
142
143     @Test
144     public void deleteLicenseKeyGroupInvalidTest() {
145         try {
146             Set<OperationalScope> opScopeChoices;
147             opScopeChoices = new HashSet<>();
148             opScopeChoices.add(OperationalScope.Core);
149             opScopeChoices.add(OperationalScope.CPU);
150             opScopeChoices.add(OperationalScope.Network_Wide);
151
152             LicenseKeyGroupEntity licenseKeyGroup =
153                 createLicenseKeyGroup(LicenseKeyType.Unique, opScopeChoices, null);
154
155             VersionInfo info = new VersionInfo();
156             Version version = new Version();
157             info.getViewableVersions().add(version);
158             info.setActiveVersion(version);
159             doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
160
161             LimitEntity limitEntity = LimitTest.createLimitEntity(LT_NAME,LimitType.Vendor,"string",version,
162                 EntitlementMetric.Core,AggregationFunction.Average,10,EntitlementTime.Hour);
163
164             ArrayList<LimitEntity> limitEntityList = new ArrayList();
165             limitEntityList.add(limitEntity);
166
167             doReturn(licenseKeyGroup).when(licenseKeyGroupDao).get(anyObject());
168             doReturn(limitEntityList).when(vendorLicenseFacade).listLimits(anyObject(), anyObject(), anyObject(), anyObject());
169             doReturn(false).when(limitDao).isLimitPresent(anyObject());
170
171             try {
172                 Field limitField = VendorLicenseManagerImpl.class.getDeclaredField("limitDao");
173                 limitField.setAccessible(true);
174                 Field modifiersField = Field.class.getDeclaredField("modifiers");
175                 modifiersField.setAccessible(true);
176                 modifiersField.setInt(limitField, limitField.getModifiers() & ~Modifier.FINAL);
177                 limitField.set(null, limitDao);
178
179                 Field lkgField = VendorLicenseManagerImpl.class.getDeclaredField("licenseKeyGroupDao");
180                 lkgField.setAccessible(true);
181                 modifiersField = Field.class.getDeclaredField("modifiers");
182                 modifiersField.setAccessible(true);
183                 modifiersField.setInt(lkgField, lkgField.getModifiers() & ~Modifier.FINAL);
184                 lkgField.set(null, licenseKeyGroupDao);
185             } catch(NoSuchFieldException | IllegalAccessException e)
186             {
187                 Assert.fail();
188             }
189
190             vendorLicenseManagerImpl.deleteLicenseKeyGroup(licenseKeyGroup, USER);
191         } catch (CoreException exception) {
192             Assert.assertEquals(exception.code().id(), VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
193         }
194     }
195
196   @Test
197   public void createTest() {
198     Set<OperationalScope> opScopeChoices;
199     opScopeChoices = new HashSet<>();
200     opScopeChoices.add(OperationalScope.Core);
201     opScopeChoices.add(OperationalScope.CPU);
202     opScopeChoices.add(OperationalScope.Network_Wide);
203     LicenseKeyGroupEntity lkg =
204         createLicenseKeyGroup("vlm1Id", null, LKG1_NAME, "LKG1 dec",LicenseKeyType.Unique,
205             new MultiChoiceOrOther<>(opScopeChoices, null));
206     DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
207     lkg.setStartDate(LocalDate.now().format(formatter));
208     lkg.setExpiryDate(LocalDate.now().plusDays(1L).format(formatter));
209
210     vendorLicenseManagerImpl.createLicenseKeyGroup(lkg, USER1);
211   }
212
213   @Test
214   public void createWithInvalidStartExpiryDateTest() {
215     try {
216
217       Set<OperationalScope> opScopeChoices;
218       opScopeChoices = new HashSet<>();
219       opScopeChoices.add(OperationalScope.Core);
220       opScopeChoices.add(OperationalScope.CPU);
221       opScopeChoices.add(OperationalScope.Network_Wide);
222       LicenseKeyGroupEntity lkg =
223           createLicenseKeyGroup("vlm1Id", null, LKG1_NAME, "LKG1 dec",LicenseKeyType.Unique,
224               new MultiChoiceOrOther<>(opScopeChoices, null));
225       DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
226       lkg.setStartDate(LocalDate.now().format(formatter));
227       lkg.setExpiryDate(LocalDate.now().minusDays(2L).format(formatter));
228       vendorLicenseManagerImpl.createLicenseKeyGroup(lkg, USER1);
229       Assert.fail();
230     } catch (CoreException exception) {
231       Assert.assertEquals(exception.code().id(), VendorLicenseErrorCodes.DATE_RANGE_INVALID);
232     }
233   }
234
235   @Test
236   public void createWithoutStartDateTest() {
237     try {
238
239       Set<OperationalScope> opScopeChoices;
240       opScopeChoices = new HashSet<>();
241       opScopeChoices.add(OperationalScope.Core);
242       opScopeChoices.add(OperationalScope.CPU);
243       opScopeChoices.add(OperationalScope.Network_Wide);
244       LicenseKeyGroupEntity lkg =
245           createLicenseKeyGroup("vlm1Id", null, LKG1_NAME, "LKG1 dec",LicenseKeyType.Unique,
246               new MultiChoiceOrOther<>(opScopeChoices, null));
247       DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
248       lkg.setExpiryDate(LocalDate.now().plusDays(2L).format(formatter));
249       vendorLicenseManagerImpl.createLicenseKeyGroup(lkg, USER1).getId();
250       Assert.fail();
251     } catch (CoreException exception) {
252       Assert.assertEquals(exception.code().id(), VendorLicenseErrorCodes.DATE_RANGE_INVALID);
253     }
254   }
255
256   @Test
257   public void createWithSameStartExpiryDateTest() {
258     try {
259
260       Set<OperationalScope> opScopeChoices;
261       opScopeChoices = new HashSet<>();
262       opScopeChoices.add(OperationalScope.Core);
263       opScopeChoices.add(OperationalScope.CPU);
264       opScopeChoices.add(OperationalScope.Network_Wide);
265       LicenseKeyGroupEntity lkg =
266           createLicenseKeyGroup("vlm1Id", null, LKG1_NAME, "LKG1 dec",LicenseKeyType.Unique,
267               new MultiChoiceOrOther<>(opScopeChoices, null));
268       DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
269       lkg.setStartDate(LocalDate.now().plusDays(2L).format(formatter));
270       lkg.setExpiryDate(LocalDate.now().plusDays(2L).format(formatter));
271       vendorLicenseManagerImpl.createLicenseKeyGroup(lkg, USER1).getId();
272       Assert.fail();
273     } catch (CoreException exception) {
274       Assert.assertEquals(exception.code().id(), VendorLicenseErrorCodes.DATE_RANGE_INVALID);
275     }
276   }
277
278   @Test
279   public void createUpdate() {
280     Set<OperationalScope> opScopeChoices;
281     opScopeChoices = new HashSet<>();
282     opScopeChoices.add(OperationalScope.Core);
283     opScopeChoices.add(OperationalScope.CPU);
284     opScopeChoices.add(OperationalScope.Network_Wide);
285     LicenseKeyGroupEntity lkg =
286         createLicenseKeyGroup("vlm1Id", null, LKG1_NAME, "LKG1 dec",LicenseKeyType.Unique,
287             new MultiChoiceOrOther<>(opScopeChoices, null));
288     DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
289     lkg.setStartDate(LocalDate.now().minusDays(3L).format(formatter));
290     lkg.setExpiryDate(LocalDate.now().minusDays(2L).format(formatter));
291     VersionInfo info = new VersionInfo();
292     Version version = new Version();
293     info.getViewableVersions().add(version);
294     info.setActiveVersion(version);
295     doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
296
297     vendorLicenseManagerImpl.updateLicenseKeyGroup(lkg, USER1);
298   }
299
300   @Test
301   public void updateWithInvalidStartExpiryDateTest() {
302     try {
303
304       Set<OperationalScope> opScopeChoices;
305       opScopeChoices = new HashSet<>();
306       opScopeChoices.add(OperationalScope.Core);
307       opScopeChoices.add(OperationalScope.CPU);
308       opScopeChoices.add(OperationalScope.Network_Wide);
309       LicenseKeyGroupEntity lkg =
310           createLicenseKeyGroup("vlm1Id", null, LKG1_NAME, "LKG1 dec",LicenseKeyType.Unique,
311               new MultiChoiceOrOther<>(opScopeChoices, null));
312       DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
313       lkg.setStartDate(LocalDate.now().format(formatter));
314       lkg.setExpiryDate(LocalDate.now().minusDays(2L).format(formatter));
315       vendorLicenseManagerImpl.updateLicenseKeyGroup(lkg, USER1);
316       Assert.fail();
317     } catch (CoreException exception) {
318       Assert.assertEquals(exception.code().id(), VendorLicenseErrorCodes.DATE_RANGE_INVALID);
319     }
320   }
321
322   @Test
323   public void updateWithoutStartDateTest() {
324     try {
325
326       Set<OperationalScope> opScopeChoices;
327       opScopeChoices = new HashSet<>();
328       opScopeChoices.add(OperationalScope.Core);
329       opScopeChoices.add(OperationalScope.CPU);
330       opScopeChoices.add(OperationalScope.Network_Wide);
331       LicenseKeyGroupEntity lkg =
332           createLicenseKeyGroup("vlm1Id", null, LKG1_NAME, "LKG1 dec",LicenseKeyType.Unique,
333               new MultiChoiceOrOther<>(opScopeChoices, null));
334       DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
335       lkg.setExpiryDate(LocalDate.now().plusDays(2L).format(formatter));
336       vendorLicenseManagerImpl.updateLicenseKeyGroup(lkg, USER1);
337       Assert.fail();
338     } catch (CoreException exception) {
339       Assert.assertEquals(exception.code().id(), VendorLicenseErrorCodes.DATE_RANGE_INVALID);
340     }
341   }
342
343   @Test
344   public void updateWithSameStartExpiryDateTest() {
345     try {
346
347       Set<OperationalScope> opScopeChoices;
348       opScopeChoices = new HashSet<>();
349       opScopeChoices.add(OperationalScope.Core);
350       opScopeChoices.add(OperationalScope.CPU);
351       opScopeChoices.add(OperationalScope.Network_Wide);
352       LicenseKeyGroupEntity lkg =
353           createLicenseKeyGroup("vlm1Id", null, LKG1_NAME, "LKG1 dec",LicenseKeyType.Unique,
354               new MultiChoiceOrOther<>(opScopeChoices, null));
355       DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
356       lkg.setStartDate(LocalDate.now().format(formatter));
357       lkg.setExpiryDate(LocalDate.now().format(formatter));
358       vendorLicenseManagerImpl.updateLicenseKeyGroup(lkg, USER1);
359       Assert.fail();
360     } catch (CoreException exception) {
361       Assert.assertEquals(exception.code().id(), VendorLicenseErrorCodes.DATE_RANGE_INVALID);
362     }
363   }
364
365
366   public static LicenseKeyGroupEntity createLicenseKeyGroup(String vlmId, Version version,
367                                                             String name, String desc,
368                                                             LicenseKeyType type,
369                                                             MultiChoiceOrOther<OperationalScope> operationalScope) {
370     LicenseKeyGroupEntity licenseKeyGroup = new LicenseKeyGroupEntity();
371     licenseKeyGroup.setVendorLicenseModelId(vlmId);
372     licenseKeyGroup.setVersion(version);
373     licenseKeyGroup.setName(name);
374     licenseKeyGroup.setDescription(desc);
375     licenseKeyGroup.setType(type);
376     licenseKeyGroup.setOperationalScope(operationalScope);
377     return licenseKeyGroup;
378   }
379
380   /*public static final String LKG1_NAME = "LKG1 name";
381   private static final Version VERSION01 = new Version(0, 1);
382   public static final String LKG1_NAME = "LKG1 name";
383   private static final String USER1 = "user1";
384   public static String vlm1Id;
385   public static String vlm2Id;
386   private static VendorLicenseManager vendorLicenseManager = new VendorLicenseManagerImpl();
387   private static LicenseKeyGroupDao licenseKeyGroupDao;
388   private static NoSqlDb noSqlDb;
389   private static String lkg1Id;
390   private static String lkg2Id;
391
392   public static LicenseKeyGroupEntity createLicenseKeyGroup(String vlmId, Version version,
393                                                             String name, String desc,
394                                                             LicenseKeyType type,
395                                                             MultiChoiceOrOther<OperationalScope> operationalScope) {
396     LicenseKeyGroupEntity licenseKeyGroup = new LicenseKeyGroupEntity();
397     licenseKeyGroup.setVendorLicenseModelId(vlmId);
398     licenseKeyGroup.setVersion(version);
399     licenseKeyGroup.setName(name);
400     licenseKeyGroup.setDescription(desc);
401     licenseKeyGroup.setType(type);
402     licenseKeyGroup.setOperationalScope(operationalScope);
403     return licenseKeyGroup;
404   }
405
406   @BeforeMethod
407   public void setUp() throws Exception {
408     MockitoAnnotations.initMocks(this);
409   }
410
411   /*@BeforeClass
412   private void init() {
413     licenseKeyGroupDao = LicenseKeyGroupDaoFactory.getInstance().createInterface();
414     noSqlDb = NoSqlDbFactory.getInstance().createInterface();
415
416     vlm1Id = vendorLicenseManager.createVendorLicenseModel(VendorLicenseModelTest
417         .createVendorLicenseModel("vendor1 name " + CommonMethods.nextUuId(), "vlm1Id dec",
418             "icon1"), USER1).getId();
419     vlm2Id = vendorLicenseManager.createVendorLicenseModel(VendorLicenseModelTest
420             .createVendorLicenseModel("vendor2 name " + CommonMethods.nextUuId(), "vlm2 dec", "icon2"),
421         USER1).getId();
422   }
423
424   @Test
425   public void createTest() {
426     lkg1Id = testCreate(vlm1Id, LKG1_NAME);
427   }
428
429   private String testCreate(String vlmId, String name) {
430     Set<OperationalScope> opScopeChoices = new HashSet<>();
431     opScopeChoices.add(OperationalScope.CPU);
432     opScopeChoices.add(OperationalScope.VM);
433     opScopeChoices.add(OperationalScope.Tenant);
434     opScopeChoices.add(OperationalScope.Data_Center);
435     LicenseKeyGroupEntity
436         lkg1 = createLicenseKeyGroup(vlmId, VERSION01, name, "LKG1 dec", LicenseKeyType.One_Time,
437         new MultiChoiceOrOther<>(opScopeChoices, null));
438     String lkg1Id = vendorLicenseManager.createLicenseKeyGroup(lkg1, USER1).getId();
439     lkg1.setId(lkg1Id);
440
441     LicenseKeyGroupEntity loadedLkg1 = licenseKeyGroupDao.get(lkg1);
442     Assert.assertTrue(loadedLkg1.equals(lkg1));
443     return lkg1Id;
444   }
445
446   @Test(dependsOnMethods = {"createTest"})
447   public void testCreateWithExistingName_negative() {
448     try {
449       LicenseKeyGroupEntity lkg1 =
450           createLicenseKeyGroup(vlm1Id, VERSION01, LKG1_NAME, "LKG1 dec", LicenseKeyType.One_Time,
451               new MultiChoiceOrOther<>(Collections.singleton(OperationalScope.Other),
452                   "other op scope"));
453       vendorLicenseManager.createLicenseKeyGroup(lkg1, USER1).getId();
454       Assert.fail();
455     } catch (CoreException exception) {
456       Assert.assertEquals(exception.code().id(), UniqueValueUtil.UNIQUE_VALUE_VIOLATION);
457     }
458   }
459
460   @Test(dependsOnMethods = {"createTest"})
461   public void testCreateWithExistingNameUnderOtherVlm() {
462     testCreate(vlm2Id, LKG1_NAME);
463   }
464
465   @Test(dependsOnMethods = {"testCreateWithExistingName_negative"})
466   public void updateAndGetTest() {
467     LicenseKeyGroupEntity lkg1 =
468         licenseKeyGroupDao.get(new LicenseKeyGroupEntity(vlm1Id, VERSION01, lkg1Id));
469     Set<OperationalScope> opScopeChoices = new HashSet<>();
470     opScopeChoices.add(OperationalScope.Other);
471     lkg1.setOperationalScope(new MultiChoiceOrOther<>(opScopeChoices, "op scope1 updated"));
472     lkg1.setDescription("LKG1 dec updated");
473
474     vendorLicenseManager.updateLicenseKeyGroup(lkg1, USER1);
475
476     LicenseKeyGroupEntity loadedLkg1 = vendorLicenseManager.getLicenseKeyGroup(lkg1, USER1);
477     Assert.assertTrue(loadedLkg1.equals(lkg1));
478
479   }
480
481   @Test(dependsOnMethods = {"updateAndGetTest"})
482   public void listTest() {
483     Set<OperationalScope> opScopeChoices = new HashSet<>();
484     opScopeChoices.add(OperationalScope.Network_Wide);
485     LicenseKeyGroupEntity lkg2 =
486         createLicenseKeyGroup(vlm1Id, VERSION01, "LKG2", "LKG2 dec", LicenseKeyType.Universal,
487             new MultiChoiceOrOther<>(opScopeChoices, null));
488     lkg2Id = vendorLicenseManager.createLicenseKeyGroup(lkg2, USER1).getId();
489     lkg2.setId(lkg2Id);
490
491     Collection<LicenseKeyGroupEntity> loadedLkgs =
492         vendorLicenseManager.listLicenseKeyGroups(vlm1Id, null, USER1);
493     Assert.assertEquals(loadedLkgs.size(), 2);
494     for (LicenseKeyGroupEntity loadedLkg : loadedLkgs) {
495       if (lkg2Id.equals(loadedLkg.getId())) {
496         Assert.assertTrue(loadedLkg.equals(lkg2));
497       }
498     }
499   }
500
501   @Test(dependsOnMethods = {"listTest"})
502   public void deleteTest() {
503     vendorLicenseManager
504         .deleteLicenseKeyGroup(new LicenseKeyGroupEntity(vlm1Id, VERSION01, lkg1Id), USER1);
505
506     LicenseKeyGroupEntity loadedLkg1 =
507         licenseKeyGroupDao.get(new LicenseKeyGroupEntity(vlm1Id, VERSION01, lkg1Id));
508     Assert.assertEquals(loadedLkg1, null);
509
510     Collection<LicenseKeyGroupEntity> loadedLkgs =
511         licenseKeyGroupDao.list(new LicenseKeyGroupEntity(vlm1Id, VERSION01, null));
512     Assert.assertEquals(loadedLkgs.size(), 1);
513     Assert.assertEquals(loadedLkgs.iterator().next().getId(), lkg2Id);
514   }
515
516   @Test(dependsOnMethods = "deleteTest")
517   public void testCreateWithRemovedName() {
518     testCreate(vlm1Id, LKG1_NAME);
519   }
520   */
521 }