aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend/openecomp-sdc-vendor-license-manager
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-license-manager')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseManager.java79
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerFactoryImpl.java6
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java773
-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
12 files changed, 986 insertions, 1651 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseManager.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseManager.java
index a76b9b865d..9184afe823 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseManager.java
@@ -28,8 +28,6 @@ import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementModel;
import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity;
import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
-import org.openecomp.sdc.vendorlicense.errors.LimitErrorBuilder;
-import org.openecomp.sdc.vendorlicense.types.VersionedVendorLicenseModel;
import org.openecomp.sdc.versioning.dao.types.Version;
import java.util.Collection;
@@ -37,88 +35,71 @@ import java.util.Set;
public interface VendorLicenseManager {
- void checkout(String vendorLicenseModelId, String user);
+ void validate(String vendorLicenseModelId, Version version);
- void undoCheckout(String vendorLicenseModelId, String user);
+ VendorLicenseModelEntity createVendorLicenseModel(VendorLicenseModelEntity licenseModel);
- void checkin(String vendorLicenseModelId, String user);
+ void updateVendorLicenseModel(VendorLicenseModelEntity licenseModel);
- void submit(String vendorLicenseModelId, String user);
+ VendorLicenseModelEntity getVendorLicenseModel(String vlmId, Version version);
- Collection<VersionedVendorLicenseModel> listVendorLicenseModels(String versionFilter,
- String user);
+ void deleteVendorLicenseModel(String vlmId, Version version);
- VendorLicenseModelEntity createVendorLicenseModel(VendorLicenseModelEntity licenseModel,
- String user);
- void updateVendorLicenseModel(VendorLicenseModelEntity licenseModel, String user);
+ Collection<LicenseAgreementEntity> listLicenseAgreements(String vlmId, Version version);
- VersionedVendorLicenseModel getVendorLicenseModel(String vlmId, Version version, String user);
-
- void deleteVendorLicenseModel(String vlmId, String user);
-
-
- Collection<LicenseAgreementEntity> listLicenseAgreements(String vlmId, Version version,
- String user);
-
- LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement,
- String user);
+ LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement);
void updateLicenseAgreement(LicenseAgreementEntity licenseAgreement,
- Set<String> addedFeatureGroupIds, Set<String> removedFeatureGroupIds,
- String user);
+ Set<String> addedFeatureGroupIds, Set<String> removedFeatureGroupIds);
LicenseAgreementModel getLicenseAgreementModel(String vlmId, Version version,
- String licenseAgreementId, String user);
+ String licenseAgreementId);
- void deleteLicenseAgreement(String vlmId, Version version, String licenseAgreementId, String user);
+ void deleteLicenseAgreement(String vlmId, Version version, String licenseAgreementId);
- Collection<FeatureGroupEntity> listFeatureGroups(String vlmId, Version version, String user);
+ Collection<FeatureGroupEntity> listFeatureGroups(String vlmId, Version version);
- FeatureGroupEntity createFeatureGroup(FeatureGroupEntity fg, String user);
+ FeatureGroupEntity createFeatureGroup(FeatureGroupEntity fg);
void updateFeatureGroup(FeatureGroupEntity featureGroup,
Set<String> addedLicenseKeyGroups, Set<String> removedLicenseKeyGroups,
- Set<String> addedEntitlementPools, Set<String> removedEntitlementPools,
- String user);
-
- FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup, String user);
+ Set<String> addedEntitlementPools, Set<String> removedEntitlementPools);
- void deleteFeatureGroup(FeatureGroupEntity featureGroup, String user);
+ FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup);
+ void deleteFeatureGroup(FeatureGroupEntity featureGroup);
- Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version,
- String user);
- EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool, String user);
+ Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version);
- void updateEntitlementPool(EntitlementPoolEntity entitlementPool, String user);
+ EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool);
- EntitlementPoolEntity getEntitlementPool(EntitlementPoolEntity entitlementPool, String user);
+ void updateEntitlementPool(EntitlementPoolEntity entitlementPool);
- void deleteEntitlementPool(EntitlementPoolEntity entitlementPool, String user);
+ EntitlementPoolEntity getEntitlementPool(EntitlementPoolEntity entitlementPool);
+ void deleteEntitlementPool(EntitlementPoolEntity entitlementPool);
- Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version,
- String user);
- LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user);
+ Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version);
- void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user);
+ LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup);
- LicenseKeyGroupEntity getLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user);
+ void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup);
- void deleteLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user);
+ LicenseKeyGroupEntity getLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup);
- LimitEntity createLimit(LimitEntity limitEntity, String user);
+ void deleteLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup);
- Collection<LimitEntity> listLimits(String vlmId, Version version, String epLkgId, String user);
+ LimitEntity createLimit(LimitEntity limitEntity);
- void deleteLimit(LimitEntity limitEntity, String user);
+ Collection<LimitEntity> listLimits(String vlmId, Version version, String epLkgId);
- void updateLimit(LimitEntity limitEntity, String user);
+ void deleteLimit(LimitEntity limitEntity);
- LimitEntity getLimit(LimitEntity entitlementPool, String user);
+ void updateLimit(LimitEntity limitEntity);
+ LimitEntity getLimit(LimitEntity entitlementPool);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerFactoryImpl.java
index 152ddd0e13..472473fdb0 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerFactoryImpl.java
@@ -1,6 +1,5 @@
package org.openecomp.sdc.vendorlicense.impl;
-import org.openecomp.sdc.activityLog.ActivityLogManagerFactory;
import org.openecomp.sdc.vendorlicense.VendorLicenseManager;
import org.openecomp.sdc.vendorlicense.VendorLicenseManagerFactory;
import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDaoFactory;
@@ -10,22 +9,19 @@ import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDaoFactory;
import org.openecomp.sdc.vendorlicense.dao.LimitDaoFactory;
import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDaoFactory;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory;
-import org.openecomp.sdc.versioning.VersioningManagerFactory;
/**
* Created by ayalaben on 8/3/2017
*/
-public class VendorLicenseManagerFactoryImpl extends VendorLicenseManagerFactory {
+public class VendorLicenseManagerFactoryImpl extends VendorLicenseManagerFactory {
private static final VendorLicenseManager INSTANCE =
new VendorLicenseManagerImpl(
- VersioningManagerFactory.getInstance().createInterface(),
VendorLicenseFacadeFactory.getInstance().createInterface(),
VendorLicenseModelDaoFactory.getInstance().createInterface(),
LicenseAgreementDaoFactory.getInstance().createInterface(),
FeatureGroupDaoFactory.getInstance().createInterface(),
EntitlementPoolDaoFactory.getInstance().createInterface(),
LicenseKeyGroupDaoFactory.getInstance().createInterface(),
- ActivityLogManagerFactory.getInstance().createInterface(),
LimitDaoFactory.getInstance().createInterface());
@Override
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java
index e07a13c2e8..2489b5a89b 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-license-manager/src/main/java/org/openecomp/sdc/vendorlicense/impl/VendorLicenseManagerImpl.java
@@ -20,16 +20,10 @@
package org.openecomp.sdc.vendorlicense.impl;
-import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE;
-
import org.openecomp.core.util.UniqueValueUtil;
-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.common.errors.ErrorCode;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.logging.types.LoggerConstants;
@@ -57,26 +51,16 @@ import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
import org.openecomp.sdc.vendorlicense.errors.InvalidDateErrorBuilder;
import org.openecomp.sdc.vendorlicense.errors.LimitErrorBuilder;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
-import org.openecomp.sdc.vendorlicense.types.VersionedVendorLicenseModel;
-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.openecomp.sdcrests.activitylog.types.ActivityType;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.List;
-import java.util.Map;
import java.util.Optional;
import java.util.Set;
public class VendorLicenseManagerImpl implements VendorLicenseManager {
- private VersioningManager versioningManager;
private VendorLicenseFacade vendorLicenseFacade;
private VendorLicenseModelDao vendorLicenseModelDao;
private LicenseAgreementDao licenseAgreementDao;
@@ -84,278 +68,134 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager {
private EntitlementPoolDao entitlementPoolDao;
private LicenseKeyGroupDao licenseKeyGroupDao;
private LimitDao limitDao;
- private ActivityLogManager activityLogManager;
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- private static final Logger logger =
- LoggerFactory.getLogger(VendorLicenseManagerImpl.class);
- public VendorLicenseManagerImpl(VersioningManager versioningManager,
- VendorLicenseFacade vendorLicenseFacade,
+ public VendorLicenseManagerImpl(VendorLicenseFacade vendorLicenseFacade,
VendorLicenseModelDao vendorLicenseModelDao,
LicenseAgreementDao licenseAgreementDao,
FeatureGroupDao featureGroupDao,
EntitlementPoolDao entitlementPoolDao,
LicenseKeyGroupDao licenseKeyGroupDao,
- ActivityLogManager activityLogManager,
LimitDao limitDao) {
- this.versioningManager = versioningManager;
this.vendorLicenseFacade = vendorLicenseFacade;
this.vendorLicenseModelDao = vendorLicenseModelDao;
this.licenseAgreementDao = licenseAgreementDao;
this.featureGroupDao = featureGroupDao;
this.entitlementPoolDao = entitlementPoolDao;
this.licenseKeyGroupDao = licenseKeyGroupDao;
- this.activityLogManager = activityLogManager;
this.limitDao = limitDao;
}
- private static void sortVlmListByModificationTimeDescOrder(
- List<VersionedVendorLicenseModel> vendorLicenseModels) {
- vendorLicenseModels.sort((o1, o2) -> o2.getVendorLicenseModel().getWritetimeMicroSeconds()
- .compareTo(o1.getVendorLicenseModel().getWritetimeMicroSeconds()));
- }
-
@Override
- public void checkout(String vendorLicenseModelId, String user) {
-
+ public void validate(String vendorLicenseModelId, Version version) {
mdcDataDebugMessage.debugEntryMessage("VLM id", vendorLicenseModelId);
- Version newVersion = versioningManager
- .checkout(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vendorLicenseModelId, user);
-
- ActivityLogEntity activityLogEntity = new ActivityLogEntity(vendorLicenseModelId, String.valueOf(newVersion.getMajor()+1),
- ActivityType.CHECKOUT.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
-
- newVersion.setStatus(VersionStatus.Locked);
- vendorLicenseFacade.updateVlmLastModificationTime(vendorLicenseModelId, newVersion);
+ vendorLicenseFacade.validate(vendorLicenseModelId, version);
mdcDataDebugMessage.debugExitMessage("VLM id", vendorLicenseModelId);
}
@Override
- public void undoCheckout(String vendorLicenseModelId, String user) {
-
- mdcDataDebugMessage.debugEntryMessage("VLM id", vendorLicenseModelId);
-
- Version newVersion = versioningManager
- .undoCheckout(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vendorLicenseModelId, user);
-
- ActivityLogEntity activityLogEntity =
- new ActivityLogEntity(vendorLicenseModelId, String.valueOf(newVersion.getMajor() + 1),
- ActivityType.UNDO_CHECKOUT.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
-
- vendorLicenseFacade.updateVlmLastModificationTime(vendorLicenseModelId, newVersion);
-
- mdcDataDebugMessage.debugExitMessage("VLM id", vendorLicenseModelId);
- }
-
- @Override
- public void checkin(String vendorLicenseModelId, String user) {
-
- mdcDataDebugMessage.debugEntryMessage("VLM id", vendorLicenseModelId);
-
- Version newVersion = vendorLicenseFacade.checkin(vendorLicenseModelId, user);
-
- ActivityLogEntity activityLogEntity = new ActivityLogEntity(vendorLicenseModelId,
- String.valueOf(newVersion.getMajor()+1), ActivityType.CHECKIN.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
-
- mdcDataDebugMessage.debugExitMessage("VLM id", vendorLicenseModelId);
- }
-
- @Override
- public void submit(String vendorLicenseModelId, String user) {
-
- mdcDataDebugMessage.debugEntryMessage("VLM id", vendorLicenseModelId);
-
- Version newVersion = vendorLicenseFacade.submit(vendorLicenseModelId, user);
-
- ActivityLogEntity activityLogEntity = new ActivityLogEntity(vendorLicenseModelId, String.valueOf(newVersion.getMajor()),
- ActivityType.SUBMIT.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
-
- mdcDataDebugMessage.debugExitMessage("VLM id", vendorLicenseModelId);
- }
-
- @Override
- public Collection<VersionedVendorLicenseModel> listVendorLicenseModels(String versionFilter,
- String user) {
+ public VendorLicenseModelEntity createVendorLicenseModel(
+ VendorLicenseModelEntity vendorLicenseModelEntity) {
mdcDataDebugMessage.debugEntryMessage(null);
- Map<String, VersionInfo> idToVersionsInfo = versioningManager
- .listEntitiesVersionInfo(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, user,
- VersionableEntityAction.Read);
-
- List<VersionedVendorLicenseModel> vendorLicenseModels = new ArrayList<>();
- for (Map.Entry<String, VersionInfo> entry : idToVersionsInfo.entrySet()) {
- VersionInfo versionInfo = entry.getValue();
- if (versionFilter != null && versionFilter.equals(VersionStatus.Final.name())) {
- if (versionInfo.getLatestFinalVersion() == null) {
- continue;
- }
- versionInfo.setActiveVersion(versionInfo.getLatestFinalVersion());
- versionInfo.setStatus(VersionStatus.Final);
- versionInfo.setLockingUser(null);
- }
-
- Version version = versionInfo.getActiveVersion();
- if (user.equals(versionInfo.getLockingUser())) {
- version.setStatus(VersionStatus.Locked);
- }
-
- try {
- VendorLicenseModelEntity vlm =
- vendorLicenseModelDao.get(new VendorLicenseModelEntity(entry.getKey(), version));
- if (vlm != null) {
- VersionedVendorLicenseModel versionedVlm = new VersionedVendorLicenseModel();
- versionedVlm.setVendorLicenseModel(vlm);
- versionedVlm.setVersionInfo(versionInfo);
- vendorLicenseModels.add(versionedVlm);
- }
- }catch(RuntimeException rte){
- logger.error("Error trying to retrieve vlm["+entry.getKey()+"] version["+version.toString
- ()+"] " +
- "message:"+rte
- .getMessage());
- }
- }
-
- sortVlmListByModificationTimeDescOrder(vendorLicenseModels);
-
+ vendorLicenseModelDao.create(vendorLicenseModelEntity);
mdcDataDebugMessage.debugExitMessage(null);
- return vendorLicenseModels;
- }
-
- @Override
- public VendorLicenseModelEntity createVendorLicenseModel(VendorLicenseModelEntity vendorLicenseModelEntity, String user) {
-
- VendorLicenseModelEntity vendorLicenseModelCreated = vendorLicenseFacade.createVendorLicenseModel(vendorLicenseModelEntity, user);
-
- ActivityLogEntity activityLogEntity = new ActivityLogEntity(vendorLicenseModelCreated.getId(),
- String.valueOf(vendorLicenseModelCreated.getVersion().getMajor()+1),
- ActivityType.CREATE_NEW.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
- return vendorLicenseModelCreated;
+ return vendorLicenseModelEntity;
}
@Override
- public void updateVendorLicenseModel(VendorLicenseModelEntity vendorLicenseModelEntity,
- String user) {
+ public void updateVendorLicenseModel(VendorLicenseModelEntity vendorLicenseModelEntity) {
mdcDataDebugMessage.debugEntryMessage("VLM id", vendorLicenseModelEntity.getId());
- Version version = resloveVersion(vendorLicenseModelEntity.getId(),null,
- getVersionInfo(vendorLicenseModelEntity.getId(), VersionableEntityAction.Write, user),
- user);
- vendorLicenseModelEntity.setVersion(version);
-
String existingVendorName = vendorLicenseModelDao.get(vendorLicenseModelEntity).getVendorName();
updateUniqueName(VendorLicenseConstants.UniqueValues.VENDOR_NAME, existingVendorName,
- vendorLicenseModelEntity.getVendorName());
+ vendorLicenseModelEntity.getVendorName());
vendorLicenseModelDao.update(vendorLicenseModelEntity);
- vendorLicenseFacade
- .updateVlmLastModificationTime(vendorLicenseModelEntity.getId(), version);
-
mdcDataDebugMessage.debugExitMessage("VLM id", vendorLicenseModelEntity.getId());
}
@Override
- public VersionedVendorLicenseModel getVendorLicenseModel(String vlmId, Version version,
- String user) {
- return vendorLicenseFacade.getVendorLicenseModel(vlmId, version, user);
+ public VendorLicenseModelEntity getVendorLicenseModel(String vlmId, Version version) {
+ return vendorLicenseFacade.getVendorLicenseModel(vlmId, version);
}
@Override
- public void deleteVendorLicenseModel(String vlmId, String user) {
+ public void deleteVendorLicenseModel(String vlmId, Version version) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.DELETE_ENTITY, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.UNSUPPORTED_OPERATION);
+ LoggerTragetServiceName.DELETE_ENTITY, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.UNSUPPORTED_OPERATION);
throw new UnsupportedOperationException(VendorLicenseConstants.UNSUPPORTED_OPERATION_ERROR);
}
@Override
- public Collection<LicenseAgreementEntity> listLicenseAgreements(String vlmId, Version version,
- String user) {
+ public Collection<LicenseAgreementEntity> listLicenseAgreements(String vlmId, Version version) {
mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId);
mdcDataDebugMessage.debugExitMessage("VLM id", vlmId);
- LicenseAgreementEntity licenseAgreementEntity = createLicenseAgreementForList(vlmId, version,
- user);
-// return licenseAgreementDao.list(new LicenseAgreementEntity(vlmId, VersioningUtil
-// .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user), user),
-// null));
- return licenseAgreementDao.list(licenseAgreementEntity);
+ return licenseAgreementDao.list(new LicenseAgreementEntity(vlmId, version, null));
}
@Override
- public LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement,
- String user) {
+ public LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement) {
mdcDataDebugMessage
- .debugEntryMessage("VLM id", licenseAgreement.getVendorLicenseModelId());
+ .debugEntryMessage("VLM id", licenseAgreement.getVendorLicenseModelId());
mdcDataDebugMessage
- .debugExitMessage("VLM id", licenseAgreement.getVendorLicenseModelId());
- return vendorLicenseFacade.createLicenseAgreement(licenseAgreement, user);
+ .debugExitMessage("VLM id", licenseAgreement.getVendorLicenseModelId());
+ return vendorLicenseFacade.createLicenseAgreement(licenseAgreement);
}
@Override
public void updateLicenseAgreement(LicenseAgreementEntity licenseAgreement,
Set<String> addedFeatureGroupIds,
- Set<String> removedFeatureGroupIds, String user) {
+ Set<String> removedFeatureGroupIds) {
mdcDataDebugMessage.debugEntryMessage("VLM id, LA id", licenseAgreement
- .getVendorLicenseModelId(), licenseAgreement.getId());
+ .getVendorLicenseModelId(), licenseAgreement.getId());
- Version version = VersioningUtil.resolveVersion(licenseAgreement.getVersion(),
- getVersionInfo(licenseAgreement.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user);
- licenseAgreement.setVersion(version);
LicenseAgreementEntity retrieved = licenseAgreementDao.get(licenseAgreement);
VersioningUtil
- .validateEntityExistence(retrieved, licenseAgreement, VendorLicenseModelEntity.ENTITY_TYPE);
+ .validateEntityExistence(retrieved, licenseAgreement, VendorLicenseModelEntity.ENTITY_TYPE);
VersioningUtil.validateContainedEntitiesExistence(new FeatureGroupEntity().getEntityType(),
- removedFeatureGroupIds, retrieved, retrieved.getFeatureGroupIds());
+ removedFeatureGroupIds, retrieved, retrieved.getFeatureGroupIds());
VersioningUtil.validateEntitiesExistence(addedFeatureGroupIds,
- new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(), version, null),
- featureGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
+ new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion(),
+ null),
+ featureGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
updateUniqueName(VendorLicenseConstants.UniqueValues.LICENSE_AGREEMENT_NAME,
- retrieved.getName(), licenseAgreement.getName(), licenseAgreement.getVendorLicenseModelId(),
- licenseAgreement.getVersion().toString());
+ retrieved.getName(), licenseAgreement.getName(), licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion().getId());
licenseAgreementDao.updateColumnsAndDeltaFeatureGroupIds(licenseAgreement, addedFeatureGroupIds,
- removedFeatureGroupIds);
+ removedFeatureGroupIds);
addFeatureGroupsToLicenseAgreementRef(addedFeatureGroupIds, licenseAgreement);
removeFeatureGroupsToLicenseAgreementRef(removedFeatureGroupIds, licenseAgreement);
- vendorLicenseFacade
- .updateVlmLastModificationTime(licenseAgreement.getVendorLicenseModelId(), version);
-
mdcDataDebugMessage.debugExitMessage("VLM id, LA id", licenseAgreement
- .getVendorLicenseModelId(), licenseAgreement.getId());
+ .getVendorLicenseModelId(), licenseAgreement.getId());
}
@Override
public LicenseAgreementModel getLicenseAgreementModel(String vlmId, Version version,
- String licenseAgreementId, String user) {
+ String licenseAgreementId) {
mdcDataDebugMessage.debugEntryMessage("VLM id, LA id", vlmId, licenseAgreementId);
mdcDataDebugMessage.debugExitMessage("VLM id, LA id", vlmId, licenseAgreementId);
- return vendorLicenseFacade.getLicenseAgreementModel(vlmId, version, licenseAgreementId, user);
+ return vendorLicenseFacade.getLicenseAgreementModel(vlmId, version, licenseAgreementId);
}
@Override
- public void deleteLicenseAgreement(String vlmId, Version version, String licenseAgreementId,
- String user) {
+ public void deleteLicenseAgreement(String vlmId, Version version, String licenseAgreementId) {
mdcDataDebugMessage.debugEntryMessage("VLM id, LA id", vlmId, licenseAgreementId);
- version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Write, user), user);
LicenseAgreementEntity input =
- new LicenseAgreementEntity(vlmId, version, licenseAgreementId);
+ new LicenseAgreementEntity(vlmId, version, licenseAgreementId);
LicenseAgreementEntity retrieved = licenseAgreementDao.get(input);
VersioningUtil.validateEntityExistence(retrieved, input, VendorLicenseModelEntity.ENTITY_TYPE);
@@ -364,29 +204,25 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager {
licenseAgreementDao.delete(retrieved);
deleteUniqueName(VendorLicenseConstants.UniqueValues.LICENSE_AGREEMENT_NAME,
- retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
- retrieved.getName());
-
- vendorLicenseFacade
- .updateVlmLastModificationTime(input.getVendorLicenseModelId(), input.getVersion());
+ retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
+ retrieved.getName());
mdcDataDebugMessage.debugExitMessage("VLM id, LA id", vlmId, licenseAgreementId);
}
@Override
- public Collection<FeatureGroupEntity> listFeatureGroups(String vlmId, Version version,
- String user) {
+ public Collection<FeatureGroupEntity> listFeatureGroups(String vlmId, Version version) {
mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId);
mdcDataDebugMessage.debugExitMessage("VLM id", vlmId);
- return vendorLicenseFacade.listFeatureGroups(vlmId, version, user);
+ return vendorLicenseFacade.listFeatureGroups(vlmId, version);
}
@Override
- public FeatureGroupEntity createFeatureGroup(FeatureGroupEntity featureGroup, String user) {
+ public FeatureGroupEntity createFeatureGroup(FeatureGroupEntity featureGroup) {
mdcDataDebugMessage
- .debugEntryMessage("VLM id", featureGroup.getVendorLicenseModelId());
+ .debugEntryMessage("VLM id", featureGroup.getVendorLicenseModelId());
mdcDataDebugMessage.debugExitMessage("VLM id", featureGroup.getId());
- return vendorLicenseFacade.createFeatureGroup(featureGroup, user);
+ return vendorLicenseFacade.createFeatureGroup(featureGroup);
}
@Override
@@ -394,35 +230,31 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager {
Set<String> addedLicenseKeyGroups,
Set<String> removedLicenseKeyGroups,
Set<String> addedEntitlementPools,
- Set<String> removedEntitlementPools,
- String user) {
+ Set<String> removedEntitlementPools) {
mdcDataDebugMessage.debugEntryMessage("VLM id, FG id", featureGroup
- .getVendorLicenseModelId(), featureGroup.getId());
-
- Version version = VersioningUtil.resolveVersion(featureGroup.getVersion(),
- getVersionInfo(featureGroup.getVendorLicenseModelId(), VersionableEntityAction.Write, user),
- user);
- featureGroup.setVersion(version);
+ .getVendorLicenseModelId(), featureGroup.getId());
FeatureGroupEntity retrieved = featureGroupDao.get(featureGroup);
VersioningUtil
- .validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE);
+ .validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE);
VersioningUtil.validateContainedEntitiesExistence(new LicenseKeyGroupEntity().getEntityType(),
- removedLicenseKeyGroups, retrieved, retrieved.getLicenseKeyGroupIds());
+ removedLicenseKeyGroups, retrieved, retrieved.getLicenseKeyGroupIds());
VersioningUtil.validateContainedEntitiesExistence(new EntitlementPoolEntity().getEntityType(),
- removedEntitlementPools, retrieved, retrieved.getEntitlementPoolIds());
+ removedEntitlementPools, retrieved, retrieved.getEntitlementPoolIds());
VersioningUtil.validateEntitiesExistence(addedLicenseKeyGroups,
- new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), version, null),
- licenseKeyGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
+ new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), featureGroup.getVersion(),
+ null),
+ licenseKeyGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
VersioningUtil.validateEntitiesExistence(addedEntitlementPools,
- new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), version, null),
- entitlementPoolDao, VendorLicenseModelEntity.ENTITY_TYPE);
+ new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), featureGroup.getVersion(),
+ null),
+ entitlementPoolDao, VendorLicenseModelEntity.ENTITY_TYPE);
updateUniqueName(VendorLicenseConstants.UniqueValues.FEATURE_GROUP_NAME,
- retrieved.getName(), featureGroup.getName(), featureGroup.getVendorLicenseModelId(),
- featureGroup.getVersion().toString());
+ retrieved.getName(), featureGroup.getName(), featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion().getId());
addLicenseKeyGroupsToFeatureGroupsRef(addedLicenseKeyGroups, featureGroup);
removeLicenseKeyGroupsToFeatureGroupsRef(removedLicenseKeyGroups, featureGroup);
@@ -430,413 +262,364 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager {
removeEntitlementPoolsToFeatureGroupsRef(removedEntitlementPools, featureGroup);
featureGroupDao.updateFeatureGroup(featureGroup, addedEntitlementPools, removedEntitlementPools,
- addedLicenseKeyGroups, removedLicenseKeyGroups);
-
- vendorLicenseFacade
- .updateVlmLastModificationTime(featureGroup.getVendorLicenseModelId(), version);
+ addedLicenseKeyGroups, removedLicenseKeyGroups);
mdcDataDebugMessage.debugExitMessage("VLM id, FG id", featureGroup
- .getVendorLicenseModelId(), featureGroup.getId());
+ .getVendorLicenseModelId(), featureGroup.getId());
}
@Override
- public FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup, String user) {
+ public FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup) {
mdcDataDebugMessage.debugEntryMessage("VLM id, FG id",
- featureGroup.getVendorLicenseModelId(), featureGroup.getId());
+ featureGroup.getVendorLicenseModelId(), featureGroup.getId());
mdcDataDebugMessage.debugExitMessage("VLM id, FG id",
- featureGroup.getVendorLicenseModelId(), featureGroup.getId());
- return vendorLicenseFacade.getFeatureGroupModel(featureGroup, user);
+ featureGroup.getVendorLicenseModelId(), featureGroup.getId());
+ return vendorLicenseFacade.getFeatureGroupModel(featureGroup);
}
@Override
- public void deleteFeatureGroup(FeatureGroupEntity featureGroup, String user) {
+ public void deleteFeatureGroup(FeatureGroupEntity featureGroup) {
mdcDataDebugMessage.debugEntryMessage("VLM id, FG id",
- featureGroup.getVendorLicenseModelId(), featureGroup.getId());
+ featureGroup.getVendorLicenseModelId(), featureGroup.getId());
- Version version = VersioningUtil.resolveVersion(featureGroup.getVersion(),
- getVersionInfo(featureGroup.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user);
- featureGroup.setVersion(version);
FeatureGroupEntity retrieved = featureGroupDao.get(featureGroup);
VersioningUtil
- .validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE);
+ .validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE);
removeLicenseKeyGroupsToFeatureGroupsRef(retrieved.getLicenseKeyGroupIds(), featureGroup);
removeEntitlementPoolsToFeatureGroupsRef(retrieved.getEntitlementPoolIds(), featureGroup);
for (String licenceAgreementId : retrieved.getReferencingLicenseAgreements()) {
licenseAgreementDao.removeFeatureGroup(
- new LicenseAgreementEntity(featureGroup.getVendorLicenseModelId(), version,
- licenceAgreementId), featureGroup.getId());
+ new LicenseAgreementEntity(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion(),
+ licenceAgreementId), featureGroup.getId());
}
featureGroupDao.delete(featureGroup);
deleteUniqueName(VendorLicenseConstants.UniqueValues.FEATURE_GROUP_NAME,
- retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
- retrieved.getName());
-
- vendorLicenseFacade.updateVlmLastModificationTime(featureGroup.getVendorLicenseModelId(),
- featureGroup.getVersion());
+ retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
+ retrieved.getName());
mdcDataDebugMessage
- .debugExitMessage("VLM id, FG id",
- featureGroup.getVendorLicenseModelId(), featureGroup.getId());
+ .debugExitMessage("VLM id, FG id",
+ featureGroup.getVendorLicenseModelId(), featureGroup.getId());
}
@Override
- public Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version,
- String user) {
+ public Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version) {
mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId);
mdcDataDebugMessage.debugExitMessage("VLM id", vlmId);
- return vendorLicenseFacade.listEntitlementPools(vlmId, version, user);
+ return vendorLicenseFacade.listEntitlementPools(vlmId, version);
}
@Override
- public EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool,
- String user) {
+ public EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool) {
mdcDataDebugMessage
- .debugEntryMessage("VLM id", entitlementPool.getVendorLicenseModelId());
+ .debugEntryMessage("VLM id", entitlementPool.getVendorLicenseModelId());
mdcDataDebugMessage
- .debugExitMessage("VLM id", entitlementPool.getVendorLicenseModelId());
+ .debugExitMessage("VLM id", entitlementPool.getVendorLicenseModelId());
entitlementPool.setStartDate(entitlementPool.getStartDate() != null ? (entitlementPool
- .getStartDate().trim().length() != 0 ? entitlementPool.getStartDate()+"T00:00:00Z"
- : null) : null);
+ .getStartDate().trim().length() != 0 ? entitlementPool.getStartDate() + "T00:00:00Z"
+ : null) : null);
entitlementPool.setExpiryDate(entitlementPool.getExpiryDate() != null ? (entitlementPool
- .getExpiryDate().trim().length() != 0 ? entitlementPool.getExpiryDate()+"T23:59:59Z"
- : null) : null);
+ .getExpiryDate().trim().length() != 0 ? entitlementPool.getExpiryDate() + "T23:59:59Z"
+ : null) : null);
validateCreateDate(entitlementPool.getStartDate(), entitlementPool.getExpiryDate(),
- entitlementPool.getVendorLicenseModelId());
- return vendorLicenseFacade.createEntitlementPool(entitlementPool, user);
+ entitlementPool.getVendorLicenseModelId());
+ return vendorLicenseFacade.createEntitlementPool(entitlementPool);
}
- private void validateCreateDate(String startDate, String expiryDate, String vendorLicenseModelId){
+ private void validateCreateDate(String startDate, String expiryDate,
+ String vendorLicenseModelId) {
mdcDataDebugMessage.debugEntryMessage("Start date and end date", startDate
- +" "+expiryDate);
+ + " " + expiryDate);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy'T'HH:mm:ss'Z'");
- if(startDate != null && expiryDate != null) {
+ if (startDate != null && expiryDate != null) {
if (LocalDate.parse(startDate, formatter).atStartOfDay().isBefore
- (LocalDate.now().atStartOfDay()) || LocalDate.parse(expiryDate, formatter).atStartOfDay()
- .isEqual(LocalDate.parse(startDate, formatter).atStartOfDay()) || LocalDate
- .parse(expiryDate, formatter).isBefore(LocalDate.parse(startDate, formatter))) {
+ (LocalDate.now().atStartOfDay()) || LocalDate.parse(expiryDate, formatter).atStartOfDay()
+ .isEqual(LocalDate.parse(startDate, formatter).atStartOfDay()) || LocalDate
+ .parse(expiryDate, formatter).isBefore(LocalDate.parse(startDate, formatter))) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.VALIDATE_DATE_RANGE,ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VALUE);
+ LoggerTragetServiceName.VALIDATE_DATE_RANGE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VALUE);
throw new CoreException(
- new InvalidDateErrorBuilder(vendorLicenseModelId)
- .build());
+ new InvalidDateErrorBuilder(vendorLicenseModelId)
+ .build());
}
}
- if(startDate != null && expiryDate == null) {
+ if (startDate != null && expiryDate == null) {
if (LocalDate.parse(startDate, formatter).atStartOfDay().isBefore
- (LocalDate.now().atStartOfDay())) {
+ (LocalDate.now().atStartOfDay())) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.VALIDATE_DATE_RANGE,ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VALUE);
+ LoggerTragetServiceName.VALIDATE_DATE_RANGE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VALUE);
throw new CoreException(
- new InvalidDateErrorBuilder(vendorLicenseModelId)
- .build());
+ new InvalidDateErrorBuilder(vendorLicenseModelId)
+ .build());
}
}
- if(startDate == null && expiryDate != null) {
+ if (startDate == null && expiryDate != null) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.VALIDATE_DATE_RANGE,ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VALUE);
+ LoggerTragetServiceName.VALIDATE_DATE_RANGE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VALUE);
throw new CoreException(
- new InvalidDateErrorBuilder(vendorLicenseModelId)
- .build());
+ new InvalidDateErrorBuilder(vendorLicenseModelId)
+ .build());
}
- mdcDataDebugMessage.debugExitMessage(null,null);
+ mdcDataDebugMessage.debugExitMessage(null);
}
- private void validateUpdateDate(String startDate, String expiryDate, String vendorLicenseModelId){
+ private void validateUpdateDate(String startDate, String expiryDate,
+ String vendorLicenseModelId) {
mdcDataDebugMessage.debugEntryMessage("Start date and end date", startDate
- +" "+ expiryDate);
+ + " " + expiryDate);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy'T'HH:mm:ss'Z'");
- if(startDate != null && expiryDate != null) {
+ if (startDate != null && expiryDate != null) {
if (LocalDate.parse(expiryDate, formatter).atStartOfDay()
- .isEqual(LocalDate.parse(startDate, formatter).atStartOfDay()) ||
- LocalDate.parse(expiryDate, formatter).isBefore(LocalDate.parse(startDate, formatter))) {
+ .isEqual(LocalDate.parse(startDate, formatter).atStartOfDay()) ||
+ LocalDate.parse(expiryDate, formatter).isBefore(LocalDate.parse(startDate, formatter))) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.VALIDATE_DATE_RANGE,ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VALUE);
+ LoggerTragetServiceName.VALIDATE_DATE_RANGE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VALUE);
throw new CoreException(
- new InvalidDateErrorBuilder(vendorLicenseModelId)
- .build());
+ new InvalidDateErrorBuilder(vendorLicenseModelId)
+ .build());
}
}
- if(startDate == null && expiryDate != null) {
+ if (startDate == null && expiryDate != null) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.VALIDATE_DATE_RANGE,ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VALUE);
+ LoggerTragetServiceName.VALIDATE_DATE_RANGE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VALUE);
throw new CoreException(
- new InvalidDateErrorBuilder(vendorLicenseModelId)
- .build());
+ new InvalidDateErrorBuilder(vendorLicenseModelId)
+ .build());
}
- mdcDataDebugMessage.debugExitMessage(null,null);
+ mdcDataDebugMessage.debugExitMessage(null);
}
@Override
- public void updateEntitlementPool(EntitlementPoolEntity entitlementPool, String user) {
+ public void updateEntitlementPool(EntitlementPoolEntity entitlementPool) {
mdcDataDebugMessage.debugEntryMessage("VLM id, EP id", entitlementPool
- .getVendorLicenseModelId(), entitlementPool.getId());
+ .getVendorLicenseModelId(), entitlementPool.getId());
entitlementPool.setStartDate(entitlementPool.getStartDate() != null ? (entitlementPool
- .getStartDate().trim().length() != 0 ? entitlementPool.getStartDate()+"T00:00:00Z"
- : null) : null);
+ .getStartDate().trim().length() != 0 ? entitlementPool.getStartDate() + "T00:00:00Z"
+ : null) : null);
entitlementPool.setExpiryDate(entitlementPool.getExpiryDate() != null ? (entitlementPool
- .getExpiryDate().trim().length() != 0 ? entitlementPool.getExpiryDate()+"T23:59:59Z"
- : null) : null);
+ .getExpiryDate().trim().length() != 0 ? entitlementPool.getExpiryDate() + "T23:59:59Z"
+ : null) : null);
validateUpdateDate(entitlementPool.getStartDate(), entitlementPool.getExpiryDate(),
- entitlementPool.getVendorLicenseModelId());
- Version version = VersioningUtil.resolveVersion(entitlementPool.getVersion(),
- getVersionInfo(entitlementPool.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user);
- vendorLicenseFacade
- .updateVlmLastModificationTime(entitlementPool.getVendorLicenseModelId(), version);
- vendorLicenseFacade.updateEntitlementPool(entitlementPool, user);
+ entitlementPool.getVendorLicenseModelId());
+ vendorLicenseFacade.updateEntitlementPool(entitlementPool);
mdcDataDebugMessage.debugExitMessage("VLM id, EP id", entitlementPool
- .getVendorLicenseModelId(), entitlementPool.getId());
+ .getVendorLicenseModelId(), entitlementPool.getId());
}
@Override
- public EntitlementPoolEntity getEntitlementPool(EntitlementPoolEntity entitlementPool,
- String user) {
+ public EntitlementPoolEntity getEntitlementPool(EntitlementPoolEntity entitlementPool) {
mdcDataDebugMessage.debugEntryMessage("VLM id, EP id", entitlementPool
- .getVendorLicenseModelId(), entitlementPool.getId());
-
- entitlementPool.setVersion(VersioningUtil.resolveVersion(entitlementPool.getVersion(),
- getVersionInfo(entitlementPool.getVendorLicenseModelId(), VersionableEntityAction.Read,
- user), user));
+ .getVendorLicenseModelId(), entitlementPool.getId());
EntitlementPoolEntity retrieved = entitlementPoolDao.get(entitlementPool);
VersioningUtil
- .validateEntityExistence(retrieved, entitlementPool, VendorLicenseModelEntity.ENTITY_TYPE);
+ .validateEntityExistence(retrieved, entitlementPool, VendorLicenseModelEntity.ENTITY_TYPE);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy'T'HH:mm:ss'Z'");
DateTimeFormatter targetFormatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
- if(retrieved.getStartDate() != null){
- retrieved.setStartDate(LocalDate.parse(retrieved.getStartDate(),formatter).format
- (targetFormatter));
+ if (retrieved.getStartDate() != null) {
+ retrieved.setStartDate(LocalDate.parse(retrieved.getStartDate(), formatter).format
+ (targetFormatter));
}
- if(retrieved.getExpiryDate() != null){
- retrieved.setExpiryDate(LocalDate.parse(retrieved.getExpiryDate(),formatter).format
- (targetFormatter));
+ if (retrieved.getExpiryDate() != null) {
+ retrieved.setExpiryDate(LocalDate.parse(retrieved.getExpiryDate(), formatter).format
+ (targetFormatter));
}
mdcDataDebugMessage.debugExitMessage("VLM id, EP id", entitlementPool
- .getVendorLicenseModelId(), entitlementPool.getId());
+ .getVendorLicenseModelId(), entitlementPool.getId());
return retrieved;
}
@Override
- public void deleteEntitlementPool(EntitlementPoolEntity entitlementPool, String user) {
+ public void deleteEntitlementPool(EntitlementPoolEntity entitlementPool) {
mdcDataDebugMessage.debugEntryMessage("VLM id, EP id", entitlementPool
- .getVendorLicenseModelId(), entitlementPool.getId());
-
- Version version = VersioningUtil.resolveVersion(entitlementPool.getVersion(),
- getVersionInfo(entitlementPool.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user);
- entitlementPool.setVersion(version);
+ .getVendorLicenseModelId(), entitlementPool.getId());
EntitlementPoolEntity retrieved = entitlementPoolDao.get(entitlementPool);
VersioningUtil
- .validateEntityExistence(retrieved, entitlementPool, VendorLicenseModelEntity.ENTITY_TYPE);
+ .validateEntityExistence(retrieved, entitlementPool, VendorLicenseModelEntity.ENTITY_TYPE);
for (String referencingFeatureGroupId : retrieved.getReferencingFeatureGroups()) {
featureGroupDao.removeEntitlementPool(
- new FeatureGroupEntity(entitlementPool.getVendorLicenseModelId(), version,
- referencingFeatureGroupId), entitlementPool.getId());
+ new FeatureGroupEntity(entitlementPool.getVendorLicenseModelId(),
+ entitlementPool.getVersion(),
+ referencingFeatureGroupId), entitlementPool.getId());
}
- deleteChildLimits(entitlementPool.getVendorLicenseModelId(), entitlementPool.getVersion(), entitlementPool.getId(), user);
+ deleteChildLimits(entitlementPool.getVendorLicenseModelId(), entitlementPool.getVersion(),
+ entitlementPool.getId());
entitlementPoolDao.delete(entitlementPool);
deleteUniqueName(VendorLicenseConstants.UniqueValues.ENTITLEMENT_POOL_NAME,
- retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
- retrieved.getName());
-
- vendorLicenseFacade.updateVlmLastModificationTime(entitlementPool.getVendorLicenseModelId(),
- entitlementPool.getVersion());
+ retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
+ retrieved.getName());
mdcDataDebugMessage.debugExitMessage("VLM id, EP id", entitlementPool
- .getVendorLicenseModelId(), entitlementPool.getId());
+ .getVendorLicenseModelId(), entitlementPool.getId());
}
- protected void deleteChildLimits(String vlmId, Version version, String epLkgId, String user) {
+ protected void deleteChildLimits(String vlmId, Version version, String epLkgId) {
Optional<Collection<LimitEntity>> limitEntities = Optional.ofNullable(
- listLimits(vlmId, version, epLkgId, user));
- limitEntities.ifPresent(entities->
- entities.forEach(entity->
- deleteLimit(entity, user)));
+ listLimits(vlmId, version, epLkgId));
+ limitEntities.ifPresent(entities -> entities.forEach(this::deleteLimit));
}
@Override
- public Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version,
- String user) {
+ public Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version) {
mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId);
mdcDataDebugMessage.debugExitMessage("VLM id", vlmId);
- return vendorLicenseFacade.listLicenseKeyGroups(vlmId, version, user);
+ return vendorLicenseFacade.listLicenseKeyGroups(vlmId, version);
}
@Override
- public LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup,
- String user) {
+ public LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup) {
mdcDataDebugMessage
- .debugEntryMessage("VLM id", licenseKeyGroup.getVendorLicenseModelId());
+ .debugEntryMessage("VLM id", licenseKeyGroup.getVendorLicenseModelId());
mdcDataDebugMessage.debugExitMessage("VLM id", licenseKeyGroup
- .getVendorLicenseModelId());
+ .getVendorLicenseModelId());
licenseKeyGroup.setStartDate(licenseKeyGroup.getStartDate() != null ? (licenseKeyGroup
- .getStartDate().trim().length() != 0 ? licenseKeyGroup.getStartDate()+"T00:00:00Z"
- : null) : null);
+ .getStartDate().trim().length() != 0 ? licenseKeyGroup.getStartDate() + "T00:00:00Z"
+ : null) : null);
licenseKeyGroup.setExpiryDate(licenseKeyGroup.getExpiryDate() != null ? (licenseKeyGroup
- .getExpiryDate().trim().length() != 0 ? licenseKeyGroup.getExpiryDate()+"T23:59:59Z"
- : null) : null);
+ .getExpiryDate().trim().length() != 0 ? licenseKeyGroup.getExpiryDate() + "T23:59:59Z"
+ : null) : null);
validateCreateDate(licenseKeyGroup.getStartDate(), licenseKeyGroup.getExpiryDate(),
- licenseKeyGroup.getVendorLicenseModelId());
- return vendorLicenseFacade.createLicenseKeyGroup(licenseKeyGroup, user);
+ licenseKeyGroup.getVendorLicenseModelId());
+ return vendorLicenseFacade.createLicenseKeyGroup(licenseKeyGroup);
}
@Override
- public void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user) {
+ public void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup) {
mdcDataDebugMessage.debugEntryMessage("VLM id, LKG id", licenseKeyGroup
- .getVendorLicenseModelId(), licenseKeyGroup.getId());
+ .getVendorLicenseModelId(), licenseKeyGroup.getId());
licenseKeyGroup.setStartDate(licenseKeyGroup.getStartDate() != null ? (licenseKeyGroup
- .getStartDate().trim().length() != 0 ? licenseKeyGroup.getStartDate()+"T00:00:00Z"
- : null) : null);
+ .getStartDate().trim().length() != 0 ? licenseKeyGroup.getStartDate() + "T00:00:00Z"
+ : null) : null);
licenseKeyGroup.setExpiryDate(licenseKeyGroup.getExpiryDate() != null ? (licenseKeyGroup
- .getExpiryDate().trim().length() != 0 ? licenseKeyGroup.getExpiryDate()+"T23:59:59Z"
- : null) : null);
+ .getExpiryDate().trim().length() != 0 ? licenseKeyGroup.getExpiryDate() + "T23:59:59Z"
+ : null) : null);
validateUpdateDate(licenseKeyGroup.getStartDate(), licenseKeyGroup.getExpiryDate(),
- licenseKeyGroup.getVendorLicenseModelId());
-
- Version version = VersioningUtil.resolveVersion(licenseKeyGroup.getVersion(),
- getVersionInfo(licenseKeyGroup.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user);
- vendorLicenseFacade
- .updateVlmLastModificationTime(licenseKeyGroup.getVendorLicenseModelId(), version);
-
- vendorLicenseFacade.updateLicenseKeyGroup(licenseKeyGroup, user);
+ licenseKeyGroup.getVendorLicenseModelId());
+ vendorLicenseFacade.updateLicenseKeyGroup(licenseKeyGroup);
mdcDataDebugMessage.debugExitMessage("VLM id, LKG id", licenseKeyGroup
- .getVendorLicenseModelId(), licenseKeyGroup.getId());
+ .getVendorLicenseModelId(), licenseKeyGroup.getId());
}
@Override
- public LicenseKeyGroupEntity getLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup,
- String user) {
+ public LicenseKeyGroupEntity getLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup) {
mdcDataDebugMessage.debugEntryMessage("VLM id, LKG id", licenseKeyGroup
- .getVendorLicenseModelId(), licenseKeyGroup.getId());
-
- licenseKeyGroup.setVersion(VersioningUtil.resolveVersion(licenseKeyGroup.getVersion(),
- getVersionInfo(licenseKeyGroup.getVendorLicenseModelId(), VersionableEntityAction.Read,
- user), user));
+ .getVendorLicenseModelId(), licenseKeyGroup.getId());
LicenseKeyGroupEntity retrieved = licenseKeyGroupDao.get(licenseKeyGroup);
VersioningUtil
- .validateEntityExistence(retrieved, licenseKeyGroup, VendorLicenseModelEntity.ENTITY_TYPE);
+ .validateEntityExistence(retrieved, licenseKeyGroup, VendorLicenseModelEntity.ENTITY_TYPE);
mdcDataDebugMessage.debugExitMessage("VLM id, LKG id", licenseKeyGroup
- .getVendorLicenseModelId(), licenseKeyGroup.getId());
+ .getVendorLicenseModelId(), licenseKeyGroup.getId());
return retrieved;
}
@Override
- public void deleteLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user) {
+ public void deleteLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup) {
mdcDataDebugMessage.debugEntryMessage("VLM id, LKG id", licenseKeyGroup
- .getVendorLicenseModelId(), licenseKeyGroup.getId());
-
- Version version = VersioningUtil.resolveVersion(licenseKeyGroup.getVersion(),
- getVersionInfo(licenseKeyGroup.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user);
- licenseKeyGroup.setVersion(version);
+ .getVendorLicenseModelId(), licenseKeyGroup.getId());
LicenseKeyGroupEntity retrieved = licenseKeyGroupDao.get(licenseKeyGroup);
VersioningUtil
- .validateEntityExistence(retrieved, licenseKeyGroup, VendorLicenseModelEntity.ENTITY_TYPE);
+ .validateEntityExistence(retrieved, licenseKeyGroup, VendorLicenseModelEntity.ENTITY_TYPE);
for (String referencingFeatureGroupId : retrieved.getReferencingFeatureGroups()) {
featureGroupDao.removeLicenseKeyGroup(
- new FeatureGroupEntity(licenseKeyGroup.getVendorLicenseModelId(), version,
- referencingFeatureGroupId), licenseKeyGroup.getId());
+ new FeatureGroupEntity(licenseKeyGroup.getVendorLicenseModelId(),
+ licenseKeyGroup.getVersion(),
+ referencingFeatureGroupId), licenseKeyGroup.getId());
}
- deleteChildLimits(licenseKeyGroup.getVendorLicenseModelId(), licenseKeyGroup.getVersion(), licenseKeyGroup.getId(), user);
+ deleteChildLimits(licenseKeyGroup.getVendorLicenseModelId(), licenseKeyGroup.getVersion(),
+ licenseKeyGroup.getId());
licenseKeyGroupDao.delete(licenseKeyGroup);
deleteUniqueName(VendorLicenseConstants.UniqueValues.LICENSE_KEY_GROUP_NAME,
- retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
- retrieved.getName());
-
- vendorLicenseFacade.updateVlmLastModificationTime(licenseKeyGroup.getVendorLicenseModelId(),
- licenseKeyGroup.getVersion());
+ retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
+ retrieved.getName());
mdcDataDebugMessage.debugExitMessage("VLM id, LKG id", licenseKeyGroup
- .getVendorLicenseModelId(), licenseKeyGroup.getId());
+ .getVendorLicenseModelId(), licenseKeyGroup.getId());
}
@Override
- public LimitEntity createLimit(LimitEntity limit, String user) {
+ public LimitEntity createLimit(LimitEntity limit) {
mdcDataDebugMessage
- .debugEntryMessage("VLM id", limit.getVendorLicenseModelId(), "EP/LKGId", limit
- .getEpLkgId());
+ .debugEntryMessage("VLM id", limit.getVendorLicenseModelId(), "EP/LKGId", limit
+ .getEpLkgId());
mdcDataDebugMessage
- .debugExitMessage("VLM id", limit.getVendorLicenseModelId(), "EP/LKGId", limit
- .getEpLkgId());
- validateLimit(limit, user);
- LimitEntity createdLimit = vendorLicenseFacade.createLimit(limit, user);
- updateParentForLimit(limit,user);
+ .debugExitMessage("VLM id", limit.getVendorLicenseModelId(), "EP/LKGId", limit
+ .getEpLkgId());
+ validateLimit(limit);
+ LimitEntity createdLimit = vendorLicenseFacade.createLimit(limit);
+ updateParentForLimit(limit);
return createdLimit;
}
- private void validateLimit(LimitEntity limit, String user) {
- Version version = VersioningUtil.resolveVersion(limit.getVersion(),
- getVersionInfo(limit.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user);
- Collection<LimitEntity> limitList = listLimits(limit.getVendorLicenseModelId(),version
- ,limit.getEpLkgId(), user);
+ private void validateLimit(LimitEntity limit) {
+ Collection<LimitEntity> limitList =
+ listLimits(limit.getVendorLicenseModelId(), limit.getVersion()
+ , limit.getEpLkgId());
- if (!isLimitNameUnique(limitList,limit.getName(), limit.getType(), limit.getId())) {
+ if (!isLimitNameUnique(limitList, limit.getName(), limit.getType(), limit.getId())) {
final ErrorCode duplicateLimitNameErrorBuilder =
- LimitErrorBuilder.getDuplicateNameErrorbuilder(limit.getName(), limit.getType().name());
+ LimitErrorBuilder.getDuplicateNameErrorbuilder(limit.getName(), limit.getType().name());
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerServiceName.Create_LIMIT.toString(), ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(),
- duplicateLimitNameErrorBuilder.message());
+ LoggerServiceName.Create_LIMIT.toString(), ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(),
+ duplicateLimitNameErrorBuilder.message());
throw new CoreException(duplicateLimitNameErrorBuilder);
}
}
private boolean isLimitNameUnique(Collection<LimitEntity> limitList, String name, LimitType
- type, String id) {
+ type, String id) {
for (LimitEntity limit : limitList) {
- if(limit.getName().equalsIgnoreCase(name) &&
- limit.getType().name().equalsIgnoreCase(type.name())) {
- if(id != null && limit.getId().equals(id)){
+ if (limit.getName().equalsIgnoreCase(name) &&
+ limit.getType().name().equalsIgnoreCase(type.name())) {
+ if (id != null && limit.getId().equals(id)) {
continue;
}
return false;
@@ -846,54 +629,45 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager {
}
@Override
- public Collection<LimitEntity> listLimits(String vlmId, Version version, String epLkgId,
- String user) {
+ public Collection<LimitEntity> listLimits(String vlmId, Version version, String epLkgId) {
mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId, "EP/LKGId", epLkgId);
mdcDataDebugMessage.debugExitMessage("VLM id", vlmId, "EP/LKGId", epLkgId);
- return vendorLicenseFacade.listLimits(vlmId, version, epLkgId, user);
+ return vendorLicenseFacade.listLimits(vlmId, version, epLkgId);
}
@Override
- public void deleteLimit(LimitEntity limitEntity, String user) {
+ public void deleteLimit(LimitEntity limitEntity) {
mdcDataDebugMessage.debugEntryMessage("VLM id, EP id, Limit Id", limitEntity
- .getVendorLicenseModelId(), limitEntity.getEpLkgId(), limitEntity.getId());
-
- Version version = VersioningUtil.resolveVersion(limitEntity.getVersion(),
- getVersionInfo(limitEntity.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user);
- limitEntity.setVersion(version);
+ .getVendorLicenseModelId(), limitEntity.getEpLkgId(), limitEntity.getId());
- if ( !isLimitPresent(limitEntity)) {
+ if (!isLimitPresent(limitEntity)) {
VersioningUtil
- .validateEntityExistence(null, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
+ .validateEntityExistence(null, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
}
LimitEntity retrieved = limitDao.get(limitEntity);
VersioningUtil
- .validateEntityExistence(retrieved, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
+ .validateEntityExistence(retrieved, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
limitDao.delete(limitEntity);
- vendorLicenseFacade.updateVlmLastModificationTime(limitEntity.getVendorLicenseModelId(),
- limitEntity.getVersion());
-
- updateParentForLimit(limitEntity,user);
+ updateParentForLimit(limitEntity);
mdcDataDebugMessage.debugExitMessage("VLM id, EP id, Limit Id", limitEntity
- .getVendorLicenseModelId(), limitEntity.getEpLkgId(), limitEntity.getId());
+ .getVendorLicenseModelId(), limitEntity.getEpLkgId(), limitEntity.getId());
}
@Override
- public void updateLimit(LimitEntity limit, String user) {
+ public void updateLimit(LimitEntity limit) {
mdcDataDebugMessage
- .debugEntryMessage("VLM id", limit.getVendorLicenseModelId(), "EP/LKGId", limit
- .getEpLkgId());
- getLimit(limit,user);
- validateLimit(limit, user);
- vendorLicenseFacade.updateLimit(limit, user);
- updateParentForLimit(limit,user);
+ .debugEntryMessage("VLM id", limit.getVendorLicenseModelId(), "EP/LKGId", limit
+ .getEpLkgId());
+ getLimit(limit);
+ validateLimit(limit);
+ vendorLicenseFacade.updateLimit(limit);
+ updateParentForLimit(limit);
mdcDataDebugMessage
- .debugExitMessage("VLM id", limit.getVendorLicenseModelId(), "EP/LKGId", limit
- .getEpLkgId());
+ .debugExitMessage("VLM id", limit.getVendorLicenseModelId(), "EP/LKGId", limit
+ .getEpLkgId());
}
private boolean isLimitPresent(LimitEntity limit) {
@@ -901,52 +675,46 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager {
}
@Override
- public LimitEntity getLimit(LimitEntity limitEntity,
- String user) {
+ public LimitEntity getLimit(LimitEntity limitEntity) {
mdcDataDebugMessage.debugEntryMessage("VLM id", limitEntity.getVendorLicenseModelId(),
- "EP/LKGId", limitEntity.getEpLkgId());
+ "EP/LKGId", limitEntity.getEpLkgId());
- limitEntity.setVersion(VersioningUtil.resolveVersion(limitEntity.getVersion(),
- getVersionInfo(limitEntity.getVendorLicenseModelId(), VersionableEntityAction.Read,
- user), user));
- if(!isLimitPresent(limitEntity)){
+ if (!isLimitPresent(limitEntity)) {
VersioningUtil
- .validateEntityExistence(null, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
+ .validateEntityExistence(null, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
}
LimitEntity retrieved = limitDao.get(limitEntity);
VersioningUtil
- .validateEntityExistence(retrieved, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
+ .validateEntityExistence(retrieved, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
mdcDataDebugMessage.debugExitMessage("VLM id", limitEntity.getVendorLicenseModelId(),
- "EP/LKGId", limitEntity.getEpLkgId());
+ "EP/LKGId", limitEntity.getEpLkgId());
return retrieved;
}
/**
* update Parent of limit (EP/LKG) versionuuid when limit is modified so that limit updates are
* captured in VLM XML
- * @param limit
- * @param user
*/
- private void updateParentForLimit(LimitEntity limit, String user) {
+ private void updateParentForLimit(LimitEntity limit) {
mdcDataDebugMessage.debugEntryMessage("VLM id", limit.getVendorLicenseModelId(),
- "EP/LKGId", limit.getEpLkgId(), "Limit Parent ", limit.getParent());
- if ("EntitlementPool".equals(limit.getParent()) ) {
+ "EP/LKGId", limit.getEpLkgId(), "Limit Parent ", limit.getParent());
+ if ("EntitlementPool".equals(limit.getParent())) {
EntitlementPoolEntity entitlementPoolEntity =
- entitlementPoolDao.get(new EntitlementPoolEntity(limit.getVendorLicenseModelId(),
- limit.getVersion(), limit.getEpLkgId()));
- vendorLicenseFacade.updateEntitlementPool(entitlementPoolEntity, user);
+ entitlementPoolDao.get(new EntitlementPoolEntity(limit.getVendorLicenseModelId(),
+ limit.getVersion(), limit.getEpLkgId()));
+ vendorLicenseFacade.updateEntitlementPool(entitlementPoolEntity);
}
if ("LicenseKeyGroup".equals(limit.getParent())) {
LicenseKeyGroupEntity licenseKeyGroupEntity = licenseKeyGroupDao.get(
- new LicenseKeyGroupEntity(limit.getVendorLicenseModelId(), limit.getVersion(),
- limit.getEpLkgId()));
- vendorLicenseFacade.updateLicenseKeyGroup(licenseKeyGroupEntity, user);
+ new LicenseKeyGroupEntity(limit.getVendorLicenseModelId(), limit.getVersion(),
+ limit.getEpLkgId()));
+ vendorLicenseFacade.updateLicenseKeyGroup(licenseKeyGroupEntity);
}
mdcDataDebugMessage.debugEntryMessage("VLM id", limit.getVendorLicenseModelId(),
- "EP/LKGId", limit.getEpLkgId(), "Limit Parent ", limit.getParent());
+ "EP/LKGId", limit.getEpLkgId(), "Limit Parent ", limit.getParent());
}
protected void addFeatureGroupsToLicenseAgreementRef(Set<String> featureGroupIds,
@@ -954,8 +722,8 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager {
if (featureGroupIds != null) {
for (String featureGroupId : featureGroupIds) {
featureGroupDao.addReferencingLicenseAgreement(
- new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(),
- licenseAgreement.getVersion(), featureGroupId), licenseAgreement.getId());
+ new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion(), featureGroupId), licenseAgreement.getId());
}
}
}
@@ -965,8 +733,8 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager {
if (featureGroupIds != null) {
for (String featureGroupId : featureGroupIds) {
featureGroupDao.removeReferencingLicenseAgreement(
- new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(),
- licenseAgreement.getVersion(), featureGroupId), licenseAgreement.getId());
+ new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion(), featureGroupId), licenseAgreement.getId());
}
}
}
@@ -976,8 +744,8 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager {
if (licenseKeyGroupIds != null) {
for (String licenseKeyGroupId : licenseKeyGroupIds) {
licenseKeyGroupDao.addReferencingFeatureGroup(
- new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(),
- featureGroup.getVersion(), licenseKeyGroupId), featureGroup.getId());
+ new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion(), licenseKeyGroupId), featureGroup.getId());
}
}
}
@@ -987,8 +755,8 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager {
if (licenseKeyGroupIds != null) {
for (String licenseKeyGroupId : licenseKeyGroupIds) {
licenseKeyGroupDao.removeReferencingFeatureGroup(
- new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(),
- featureGroup.getVersion(), licenseKeyGroupId), featureGroup.getId());
+ new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion(), licenseKeyGroupId), featureGroup.getId());
}
}
}
@@ -998,8 +766,8 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager {
if (entitlementPoolIds != null) {
for (String entitlementPoolId : entitlementPoolIds) {
entitlementPoolDao.addReferencingFeatureGroup(
- new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(),
- featureGroup.getVersion(), entitlementPoolId), featureGroup.getId());
+ new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion(), entitlementPoolId), featureGroup.getId());
}
}
}
@@ -1009,38 +777,19 @@ public class VendorLicenseManagerImpl implements VendorLicenseManager {
if (entitlementPoolIds != null) {
for (String entitlementPoolId : entitlementPoolIds) {
entitlementPoolDao.removeReferencingFeatureGroup(
- new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(),
- featureGroup.getVersion(), entitlementPoolId), featureGroup.getId());
+ new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion(), entitlementPoolId), featureGroup.getId());
}
}
}
- protected VersionInfo getVersionInfo(String vendorLicenseModelId, VersionableEntityAction action,
- String user) {
- return vendorLicenseFacade.getVersionInfo(vendorLicenseModelId, action, user);
- }
-
- protected LicenseAgreementEntity createLicenseAgreementForList(String vlmId, Version version,
- String user) {
- return new LicenseAgreementEntity(vlmId, VersioningUtil
- .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user), user),
- null);
- }
-
- protected void updateUniqueName(String uniqueValueType ,String oldName, String newName,String ...
- context) {
+ protected void updateUniqueName(String uniqueValueType, String oldName, String newName, String...
+ context) {
UniqueValueUtil
- .updateUniqueValue(uniqueValueType, oldName, newName,context);
+ .updateUniqueValue(uniqueValueType, oldName, newName, context);
}
- protected void deleteUniqueName(String uniqueValueType,String ... uniqueCombination) {
+ protected void deleteUniqueName(String uniqueValueType, String... uniqueCombination) {
UniqueValueUtil.deleteUniqueValue(uniqueValueType, uniqueCombination);
}
-
- protected Version resloveVersion(String vlmId,Version requestedVersion, VersionInfo versionInfo,
- String user){
- return VersioningUtil.resolveVersion(null,
- getVersionInfo(vlmId, VersionableEntityAction.Write, user), user);
- }
-
}
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 {