summaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/ArtifactTestUtils.java35
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/LimitTest.java117
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/VendorLicenseFacadeImplTest.java34
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/EntitlementPoolTest.java597
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/FeatureGroupTest.java499
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseAgreementTest.java101
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseKeyGroupTest.java161
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseModelTest.java221
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceTest.java14
9 files changed, 694 insertions, 1085 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/ArtifactTestUtils.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/ArtifactTestUtils.java
index 5d9729de53..c005e9696f 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/ArtifactTestUtils.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/ArtifactTestUtils.java
@@ -20,41 +20,6 @@
package org.openecomp.sdc.vendorlicense;
-import org.openecomp.core.utilities.CommonMethods;
-import org.openecomp.sdc.vendorlicense.dao.types.AggregationFunction;
-import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther;
-import org.openecomp.sdc.vendorlicense.dao.types.EntitlementMetric;
-import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.EntitlementTime;
-import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyType;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseTerm;
-import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther;
-import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope;
-import org.openecomp.sdc.vendorlicense.dao.types.ThresholdUnit;
-import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
-import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory;
-import org.openecomp.sdc.vendorlicense.impl.VendorLicenseManagerImpl;
-import org.openecomp.sdc.vendorlicense.licenseartifacts.VendorLicenseArtifactsService;
-import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
-import org.openecomp.sdc.vendorsoftwareproduct.impl.VendorSoftwareProductManagerImpl;
-import org.openecomp.sdc.versioning.VersioningManager;
-import org.openecomp.sdc.versioning.VersioningManagerFactory;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
-import org.testng.annotations.BeforeMethod;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE;
-
/**
* Created by Katyr on 29-May-16
*/
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/LimitTest.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/LimitTest.java
index 07fdeeeee8..0197dd9d28 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/LimitTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/LimitTest.java
@@ -20,17 +20,11 @@
package org.openecomp.sdc.vendorlicense;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.verify;
-
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.vendorlicense.dao.LimitDao;
import org.openecomp.sdc.vendorlicense.dao.types.AggregationFunction;
import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity;
@@ -45,19 +39,19 @@ import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
-public class LimitTest {
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
- private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
+public class LimitTest {
- private final String USER1 = "limitTestUser1";
- private final String LT1_NAME = "LT1 name";
+ private final String USER1 = "limitTestUser1";
+ private final String LT1_NAME = "LT1 name";
private static final String VLM_ID = "VLM_ID";
private static final Version VERSION = new Version(0, 1);
@@ -76,8 +70,8 @@ public class LimitTest {
private VendorLicenseManagerImpl vendorLicenseManagerImpl;
public static LimitEntity createLimitEntity(String name, LimitType type, String description,
- Version version, String metric,
- AggregationFunction aggregationFunction, int unit,
+ Version version, String metric,
+ AggregationFunction aggregationFunction, int unit,
String time) {
LimitEntity limitEntity = new LimitEntity();
limitEntity.setName(name);
@@ -92,22 +86,22 @@ public class LimitTest {
}
@BeforeMethod
- public void setUp() {
+ public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
}
@Test
public void testUpdateLimit() {
Version version = new Version();
- LimitEntity limitEntity1 = createLimitEntity(LT1_NAME,LimitType.Vendor,"string",version,
- "Core",AggregationFunction.Average,10,"Hour");
- LimitEntity limitEntity2 = createLimitEntity(LT1_NAME,LimitType.Vendor,"string",version,
- "Tokens",AggregationFunction.Peak,12,"Month");
+ LimitEntity limitEntity1 = createLimitEntity(LT1_NAME, LimitType.Vendor, "string", version,
+ "Core", AggregationFunction.Average, 10, "Hour");
+ LimitEntity limitEntity2 = createLimitEntity(LT1_NAME, LimitType.Vendor, "string", version,
+ "Tokens", AggregationFunction.Peak, 12, "Month");
VersionInfo info = new VersionInfo();
info.getViewableVersions().add(version);
info.setActiveVersion(version);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
+ /*doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(), anyObject(), anyObject());*/
doReturn(true).when(limitDao).isLimitPresent(anyObject());
doReturn(limitEntity1).when(limitDao).get(anyObject());
@@ -116,27 +110,28 @@ public class LimitTest {
limitEntityList.add(limitEntity2);
limitEntity1.setId("1234");
limitEntity2.setId("1234");
- doReturn(limitEntityList).when(vendorLicenseFacade).listLimits(anyObject(),anyObject(),
- anyObject(),anyObject());
+ doReturn(limitEntityList).when(vendorLicenseFacade)
+ .listLimits(anyObject(), anyObject(), anyObject());
- vendorLicenseManagerImpl.updateLimit(limitEntity2,USER1);
+ vendorLicenseManagerImpl.updateLimit(limitEntity2);
- verify(vendorLicenseFacade).updateLimit(anyObject(), anyObject());
+ verify(vendorLicenseFacade).updateLimit(anyObject());
}
@Test
public void testUpdateLimitErrorWithSameNameType() {
try {
Version version = new Version();
- LimitEntity limitEntity1 = createLimitEntity(LT1_NAME,LimitType.Vendor,"string",version,
- "Core",AggregationFunction.Average,10,"Hour");
- LimitEntity limitEntity2 = createLimitEntity(LT1_NAME,LimitType.Vendor,"string",version,
- "Tokens",AggregationFunction.Peak,12,"Month");
+ LimitEntity limitEntity1 = createLimitEntity(LT1_NAME, LimitType.Vendor, "string", version,
+ "Core", AggregationFunction.Average, 10, "Hour");
+ LimitEntity limitEntity2 = createLimitEntity(LT1_NAME, LimitType.Vendor, "string", version,
+ "Tokens", AggregationFunction.Peak, 12, "Month");
VersionInfo info = new VersionInfo();
info.getViewableVersions().add(version);
info.setActiveVersion(version);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
+/* doReturn(info).when(vendorLicenseFacade)
+ .getVersionInfo(anyObject(), anyObject(), anyObject());*/
doReturn(limitEntity1).when(limitDao).get(anyObject());
List<LimitEntity> limitEntityList = new ArrayList<>();
@@ -144,13 +139,12 @@ public class LimitTest {
limitEntityList.add(limitEntity2);
limitEntity1.setId("1234");
limitEntity2.setId("9632");
- doReturn(limitEntityList).when(vendorLicenseFacade).listLimits(anyObject(),anyObject(),
- anyObject(),anyObject());
+ doReturn(limitEntityList).when(vendorLicenseFacade)
+ .listLimits(anyObject(), anyObject(), anyObject());
- vendorLicenseManagerImpl.updateLimit(limitEntity2,USER1);
+ vendorLicenseManagerImpl.updateLimit(limitEntity2);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(),
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@@ -159,13 +153,13 @@ public class LimitTest {
@Test
public void testDeleteLimit() {
Version version = new Version();
- LimitEntity limitEntity = createLimitEntity(LT1_NAME,LimitType.Vendor,"string",version,
- "Core",AggregationFunction.Average,10,"Hour");
+ LimitEntity limitEntity = createLimitEntity(LT1_NAME, LimitType.Vendor, "string", version,
+ "Core", AggregationFunction.Average, 10, "Hour");
VersionInfo info = new VersionInfo();
info.getViewableVersions().add(version);
info.setActiveVersion(version);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
+ /*doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(), anyObject(), anyObject());*/
doReturn(true).when(limitDao).isLimitPresent(anyObject());
doReturn(limitEntity).when(limitDao).get(anyObject());
@@ -173,27 +167,28 @@ public class LimitTest {
limitEntityList.add(limitEntity);
limitEntity.setId("1234");
- vendorLicenseManagerImpl.deleteLimit(limitEntity,LT1_NAME);
+ vendorLicenseManagerImpl.deleteLimit(limitEntity);
- verify(vendorLicenseManagerImpl).deleteLimit(anyObject(), anyObject());
+ verify(vendorLicenseManagerImpl).deleteLimit(anyObject());
}
@Test
public void testUpdateLimitErrorWithInvalidId() {
try {
Version version = new Version();
- LimitEntity limitEntity1 = createLimitEntity(LT1_NAME,LimitType.Vendor,"string",version,
- "Core",AggregationFunction.Average,10,"Hour");
- LimitEntity limitEntity2 = createLimitEntity(LT1_NAME,LimitType.Vendor,"string",version,
- "Tokens",AggregationFunction.Peak,12,"Month");
+ LimitEntity limitEntity1 = createLimitEntity(LT1_NAME, LimitType.Vendor, "string", version,
+ "Core", AggregationFunction.Average, 10, "Hour");
+ LimitEntity limitEntity2 = createLimitEntity(LT1_NAME, LimitType.Vendor, "string", version,
+ "Tokens", AggregationFunction.Peak, 12, "Month");
VersionInfo info = new VersionInfo();
info.getViewableVersions().add(version);
info.setActiveVersion(version);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
+/* doReturn(info).when(vendorLicenseFacade)
+ .getVersionInfo(anyObject(), anyObject(), anyObject());*/
doReturn(null).when(limitDao).get(anyObject());
- vendorLicenseManagerImpl.updateLimit(limitEntity2,USER1);
+ vendorLicenseManagerImpl.updateLimit(limitEntity2);
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(),
@@ -206,14 +201,14 @@ public class LimitTest {
doReturn(Arrays.asList(
createLimit(VLM_ID, VERSION, EPLKG_ID, LIMIT1_ID),
createLimit(VLM_ID, VERSION, EPLKG_ID, LIMIT2_ID)))
- .when(vendorLicenseFacade).listLimits(VLM_ID, VERSION, EPLKG_ID, USER1);
+ .when(vendorLicenseFacade).listLimits(VLM_ID, VERSION, EPLKG_ID);
final Collection<LimitEntity> limits =
- vendorLicenseManagerImpl.listLimits(VLM_ID, VERSION, EPLKG_ID, USER1);
+ vendorLicenseManagerImpl.listLimits(VLM_ID, VERSION, EPLKG_ID);
Assert.assertEquals(limits.size(), 2);
for (LimitEntity limit : limits) {
Assert.assertEquals(limit.getName(),
- LIMIT1_ID.equals(limit.getId()) ? LIMIT1_ID+" name" : LIMIT2_ID+" name" );
+ LIMIT1_ID.equals(limit.getId()) ? LIMIT1_ID + " name" : LIMIT2_ID + " name");
}
}
@@ -224,10 +219,10 @@ public class LimitTest {
info.getViewableVersions().add(VERSION);
info.setActiveVersion(VERSION);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
+ /*doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(), anyObject(), anyObject());*/
- vendorLicenseManagerImpl.createLimit(expected, USER1);
- verify(vendorLicenseFacade).createLimit(expected,USER1);
+ vendorLicenseManagerImpl.createLimit(expected);
+ verify(vendorLicenseFacade).createLimit(expected);
}
@Test
@@ -241,20 +236,19 @@ public class LimitTest {
List<LimitEntity> vfcImageList = new ArrayList<LimitEntity>();
vfcImageList.add(expectedDiffName);
- doReturn(vfcImageList).when(vendorLicenseFacade).listLimits(anyObject(), anyObject(), anyObject(),
- anyObject());
+ doReturn(vfcImageList).when(vendorLicenseFacade)
+ .listLimits(anyObject(), anyObject(), anyObject());
VersionInfo info = new VersionInfo();
info.getViewableVersions().add(VERSION);
info.setActiveVersion(VERSION);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
+/* doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(), anyObject(), anyObject());*/
try {
- vendorLicenseManagerImpl.createLimit(expected, USER1);
+ vendorLicenseManagerImpl.createLimit(expected);
Assert.fail();
- }
- catch (CoreException ex) {
+ } catch (CoreException ex) {
Assert.assertEquals(ex.code().id(),
VendorLicenseErrorCodes.DUPLICATE_LIMIT_NAME_NOT_ALLOWED);
}
@@ -267,13 +261,14 @@ public class LimitTest {
info.getViewableVersions().add(VERSION);
info.setActiveVersion(VERSION);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
+ /*doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(), anyObject(), anyObject());*/
try {
- vendorLicenseManagerImpl.getLimit(limit , USER1);
+ vendorLicenseManagerImpl.getLimit(limit);
Assert.fail();
} catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(), VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ Assert.assertEquals(exception.code().id(),
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
}
@@ -293,10 +288,10 @@ public class LimitTest {
info.getViewableVersions().add(VERSION);
info.setActiveVersion(VERSION);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
+ /*doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(), anyObject(), anyObject());*/
LimitEntity actual = createLimit(VLM_ID, VERSION, EPLKG_ID, LIMIT1_ID);
- vendorLicenseManagerImpl.getLimit(actual, USER1);
+ vendorLicenseManagerImpl.getLimit(actual);
Assert.assertEquals(actual.getId(), expected.getId());
Assert.assertEquals(actual.getName(), expected.getName());
Assert.assertEquals(actual.getUnit(), expected.getUnit());
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/VendorLicenseFacadeImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/VendorLicenseFacadeImplTest.java
index ab6262d8ca..e3719ab515 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/VendorLicenseFacadeImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/VendorLicenseFacadeImplTest.java
@@ -1,39 +1,5 @@
package org.openecomp.sdc.vendorlicense;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.mockito.Spy;
-import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
-import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDao;
-import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDao;
-import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao;
-import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDao;
-import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
-import org.openecomp.sdc.vendorlicense.facade.impl.VendorLicenseFacadeImpl;
-import org.openecomp.sdc.versioning.VersioningManager;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.doReturn;
-import static org.openecomp.sdc.vendorlicense.errors.UncompletedVendorLicenseModelErrorType.SUBMIT_UNCOMPLETED_VLM_MSG_FG_MISSING_EP;
-import static org.openecomp.sdc.vendorlicense.errors.UncompletedVendorLicenseModelErrorType.SUBMIT_UNCOMPLETED_VLM_MSG_LA_MISSING_FG;
-
/**
* This test just verifies Feature Group Get and List APIs.
*/
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/EntitlementPoolTest.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/EntitlementPoolTest.java
index 178d05e6c8..57d22544ad 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/EntitlementPoolTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/EntitlementPoolTest.java
@@ -28,12 +28,16 @@ import org.mockito.Spy;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
import org.openecomp.sdc.vendorlicense.dao.LimitDao;
-import org.openecomp.sdc.vendorlicense.dao.types.*;
+import org.openecomp.sdc.vendorlicense.dao.types.AggregationFunction;
+import org.openecomp.sdc.vendorlicense.dao.types.EntitlementMetric;
+import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.EntitlementTime;
+import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther;
+import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope;
+import org.openecomp.sdc.vendorlicense.dao.types.ThresholdUnit;
import org.openecomp.sdc.vendorlicense.errors.VendorLicenseErrorCodes;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -41,7 +45,6 @@ import org.testng.annotations.Test;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
@@ -54,353 +57,323 @@ import static org.mockito.Mockito.verify;
public class EntitlementPoolTest {
- //JUnit Test Cases using Mockito
- private final String USER1 = "epTestUser1";
- private final String EP1_NAME = "EP1 name";
- private final String EP2_NAME = "EP2 name";
- private final String LT1_NAME = "LT1 name";
- private static String vlm1_id = "vlm1_id";
- private static String ep1_id = "ep1_id";
- private static String ep2_id = "ep2_id";
- public static final Version VERSION01 = new Version(0, 1);
-
- @Mock
- private VendorLicenseFacade vendorLicenseFacade;
-
- @Mock
- private EntitlementPoolDao entitlementPoolDao;
- @Mock
- private LimitDao limitDao;
-
- @InjectMocks
- @Spy
- private VendorLicenseManagerImpl vendorLicenseManagerImpl;
-
- public EntitlementPoolEntity createEntitlementPool(String vlmId, Version version,String id,
- String name, String desc, int threshold,
- ThresholdUnit thresholdUnit,
- EntitlementMetric entitlementMetricChoice,
- String entitlementMetricOther,
- String increments,
- AggregationFunction aggregationFunctionChoice,
- String aggregationFunctionOther,
- Set<OperationalScope> operationalScopeChoices,
- String operationalScopeOther,
- EntitlementTime timeChoice,
- String timeOther, String sku) {
- EntitlementPoolEntity entitlementPool = new EntitlementPoolEntity();
- entitlementPool.setVendorLicenseModelId(vlmId);
- entitlementPool.setId(id);
- entitlementPool.setVersion(version);
- entitlementPool.setName(name);
- entitlementPool.setDescription(desc);
- entitlementPool.setThresholdValue(threshold);
- entitlementPool.setThresholdUnit(thresholdUnit);
- entitlementPool.setIncrements(increments);
- entitlementPool.setOperationalScope(
- new MultiChoiceOrOther<>(operationalScopeChoices, operationalScopeOther));
- return entitlementPool;
- }
-
- @BeforeMethod
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- }
+ //JUnit Test Cases using Mockito
+ private final String USER1 = "epTestUser1";
+ private final String EP1_NAME = "EP1 name";
+ private final String EP2_NAME = "EP2 name";
+ private final String LT1_NAME = "LT1 name";
+ private static String vlm1_id = "vlm1_id";
+ private static String ep1_id = "ep1_id";
+ private static String ep2_id = "ep2_id";
+ public static final Version VERSION01 = new Version(0, 1);
+
+ @Mock
+ private VendorLicenseFacade vendorLicenseFacade;
+
+ @Mock
+ private EntitlementPoolDao entitlementPoolDao;
+ @Mock
+ private LimitDao limitDao;
+
+ @InjectMocks
+ @Spy
+ private VendorLicenseManagerImpl vendorLicenseManagerImpl;
+
+ public EntitlementPoolEntity createEntitlementPool(String vlmId, Version version, String id,
+ String name, String desc, int threshold,
+ ThresholdUnit thresholdUnit,
+ EntitlementMetric entitlementMetricChoice,
+ String entitlementMetricOther,
+ String increments,
+ AggregationFunction aggregationFunctionChoice,
+ String aggregationFunctionOther,
+ Set<OperationalScope> operationalScopeChoices,
+ String operationalScopeOther,
+ EntitlementTime timeChoice,
+ String timeOther, String sku) {
+ EntitlementPoolEntity entitlementPool = new EntitlementPoolEntity();
+ entitlementPool.setVendorLicenseModelId(vlmId);
+ entitlementPool.setId(id);
+ entitlementPool.setVersion(version);
+ entitlementPool.setName(name);
+ entitlementPool.setDescription(desc);
+ entitlementPool.setThresholdValue(threshold);
+ entitlementPool.setThresholdUnit(thresholdUnit);
+ entitlementPool.setIncrements(increments);
+ entitlementPool.setOperationalScope(
+ new MultiChoiceOrOther<>(operationalScopeChoices, operationalScopeOther));
+ return entitlementPool;
+ }
- @Test
- public void createTest() {
- Set<OperationalScope> opScopeChoices;
- opScopeChoices = new HashSet<>();
- opScopeChoices.add(OperationalScope.Core);
- opScopeChoices.add(OperationalScope.CPU);
- opScopeChoices.add(OperationalScope.Network_Wide);
- EntitlementPoolEntity ep2 =
- createEntitlementPool("vlm1Id", null, ep1_id,EP1_NAME, "EP2 dec", 70, ThresholdUnit
- .Absolute,
- EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
- opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
- ep2.setStartDate(LocalDate.now().format(formatter));
- ep2.setExpiryDate(LocalDate.now().plusDays(1L).format(formatter));
+ @BeforeMethod
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
- vendorLicenseManagerImpl.createEntitlementPool(ep2, USER1);
- verify(vendorLicenseFacade).createEntitlementPool(ep2,USER1);
+ @Test
+ public void createTest() {
+ Set<OperationalScope> opScopeChoices;
+ opScopeChoices = new HashSet<>();
+ opScopeChoices.add(OperationalScope.Core);
+ opScopeChoices.add(OperationalScope.CPU);
+ opScopeChoices.add(OperationalScope.Network_Wide);
+ EntitlementPoolEntity ep2 =
+ createEntitlementPool("vlm1Id", null, ep1_id, EP1_NAME, "EP2 dec", 70, ThresholdUnit
+ .Absolute,
+ EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
+ opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
+ ep2.setStartDate(LocalDate.now().format(formatter));
+ ep2.setExpiryDate(LocalDate.now().plusDays(1L).format(formatter));
- }
+ vendorLicenseManagerImpl.createEntitlementPool(ep2);
+ verify(vendorLicenseFacade).createEntitlementPool(ep2);
- @Test(expectedExceptions = CoreException.class, expectedExceptionsMessageRegExp = "Vendor " +
- "license model with id vlm1_id has invalid date range.")
- public void createWithInvalidStartExpiryDateTest() {
+ }
- Set<OperationalScope> opScopeChoices;
- opScopeChoices = new HashSet<>();
- opScopeChoices.add(OperationalScope.Core);
- opScopeChoices.add(OperationalScope.CPU);
- opScopeChoices.add(OperationalScope.Network_Wide);
- EntitlementPoolEntity ep2 =
- createEntitlementPool("vlm2Id", null, ep1_id,EP1_NAME, "EP2 dec", 70,
- ThresholdUnit.Absolute,
- EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
- opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
- ep2.setStartDate(LocalDate.now().format(formatter));
- ep2.setExpiryDate(LocalDate.now().minusDays(2L).format(formatter));
- ep2.setVendorLicenseModelId(vlm1_id);
- vendorLicenseManagerImpl.createEntitlementPool(ep2, USER1).getId();
- Assert.fail();
+ @Test(expectedExceptions = CoreException.class, expectedExceptionsMessageRegExp = "Vendor " +
+ "license model with id vlm1_id has invalid date range.")
+ public void createWithInvalidStartExpiryDateTest() {
- }
+ Set<OperationalScope> opScopeChoices;
+ opScopeChoices = new HashSet<>();
+ opScopeChoices.add(OperationalScope.Core);
+ opScopeChoices.add(OperationalScope.CPU);
+ opScopeChoices.add(OperationalScope.Network_Wide);
+ EntitlementPoolEntity ep2 =
+ createEntitlementPool("vlm2Id", null, ep1_id, EP1_NAME, "EP2 dec", 70,
+ ThresholdUnit.Absolute,
+ EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
+ opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
+ ep2.setStartDate(LocalDate.now().format(formatter));
+ ep2.setExpiryDate(LocalDate.now().minusDays(2L).format(formatter));
+ ep2.setVendorLicenseModelId(vlm1_id);
+ vendorLicenseManagerImpl.createEntitlementPool(ep2).getId();
+ Assert.fail();
- @Test(expectedExceptions = CoreException.class, expectedExceptionsMessageRegExp = "Vendor " +
- "license model with id vlm1_id has invalid date range.")
- public void createWithoutStartDateTest() {
+ }
- Set<OperationalScope> opScopeChoices;
- opScopeChoices = new HashSet<>();
- opScopeChoices.add(OperationalScope.Core);
- opScopeChoices.add(OperationalScope.CPU);
- opScopeChoices.add(OperationalScope.Network_Wide);
- EntitlementPoolEntity ep2 =
- createEntitlementPool("vlm3Id", null, ep1_id,EP1_NAME, "EP2 dec", 70,
- ThresholdUnit.Absolute,
- EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
- opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
- ep2.setExpiryDate(LocalDate.now().plusDays(2L).format(formatter));
- ep2.setVendorLicenseModelId(vlm1_id);
- vendorLicenseManagerImpl.createEntitlementPool(ep2, USER1).getId();
- Assert.fail();
+ @Test(expectedExceptions = CoreException.class, expectedExceptionsMessageRegExp = "Vendor " +
+ "license model with id vlm1_id has invalid date range.")
+ public void createWithoutStartDateTest() {
- }
+ Set<OperationalScope> opScopeChoices;
+ opScopeChoices = new HashSet<>();
+ opScopeChoices.add(OperationalScope.Core);
+ opScopeChoices.add(OperationalScope.CPU);
+ opScopeChoices.add(OperationalScope.Network_Wide);
+ EntitlementPoolEntity ep2 =
+ createEntitlementPool("vlm3Id", null, ep1_id, EP1_NAME, "EP2 dec", 70,
+ ThresholdUnit.Absolute,
+ EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
+ opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
+ ep2.setExpiryDate(LocalDate.now().plusDays(2L).format(formatter));
+ ep2.setVendorLicenseModelId(vlm1_id);
+ vendorLicenseManagerImpl.createEntitlementPool(ep2).getId();
+ Assert.fail();
- @Test(expectedExceptions = CoreException.class, expectedExceptionsMessageRegExp = "Vendor " +
- "license model with id vlm1_id has invalid date range.")
- public void createWithSameStartExpiryDateTest() {
+ }
- Set<OperationalScope> opScopeChoices;
- opScopeChoices = new HashSet<>();
- opScopeChoices.add(OperationalScope.Core);
- opScopeChoices.add(OperationalScope.CPU);
- opScopeChoices.add(OperationalScope.Network_Wide);
- EntitlementPoolEntity ep2 =
- createEntitlementPool("vlm4Id", null, ep1_id,EP1_NAME, "EP2 dec", 70,
- ThresholdUnit.Absolute,
- EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
- opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
- ep2.setStartDate(LocalDate.now().format(formatter));
- ep2.setExpiryDate(LocalDate.now().format(formatter));
- ep2.setVendorLicenseModelId(vlm1_id);
- vendorLicenseManagerImpl.createEntitlementPool(ep2, USER1).getId();
- Assert.fail();
- }
+ @Test(expectedExceptions = CoreException.class, expectedExceptionsMessageRegExp = "Vendor " +
+ "license model with id vlm1_id has invalid date range.")
+ public void createWithSameStartExpiryDateTest() {
- @Test
- public void testUpdate() {
- Set<OperationalScope> opScopeChoices;
- opScopeChoices = new HashSet<>();
- opScopeChoices.add(OperationalScope.Core);
- opScopeChoices.add(OperationalScope.CPU);
- opScopeChoices.add(OperationalScope.Network_Wide);
- EntitlementPoolEntity ep2 =
- createEntitlementPool(vlm1_id, VERSION01, ep1_id,EP1_NAME, "EP2 dec", 70,
- ThresholdUnit
- .Absolute,
- EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
- opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
- ep2.setStartDate(LocalDate.now().minusDays(3L).format(formatter));
- ep2.setExpiryDate(LocalDate.now().minusDays(2L).format(formatter));
+ Set<OperationalScope> opScopeChoices;
+ opScopeChoices = new HashSet<>();
+ opScopeChoices.add(OperationalScope.Core);
+ opScopeChoices.add(OperationalScope.CPU);
+ opScopeChoices.add(OperationalScope.Network_Wide);
+ EntitlementPoolEntity ep2 =
+ createEntitlementPool("vlm4Id", null, ep1_id, EP1_NAME, "EP2 dec", 70,
+ ThresholdUnit.Absolute,
+ EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
+ opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
+ ep2.setStartDate(LocalDate.now().format(formatter));
+ ep2.setExpiryDate(LocalDate.now().format(formatter));
+ ep2.setVendorLicenseModelId(vlm1_id);
+ vendorLicenseManagerImpl.createEntitlementPool(ep2).getId();
+ Assert.fail();
+ }
- VersionInfo info = new VersionInfo();
- info.getViewableVersions().add(VERSION01);
- info.setActiveVersion(VERSION01);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
+ @Test
+ public void testUpdate() {
+ Set<OperationalScope> opScopeChoices;
+ opScopeChoices = new HashSet<>();
+ opScopeChoices.add(OperationalScope.Core);
+ opScopeChoices.add(OperationalScope.CPU);
+ opScopeChoices.add(OperationalScope.Network_Wide);
+ EntitlementPoolEntity ep2 =
+ createEntitlementPool(vlm1_id, VERSION01, ep1_id, EP1_NAME, "EP2 dec", 70,
+ ThresholdUnit
+ .Absolute,
+ EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
+ opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
+ ep2.setStartDate(LocalDate.now().minusDays(3L).format(formatter));
+ ep2.setExpiryDate(LocalDate.now().minusDays(2L).format(formatter));
- vendorLicenseManagerImpl.updateEntitlementPool(ep2, USER1);
- verify(vendorLicenseFacade).updateEntitlementPool(ep2,USER1);
- verify(vendorLicenseFacade).updateVlmLastModificationTime(vlm1_id,VERSION01);
- }
+ vendorLicenseManagerImpl.updateEntitlementPool(ep2);
+ }
- @Test(expectedExceptions = CoreException.class, expectedExceptionsMessageRegExp = "Vendor " +
- "license model with id vlm1_id has invalid date range.")
- public void updateWithInvalidStartExpiryDateTest() {
+ @Test(expectedExceptions = CoreException.class, expectedExceptionsMessageRegExp = "Vendor " +
+ "license model with id vlm1_id has invalid date range.")
+ public void updateWithInvalidStartExpiryDateTest() {
- Set<OperationalScope> opScopeChoices;
- opScopeChoices = new HashSet<>();
- opScopeChoices.add(OperationalScope.Core);
- opScopeChoices.add(OperationalScope.CPU);
- opScopeChoices.add(OperationalScope.Network_Wide);
- EntitlementPoolEntity ep2 =
- createEntitlementPool("vlm2Id", null, ep1_id,EP1_NAME, "EP2 dec", 70,
- ThresholdUnit.Absolute,
- EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
- opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
- ep2.setStartDate(LocalDate.now().format(formatter));
- ep2.setExpiryDate(LocalDate.now().minusDays(2L).format(formatter));
- ep2.setVendorLicenseModelId(vlm1_id);
- vendorLicenseManagerImpl.updateEntitlementPool(ep2, USER1);
- Assert.fail();
+ Set<OperationalScope> opScopeChoices;
+ opScopeChoices = new HashSet<>();
+ opScopeChoices.add(OperationalScope.Core);
+ opScopeChoices.add(OperationalScope.CPU);
+ opScopeChoices.add(OperationalScope.Network_Wide);
+ EntitlementPoolEntity ep2 =
+ createEntitlementPool("vlm2Id", null, ep1_id, EP1_NAME, "EP2 dec", 70,
+ ThresholdUnit.Absolute,
+ EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
+ opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
+ ep2.setStartDate(LocalDate.now().format(formatter));
+ ep2.setExpiryDate(LocalDate.now().minusDays(2L).format(formatter));
+ ep2.setVendorLicenseModelId(vlm1_id);
+ vendorLicenseManagerImpl.updateEntitlementPool(ep2);
+ Assert.fail();
- }
+ }
- @Test
- public void updateWithoutStartDateTest() {
- try {
+ @Test
+ public void updateWithoutStartDateTest() {
+ try {
- Set<OperationalScope> opScopeChoices;
- opScopeChoices = new HashSet<>();
- opScopeChoices.add(OperationalScope.Core);
- opScopeChoices.add(OperationalScope.CPU);
- opScopeChoices.add(OperationalScope.Network_Wide);
- EntitlementPoolEntity ep2 =
- createEntitlementPool("vlm3Id", null, ep1_id,EP1_NAME, "EP2 dec", 70,
- ThresholdUnit.Absolute,
- EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
- opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
- ep2.setExpiryDate(LocalDate.now().plusDays(2L).format(formatter));
- vendorLicenseManagerImpl.updateEntitlementPool(ep2, USER1);
- Assert.fail();
- } catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(), VendorLicenseErrorCodes.DATE_RANGE_INVALID);
- }
+ Set<OperationalScope> opScopeChoices;
+ opScopeChoices = new HashSet<>();
+ opScopeChoices.add(OperationalScope.Core);
+ opScopeChoices.add(OperationalScope.CPU);
+ opScopeChoices.add(OperationalScope.Network_Wide);
+ EntitlementPoolEntity ep2 =
+ createEntitlementPool("vlm3Id", null, ep1_id, EP1_NAME, "EP2 dec", 70,
+ ThresholdUnit.Absolute,
+ EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average,
+ null,
+ opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
+ ep2.setExpiryDate(LocalDate.now().plusDays(2L).format(formatter));
+ vendorLicenseManagerImpl.updateEntitlementPool(ep2);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), VendorLicenseErrorCodes.DATE_RANGE_INVALID);
}
+ }
- @Test
- public void updateWithSameStartExpiryDateTest() {
- try {
+ @Test
+ public void updateWithSameStartExpiryDateTest() {
+ try {
- Set<OperationalScope> opScopeChoices;
- opScopeChoices = new HashSet<>();
- opScopeChoices.add(OperationalScope.Core);
- opScopeChoices.add(OperationalScope.CPU);
- opScopeChoices.add(OperationalScope.Network_Wide);
- EntitlementPoolEntity ep2 =
- createEntitlementPool("vlm4Id", null, ep1_id,EP1_NAME, "EP2 dec", 70,
- ThresholdUnit.Absolute,
- EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average, null,
- opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
- ep2.setStartDate(LocalDate.now().format(formatter));
- ep2.setExpiryDate(LocalDate.now().format(formatter));
- vendorLicenseManagerImpl.updateEntitlementPool(ep2, USER1);
- Assert.fail();
- } catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(), VendorLicenseErrorCodes.DATE_RANGE_INVALID);
- }
+ Set<OperationalScope> opScopeChoices;
+ opScopeChoices = new HashSet<>();
+ opScopeChoices.add(OperationalScope.Core);
+ opScopeChoices.add(OperationalScope.CPU);
+ opScopeChoices.add(OperationalScope.Network_Wide);
+ EntitlementPoolEntity ep2 =
+ createEntitlementPool("vlm4Id", null, ep1_id, EP1_NAME, "EP2 dec", 70,
+ ThresholdUnit.Absolute,
+ EntitlementMetric.Other, "exception metric2", "inc2", AggregationFunction.Average,
+ null,
+ opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
+ ep2.setStartDate(LocalDate.now().format(formatter));
+ ep2.setExpiryDate(LocalDate.now().format(formatter));
+ vendorLicenseManagerImpl.updateEntitlementPool(ep2);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), VendorLicenseErrorCodes.DATE_RANGE_INVALID);
}
+ }
- @Test
- public void deleteEntitlementPoolTest() {
-
- VersionInfo versionInfo = new VersionInfo();
- versionInfo.setActiveVersion(VERSION01);
- versionInfo.setLockingUser(USER1);
- ArrayList<Version> viewable = new ArrayList<Version>();
- viewable.add(VERSION01);
- versionInfo.setViewableVersions(viewable);
-
- doReturn(versionInfo).when(vendorLicenseManagerImpl).getVersionInfo(vlm1_id,
- VersionableEntityAction.Write, USER1);
-
- Set<OperationalScope> opScopeChoices;
- opScopeChoices = new HashSet<>();
- opScopeChoices.add(OperationalScope.Core);
- opScopeChoices.add(OperationalScope.CPU);
- opScopeChoices.add(OperationalScope.Network_Wide);
-
- EntitlementPoolEntity entitlementPool =
- createEntitlementPool(vlm1_id,VERSION01, ep1_id,EP1_NAME, "EP2 dec", 70,
- ThresholdUnit.Absolute,EntitlementMetric.Other, "exception metric2", "inc2",
- AggregationFunction.Average, null,
- opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
- entitlementPool.setStartDate(LocalDate.now().format(formatter));
- entitlementPool.setExpiryDate(LocalDate.now().plusDays(1L).format(formatter));
-
- doReturn(entitlementPool).when(entitlementPoolDao).get(anyObject());
-
- doNothing().when(vendorLicenseManagerImpl).deleteChildLimits(vlm1_id,VERSION01,ep1_id,USER1);
-
- doNothing().when(vendorLicenseManagerImpl).deleteUniqueName(anyObject(),anyObject(),
- anyObject(),anyObject());
+ @Test
+ public void deleteEntitlementPoolTest() {
+ Set<OperationalScope> opScopeChoices;
+ opScopeChoices = new HashSet<>();
+ opScopeChoices.add(OperationalScope.Core);
+ opScopeChoices.add(OperationalScope.CPU);
+ opScopeChoices.add(OperationalScope.Network_Wide);
- vendorLicenseManagerImpl.deleteEntitlementPool(entitlementPool, USER1);
+ EntitlementPoolEntity entitlementPool =
+ createEntitlementPool(vlm1_id, VERSION01, ep1_id, EP1_NAME, "EP2 dec", 70,
+ ThresholdUnit.Absolute, EntitlementMetric.Other, "exception metric2", "inc2",
+ AggregationFunction.Average, null,
+ opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
+ entitlementPool.setStartDate(LocalDate.now().format(formatter));
+ entitlementPool.setExpiryDate(LocalDate.now().plusDays(1L).format(formatter));
- verify(entitlementPoolDao).delete(entitlementPool);
- verify(vendorLicenseFacade).updateVlmLastModificationTime(vlm1_id,VERSION01);
+ doReturn(entitlementPool).when(entitlementPoolDao).get(anyObject());
- }
+ doNothing().when(vendorLicenseManagerImpl).deleteChildLimits(vlm1_id, VERSION01, ep1_id);
- @Test
- public void testGetEntitlementPool(){
+ doNothing().when(vendorLicenseManagerImpl).deleteUniqueName(anyObject(), anyObject(),
+ anyObject(), anyObject());
- VersionInfo versionInfo = new VersionInfo();
- versionInfo.setActiveVersion(VERSION01);
- versionInfo.setLockingUser(USER1);
- ArrayList<Version> viewable = new ArrayList<Version>();
- viewable.add(VERSION01);
- versionInfo.setViewableVersions(viewable);
- versionInfo.setActiveVersion(VERSION01);
+ vendorLicenseManagerImpl.deleteEntitlementPool(entitlementPool);
- doReturn(versionInfo).when(vendorLicenseManagerImpl).getVersionInfo(vlm1_id,
- VersionableEntityAction.Read, USER1);
+ verify(entitlementPoolDao).delete(entitlementPool);
+ }
- Set<OperationalScope> opScopeChoices;
- opScopeChoices = new HashSet<>();
- opScopeChoices.add(OperationalScope.Core);
- opScopeChoices.add(OperationalScope.CPU);
- opScopeChoices.add(OperationalScope.Network_Wide);
+ @Test
+ public void testGetEntitlementPool() {
+ Set<OperationalScope> opScopeChoices;
+ opScopeChoices = new HashSet<>();
+ opScopeChoices.add(OperationalScope.Core);
+ opScopeChoices.add(OperationalScope.CPU);
+ opScopeChoices.add(OperationalScope.Network_Wide);
- EntitlementPoolEntity entitlementPool =
- createEntitlementPool(vlm1_id,VERSION01, ep1_id,EP1_NAME, "EP2 dec", 70,
- ThresholdUnit.Absolute,EntitlementMetric.Other, "exception metric2", "inc2",
- AggregationFunction.Average, null,
- opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy'T'HH:mm:ss'Z'");
+ EntitlementPoolEntity entitlementPool =
+ createEntitlementPool(vlm1_id, VERSION01, ep1_id, EP1_NAME, "EP2 dec", 70,
+ ThresholdUnit.Absolute, EntitlementMetric.Other, "exception metric2", "inc2",
+ AggregationFunction.Average, null,
+ opScopeChoices, null, EntitlementTime.Other, "time2", "sku2");
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy'T'HH:mm:ss'Z'");
- entitlementPool.setStartDate(LocalDateTime.now().format(formatter));
- entitlementPool.setExpiryDate(LocalDateTime.now().plusDays(1L).format(formatter));
+ entitlementPool.setStartDate(LocalDateTime.now().format(formatter));
+ entitlementPool.setExpiryDate(LocalDateTime.now().plusDays(1L).format(formatter));
- doReturn(entitlementPool).when(entitlementPoolDao).get(anyObject());
+ doReturn(entitlementPool).when(entitlementPoolDao).get(anyObject());
- EntitlementPoolEntity retrived = vendorLicenseManagerImpl.getEntitlementPool
- (entitlementPool,USER1);
+ EntitlementPoolEntity retrived = vendorLicenseManagerImpl.getEntitlementPool(entitlementPool);
- Assert.assertEquals(retrived.getId(),entitlementPool.getId());
- Assert.assertEquals(retrived.getVendorLicenseModelId(),entitlementPool.getVendorLicenseModelId());
- Assert.assertEquals(retrived.getVersion(),entitlementPool.getVersion());
- }
+ Assert.assertEquals(retrived.getId(), entitlementPool.getId());
+ Assert.assertEquals(retrived.getVendorLicenseModelId(),
+ entitlementPool.getVendorLicenseModelId());
+ Assert.assertEquals(retrived.getVersion(), entitlementPool.getVersion());
+ }
- @Test
- public void testListEntitlmentPool(){
+ @Test
+ public void testListEntitlmentPool() {
- Set<OperationalScope> opScopeChoices;
- opScopeChoices = new HashSet<>();
- opScopeChoices.add(OperationalScope.Core);
- opScopeChoices.add(OperationalScope.CPU);
- opScopeChoices.add(OperationalScope.Network_Wide);
+ Set<OperationalScope> opScopeChoices;
+ opScopeChoices = new HashSet<>();
+ opScopeChoices.add(OperationalScope.Core);
+ opScopeChoices.add(OperationalScope.CPU);
+ opScopeChoices.add(OperationalScope.Network_Wide);
- doReturn(Arrays.asList(
- createEntitlementPool(vlm1_id,VERSION01, ep1_id, EP1_NAME,"EP1 dec", 70,
- ThresholdUnit.Absolute,EntitlementMetric.Other, "exception metric1",
- "inc1", AggregationFunction.Average, null,
- opScopeChoices, null, EntitlementTime.Other, "time1", "sku1"),
- createEntitlementPool(vlm1_id,VERSION01, ep2_id, EP2_NAME,"EP2 dec", 70,
- ThresholdUnit.Absolute,EntitlementMetric.Other, "exception metric2",
- "inc2", AggregationFunction.Average, null,
- opScopeChoices, null, EntitlementTime.Other, "time2", "sku2")))
- .when(vendorLicenseFacade).listEntitlementPools(vlm1_id, VERSION01, USER1);
-
- Collection<EntitlementPoolEntity> EPs =
- vendorLicenseManagerImpl.listEntitlementPools(vlm1_id, VERSION01, USER1);
-
- verify(vendorLicenseFacade).listEntitlementPools(vlm1_id, VERSION01, USER1);
- Assert.assertEquals(EPs.size(), 2);
- EPs.forEach(ep -> Assert.assertTrue(ep.getId().matches(ep1_id + "|" + ep2_id)));
- }
+ doReturn(Arrays.asList(
+ createEntitlementPool(vlm1_id, VERSION01, ep1_id, EP1_NAME, "EP1 dec", 70,
+ ThresholdUnit.Absolute, EntitlementMetric.Other, "exception metric1",
+ "inc1", AggregationFunction.Average, null,
+ opScopeChoices, null, EntitlementTime.Other, "time1", "sku1"),
+ createEntitlementPool(vlm1_id, VERSION01, ep2_id, EP2_NAME, "EP2 dec", 70,
+ ThresholdUnit.Absolute, EntitlementMetric.Other, "exception metric2",
+ "inc2", AggregationFunction.Average, null,
+ opScopeChoices, null, EntitlementTime.Other, "time2", "sku2")))
+ .when(vendorLicenseFacade).listEntitlementPools(vlm1_id, VERSION01);
+
+ Collection<EntitlementPoolEntity> EPs =
+ vendorLicenseManagerImpl.listEntitlementPools(vlm1_id, VERSION01);
+
+ verify(vendorLicenseFacade).listEntitlementPools(vlm1_id, VERSION01);
+ Assert.assertEquals(EPs.size(), 2);
+ EPs.forEach(ep -> Assert.assertTrue(ep.getId().matches(ep1_id + "|" + ep2_id)));
+ }
/* @Test
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/FeatureGroupTest.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/FeatureGroupTest.java
index dd3560615e..b9eacc3e6f 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/FeatureGroupTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/FeatureGroupTest.java
@@ -21,35 +21,27 @@
package org.openecomp.sdc.vendorlicense.impl;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.doReturn;
-
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
-import org.openecomp.sdc.vendorlicense.dao.*;
-import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther;
+import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
+import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDao;
+import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDao;
+import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao;
+import org.openecomp.sdc.vendorlicense.dao.LimitDao;
+import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDao;
import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseTerm;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
-import org.openecomp.sdc.vendorlicense.facade.impl.VendorLicenseFacadeImpl;
-import org.openecomp.sdc.vendorlicense.impl.VendorLicenseManagerImpl;
import org.openecomp.sdc.versioning.VersioningManager;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
import org.testng.Assert;
-import org.testng.AssertJUnit.*;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
@@ -58,7 +50,6 @@ import java.util.Set;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
/**
@@ -66,272 +57,254 @@ import static org.mockito.Mockito.verify;
*/
public class FeatureGroupTest {
- //JUnit Test Cases using Mockito
- private static final Version VERSION01 = new Version(0, 1);
- private static final Version VERSION10 = new Version(1, 0);
- private final String FG1_NAME = "FG1 name";
- private static final String USER1 = "TestUser1";
- private static final String USER2 = "TestUser2";
-
- private static String vlm1_id = "vlm1_id";
- private static String vlm2_id = "vlm2_id";
- private static String lkg1_id = "lkg1_id";
- private static String lkg2_id = "lkg2_id";
- private static String fg1_id = "fg1_id";
- private static String fg2_id = "fg2_id";
- private static String ep1_id = "ep1_id";
- private static String ep2_id = "ep2_id";
-
- @Mock
- private VendorLicenseFacade vendorLicenseFacadeMcok;
-
- @Mock
- private LimitDao limitDaoMcok;
- @Mock
- private ActivityLogManager activityLogManagerMcok;
-
- @Mock
- private VendorLicenseModelDao vendorLicenseModelDao;
-
- @Mock
- private LicenseAgreementDao licenseAgreementDao;
-
- @Mock
- private FeatureGroupDao featureGroupDao;
-
- @Mock
- private EntitlementPoolDao entitlementPoolDao;
-
- @Mock
- private LicenseKeyGroupDao licenseKeyGroupDao;
-
- @Mock
- private VersioningManager versioningManager;
-
- @InjectMocks
- @Spy
- private VendorLicenseManagerImpl vendorLicenseManagerImpl;
-
- public FeatureGroupEntity updateFeatureGroup(String vlmId, Version version, String id, String name, String desc,
- String partNumber, String manufacturerReferenceNumber, Set<String>
- licenseKeyGroupIds, Set<String> entitlementPoolIds, Set<String>
- referencingLicenseAgreements){
- FeatureGroupEntity featureGroup = new FeatureGroupEntity(vlmId, version, id);
- featureGroup.setVendorLicenseModelId(vlmId);
- featureGroup.setVersion(version);
- featureGroup.setId(id);
- featureGroup.setName(name);
- featureGroup.setDescription(desc);
- featureGroup.setPartNumber(partNumber);
- //featureGroup.setManufacturerReferenceNumber(manufacturerReferenceNumber);
- featureGroup.setLicenseKeyGroupIds(licenseKeyGroupIds);
- featureGroup.setEntitlementPoolIds(entitlementPoolIds);
- featureGroup.setReferencingLicenseAgreements(referencingLicenseAgreements);
-
- return featureGroup;
- }
-
- @BeforeMethod
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void testUpdate(){
- Set<String> licenseKeyGroupIds;
- licenseKeyGroupIds = new HashSet<>();
- licenseKeyGroupIds.add("lkg1");
-
- Set<String> entitlementPoolIds;
- entitlementPoolIds = new HashSet<>();
- entitlementPoolIds.add("ep1");
-
- Set<String> referencingLicenseAgreements;
- referencingLicenseAgreements = new HashSet<>();
- referencingLicenseAgreements.add("la1");
-
- FeatureGroupEntity featureGroupEntity = updateFeatureGroup("vlmId", VERSION01, "fgId", FG1_NAME, "fg1 desc",
+ //JUnit Test Cases using Mockito
+ private static final Version VERSION01 = new Version(0, 1);
+ private static final Version VERSION10 = new Version(1, 0);
+ private final String FG1_NAME = "FG1 name";
+ private static final String USER1 = "TestUser1";
+ private static final String USER2 = "TestUser2";
+
+ private static String vlm1_id = "vlm1_id";
+ private static String vlm2_id = "vlm2_id";
+ private static String lkg1_id = "lkg1_id";
+ private static String lkg2_id = "lkg2_id";
+ private static String fg1_id = "fg1_id";
+ private static String fg2_id = "fg2_id";
+ private static String ep1_id = "ep1_id";
+ private static String ep2_id = "ep2_id";
+
+ @Mock
+ private VendorLicenseFacade vendorLicenseFacadeMcok;
+
+ @Mock
+ private LimitDao limitDaoMcok;
+
+ @Mock
+ private VendorLicenseModelDao vendorLicenseModelDao;
+
+ @Mock
+ private LicenseAgreementDao licenseAgreementDao;
+
+ @Mock
+ private FeatureGroupDao featureGroupDao;
+
+ @Mock
+ private EntitlementPoolDao entitlementPoolDao;
+
+ @Mock
+ private LicenseKeyGroupDao licenseKeyGroupDao;
+
+ @Mock
+ private VersioningManager versioningManager;
+
+ @InjectMocks
+ @Spy
+ private VendorLicenseManagerImpl vendorLicenseManagerImpl;
+
+ public FeatureGroupEntity updateFeatureGroup(String vlmId, Version version, String id,
+ String name, String desc,
+ String partNumber,
+ String manufacturerReferenceNumber, Set<String>
+ licenseKeyGroupIds,
+ Set<String> entitlementPoolIds, Set<String>
+ referencingLicenseAgreements) {
+ FeatureGroupEntity featureGroup = new FeatureGroupEntity(vlmId, version, id);
+ featureGroup.setVendorLicenseModelId(vlmId);
+ featureGroup.setVersion(version);
+ featureGroup.setId(id);
+ featureGroup.setName(name);
+ featureGroup.setDescription(desc);
+ featureGroup.setPartNumber(partNumber);
+ //featureGroup.setManufacturerReferenceNumber(manufacturerReferenceNumber);
+ featureGroup.setLicenseKeyGroupIds(licenseKeyGroupIds);
+ featureGroup.setEntitlementPoolIds(entitlementPoolIds);
+ featureGroup.setReferencingLicenseAgreements(referencingLicenseAgreements);
+
+ return featureGroup;
+ }
+
+ @BeforeMethod
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testUpdate() {
+ Set<String> licenseKeyGroupIds;
+ licenseKeyGroupIds = new HashSet<>();
+ licenseKeyGroupIds.add("lkg1");
+
+ Set<String> entitlementPoolIds;
+ entitlementPoolIds = new HashSet<>();
+ entitlementPoolIds.add("ep1");
+
+ Set<String> referencingLicenseAgreements;
+ referencingLicenseAgreements = new HashSet<>();
+ referencingLicenseAgreements.add("la1");
+
+ FeatureGroupEntity featureGroupEntity =
+ updateFeatureGroup("vlmId", VERSION01, "fgId", FG1_NAME, "fg1 desc",
"partNumber", "MRN", licenseKeyGroupIds, entitlementPoolIds,
referencingLicenseAgreements);
- doReturn(featureGroupEntity).when(featureGroupDao).get(anyObject());
+ doReturn(featureGroupEntity).when(featureGroupDao).get(anyObject());
/*if(featureGroupEntity.getManufacturerReferenceNumber() != null)
featureGroupDao.update(featureGroupEntity);
verify(featureGroupDao).update(anyObject());*/
- }
+ }
- @Test
- public void testUpdateWithoutManufacturingReferenceNumber(){
- Set<String> licenseKeyGroupIds;
- licenseKeyGroupIds = new HashSet<>();
- licenseKeyGroupIds.add("lkg1");
+ @Test
+ public void testUpdateWithoutManufacturingReferenceNumber() {
+ Set<String> licenseKeyGroupIds;
+ licenseKeyGroupIds = new HashSet<>();
+ licenseKeyGroupIds.add("lkg1");
- Set<String> entitlementPoolIds;
- entitlementPoolIds = new HashSet<>();
- entitlementPoolIds.add("ep1");
+ Set<String> entitlementPoolIds;
+ entitlementPoolIds = new HashSet<>();
+ entitlementPoolIds.add("ep1");
- Set<String> referencingLicenseAgreements;
- referencingLicenseAgreements = new HashSet<>();
- referencingLicenseAgreements.add("la1");
+ Set<String> referencingLicenseAgreements;
+ referencingLicenseAgreements = new HashSet<>();
+ referencingLicenseAgreements.add("la1");
- FeatureGroupEntity featureGroupEntity = updateFeatureGroup("vlmId", VERSION01, "fgId", FG1_NAME, "fg1 desc",
+ FeatureGroupEntity featureGroupEntity =
+ updateFeatureGroup("vlmId", VERSION01, "fgId", FG1_NAME, "fg1 desc",
"partNumber", null, licenseKeyGroupIds, entitlementPoolIds,
referencingLicenseAgreements);
- doReturn(featureGroupEntity).when(featureGroupDao).get(anyObject());
+ doReturn(featureGroupEntity).when(featureGroupDao).get(anyObject());
/*if(featureGroupEntity.getManufacturerReferenceNumber() != null)
featureGroupDao.update(featureGroupEntity);
verify(featureGroupDao, never()).update(anyObject());*/
- }
-
- @Test
- public void testListFeatureGroups() {
- doReturn(Arrays.asList(
- createFeatureGroup(vlm1_id, VERSION01, fg1_id, "FG1", "FG1 desc", new HashSet<String>(),
- new HashSet<String>()),
- createFeatureGroup(vlm1_id, VERSION01, fg2_id, "FG2", "FG2 desc", new HashSet<String>(),
- new HashSet<String>())))
- .when(vendorLicenseFacadeMcok).listFeatureGroups(vlm1_id, VERSION01, USER1);
-
- Collection<FeatureGroupEntity> FGs =
- vendorLicenseManagerImpl.listFeatureGroups(vlm1_id, VERSION01, USER1);
-
- verify(vendorLicenseFacadeMcok).listFeatureGroups(vlm1_id, VERSION01, USER1);
- Assert.assertEquals(FGs.size(), 2);
- FGs.forEach(fg -> Assert.assertTrue(fg.getId().matches(fg1_id + "|" + fg2_id)));
- }
-
- @Test
- public void testCreateFeatureGroup() {
- FeatureGroupEntity featureGroupEntity = new FeatureGroupEntity(vlm1_id,VERSION01,
- fg1_id);
-
- doReturn(featureGroupEntity).when(vendorLicenseFacadeMcok).createFeatureGroup
- (featureGroupEntity,USER1);
+ }
+
+ @Test
+ public void testListFeatureGroups() {
+ doReturn(Arrays.asList(
+ createFeatureGroup(vlm1_id, VERSION01, fg1_id, "FG1", "FG1 desc", new HashSet<String>(),
+ new HashSet<String>()),
+ createFeatureGroup(vlm1_id, VERSION01, fg2_id, "FG2", "FG2 desc", new HashSet<String>(),
+ new HashSet<String>())))
+ .when(vendorLicenseFacadeMcok).listFeatureGroups(vlm1_id, VERSION01);
+
+ Collection<FeatureGroupEntity> FGs =
+ vendorLicenseManagerImpl.listFeatureGroups(vlm1_id, VERSION01);
+
+ verify(vendorLicenseFacadeMcok).listFeatureGroups(vlm1_id, VERSION01);
+ Assert.assertEquals(FGs.size(), 2);
+ FGs.forEach(fg -> Assert.assertTrue(fg.getId().matches(fg1_id + "|" + fg2_id)));
+ }
- vendorLicenseManagerImpl.createFeatureGroup(featureGroupEntity,USER1);
-
- verify(vendorLicenseFacadeMcok).createFeatureGroup(featureGroupEntity,USER1);
- }
-
-
- @Test
- public void testUpdateFeatureGroup(){
- VersionInfo versionInfo = new VersionInfo();
- versionInfo.setActiveVersion(VERSION01);
- versionInfo.setLockingUser(USER1);
- ArrayList<Version> viewable = new ArrayList<Version>();
- viewable.add(VERSION01);
- versionInfo.setViewableVersions(viewable);
-
- doReturn(versionInfo).when(vendorLicenseManagerImpl).getVersionInfo(vlm1_id,
- VersionableEntityAction.Write, USER1);
- FeatureGroupEntity existingFG = new FeatureGroupEntity(vlm1_id, VERSION01, fg1_id);
-
- existingFG.setEntitlementPoolIds(new HashSet<String>());
- existingFG.setLicenseKeyGroupIds(new HashSet<String>());
-
- doReturn(existingFG).when(featureGroupDao).get(existingFG);
-
- Set<String> removedEPs = new HashSet<>();
- Set<String> addedEPs = new HashSet<>();
-
- addedEPs.add(ep1_id);
- addedEPs.add(ep2_id);
- EntitlementPoolEntity ep1 = new EntitlementPoolEntity(vlm1_id, VERSION01, ep1_id);
- EntitlementPoolEntity ep2 = new EntitlementPoolEntity(vlm1_id, VERSION01, ep2_id);
- doReturn(ep1).when(entitlementPoolDao).get(ep1);
- doReturn(ep2).when(entitlementPoolDao).get(ep2);
-
- Set<String> removedLKGs = new HashSet<>();
- Set<String> addedLKGs = new HashSet<>();
-
- addedLKGs.add(lkg1_id);
- addedLKGs.add(lkg2_id);
- LicenseKeyGroupEntity lkg1 = new LicenseKeyGroupEntity(vlm1_id, VERSION01, lkg1_id);
- LicenseKeyGroupEntity lkg2 = new LicenseKeyGroupEntity(vlm1_id, VERSION01, lkg2_id);
- doReturn(lkg1).when(licenseKeyGroupDao).get(lkg1);
- doReturn(lkg2).when(licenseKeyGroupDao).get(lkg2);
-
- doNothing().when(vendorLicenseManagerImpl).updateUniqueName(anyObject(), anyObject(),
- anyObject(),anyObject(), anyObject());
-
- vendorLicenseManagerImpl.updateFeatureGroup(existingFG,addedLKGs,removedLKGs, addedEPs,
- removedEPs, USER1);
-
- verify(vendorLicenseManagerImpl).addLicenseKeyGroupsToFeatureGroupsRef(addedLKGs,
- existingFG);
- verify(vendorLicenseManagerImpl).removeLicenseKeyGroupsToFeatureGroupsRef(removedLKGs,
- existingFG);
- verify(vendorLicenseManagerImpl).addEntitlementPoolsToFeatureGroupsRef(addedEPs,existingFG);
- verify(vendorLicenseManagerImpl).removeEntitlementPoolsToFeatureGroupsRef(removedEPs,
- existingFG);
-
- verify(featureGroupDao)
- .updateFeatureGroup(existingFG,addedEPs,removedEPs, addedLKGs, removedLKGs);
- verify(vendorLicenseFacadeMcok).updateVlmLastModificationTime(vlm1_id,VERSION01);
- }
-
-
- @Test
- public void testGetFeatureGroup(){
- FeatureGroupEntity featureGroupEntity = new FeatureGroupEntity(vlm1_id,VERSION01,fg1_id);
- vendorLicenseManagerImpl.getFeatureGroupModel(featureGroupEntity,USER1);
- verify(vendorLicenseFacadeMcok).getFeatureGroupModel(featureGroupEntity,USER1);
- }
-
- @Test
- public void deleteFeatureGroupTest() {
-
- VersionInfo versionInfo = new VersionInfo();
- versionInfo.setActiveVersion(VERSION01);
- versionInfo.setLockingUser(USER1);
- ArrayList<Version> viewable = new ArrayList<Version>();
- viewable.add(VERSION01);
- versionInfo.setViewableVersions(viewable);
-
- doReturn(versionInfo).when(vendorLicenseManagerImpl).getVersionInfo(vlm1_id,
- VersionableEntityAction.Write, USER1);
-
- FeatureGroupEntity existingFG = new FeatureGroupEntity(vlm1_id, VERSION01, fg1_id);
- existingFG.setName("FG_name");
- existingFG.setLicenseKeyGroupIds(new HashSet<String>());
- existingFG.setEntitlementPoolIds(new HashSet<String>());
- existingFG.setLicenseKeyGroupIds(new HashSet<String>());
-
- doReturn(existingFG).when(featureGroupDao).get(anyObject());
-
- doNothing().when(vendorLicenseManagerImpl).deleteUniqueName(VendorLicenseConstants
- .UniqueValues.FEATURE_GROUP_NAME,vlm1_id,VERSION01.toString(),existingFG.getName());
-
- vendorLicenseManagerImpl.deleteFeatureGroup(existingFG, USER1);
-
- verify(featureGroupDao).delete(existingFG);
- verify(vendorLicenseFacadeMcok).updateVlmLastModificationTime(vlm1_id,VERSION01);
-
- verify(vendorLicenseManagerImpl).removeLicenseKeyGroupsToFeatureGroupsRef(existingFG
- .getLicenseKeyGroupIds(),existingFG);
- verify(vendorLicenseManagerImpl).removeEntitlementPoolsToFeatureGroupsRef(existingFG
- .getEntitlementPoolIds(),existingFG);
- verify(vendorLicenseManagerImpl).deleteUniqueName(VendorLicenseConstants
- .UniqueValues.FEATURE_GROUP_NAME,vlm1_id,VERSION01.toString(),existingFG.getName());
- }
-
- private FeatureGroupEntity createFeatureGroup(String vendorId, Version version, String id,
- String name, String description,
- Set<String> entitlementPoolIds,
- Set<String> licenseKeyGroupIds) {
- FeatureGroupEntity featureGroup = new FeatureGroupEntity();
- featureGroup.setVendorLicenseModelId(vendorId);
- featureGroup.setVersion(version);
- featureGroup.setId(id);
- featureGroup.setName(name);
- featureGroup.setDescription(description);
- featureGroup.setEntitlementPoolIds(entitlementPoolIds);
- featureGroup.setLicenseKeyGroupIds(licenseKeyGroupIds);
- return featureGroup;
- }
+ @Test
+ public void testCreateFeatureGroup() {
+ FeatureGroupEntity featureGroupEntity = new FeatureGroupEntity(vlm1_id, VERSION01,
+ fg1_id);
+
+ doReturn(featureGroupEntity).when(vendorLicenseFacadeMcok).createFeatureGroup
+ (featureGroupEntity);
+
+ vendorLicenseManagerImpl.createFeatureGroup(featureGroupEntity);
+
+ verify(vendorLicenseFacadeMcok).createFeatureGroup(featureGroupEntity);
+ }
+
+
+ @Test
+ public void testUpdateFeatureGroup() {
+ FeatureGroupEntity existingFG = new FeatureGroupEntity(vlm1_id, VERSION01, fg1_id);
+
+ existingFG.setEntitlementPoolIds(new HashSet<String>());
+ existingFG.setLicenseKeyGroupIds(new HashSet<String>());
+
+ doReturn(existingFG).when(featureGroupDao).get(existingFG);
+
+ Set<String> removedEPs = new HashSet<>();
+ Set<String> addedEPs = new HashSet<>();
+
+ addedEPs.add(ep1_id);
+ addedEPs.add(ep2_id);
+ EntitlementPoolEntity ep1 = new EntitlementPoolEntity(vlm1_id, VERSION01, ep1_id);
+ EntitlementPoolEntity ep2 = new EntitlementPoolEntity(vlm1_id, VERSION01, ep2_id);
+ doReturn(ep1).when(entitlementPoolDao).get(ep1);
+ doReturn(ep2).when(entitlementPoolDao).get(ep2);
+
+ Set<String> removedLKGs = new HashSet<>();
+ Set<String> addedLKGs = new HashSet<>();
+
+ addedLKGs.add(lkg1_id);
+ addedLKGs.add(lkg2_id);
+ LicenseKeyGroupEntity lkg1 = new LicenseKeyGroupEntity(vlm1_id, VERSION01, lkg1_id);
+ LicenseKeyGroupEntity lkg2 = new LicenseKeyGroupEntity(vlm1_id, VERSION01, lkg2_id);
+ doReturn(lkg1).when(licenseKeyGroupDao).get(lkg1);
+ doReturn(lkg2).when(licenseKeyGroupDao).get(lkg2);
+
+ doNothing().when(vendorLicenseManagerImpl).updateUniqueName(anyObject(), anyObject(),
+ anyObject(), anyObject(), anyObject());
+
+ vendorLicenseManagerImpl.updateFeatureGroup(existingFG, addedLKGs, removedLKGs, addedEPs,
+ removedEPs);
+
+ verify(vendorLicenseManagerImpl).addLicenseKeyGroupsToFeatureGroupsRef(addedLKGs,
+ existingFG);
+ verify(vendorLicenseManagerImpl).removeLicenseKeyGroupsToFeatureGroupsRef(removedLKGs,
+ existingFG);
+ verify(vendorLicenseManagerImpl).addEntitlementPoolsToFeatureGroupsRef(addedEPs, existingFG);
+ verify(vendorLicenseManagerImpl).removeEntitlementPoolsToFeatureGroupsRef(removedEPs,
+ existingFG);
+
+ verify(featureGroupDao)
+ .updateFeatureGroup(existingFG, addedEPs, removedEPs, addedLKGs, removedLKGs);
+ }
+
+
+ @Test
+ public void testGetFeatureGroup() {
+ FeatureGroupEntity featureGroupEntity = new FeatureGroupEntity(vlm1_id, VERSION01, fg1_id);
+ vendorLicenseManagerImpl.getFeatureGroupModel(featureGroupEntity);
+ verify(vendorLicenseFacadeMcok).getFeatureGroupModel(featureGroupEntity);
+ }
+
+ @Test
+ public void deleteFeatureGroupTest() {
+
+ FeatureGroupEntity existingFG = new FeatureGroupEntity(vlm1_id, VERSION01, fg1_id);
+ existingFG.setName("FG_name");
+ existingFG.setLicenseKeyGroupIds(new HashSet<String>());
+ existingFG.setEntitlementPoolIds(new HashSet<String>());
+ existingFG.setLicenseKeyGroupIds(new HashSet<String>());
+
+ doReturn(existingFG).when(featureGroupDao).get(anyObject());
+
+ doNothing().when(vendorLicenseManagerImpl).deleteUniqueName(VendorLicenseConstants
+ .UniqueValues.FEATURE_GROUP_NAME, vlm1_id, VERSION01.toString(), existingFG.getName());
+
+ vendorLicenseManagerImpl.deleteFeatureGroup(existingFG);
+
+ verify(featureGroupDao).delete(existingFG);
+
+ verify(vendorLicenseManagerImpl).removeLicenseKeyGroupsToFeatureGroupsRef(existingFG
+ .getLicenseKeyGroupIds(), existingFG);
+ verify(vendorLicenseManagerImpl).removeEntitlementPoolsToFeatureGroupsRef(existingFG
+ .getEntitlementPoolIds(), existingFG);
+ verify(vendorLicenseManagerImpl).deleteUniqueName(VendorLicenseConstants
+ .UniqueValues.FEATURE_GROUP_NAME, vlm1_id, VERSION01.toString(), existingFG.getName());
+ }
+
+ private FeatureGroupEntity createFeatureGroup(String vendorId, Version version, String id,
+ String name, String description,
+ Set<String> entitlementPoolIds,
+ Set<String> licenseKeyGroupIds) {
+ FeatureGroupEntity featureGroup = new FeatureGroupEntity();
+ featureGroup.setVendorLicenseModelId(vendorId);
+ featureGroup.setVersion(version);
+ featureGroup.setId(id);
+ featureGroup.setName(name);
+ featureGroup.setDescription(description);
+ featureGroup.setEntitlementPoolIds(entitlementPoolIds);
+ featureGroup.setLicenseKeyGroupIds(licenseKeyGroupIds);
+ return featureGroup;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseAgreementTest.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseAgreementTest.java
index b0b5953a53..91435e85fd 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseAgreementTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseAgreementTest.java
@@ -26,17 +26,11 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
-import org.openecomp.core.util.UniqueValueUtil;
-import org.openecomp.core.utilities.CommonMethods;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
-import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDao;
-import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDaoFactory;
import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDao;
-import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDaoFactory;
import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao;
import org.openecomp.sdc.vendorlicense.dao.LimitDao;
import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDao;
@@ -44,36 +38,24 @@ import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther;
import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
import org.openecomp.sdc.vendorlicense.dao.types.LicenseTerm;
-import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
-import org.openecomp.sdc.vendorlicense.impl.VendorLicenseManagerImpl;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
import org.openecomp.sdc.versioning.VersioningManager;
-import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.verify;
-import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE;
-import static org.testng.AssertJUnit.assertEquals;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+
public class LicenseAgreementTest {
private static final String USER1 = "TestUser1";
@@ -104,8 +86,6 @@ public class LicenseAgreementTest {
private LicenseKeyGroupDao licenseKeyGroupDaoMcok;
@Mock
private LimitDao limitDaoMcok;
- @Mock
- private ActivityLogManager activityLogManagerMcok;
@Spy
@@ -160,12 +140,12 @@ public class LicenseAgreementTest {
@Test
public void listLicenseAgreementsTest() {
- LicenseAgreementEntity la = new LicenseAgreementEntity(vlm1_id,VERSION01,USER1);
- doReturn(la).when(vendorLicenseManager).createLicenseAgreementForList(vlm1_id,VERSION01, USER1);
+ LicenseAgreementEntity la =
+ new LicenseAgreementEntity(vlm1_id, VERSION01, null); // TODO: 8/13/2017
doReturn(Arrays.asList(
createLicenseAgreement(vlm1_id, VERSION01, la1_id, "LA1", "LA1 " +
- "desc","RequirementsAndConstrains2", new ChoiceOrOther<>(LicenseTerm.Unlimited, null),
+ "desc", "RequirementsAndConstrains2", new ChoiceOrOther<>(LicenseTerm.Unlimited, null),
"fg1"),
createLicenseAgreement(vlm1_id, VERSION01, la2_id, "LA2", "LA2 desc",
"RequirementsAndConstrains2", new ChoiceOrOther<>(LicenseTerm.Unlimited, null),
@@ -173,23 +153,23 @@ public class LicenseAgreementTest {
.when(licenseAgreementDaoMcok).list(la);
Collection<LicenseAgreementEntity> LAs =
- vendorLicenseManager.listLicenseAgreements(vlm1_id, VERSION01, USER1);
+ vendorLicenseManager.listLicenseAgreements(vlm1_id, VERSION01);
Assert.assertEquals(LAs.size(), 2);
- LAs.forEach(licseAgreement-> Assert.assertTrue(licseAgreement.getId().matches(la1_id + "|" + la2_id)));
+ LAs.forEach(
+ licseAgreement -> Assert.assertTrue(licseAgreement.getId().matches(la1_id + "|" + la2_id)));
}
@Test
public void testListLicenseAgreementsWhenNone() {
- LicenseAgreementEntity la = new LicenseAgreementEntity(vlm1_id,VERSION01,USER1);
- doReturn(la).when(vendorLicenseManager).createLicenseAgreementForList(vlm1_id,VERSION01,
- USER1);
+ LicenseAgreementEntity la =
+ new LicenseAgreementEntity(vlm1_id, VERSION01, null); // TODO: 8/13/2017
doReturn(new ArrayList<LicenseAgreementEntity>())
.when(licenseAgreementDaoMcok).list(la);
Collection<LicenseAgreementEntity> LAs =
- vendorLicenseManager.listLicenseAgreements(vlm1_id, VERSION01, USER1);
+ vendorLicenseManager.listLicenseAgreements(vlm1_id, VERSION01);
verify(licenseAgreementDaoMcok).list(la);
Assert.assertEquals(LAs.size(), 0);
@@ -199,29 +179,19 @@ public class LicenseAgreementTest {
@Test
public void testCreateLicenseAgreement() {
- LicenseAgreementEntity licenseAgreementEntity = new LicenseAgreementEntity(vlm1_id,VERSION01,
+ LicenseAgreementEntity licenseAgreementEntity = new LicenseAgreementEntity(vlm1_id, VERSION01,
la2_id);
doReturn(licenseAgreementEntity).when(vendorLicenseFacadeMcok).createLicenseAgreement
- (licenseAgreementEntity,USER1);
+ (licenseAgreementEntity);
- vendorLicenseManager.createLicenseAgreement(licenseAgreementEntity,USER1);
+ vendorLicenseManager.createLicenseAgreement(licenseAgreementEntity);
- verify(vendorLicenseFacadeMcok).createLicenseAgreement(licenseAgreementEntity,USER1);
+ verify(vendorLicenseFacadeMcok).createLicenseAgreement(licenseAgreementEntity);
}
@Test
public void testUpdateLicenseAgreement() {
-
- VersionInfo versionInfo = new VersionInfo();
- versionInfo.setActiveVersion(VERSION01);
- versionInfo.setLockingUser(USER1);
- ArrayList<Version> viewable = new ArrayList<Version>();
- viewable.add(VERSION01);
- versionInfo.setViewableVersions(viewable);
-
- doReturn(versionInfo).when(vendorLicenseManager).getVersionInfo(vlm1_id,
- VersionableEntityAction.Write, USER1);
LicenseAgreementEntity existingLA = new LicenseAgreementEntity(vlm1_id, VERSION01, la1_id);
existingLA.setFeatureGroupIds(new HashSet<String>());
@@ -236,34 +206,20 @@ public class LicenseAgreementTest {
FeatureGroupEntity fg2 = new FeatureGroupEntity(vlm1_id, VERSION01, fg2_id);
doReturn(fg1).when(featureGroupDaoMcok).get(fg1);
doReturn(fg2).when(featureGroupDaoMcok).get(fg2);
- doReturn(existingLA).when(vendorLicenseManager).createLicenseAgreementForList(vlm1_id,VERSION01,
- USER1);
doNothing().when(vendorLicenseManager).updateUniqueName(anyObject(), anyObject(), anyObject(),
anyObject(), anyObject());
- vendorLicenseManager.updateLicenseAgreement(existingLA, addedFGs, removedFGs, USER1);
+ vendorLicenseManager.updateLicenseAgreement(existingLA, addedFGs, removedFGs);
verify(licenseAgreementDaoMcok)
.updateColumnsAndDeltaFeatureGroupIds(existingLA, addedFGs, removedFGs);
- verify(vendorLicenseManager).addFeatureGroupsToLicenseAgreementRef(addedFGs,existingLA);
- verify(vendorLicenseManager).removeFeatureGroupsToLicenseAgreementRef(removedFGs,existingLA);
- verify(vendorLicenseFacadeMcok).updateVlmLastModificationTime(vlm1_id,VERSION01);
+ verify(vendorLicenseManager).addFeatureGroupsToLicenseAgreementRef(addedFGs, existingLA);
+ verify(vendorLicenseManager).removeFeatureGroupsToLicenseAgreementRef(removedFGs, existingLA);
}
@Test
public void deleteLicenseAgreementsTest() {
-
- VersionInfo versionInfo = new VersionInfo();
- versionInfo.setActiveVersion(VERSION01);
- versionInfo.setLockingUser(USER1);
- ArrayList<Version> viewable = new ArrayList<Version>();
- viewable.add(VERSION01);
- versionInfo.setViewableVersions(viewable);
-
- doReturn(versionInfo).when(vendorLicenseManager).getVersionInfo(vlm1_id,
- VersionableEntityAction.Write, USER1);
-
LicenseAgreementEntity existingLA = new LicenseAgreementEntity(vlm1_id, VERSION01, la1_id);
existingLA.setName("LA");
existingLA.setFeatureGroupIds(new HashSet<>());
@@ -271,20 +227,19 @@ public class LicenseAgreementTest {
doReturn(existingLA).when(licenseAgreementDaoMcok).get(anyObject());
doNothing().when(vendorLicenseManager).deleteUniqueName(VendorLicenseConstants.UniqueValues
- .LICENSE_AGREEMENT_NAME,vlm1_id,VERSION01.toString(),existingLA.getName());
+ .LICENSE_AGREEMENT_NAME, vlm1_id, VERSION01.toString(), existingLA.getName());
- vendorLicenseManager.deleteLicenseAgreement(vlm1_id, VERSION01, la1_id, USER1);
+ vendorLicenseManager.deleteLicenseAgreement(vlm1_id, VERSION01, la1_id);
verify(licenseAgreementDaoMcok).delete(existingLA);
- verify(vendorLicenseFacadeMcok).updateVlmLastModificationTime(vlm1_id,VERSION01);
verify(vendorLicenseManager).removeFeatureGroupsToLicenseAgreementRef(existingLA
- .getFeatureGroupIds(),existingLA);
+ .getFeatureGroupIds(), existingLA);
}
@Test
- public void testGetLicenseAgreement(){
- vendorLicenseManager.getLicenseAgreementModel(vlm1_id,VERSION01,la1_id,USER1);
- verify(vendorLicenseFacadeMcok).getLicenseAgreementModel(vlm1_id,VERSION01,la1_id,USER1);
+ public void testGetLicenseAgreement() {
+ vendorLicenseManager.getLicenseAgreementModel(vlm1_id, VERSION01, la1_id);
+ verify(vendorLicenseFacadeMcok).getLicenseAgreementModel(vlm1_id, VERSION01, la1_id);
}
/*
@@ -300,7 +255,7 @@ public class LicenseAgreementTest {
featureGroupDao.create(created);
featureGroupDao.addReferencingLicenseAgreement(created, licenseAgreement.getId());
- vendorLicenseManager.deleteFeatureGroup(created, USER1);
+ vendorLicenseManager.deleteFeatureGroup(created);
LicenseAgreementEntity afterDeletingFG = licenseAgreementDao.get(licenseAgreement);
Assert.assertEquals(afterDeletingFG.getFeatureGroupIds().size(), 1);
Assert.assertTrue(afterDeletingFG.getFeatureGroupIds().contains("fg2"));
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseKeyGroupTest.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseKeyGroupTest.java
index f0dd383a1f..dc376ee5b6 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseKeyGroupTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/LicenseKeyGroupTest.java
@@ -26,21 +26,19 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao;
import org.openecomp.sdc.vendorlicense.dao.LimitDao;
-import org.openecomp.sdc.vendorlicense.dao.types.*;
+import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyType;
+import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther;
+import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope;
import org.openecomp.sdc.vendorlicense.errors.VendorLicenseErrorCodes;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.ArrayList;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
@@ -56,10 +54,10 @@ import static org.mockito.Mockito.verify;
public class LicenseKeyGroupTest {
//JUnit Test Cases using Mockito
- private final String USER = "lkgTestUser";
- private final String LKG_NAME = "LKG name";
- private final String LKG2_NAME = "LKG2 name";
- private final String LT_NAME = "LT name";
+ private final String USER = "lkgTestUser";
+ private final String LKG_NAME = "LKG name";
+ private final String LKG2_NAME = "LKG2 name";
+ private final String LT_NAME = "LT name";
private final String LKG1_NAME = "LKG1 name";
private final String USER1 = "user1";
private static String lkg1_id = "lkg1_id";
@@ -85,15 +83,16 @@ public class LicenseKeyGroupTest {
MockitoAnnotations.initMocks(this);
}
- private LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyType type, Set<OperationalScope> operationalScopeChoices,
- String operationalScopeOther)
- {
+ private LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyType type,
+ Set<OperationalScope> operationalScopeChoices,
+ String operationalScopeOther) {
LicenseKeyGroupEntity licenseKeyGroupEntity = new LicenseKeyGroupEntity();
licenseKeyGroupEntity.setType(type);
licenseKeyGroupEntity.setOperationalScope(
new MultiChoiceOrOther<>(operationalScopeChoices, operationalScopeOther));
return licenseKeyGroupEntity;
}
+
/*
@Test
public void deleteLicenseKeyGroupTest() {
@@ -207,14 +206,14 @@ public class LicenseKeyGroupTest {
opScopeChoices.add(OperationalScope.CPU);
opScopeChoices.add(OperationalScope.Network_Wide);
LicenseKeyGroupEntity lkg =
- createLicenseKeyGroup("vlm1Id", null,lkg1_id, LKG1_NAME, "LKG1 dec",LicenseKeyType.Unique,
+ createLicenseKeyGroup("vlm1Id", null, lkg1_id, LKG1_NAME, "LKG1 dec", LicenseKeyType.Unique,
new MultiChoiceOrOther<>(opScopeChoices, null));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
lkg.setStartDate(LocalDate.now().format(formatter));
lkg.setExpiryDate(LocalDate.now().plusDays(1L).format(formatter));
- vendorLicenseManagerImpl.createLicenseKeyGroup(lkg, USER1);
- verify(vendorLicenseFacade).createLicenseKeyGroup(lkg,USER1);
+ vendorLicenseManagerImpl.createLicenseKeyGroup(lkg);
+ verify(vendorLicenseFacade).createLicenseKeyGroup(lkg);
}
@Test
@@ -227,12 +226,13 @@ public class LicenseKeyGroupTest {
opScopeChoices.add(OperationalScope.CPU);
opScopeChoices.add(OperationalScope.Network_Wide);
LicenseKeyGroupEntity lkg =
- createLicenseKeyGroup("vlm1Id", null, lkg1_id,LKG1_NAME, "LKG1 dec",LicenseKeyType.Unique,
+ createLicenseKeyGroup("vlm1Id", null, lkg1_id, LKG1_NAME, "LKG1 dec",
+ LicenseKeyType.Unique,
new MultiChoiceOrOther<>(opScopeChoices, null));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
lkg.setStartDate(LocalDate.now().format(formatter));
lkg.setExpiryDate(LocalDate.now().minusDays(2L).format(formatter));
- vendorLicenseManagerImpl.createLicenseKeyGroup(lkg, USER1);
+ vendorLicenseManagerImpl.createLicenseKeyGroup(lkg);
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), VendorLicenseErrorCodes.DATE_RANGE_INVALID);
@@ -249,11 +249,12 @@ public class LicenseKeyGroupTest {
opScopeChoices.add(OperationalScope.CPU);
opScopeChoices.add(OperationalScope.Network_Wide);
LicenseKeyGroupEntity lkg =
- createLicenseKeyGroup("vlm1Id", null, lkg1_id,LKG1_NAME, "LKG1 dec",LicenseKeyType.Unique,
+ createLicenseKeyGroup("vlm1Id", null, lkg1_id, LKG1_NAME, "LKG1 dec",
+ LicenseKeyType.Unique,
new MultiChoiceOrOther<>(opScopeChoices, null));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
lkg.setExpiryDate(LocalDate.now().plusDays(2L).format(formatter));
- vendorLicenseManagerImpl.createLicenseKeyGroup(lkg, USER1).getId();
+ vendorLicenseManagerImpl.createLicenseKeyGroup(lkg).getId();
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), VendorLicenseErrorCodes.DATE_RANGE_INVALID);
@@ -270,12 +271,13 @@ public class LicenseKeyGroupTest {
opScopeChoices.add(OperationalScope.CPU);
opScopeChoices.add(OperationalScope.Network_Wide);
LicenseKeyGroupEntity lkg =
- createLicenseKeyGroup("vlm1Id", null, lkg1_id,LKG1_NAME, "LKG1 dec",LicenseKeyType.Unique,
+ createLicenseKeyGroup("vlm1Id", null, lkg1_id, LKG1_NAME, "LKG1 dec",
+ LicenseKeyType.Unique,
new MultiChoiceOrOther<>(opScopeChoices, null));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
lkg.setStartDate(LocalDate.now().plusDays(2L).format(formatter));
lkg.setExpiryDate(LocalDate.now().plusDays(2L).format(formatter));
- vendorLicenseManagerImpl.createLicenseKeyGroup(lkg, USER1).getId();
+ vendorLicenseManagerImpl.createLicenseKeyGroup(lkg).getId();
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), VendorLicenseErrorCodes.DATE_RANGE_INVALID);
@@ -290,19 +292,14 @@ public class LicenseKeyGroupTest {
opScopeChoices.add(OperationalScope.CPU);
opScopeChoices.add(OperationalScope.Network_Wide);
LicenseKeyGroupEntity lkg =
- createLicenseKeyGroup(vlm1_id, null,lkg1_id, LKG1_NAME, "LKG1 dec",LicenseKeyType.Unique,
+ createLicenseKeyGroup(vlm1_id, null, lkg1_id, LKG1_NAME, "LKG1 dec", LicenseKeyType.Unique,
new MultiChoiceOrOther<>(opScopeChoices, null));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
lkg.setStartDate(LocalDate.now().minusDays(3L).format(formatter));
lkg.setExpiryDate(LocalDate.now().minusDays(2L).format(formatter));
- VersionInfo info = new VersionInfo();
- info.getViewableVersions().add(VERSION01);
- info.setActiveVersion(VERSION01);
- doReturn(info).when(vendorLicenseFacade).getVersionInfo(anyObject(),anyObject(),anyObject());
-
- vendorLicenseManagerImpl.updateLicenseKeyGroup(lkg, USER1);
- verify(vendorLicenseFacade).updateLicenseKeyGroup(lkg,USER1);
- verify(vendorLicenseFacade).updateVlmLastModificationTime(vlm1_id,VERSION01);
+
+ vendorLicenseManagerImpl.updateLicenseKeyGroup(lkg);
+ verify(vendorLicenseFacade).updateLicenseKeyGroup(lkg);
}
@Test
@@ -315,12 +312,13 @@ public class LicenseKeyGroupTest {
opScopeChoices.add(OperationalScope.CPU);
opScopeChoices.add(OperationalScope.Network_Wide);
LicenseKeyGroupEntity lkg =
- createLicenseKeyGroup("vlm1Id", null, lkg1_id,LKG1_NAME, "LKG1 dec",LicenseKeyType.Unique,
+ createLicenseKeyGroup("vlm1Id", null, lkg1_id, LKG1_NAME, "LKG1 dec",
+ LicenseKeyType.Unique,
new MultiChoiceOrOther<>(opScopeChoices, null));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
lkg.setStartDate(LocalDate.now().format(formatter));
lkg.setExpiryDate(LocalDate.now().minusDays(2L).format(formatter));
- vendorLicenseManagerImpl.updateLicenseKeyGroup(lkg, USER1);
+ vendorLicenseManagerImpl.updateLicenseKeyGroup(lkg);
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), VendorLicenseErrorCodes.DATE_RANGE_INVALID);
@@ -337,11 +335,12 @@ public class LicenseKeyGroupTest {
opScopeChoices.add(OperationalScope.CPU);
opScopeChoices.add(OperationalScope.Network_Wide);
LicenseKeyGroupEntity lkg =
- createLicenseKeyGroup("vlm1Id", null, lkg1_id,LKG1_NAME, "LKG1 dec",LicenseKeyType.Unique,
+ createLicenseKeyGroup("vlm1Id", null, lkg1_id, LKG1_NAME, "LKG1 dec",
+ LicenseKeyType.Unique,
new MultiChoiceOrOther<>(opScopeChoices, null));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
lkg.setExpiryDate(LocalDate.now().plusDays(2L).format(formatter));
- vendorLicenseManagerImpl.updateLicenseKeyGroup(lkg, USER1);
+ vendorLicenseManagerImpl.updateLicenseKeyGroup(lkg);
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), VendorLicenseErrorCodes.DATE_RANGE_INVALID);
@@ -358,12 +357,13 @@ public class LicenseKeyGroupTest {
opScopeChoices.add(OperationalScope.CPU);
opScopeChoices.add(OperationalScope.Network_Wide);
LicenseKeyGroupEntity lkg =
- createLicenseKeyGroup("vlm1Id", null,lkg1_id, LKG1_NAME, "LKG1 dec",LicenseKeyType.Unique,
+ createLicenseKeyGroup("vlm1Id", null, lkg1_id, LKG1_NAME, "LKG1 dec",
+ LicenseKeyType.Unique,
new MultiChoiceOrOther<>(opScopeChoices, null));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
lkg.setStartDate(LocalDate.now().format(formatter));
lkg.setExpiryDate(LocalDate.now().format(formatter));
- vendorLicenseManagerImpl.updateLicenseKeyGroup(lkg, USER1);
+ vendorLicenseManagerImpl.updateLicenseKeyGroup(lkg);
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), VendorLicenseErrorCodes.DATE_RANGE_INVALID);
@@ -371,9 +371,10 @@ public class LicenseKeyGroupTest {
}
@Test
- public void testListlistLicenseKeyGroups(){
+ public void testListlistLicenseKeyGroups() {
- MultiChoiceOrOther<OperationalScope> multiChoiceOrOther = new MultiChoiceOrOther<OperationalScope>();
+ MultiChoiceOrOther<OperationalScope> multiChoiceOrOther =
+ new MultiChoiceOrOther<OperationalScope>();
Set<OperationalScope> opScopeChoices = new HashSet<>();
opScopeChoices.add(OperationalScope.Core);
opScopeChoices.add(OperationalScope.CPU);
@@ -382,34 +383,25 @@ public class LicenseKeyGroupTest {
multiChoiceOrOther.setOther("Other");
doReturn(Arrays.asList(
- createLicenseKeyGroup(vlm1_id,VERSION01, lkg1_id, LKG1_NAME,"LKG1 dec", LicenseKeyType.Universal,
+ createLicenseKeyGroup(vlm1_id, VERSION01, lkg1_id, LKG1_NAME, "LKG1 dec",
+ LicenseKeyType.Universal,
multiChoiceOrOther),
- createLicenseKeyGroup(vlm1_id,VERSION01, lkg2_id, LKG2_NAME,"LKG2 dec", LicenseKeyType
+ createLicenseKeyGroup(vlm1_id, VERSION01, lkg2_id, LKG2_NAME, "LKG2 dec", LicenseKeyType
.Universal, multiChoiceOrOther)))
- .when(vendorLicenseFacade).listLicenseKeyGroups(vlm1_id, VERSION01, USER1);
+ .when(vendorLicenseFacade).listLicenseKeyGroups(vlm1_id, VERSION01);
Collection<LicenseKeyGroupEntity> LKGs =
- vendorLicenseManagerImpl.listLicenseKeyGroups(vlm1_id, VERSION01, USER1);
+ vendorLicenseManagerImpl.listLicenseKeyGroups(vlm1_id, VERSION01);
- verify(vendorLicenseFacade).listLicenseKeyGroups(vlm1_id, VERSION01, USER1);
+ verify(vendorLicenseFacade).listLicenseKeyGroups(vlm1_id, VERSION01);
Assert.assertEquals(LKGs.size(), 2);
LKGs.forEach(lkg -> Assert.assertTrue(lkg.getId().matches(lkg1_id + "|" + lkg2_id)));
}
@Test
- public void testGetLicenseKeyGroup(){
- VersionInfo versionInfo = new VersionInfo();
- versionInfo.setActiveVersion(VERSION01);
- versionInfo.setLockingUser(USER1);
- ArrayList<Version> viewable = new ArrayList<Version>();
- viewable.add(VERSION01);
- versionInfo.setViewableVersions(viewable);
- versionInfo.setActiveVersion(VERSION01);
-
- doReturn(versionInfo).when(vendorLicenseManagerImpl).getVersionInfo(vlm1_id,
- VersionableEntityAction.Read, USER1);
-
- MultiChoiceOrOther<OperationalScope> multiChoiceOrOther = new MultiChoiceOrOther<OperationalScope>();
+ public void testGetLicenseKeyGroup() {
+ MultiChoiceOrOther<OperationalScope> multiChoiceOrOther =
+ new MultiChoiceOrOther<OperationalScope>();
Set<OperationalScope> opScopeChoices = new HashSet<>();
opScopeChoices.add(OperationalScope.Core);
opScopeChoices.add(OperationalScope.CPU);
@@ -417,35 +409,24 @@ public class LicenseKeyGroupTest {
multiChoiceOrOther.setChoices(opScopeChoices);
multiChoiceOrOther.setOther("Other");
- LicenseKeyGroupEntity lkg = createLicenseKeyGroup(vlm1_id,VERSION01, lkg1_id, LKG1_NAME,
+ LicenseKeyGroupEntity lkg = createLicenseKeyGroup(vlm1_id, VERSION01, lkg1_id, LKG1_NAME,
"LKG1 dec", LicenseKeyType.Universal, multiChoiceOrOther);
doReturn(lkg).when(licenseKeyGroupDao).get(anyObject());
- LicenseKeyGroupEntity lkgRetrived = vendorLicenseManagerImpl.getLicenseKeyGroup(lkg,USER1);
+ LicenseKeyGroupEntity lkgRetrived = vendorLicenseManagerImpl.getLicenseKeyGroup(lkg);
verify(licenseKeyGroupDao).get(lkg);
- Assert.assertEquals(lkgRetrived.getId(),lkg.getId());
- Assert.assertEquals(lkgRetrived.getVendorLicenseModelId(),lkg.getVendorLicenseModelId());
- Assert.assertEquals(lkgRetrived.getVersion(),lkg.getVersion());
+ Assert.assertEquals(lkgRetrived.getId(), lkg.getId());
+ Assert.assertEquals(lkgRetrived.getVendorLicenseModelId(), lkg.getVendorLicenseModelId());
+ Assert.assertEquals(lkgRetrived.getVersion(), lkg.getVersion());
}
@Test
public void testDeleteLicenseKeyGroup() {
-
- VersionInfo versionInfo = new VersionInfo();
- versionInfo.setActiveVersion(VERSION01);
- versionInfo.setLockingUser(USER1);
- ArrayList<Version> viewable = new ArrayList<Version>();
- viewable.add(VERSION01);
- versionInfo.setViewableVersions(viewable);
-
- doReturn(versionInfo).when(vendorLicenseManagerImpl).getVersionInfo(vlm1_id,
- VersionableEntityAction.Write, USER1);
-
-
- MultiChoiceOrOther<OperationalScope> multiChoiceOrOther = new MultiChoiceOrOther<OperationalScope>();
+ MultiChoiceOrOther<OperationalScope> multiChoiceOrOther =
+ new MultiChoiceOrOther<OperationalScope>();
Set<OperationalScope> opScopeChoices = new HashSet<>();
opScopeChoices.add(OperationalScope.Core);
opScopeChoices.add(OperationalScope.CPU);
@@ -453,26 +434,26 @@ public class LicenseKeyGroupTest {
multiChoiceOrOther.setChoices(opScopeChoices);
multiChoiceOrOther.setOther("Other");
- LicenseKeyGroupEntity lkg = createLicenseKeyGroup(vlm1_id,VERSION01, lkg1_id, LKG1_NAME,
+ LicenseKeyGroupEntity lkg = createLicenseKeyGroup(vlm1_id, VERSION01, lkg1_id, LKG1_NAME,
"LKG1 dec", LicenseKeyType.Universal, multiChoiceOrOther);
lkg.setReferencingFeatureGroups(new HashSet<>());
doReturn(lkg).when(licenseKeyGroupDao).get(anyObject());
- doNothing().when(vendorLicenseManagerImpl).deleteChildLimits(vlm1_id,VERSION01,lkg1_id,USER1);
+ doNothing().when(vendorLicenseManagerImpl).deleteChildLimits(vlm1_id, VERSION01, lkg1_id);
- doNothing().when(vendorLicenseManagerImpl).deleteUniqueName(anyObject(),anyObject(),
- anyObject(),anyObject());
+ doNothing().when(vendorLicenseManagerImpl).deleteUniqueName(anyObject(), anyObject(),
+ anyObject(), anyObject());
- vendorLicenseManagerImpl.deleteLicenseKeyGroup(lkg, USER1);
+ vendorLicenseManagerImpl.deleteLicenseKeyGroup(lkg);
verify(licenseKeyGroupDao).delete(lkg);
- verify(vendorLicenseFacade).updateVlmLastModificationTime(vlm1_id,VERSION01);
}
- public static LicenseKeyGroupEntity createLicenseKeyGroup(String vlmId, Version version,String id,
+ public static LicenseKeyGroupEntity createLicenseKeyGroup(String vlmId, Version version,
+ String id,
String name, String desc,
LicenseKeyType type,
MultiChoiceOrOther<OperationalScope> operationalScope) {
@@ -525,7 +506,7 @@ public class LicenseKeyGroupTest {
vlm1Id = vendorLicenseManager.createVendorLicenseModel(VendorLicenseModelTest
.createVendorLicenseModel("vendor1 name " + CommonMethods.nextUuId(), "vlm1Id dec",
- "icon1"), USER1).getId();
+ "icon1")1).getId();
vlm2Id = vendorLicenseManager.createVendorLicenseModel(VendorLicenseModelTest
.createVendorLicenseModel("vendor2 name " + CommonMethods.nextUuId(), "vlm2 dec", "icon2"),
USER1).getId();
@@ -545,7 +526,7 @@ public class LicenseKeyGroupTest {
LicenseKeyGroupEntity
lkg1 = createLicenseKeyGroup(vlmId, VERSION01, name, "LKG1 dec", LicenseKeyType.One_Time,
new MultiChoiceOrOther<>(opScopeChoices, null));
- String lkg1Id = vendorLicenseManager.createLicenseKeyGroup(lkg1, USER1).getId();
+ String lkg1Id = vendorLicenseManager.createLicenseKeyGroup(lkg11).getId();
lkg1.setId(lkg1Id);
LicenseKeyGroupEntity loadedLkg1 = licenseKeyGroupDao.get(lkg1);
@@ -560,7 +541,7 @@ public class LicenseKeyGroupTest {
createLicenseKeyGroup(vlm1Id, VERSION01, LKG1_NAME, "LKG1 dec", LicenseKeyType.One_Time,
new MultiChoiceOrOther<>(Collections.singleton(OperationalScope.Other),
"other op scope"));
- vendorLicenseManager.createLicenseKeyGroup(lkg1, USER1).getId();
+ vendorLicenseManager.createLicenseKeyGroup(lkg11).getId();
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), UniqueValueUtil.UNIQUE_VALUE_VIOLATION);
@@ -581,9 +562,9 @@ public class LicenseKeyGroupTest {
lkg1.setOperationalScope(new MultiChoiceOrOther<>(opScopeChoices, "op scope1 updated"));
lkg1.setDescription("LKG1 dec updated");
- vendorLicenseManager.updateLicenseKeyGroup(lkg1, USER1);
+ vendorLicenseManager.updateLicenseKeyGroup(lkg11);
- LicenseKeyGroupEntity loadedLkg1 = vendorLicenseManager.getLicenseKeyGroup(lkg1, USER1);
+ LicenseKeyGroupEntity loadedLkg1 = vendorLicenseManager.getLicenseKeyGroup(lkg11);
Assert.assertTrue(loadedLkg1.equals(lkg1));
}
@@ -595,11 +576,11 @@ public class LicenseKeyGroupTest {
LicenseKeyGroupEntity lkg2 =
createLicenseKeyGroup(vlm1Id, VERSION01, "LKG2", "LKG2 dec", LicenseKeyType.Universal,
new MultiChoiceOrOther<>(opScopeChoices, null));
- lkg2Id = vendorLicenseManager.createLicenseKeyGroup(lkg2, USER1).getId();
+ lkg2Id = vendorLicenseManager.createLicenseKeyGroup(lkg21).getId();
lkg2.setId(lkg2Id);
Collection<LicenseKeyGroupEntity> loadedLkgs =
- vendorLicenseManager.listLicenseKeyGroups(vlm1Id, null, USER1);
+ vendorLicenseManager.listLicenseKeyGroups(vlm1Id, null1);
Assert.assertEquals(loadedLkgs.size(), 2);
for (LicenseKeyGroupEntity loadedLkg : loadedLkgs) {
if (lkg2Id.equals(loadedLkg.getId())) {
@@ -611,7 +592,7 @@ public class LicenseKeyGroupTest {
@Test(dependsOnMethods = {"listTest"})
public void deleteTest() {
vendorLicenseManager
- .deleteLicenseKeyGroup(new LicenseKeyGroupEntity(vlm1Id, VERSION01, lkg1Id), USER1);
+ .deleteLicenseKeyGroup(new LicenseKeyGroupEntity(vlm1Id, VERSION01, lkg1Id)1);
LicenseKeyGroupEntity loadedLkg1 =
licenseKeyGroupDao.get(new LicenseKeyGroupEntity(vlm1Id, VERSION01, lkg1Id));
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseModelTest.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseModelTest.java
index 195fa5d4da..d1df147a60 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseModelTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseModelTest.java
@@ -1,12 +1,12 @@
package org.openecomp.sdc.vendorlicense.impl;
-import org.junit.rules.ExpectedException;
-import org.openecomp.core.util.UniqueValueUtil;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.Spy;
import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
-import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.common.errors.ErrorCategory;
-import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDao;
@@ -14,50 +14,17 @@ import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDao;
import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao;
import org.openecomp.sdc.vendorlicense.dao.LimitDao;
import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDao;
-import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther;
-import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseTerm;
import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
-import org.openecomp.sdc.vendorlicense.types.VersionedVendorLicenseModel;
-import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
-import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo;
import org.openecomp.sdc.versioning.VersioningManager;
-import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.dao.types.VersionStatus;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
-import org.testng.annotations.BeforeMethod;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Captor;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.mockito.Spy;
-import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.verify;
-import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE;
/**
@@ -93,9 +60,6 @@ public class VendorLicenseModelTest {
private LicenseKeyGroupDao licenseKeyGroupDaoMcok;
@Mock
private LimitDao limitDaoMcok;
- @Mock
- private ActivityLogManager activityLogManagerMcok;
-
@Spy
@InjectMocks
@@ -112,159 +76,19 @@ public class VendorLicenseModelTest {
}
@Test
- public void testCheckout() {
-
- doReturn(VERSION01).when(versioningManagerMcok)
- .checkout(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vlm1_id, USER1);
-
- vendorLicenseManager.checkout(vlm1_id, USER1);
-
- Assert.assertEquals(VERSION01.getStatus(), VersionStatus.Locked);
- verify(vendorLicenseFacadeMcok).updateVlmLastModificationTime(vlm1_id, VERSION01);
-
- verify(versioningManagerMcok)
- .checkout(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vlm1_id, USER1);
-
- verify(activityLogManagerMcok).addActionLog(activityLogEntityArg.capture(), eq(USER1));
- ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
- Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION01.getMajor() + 1));
- Assert.assertTrue(activityLogEntity.isSuccess());
- }
-
- @Test
- public void testUndoCheckout() {
- Version existingVersion = new Version(0, 2);
- doReturn(existingVersion).when(versioningManagerMcok).undoCheckout(
- VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vlm1_id, USER1);
-
- vendorLicenseManager.undoCheckout(vlm1_id, USER1);
-
- verify(vendorLicenseFacadeMcok).updateVlmLastModificationTime(vlm1_id, existingVersion);
- }
-
- @Test
- public void testCheckin() {
-
- doReturn(VERSION10).when(vendorLicenseFacadeMcok).checkin(vlm1_id, USER1);
-
- vendorLicenseManager.checkin(vlm1_id, USER1);
- verify(activityLogManagerMcok).addActionLog(activityLogEntityArg.capture(), eq(USER1));
- ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
- Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION10.getMajor() + 1));
- verify(vendorLicenseFacadeMcok).checkin(vlm1_id, USER1);
-
- }
-
- @Test
- public void testSubmit() {
-
- doReturn(VERSION10).when(vendorLicenseFacadeMcok).submit(vlm1_id, USER1);
-
- vendorLicenseManager.submit(vlm1_id, USER1);
- verify(activityLogManagerMcok).addActionLog(activityLogEntityArg.capture(), eq(USER1));
- ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
- Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION10.getMajor()));
- verify(vendorLicenseFacadeMcok).submit(vlm1_id, USER1);
-
- }
-
- @Test
- public void testListWhenNone() {
- doReturn(new HashMap<>()).when(versioningManagerMcok).listEntitiesVersionInfo
- (VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, USER1, VersionableEntityAction.Read);
- Collection<VersionedVendorLicenseModel> vlms = vendorLicenseManager.listVendorLicenseModels
- (null, USER1);
- Assert.assertEquals(vlms.size(), 0);
- }
-
- @Test
- public void testList() {
-
- Map<String, VersionInfo> vlmsTobeReturned = new HashMap<>();
-
- VersionInfo versionInfo1 = new VersionInfo();
- versionInfo1.setActiveVersion(VERSION01);
- vlmsTobeReturned.put(vlm1_id, versionInfo1);
-
- VersionInfo versionInfo2 = new VersionInfo();
- versionInfo2.setActiveVersion(VERSION10);
- vlmsTobeReturned.put(vlm2_id, versionInfo2);
-
- doReturn(vlmsTobeReturned).when(versioningManagerMcok).listEntitiesVersionInfo
- (VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, USER1, VersionableEntityAction.Read);
-
- VendorLicenseModelEntity vlm1 = new VendorLicenseModelEntity(vlm1_id, VERSION01);
- vlm1.setWritetimeMicroSeconds(8L);
- doReturn(vlm1).when(vendorLicenseModelDaoMcok).get(any(VendorLicenseModelEntity.class));
-
- Collection<VersionedVendorLicenseModel> vlms = vendorLicenseManager.listVendorLicenseModels
- (null, USER1);
- Assert.assertEquals(vlms.size(), 2);
- }
-
- @Test
- public void testListFinalsWhenNone() {
-
- Map<String, VersionInfo> vspsTobeReturned = new HashMap<>();
-
- VersionInfo versionInfo1 = new VersionInfo();
- versionInfo1.setActiveVersion(VERSION01);
- vspsTobeReturned.put(vlm1_id, versionInfo1);
-
- VersionInfo versionInfo2 = new VersionInfo();
- versionInfo2.setActiveVersion(VERSION10);
- vspsTobeReturned.put(vlm2_id, versionInfo2);
-
- doReturn(vspsTobeReturned).when(versioningManagerMcok).listEntitiesVersionInfo
- (VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, USER1, VersionableEntityAction.Read);
-
- Collection<VersionedVendorLicenseModel> vlms = vendorLicenseManager.listVendorLicenseModels
- (VersionStatus.Final.name(), USER1);
- Assert.assertEquals(vlms.size(), 0);
- }
-
- @Test
- public void testListFinals() {
- Map<String, VersionInfo> vlmsTobeReturned = new HashMap<>();
-
- VersionInfo versionInfo1 = new VersionInfo();
- versionInfo1.setActiveVersion(VERSION01);
- vlmsTobeReturned.put(vlm1_id, versionInfo1);
-
- VersionInfo versionInfo2 = new VersionInfo();
-
- versionInfo2.setActiveVersion(new Version(1, 3));
- versionInfo2.setLatestFinalVersion(VERSION10);
- vlmsTobeReturned.put(vlm2_id, versionInfo2);
-
- doReturn(vlmsTobeReturned).when(versioningManagerMcok).listEntitiesVersionInfo
- (VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, USER1, VersionableEntityAction.Read);
-
- VendorLicenseModelEntity vlm1 = new VendorLicenseModelEntity(vlm1_id, VERSION01);
- vlm1.setWritetimeMicroSeconds(8L);
- doReturn(vlm1).when(vendorLicenseModelDaoMcok).get(any(VendorLicenseModelEntity.class));
-
- Collection<VersionedVendorLicenseModel> vlms = vendorLicenseManager.listVendorLicenseModels
- (VersionStatus.Final.name(), USER1);
-
- Assert.assertEquals(vlms.size(), 1);
+ public void testValidate() {
+ // TODO: 8/13/2017
+ vendorLicenseManager.validate(vlm1_id, null);
+ verify(vendorLicenseFacadeMcok).validate(vlm1_id, null);
}
@Test
public void testCreate() {
-
VendorLicenseModelEntity vlmEntity = new VendorLicenseModelEntity(vlm1_id, VERSION01);
- doReturn(vlmEntity).when(vendorLicenseFacadeMcok).createVendorLicenseModel(vlmEntity, USER1);
-
- vendorLicenseManager.createVendorLicenseModel(vlmEntity, USER1);
-
- verify(vendorLicenseFacadeMcok).createVendorLicenseModel(vlmEntity, USER1);
- verify(activityLogManagerMcok).addActionLog(activityLogEntityArg.capture(), eq(USER1));
- ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
- Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION01.getMajor() + 1));
- Assert.assertTrue(activityLogEntity.isSuccess());
+ vendorLicenseManager.createVendorLicenseModel(vlmEntity);
+ verify(vendorLicenseModelDaoMcok).create(vlmEntity);
}
@Test
@@ -277,14 +101,6 @@ public class VendorLicenseModelTest {
existingVlm.setVendorName("VLM1");
existingVlm.setDescription("decription");
- VersionInfo versionInfo = new VersionInfo();
- versionInfo.setActiveVersion(VERSION01);
-
- doReturn(versionInfo).when(vendorLicenseManager).getVersionInfo(existingVlm.getId(),
- VersionableEntityAction.Write, USER1);
-
- doReturn(VERSION01).when(vendorLicenseManager).resloveVersion(vlm1_id,null, versionInfo, USER1);
-
doReturn("VLM1").when(vendorLicenseModelDaoMcok).get(existingVlm);
VendorLicenseModelEntity updatedVlm = new VendorLicenseModelEntity();
@@ -302,21 +118,20 @@ public class VendorLicenseModelTest {
doReturn(existingVlm).when(vendorLicenseModelDaoMcok).get(any(VendorLicenseModelEntity.class));
- vendorLicenseManager.updateVendorLicenseModel(updatedVlm, USER1);
+ vendorLicenseManager.updateVendorLicenseModel(updatedVlm);
verify(vendorLicenseModelDaoMcok).update(updatedVlm);
- verify(vendorLicenseFacadeMcok).updateVlmLastModificationTime(vlm1_id, VERSION01);
}
@Test
- public void testGetVendorLicenseModel(){
- vendorLicenseManager.getVendorLicenseModel(vlm1_id,VERSION01,USER1);
- verify(vendorLicenseFacadeMcok).getVendorLicenseModel(vlm1_id,VERSION01,USER1);
+ public void testGetVendorLicenseModel() {
+ vendorLicenseManager.getVendorLicenseModel(vlm1_id, VERSION01);
+ verify(vendorLicenseFacadeMcok).getVendorLicenseModel(vlm1_id, VERSION01);
}
@Test(expectedExceptions = UnsupportedOperationException.class)
public void testDeleteVLMUnsupportedOperation() {
- vendorLicenseManager.deleteVendorLicenseModel(vlm1_id, USER1);
+ vendorLicenseManager.deleteVendorLicenseModel(vlm1_id, null); // TODO: 8/13/2017
}
@@ -324,7 +139,7 @@ public class VendorLicenseModelTest {
// public void testGetNonExistingVersion_negative() {
// Version notExistversion = new Version(43, 8);
// doReturn(null).when(vspInfoDaoMock).get(any(VspDetails.class));
-// vendorSoftwareProductManager.getVsp(VSP_ID, notExistversion, USER1);
+// vendorSoftwareProductManager.getVsp(VSP_ID, notExistversion);
// }
} \ No newline at end of file
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceTest.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceTest.java
index ec50c96f74..c20d96ac36 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/test/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceTest.java
@@ -20,22 +20,8 @@
package org.openecomp.sdc.vendorlicense.licenseartifacts.impl;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringUtils;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.sdc.vendorlicense.ArtifactTestUtils;
-import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
-import org.openecomp.sdc.vendorlicense.dao.types.EntitlementMetric;
-import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
public class VendorLicenseArtifactsServiceTest extends ArtifactTestUtils {