StoragePolicyStatusEntity storagePolicyStatusEntity, Integer storagePolicyVersion, Boolean storagePolicyLatestVersion) StoragePolicyEntity storagePolicyEntity = new StoragePolicyEntity(); storagePolicyEntity.setNamespace(namespaceEntity); storagePolicyEntity.setName(storagePolicyName); storagePolicyEntity.setStorage(storageEntity); storagePolicyEntity.setStoragePolicyRuleType(storagePolicyRuleTypeEntity); storagePolicyEntity.setStoragePolicyRuleValue(storagePolicyRuleValue); storagePolicyEntity.setBusinessObjectDefinition(businessObjectDefinitionEntity); if (StringUtils.isNotBlank(businessObjectFormatUsage)) storagePolicyEntity.setUsage(businessObjectFormatUsage); storagePolicyEntity.setFileType(fileTypeEntity); storagePolicyEntity.setStoragePolicyTransitionType(storagePolicyTransitionTypeEntity); storagePolicyEntity.setStatus(storagePolicyStatusEntity); storagePolicyEntity.setVersion(storagePolicyVersion); storagePolicyEntity.setLatestVersion(storagePolicyLatestVersion);
storagePolicy.setId(storagePolicyEntity.getId()); storagePolicyKey.setNamespace(storagePolicyEntity.getNamespace().getCode()); storagePolicyKey.setStoragePolicyName(storagePolicyEntity.getName()); storagePolicyRule.setRuleType(storagePolicyEntity.getStoragePolicyRuleType().getCode()); storagePolicyRule.setRuleValue(storagePolicyEntity.getStoragePolicyRuleValue()); storagePolicyEntity.getBusinessObjectDefinition() != null ? storagePolicyEntity.getBusinessObjectDefinition().getNamespace().getCode() : null); storagePolicyFilter.setBusinessObjectDefinitionName( storagePolicyEntity.getBusinessObjectDefinition() != null ? storagePolicyEntity.getBusinessObjectDefinition().getName() : null); storagePolicyFilter.setBusinessObjectFormatUsage(storagePolicyEntity.getUsage()); storagePolicyFilter.setBusinessObjectFormatFileType(storagePolicyEntity.getFileType() != null ? storagePolicyEntity.getFileType().getCode() : null); storagePolicyFilter.setStorageName(storagePolicyEntity.getStorage().getName()); storagePolicyTransition.setTransitionType(storagePolicyEntity.getStoragePolicyTransitionType().getCode()); storagePolicy.setStatus(storagePolicyEntity.getStatus().getCode());
Assert.isTrue((storagePolicyEntity.getBusinessObjectDefinition() == null || storagePolicyEntity.getBusinessObjectDefinition().equals(businessObjectDataEntity.getBusinessObjectFormat().getBusinessObjectDefinition())) && (StringUtils.isBlank(storagePolicyEntity.getUsage()) || storagePolicyEntity.getUsage().equalsIgnoreCase(businessObjectDataEntity.getBusinessObjectFormat().getUsage())) && (storagePolicyEntity.getFileType() == null || storagePolicyEntity.getFileType().equals(businessObjectDataEntity.getBusinessObjectFormat().getFileType())), String .format("Business object data does not match storage policy filter. " + "Storage policy: {%s}, business object data: {%s}", storagePolicyHelper.storagePolicyKeyAndVersionToString(request.getStoragePolicyKey(), storagePolicyEntity.getVersion()), businessObjectDataHelper.businessObjectDataEntityAltKeyToString(businessObjectDataEntity))); storagePolicyDaoHelper.validateStoragePolicyFilterStorage(storagePolicyEntity.getStorage()); StorageUnitEntity storageUnitEntity = getStorageUnit(businessObjectDataEntity, storagePolicyEntity.getStorage()); .buildS3KeyPrefix(storagePolicyEntity.getStorage(), storageUnitEntity.getBusinessObjectData().getBusinessObjectFormat(), businessObjectDataKey); new StoragePolicySelection(businessObjectDataKey, storagePolicyHelper.getStoragePolicyKey(storagePolicyEntity), storagePolicyEntity.getVersion());
StoragePolicyEntity storagePolicyEntity = new StoragePolicyEntity(); storagePolicyEntity.setStorage(storageEntity); storagePolicyEntity.setStoragePolicyTransitionType(storagePolicyTransitionTypeEntity);
@Test public void testGetStoragePolicyByAltKey() { StoragePolicyKey storagePolicyKey = new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME); // Create and persist a storage policy entity. StoragePolicyEntity storagePolicyEntity = storagePolicyDaoTestHelper .createStoragePolicyEntity(storagePolicyKey, STORAGE_POLICY_RULE_TYPE, STORAGE_POLICY_RULE_VALUE, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, STORAGE_NAME, STORAGE_NAME_2, StoragePolicyStatusEntity.ENABLED, INITIAL_VERSION, LATEST_VERSION_FLAG_SET); // Retrieve this storage policy by alternate key. StoragePolicyEntity resultStoragePolicyEntity = storagePolicyDao.getStoragePolicyByAltKey(storagePolicyKey); // Validate the returned object. assertNotNull(resultStoragePolicyEntity); assertEquals(storagePolicyEntity.getId(), resultStoragePolicyEntity.getId()); // Retrieve this storage policy by alternate key in upper case. resultStoragePolicyEntity = storagePolicyDao.getStoragePolicyByAltKey(new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD.toUpperCase(), STORAGE_POLICY_NAME.toUpperCase())); // Validate the returned object. assertNotNull(resultStoragePolicyEntity); assertEquals(storagePolicyEntity.getId(), resultStoragePolicyEntity.getId()); // Retrieve this storage policy by alternate key in lower case. resultStoragePolicyEntity = storagePolicyDao.getStoragePolicyByAltKey(new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD.toLowerCase(), STORAGE_POLICY_NAME.toLowerCase())); // Validate the returned object. assertNotNull(resultStoragePolicyEntity); assertEquals(storagePolicyEntity.getId(), resultStoragePolicyEntity.getId()); }
createStoragePolicyEntity(storagePolicyEntity.getNamespace(), storagePolicyEntity.getName(), storageEntity, storagePolicyRuleTypeEntity, request.getStoragePolicyRule().getRuleValue(), businessObjectDefinitionEntity, request.getStoragePolicyFilter().getBusinessObjectFormatUsage(), fileTypeEntity, storagePolicyTransitionTypeEntity, storagePolicyStatusEntity, storagePolicyEntity.getVersion() + 1, true); storagePolicyEntity.setLatestVersion(false); storagePolicyDao.saveAndRefresh(storagePolicyEntity);
String storagePolicyRuleType = storagePolicyEntity.getStoragePolicyRuleType().getCode(); Integer storagePolicyRuleValue = storagePolicyEntity.getStoragePolicyRuleValue(); new StoragePolicyKey(storagePolicyEntity.getNamespace().getCode(), storagePolicyEntity.getName()); storagePolicySelections.add(new StoragePolicySelection(businessObjectDataKey, storagePolicyKey, storagePolicyEntity.getVersion())); jsonHelper.objectToJson(storagePolicyKey), storagePolicyEntity.getVersion());
@Test public void testGetStoragePolicyByAltKeyAndVersion() { StoragePolicyKey storagePolicyKey = new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME); // Create and persist two versions of a storage policy. List<StoragePolicyEntity> storagePolicyEntities = Arrays.asList(storagePolicyDaoTestHelper .createStoragePolicyEntity(storagePolicyKey, STORAGE_POLICY_RULE_TYPE, STORAGE_POLICY_RULE_VALUE, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, STORAGE_NAME, STORAGE_NAME_2, StoragePolicyStatusEntity.ENABLED, INITIAL_VERSION, NO_LATEST_VERSION_FLAG_SET), storagePolicyDaoTestHelper .createStoragePolicyEntity(storagePolicyKey, STORAGE_POLICY_RULE_TYPE, STORAGE_POLICY_RULE_VALUE, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, STORAGE_NAME, STORAGE_NAME_2, StoragePolicyStatusEntity.ENABLED, SECOND_VERSION, LATEST_VERSION_FLAG_SET)); // Retrieve the relative storage policy versions by alternate key and version. for (StoragePolicyEntity storagePolicyEntity : storagePolicyEntities) { StoragePolicyEntity resultStoragePolicyEntity = storagePolicyDao.getStoragePolicyByAltKeyAndVersion(storagePolicyKey, storagePolicyEntity.getVersion()); // Validate the returned object. assertEquals(storagePolicyEntity, resultStoragePolicyEntity); } // Try to retrieve a non-existing storage policy version. assertNull(storagePolicyDao.getStoragePolicyByAltKeyAndVersion(storagePolicyKey, THIRD_VERSION)); } }
@Test public void testUpdateStoragePolicyUpperCaseParameters() { // Create a storage policy key. StoragePolicyKey storagePolicyKey = new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME); // Create and persist the relative database entities. storagePolicyServiceTestHelper.createDatabaseEntitiesForStoragePolicyTesting(); // Create and persist a storage policy entity. StoragePolicyEntity storagePolicyEntity = storagePolicyDaoTestHelper .createStoragePolicyEntity(storagePolicyKey, STORAGE_POLICY_RULE_TYPE_2, STORAGE_POLICY_RULE_VALUE_2, BDEF_NAMESPACE_2, BDEF_NAME_2, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, STORAGE_NAME_2, STORAGE_POLICY_TRANSITION_TYPE_2, StoragePolicyStatusEntity.ENABLED, INITIAL_VERSION, LATEST_VERSION_FLAG_SET); // Update a storage policy using upper case input parameters. StoragePolicy resultStoragePolicy = storagePolicyService .updateStoragePolicy(new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD.toUpperCase(), STORAGE_POLICY_NAME.toUpperCase()), storagePolicyServiceTestHelper .createStoragePolicyUpdateRequest(STORAGE_POLICY_RULE_TYPE.toUpperCase(), STORAGE_POLICY_RULE_VALUE, BDEF_NAMESPACE.toUpperCase(), BDEF_NAME.toUpperCase(), FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE.toUpperCase(), STORAGE_NAME.toUpperCase(), STORAGE_POLICY_TRANSITION_TYPE.toUpperCase(), StoragePolicyStatusEntity.DISABLED.toUpperCase())); // Validate the returned object. assertEquals(new StoragePolicy(resultStoragePolicy.getId(), new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME), new StoragePolicyRule(STORAGE_POLICY_RULE_TYPE, STORAGE_POLICY_RULE_VALUE), new StoragePolicyFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE.toUpperCase(), FORMAT_FILE_TYPE_CODE, STORAGE_NAME), new StoragePolicyTransition(STORAGE_POLICY_TRANSITION_TYPE), StoragePolicyStatusEntity.DISABLED), resultStoragePolicy); assertTrue(resultStoragePolicy.getId() > storagePolicyEntity.getId()); }
createStoragePolicyEntity(storagePolicyEntity.getNamespace(), storagePolicyEntity.getName(), storageEntity, storagePolicyRuleTypeEntity, request.getStoragePolicyRule().getRuleValue(), businessObjectDefinitionEntity, request.getStoragePolicyFilter().getBusinessObjectFormatUsage(), fileTypeEntity, storagePolicyTransitionTypeEntity, storagePolicyStatusEntity, storagePolicyEntity.getVersion() + 1, true); storagePolicyEntity.setLatestVersion(false); storagePolicyDao.saveAndRefresh(storagePolicyEntity);
String storagePolicyRuleType = storagePolicyEntity.getStoragePolicyRuleType().getCode(); Integer storagePolicyRuleValue = storagePolicyEntity.getStoragePolicyRuleValue(); new StoragePolicyKey(storagePolicyEntity.getNamespace().getCode(), storagePolicyEntity.getName()); storagePolicySelections.add(new StoragePolicySelection(businessObjectDataKey, storagePolicyKey, storagePolicyEntity.getVersion())); jsonHelper.objectToJson(storagePolicyKey), storagePolicyEntity.getVersion());
StoragePolicyStatusEntity storagePolicyStatusEntity, Integer storagePolicyVersion, Boolean storagePolicyLatestVersion) StoragePolicyEntity storagePolicyEntity = new StoragePolicyEntity(); storagePolicyEntity.setNamespace(namespaceEntity); storagePolicyEntity.setName(storagePolicyName); storagePolicyEntity.setStorage(storageEntity); storagePolicyEntity.setStoragePolicyRuleType(storagePolicyRuleTypeEntity); storagePolicyEntity.setStoragePolicyRuleValue(storagePolicyRuleValue); storagePolicyEntity.setBusinessObjectDefinition(businessObjectDefinitionEntity); if (StringUtils.isNotBlank(businessObjectFormatUsage)) storagePolicyEntity.setUsage(businessObjectFormatUsage); storagePolicyEntity.setFileType(fileTypeEntity); storagePolicyEntity.setStoragePolicyTransitionType(storagePolicyTransitionTypeEntity); storagePolicyEntity.setStatus(storagePolicyStatusEntity); storagePolicyEntity.setVersion(storagePolicyVersion); storagePolicyEntity.setLatestVersion(storagePolicyLatestVersion);
storagePolicy.setId(storagePolicyEntity.getId()); storagePolicyKey.setNamespace(storagePolicyEntity.getNamespace().getCode()); storagePolicyKey.setStoragePolicyName(storagePolicyEntity.getName()); storagePolicyRule.setRuleType(storagePolicyEntity.getStoragePolicyRuleType().getCode()); storagePolicyRule.setRuleValue(storagePolicyEntity.getStoragePolicyRuleValue()); storagePolicyEntity.getBusinessObjectDefinition() != null ? storagePolicyEntity.getBusinessObjectDefinition().getNamespace().getCode() : null); storagePolicyFilter.setBusinessObjectDefinitionName( storagePolicyEntity.getBusinessObjectDefinition() != null ? storagePolicyEntity.getBusinessObjectDefinition().getName() : null); storagePolicyFilter.setBusinessObjectFormatUsage(storagePolicyEntity.getUsage()); storagePolicyFilter.setBusinessObjectFormatFileType(storagePolicyEntity.getFileType() != null ? storagePolicyEntity.getFileType().getCode() : null); storagePolicyFilter.setStorageName(storagePolicyEntity.getStorage().getName()); storagePolicyTransition.setTransitionType(storagePolicyEntity.getStoragePolicyTransitionType().getCode()); storagePolicy.setStatus(storagePolicyEntity.getStatus().getCode());
@Test public void testUpdateStoragePolicyLowerCaseParameters() { // Create a storage policy key. StoragePolicyKey storagePolicyKey = new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME); // Create and persist the relative database entities. storagePolicyServiceTestHelper.createDatabaseEntitiesForStoragePolicyTesting(); // Create and persist a storage policy entity. StoragePolicyEntity storagePolicyEntity = storagePolicyDaoTestHelper .createStoragePolicyEntity(storagePolicyKey, STORAGE_POLICY_RULE_TYPE_2, STORAGE_POLICY_RULE_VALUE_2, BDEF_NAMESPACE_2, BDEF_NAME_2, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, STORAGE_NAME_2, STORAGE_POLICY_TRANSITION_TYPE_2, StoragePolicyStatusEntity.ENABLED, INITIAL_VERSION, LATEST_VERSION_FLAG_SET); // Update a storage policy using lower case input parameters. StoragePolicy resultStoragePolicy = storagePolicyService .updateStoragePolicy(new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD.toLowerCase(), STORAGE_POLICY_NAME.toLowerCase()), storagePolicyServiceTestHelper .createStoragePolicyUpdateRequest(STORAGE_POLICY_RULE_TYPE.toLowerCase(), STORAGE_POLICY_RULE_VALUE, BDEF_NAMESPACE.toLowerCase(), BDEF_NAME.toLowerCase(), FORMAT_USAGE_CODE.toLowerCase(), FORMAT_FILE_TYPE_CODE.toLowerCase(), STORAGE_NAME.toLowerCase(), STORAGE_POLICY_TRANSITION_TYPE.toLowerCase(), StoragePolicyStatusEntity.DISABLED.toLowerCase())); // Validate the returned object. assertEquals(new StoragePolicy(resultStoragePolicy.getId(), new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME), new StoragePolicyRule(STORAGE_POLICY_RULE_TYPE, STORAGE_POLICY_RULE_VALUE), new StoragePolicyFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE.toLowerCase(), FORMAT_FILE_TYPE_CODE, STORAGE_NAME), new StoragePolicyTransition(STORAGE_POLICY_TRANSITION_TYPE), StoragePolicyStatusEntity.DISABLED), resultStoragePolicy); assertTrue(resultStoragePolicy.getId() > storagePolicyEntity.getId()); }
Assert.isTrue((storagePolicyEntity.getBusinessObjectDefinition() == null || storagePolicyEntity.getBusinessObjectDefinition().equals(businessObjectDataEntity.getBusinessObjectFormat().getBusinessObjectDefinition())) && (StringUtils.isBlank(storagePolicyEntity.getUsage()) || storagePolicyEntity.getUsage().equalsIgnoreCase(businessObjectDataEntity.getBusinessObjectFormat().getUsage())) && (storagePolicyEntity.getFileType() == null || storagePolicyEntity.getFileType().equals(businessObjectDataEntity.getBusinessObjectFormat().getFileType())), String .format("Business object data does not match storage policy filter. " + "Storage policy: {%s}, business object data: {%s}", storagePolicyHelper.storagePolicyKeyAndVersionToString(request.getStoragePolicyKey(), storagePolicyEntity.getVersion()), businessObjectDataHelper.businessObjectDataEntityAltKeyToString(businessObjectDataEntity))); storagePolicyDaoHelper.validateStoragePolicyFilterStorage(storagePolicyEntity.getStorage()); StorageUnitEntity storageUnitEntity = getStorageUnit(businessObjectDataEntity, storagePolicyEntity.getStorage()); .buildS3KeyPrefix(storagePolicyEntity.getStorage(), storageUnitEntity.getBusinessObjectData().getBusinessObjectFormat(), businessObjectDataKey); new StoragePolicySelection(businessObjectDataKey, storagePolicyHelper.getStoragePolicyKey(storagePolicyEntity), storagePolicyEntity.getVersion());
StoragePolicyEntity storagePolicyEntity = new StoragePolicyEntity(); storagePolicyEntity.setNamespace(storagePolicyNamespaceEntity); storagePolicyEntity.setName(storagePolicyKey.getStoragePolicyName()); storagePolicyEntity.setStoragePolicyRuleType(storagePolicyRuleTypeEntity); storagePolicyEntity.setStoragePolicyRuleValue(storagePolicyRuleValue); storagePolicyEntity.setBusinessObjectDefinition(businessObjectDefinitionEntity); storagePolicyEntity.setUsage(businessObjectFormatUsage); storagePolicyEntity.setFileType(fileTypeEntity); storagePolicyEntity.setStorage(storageEntity); storagePolicyEntity.setStoragePolicyTransitionType(storagePolicyTransitionTypeEntity); storagePolicyEntity.setStatus(storagePolicyStatusEntity); storagePolicyEntity.setVersion(storagePolicyVersion); storagePolicyEntity.setLatestVersion(storagePolicyLatestVersion);
@Test public void testGetStoragePolicyUpperCaseParameters() { // Create a storage policy key. StoragePolicyKey storagePolicyKey = new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME); // Create and persist a storage policy entity. StoragePolicyEntity storagePolicyEntity = storagePolicyDaoTestHelper .createStoragePolicyEntity(storagePolicyKey, STORAGE_POLICY_RULE_TYPE, STORAGE_POLICY_RULE_VALUE, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, STORAGE_NAME, STORAGE_POLICY_TRANSITION_TYPE, StoragePolicyStatusEntity.ENABLED, INITIAL_VERSION, LATEST_VERSION_FLAG_SET); // Retrieve the storage policy using upper case input parameters. StoragePolicy resultStoragePolicy = storagePolicyService.getStoragePolicy(new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD.toUpperCase(), STORAGE_POLICY_NAME.toUpperCase())); // Validate the returned object. assertEquals( new StoragePolicy(storagePolicyEntity.getId(), storagePolicyKey, new StoragePolicyRule(STORAGE_POLICY_RULE_TYPE, STORAGE_POLICY_RULE_VALUE), new StoragePolicyFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, STORAGE_NAME), new StoragePolicyTransition(STORAGE_POLICY_TRANSITION_TYPE), StoragePolicyStatusEntity.ENABLED), resultStoragePolicy); }
@Test public void testGetStoragePolicyLowerCaseParameters() { // Create a storage policy key. StoragePolicyKey storagePolicyKey = new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME); // Create and persist a storage policy entity. StoragePolicyEntity storagePolicyEntity = storagePolicyDaoTestHelper .createStoragePolicyEntity(storagePolicyKey, STORAGE_POLICY_RULE_TYPE, STORAGE_POLICY_RULE_VALUE, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, STORAGE_NAME, STORAGE_POLICY_TRANSITION_TYPE, StoragePolicyStatusEntity.ENABLED, INITIAL_VERSION, LATEST_VERSION_FLAG_SET); // Retrieve the storage policy using lower case input parameters. StoragePolicy resultStoragePolicy = storagePolicyService.getStoragePolicy(new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD.toLowerCase(), STORAGE_POLICY_NAME.toLowerCase())); // Validate the returned object. assertEquals( new StoragePolicy(storagePolicyEntity.getId(), storagePolicyKey, new StoragePolicyRule(STORAGE_POLICY_RULE_TYPE, STORAGE_POLICY_RULE_VALUE), new StoragePolicyFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, STORAGE_NAME), new StoragePolicyTransition(STORAGE_POLICY_TRANSITION_TYPE), StoragePolicyStatusEntity.ENABLED), resultStoragePolicy); }
@Test public void testGetStoragePolicy() { // Create a storage policy key. StoragePolicyKey storagePolicyKey = new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME); // Create and persist a storage policy entity. StoragePolicyEntity storagePolicyEntity = storagePolicyDaoTestHelper .createStoragePolicyEntity(storagePolicyKey, STORAGE_POLICY_RULE_TYPE, STORAGE_POLICY_RULE_VALUE, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, STORAGE_NAME, STORAGE_POLICY_TRANSITION_TYPE, StoragePolicyStatusEntity.ENABLED, INITIAL_VERSION, LATEST_VERSION_FLAG_SET); // Retrieve the storage policy. StoragePolicy resultStoragePolicy = storagePolicyService.getStoragePolicy(storagePolicyKey); // Validate the returned object. assertEquals( new StoragePolicy(storagePolicyEntity.getId(), storagePolicyKey, new StoragePolicyRule(STORAGE_POLICY_RULE_TYPE, STORAGE_POLICY_RULE_VALUE), new StoragePolicyFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, STORAGE_NAME), new StoragePolicyTransition(STORAGE_POLICY_TRANSITION_TYPE), StoragePolicyStatusEntity.ENABLED), resultStoragePolicy); }
@Test public void testGetStoragePolicyTrimParameters() { // Create a storage policy key. StoragePolicyKey storagePolicyKey = new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME); // Create and persist a storage policy entity. StoragePolicyEntity storagePolicyEntity = storagePolicyDaoTestHelper .createStoragePolicyEntity(storagePolicyKey, STORAGE_POLICY_RULE_TYPE, STORAGE_POLICY_RULE_VALUE, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, STORAGE_NAME, STORAGE_POLICY_TRANSITION_TYPE, StoragePolicyStatusEntity.ENABLED, INITIAL_VERSION, LATEST_VERSION_FLAG_SET); // Retrieve the storage policy using input parameters with leading and trailing empty spaces. StoragePolicy resultStoragePolicy = storagePolicyService.getStoragePolicy(new StoragePolicyKey(addWhitespace(STORAGE_POLICY_NAMESPACE_CD), addWhitespace(STORAGE_POLICY_NAME))); // Validate the returned object. assertEquals( new StoragePolicy(storagePolicyEntity.getId(), storagePolicyKey, new StoragePolicyRule(STORAGE_POLICY_RULE_TYPE, STORAGE_POLICY_RULE_VALUE), new StoragePolicyFilter(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, STORAGE_NAME), new StoragePolicyTransition(STORAGE_POLICY_TRANSITION_TYPE), StoragePolicyStatusEntity.ENABLED), resultStoragePolicy); }