Search in sources :

Example 1 with StoragePolicyTransition

use of org.finra.herd.model.api.xml.StoragePolicyTransition in project herd by FINRAOS.

the class StoragePolicyServiceImpl method createStoragePolicyFromEntity.

/**
 * Creates the storage policy registration from the persisted entity.
 *
 * @param storagePolicyEntity the storage policy registration entity
 *
 * @return the storage policy registration
 */
private StoragePolicy createStoragePolicyFromEntity(StoragePolicyEntity storagePolicyEntity) {
    StoragePolicy storagePolicy = new StoragePolicy();
    storagePolicy.setId(storagePolicyEntity.getId());
    StoragePolicyKey storagePolicyKey = new StoragePolicyKey();
    storagePolicy.setStoragePolicyKey(storagePolicyKey);
    storagePolicyKey.setNamespace(storagePolicyEntity.getNamespace().getCode());
    storagePolicyKey.setStoragePolicyName(storagePolicyEntity.getName());
    StoragePolicyRule storagePolicyRule = new StoragePolicyRule();
    storagePolicy.setStoragePolicyRule(storagePolicyRule);
    storagePolicyRule.setRuleType(storagePolicyEntity.getStoragePolicyRuleType().getCode());
    storagePolicyRule.setRuleValue(storagePolicyEntity.getStoragePolicyRuleValue());
    StoragePolicyFilter storagePolicyFilter = new StoragePolicyFilter();
    storagePolicy.setStoragePolicyFilter(storagePolicyFilter);
    storagePolicyFilter.setNamespace(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 storagePolicyTransition = new StoragePolicyTransition();
    storagePolicy.setStoragePolicyTransition(storagePolicyTransition);
    storagePolicyTransition.setTransitionType(storagePolicyEntity.getStoragePolicyTransitionType().getCode());
    storagePolicy.setStatus(storagePolicyEntity.getStatus().getCode());
    return storagePolicy;
}
Also used : StoragePolicyRule(org.finra.herd.model.api.xml.StoragePolicyRule) StoragePolicyTransition(org.finra.herd.model.api.xml.StoragePolicyTransition) StoragePolicyFilter(org.finra.herd.model.api.xml.StoragePolicyFilter) StoragePolicyKey(org.finra.herd.model.api.xml.StoragePolicyKey) StoragePolicy(org.finra.herd.model.api.xml.StoragePolicy)

Example 2 with StoragePolicyTransition

use of org.finra.herd.model.api.xml.StoragePolicyTransition in project herd by FINRAOS.

the class StoragePolicyRestControllerTest method testGetStoragePolicy.

@Test
public void testGetStoragePolicy() {
    StoragePolicyKey storagePolicyKey = new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME);
    StoragePolicy storagePolicy = new StoragePolicy(ID, 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);
    when(storagePolicyService.getStoragePolicy(storagePolicyKey)).thenReturn(storagePolicy);
    StoragePolicy resultStoragePolicy = storagePolicyRestController.getStoragePolicy(storagePolicyKey.getNamespace(), storagePolicyKey.getStoragePolicyName());
    // Verify the external calls.
    verify(storagePolicyService).getStoragePolicy(storagePolicyKey);
    verifyNoMoreInteractions(storagePolicyService);
    // Validate the returned object.
    assertEquals(storagePolicy, resultStoragePolicy);
}
Also used : StoragePolicyRule(org.finra.herd.model.api.xml.StoragePolicyRule) StoragePolicyTransition(org.finra.herd.model.api.xml.StoragePolicyTransition) StoragePolicyFilter(org.finra.herd.model.api.xml.StoragePolicyFilter) StoragePolicyKey(org.finra.herd.model.api.xml.StoragePolicyKey) StoragePolicy(org.finra.herd.model.api.xml.StoragePolicy) Test(org.junit.Test)

Example 3 with StoragePolicyTransition

use of org.finra.herd.model.api.xml.StoragePolicyTransition in project herd by FINRAOS.

the class StoragePolicyRestControllerTest method testUpdateStoragePolicy.

@Test
public void testUpdateStoragePolicy() {
    // Create a storage policy key.
    StoragePolicyKey storagePolicyKey = new StoragePolicyKey(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME);
    StoragePolicy storagePolicy = new StoragePolicy(ID, 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);
    StoragePolicyUpdateRequest request = storagePolicyServiceTestHelper.createStoragePolicyUpdateRequest(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.DISABLED);
    when(storagePolicyService.updateStoragePolicy(storagePolicyKey, request)).thenReturn(storagePolicy);
    // Update a storage policy.
    StoragePolicy resultStoragePolicy = storagePolicyRestController.updateStoragePolicy(STORAGE_POLICY_NAMESPACE_CD, STORAGE_POLICY_NAME, request);
    // Verify the external calls.
    verify(storagePolicyService).updateStoragePolicy(storagePolicyKey, request);
    verifyNoMoreInteractions(storagePolicyService);
    // Validate the returned object.
    assertEquals(storagePolicy, resultStoragePolicy);
}
Also used : StoragePolicyRule(org.finra.herd.model.api.xml.StoragePolicyRule) StoragePolicyUpdateRequest(org.finra.herd.model.api.xml.StoragePolicyUpdateRequest) StoragePolicyTransition(org.finra.herd.model.api.xml.StoragePolicyTransition) StoragePolicyFilter(org.finra.herd.model.api.xml.StoragePolicyFilter) StoragePolicyKey(org.finra.herd.model.api.xml.StoragePolicyKey) StoragePolicy(org.finra.herd.model.api.xml.StoragePolicy) Test(org.junit.Test)

Example 4 with StoragePolicyTransition

use of org.finra.herd.model.api.xml.StoragePolicyTransition in project herd by FINRAOS.

the class StoragePolicyServiceTestHelper method createStoragePolicyCreateRequest.

/**
 * Creates a storage policy create request.
 *
 * @param storagePolicyKey the storage policy key
 * @param storagePolicyRuleType the storage policy rule type
 * @param storagePolicyRuleValue the storage policy rule value
 * @param businessObjectDefinitionNamespace the business object definition namespace
 * @param businessObjectDefinitionName the business object definition name
 * @param businessObjectFormatUsage the business object usage
 * @param businessObjectFormatFileType the business object format file type
 * @param storageName the storage name
 * @param storagePolicyTransitionType the storage policy transition type
 * @param storagePolicyStatus the storage policy status
 *
 * @return the newly created storage policy create request
 */
public StoragePolicyCreateRequest createStoragePolicyCreateRequest(StoragePolicyKey storagePolicyKey, String storagePolicyRuleType, Integer storagePolicyRuleValue, String businessObjectDefinitionNamespace, String businessObjectDefinitionName, String businessObjectFormatUsage, String businessObjectFormatFileType, String storageName, String storagePolicyTransitionType, String storagePolicyStatus) {
    StoragePolicyCreateRequest request = new StoragePolicyCreateRequest();
    request.setStoragePolicyKey(storagePolicyKey);
    StoragePolicyRule storagePolicyRule = new StoragePolicyRule();
    request.setStoragePolicyRule(storagePolicyRule);
    storagePolicyRule.setRuleType(storagePolicyRuleType);
    storagePolicyRule.setRuleValue(storagePolicyRuleValue);
    StoragePolicyFilter storagePolicyFilter = new StoragePolicyFilter();
    request.setStoragePolicyFilter(storagePolicyFilter);
    storagePolicyFilter.setNamespace(businessObjectDefinitionNamespace);
    storagePolicyFilter.setBusinessObjectDefinitionName(businessObjectDefinitionName);
    storagePolicyFilter.setBusinessObjectFormatUsage(businessObjectFormatUsage);
    storagePolicyFilter.setBusinessObjectFormatFileType(businessObjectFormatFileType);
    storagePolicyFilter.setStorageName(storageName);
    StoragePolicyTransition storagePolicyTransition = new StoragePolicyTransition();
    request.setStoragePolicyTransition(storagePolicyTransition);
    storagePolicyTransition.setTransitionType(storagePolicyTransitionType);
    request.setStatus(storagePolicyStatus);
    return request;
}
Also used : StoragePolicyRule(org.finra.herd.model.api.xml.StoragePolicyRule) StoragePolicyTransition(org.finra.herd.model.api.xml.StoragePolicyTransition) StoragePolicyFilter(org.finra.herd.model.api.xml.StoragePolicyFilter) StoragePolicyCreateRequest(org.finra.herd.model.api.xml.StoragePolicyCreateRequest)

Example 5 with StoragePolicyTransition

use of org.finra.herd.model.api.xml.StoragePolicyTransition in project herd by FINRAOS.

the class StoragePolicyServiceTestHelper method createStoragePolicyUpdateRequest.

/**
 * Creates a storage policy update request.
 *
 * @param storagePolicyRuleType the storage policy rule type
 * @param storagePolicyRuleValue the storage policy rule value
 * @param businessObjectDefinitionNamespace the business object definition namespace
 * @param businessObjectDefinitionName the business object definition name
 * @param businessObjectFormatUsage the business object usage
 * @param businessObjectFormatFileType the business object format file type
 * @param storageName the storage name
 * @param storagePolicyTransitionType the storage policy transition type
 * @param storagePolicyStatus the storage policy status
 *
 * @return the newly created storage policy create request
 */
public StoragePolicyUpdateRequest createStoragePolicyUpdateRequest(String storagePolicyRuleType, Integer storagePolicyRuleValue, String businessObjectDefinitionNamespace, String businessObjectDefinitionName, String businessObjectFormatUsage, String businessObjectFormatFileType, String storageName, String storagePolicyTransitionType, String storagePolicyStatus) {
    StoragePolicyUpdateRequest request = new StoragePolicyUpdateRequest();
    StoragePolicyRule storagePolicyRule = new StoragePolicyRule();
    request.setStoragePolicyRule(storagePolicyRule);
    storagePolicyRule.setRuleType(storagePolicyRuleType);
    storagePolicyRule.setRuleValue(storagePolicyRuleValue);
    StoragePolicyFilter storagePolicyFilter = new StoragePolicyFilter();
    request.setStoragePolicyFilter(storagePolicyFilter);
    storagePolicyFilter.setNamespace(businessObjectDefinitionNamespace);
    storagePolicyFilter.setBusinessObjectDefinitionName(businessObjectDefinitionName);
    storagePolicyFilter.setBusinessObjectFormatUsage(businessObjectFormatUsage);
    storagePolicyFilter.setBusinessObjectFormatFileType(businessObjectFormatFileType);
    storagePolicyFilter.setStorageName(storageName);
    StoragePolicyTransition storagePolicyTransition = new StoragePolicyTransition();
    request.setStoragePolicyTransition(storagePolicyTransition);
    storagePolicyTransition.setTransitionType(storagePolicyTransitionType);
    request.setStatus(storagePolicyStatus);
    return request;
}
Also used : StoragePolicyRule(org.finra.herd.model.api.xml.StoragePolicyRule) StoragePolicyUpdateRequest(org.finra.herd.model.api.xml.StoragePolicyUpdateRequest) StoragePolicyTransition(org.finra.herd.model.api.xml.StoragePolicyTransition) StoragePolicyFilter(org.finra.herd.model.api.xml.StoragePolicyFilter)

Aggregations

StoragePolicyFilter (org.finra.herd.model.api.xml.StoragePolicyFilter)22 StoragePolicyRule (org.finra.herd.model.api.xml.StoragePolicyRule)22 StoragePolicyTransition (org.finra.herd.model.api.xml.StoragePolicyTransition)22 StoragePolicy (org.finra.herd.model.api.xml.StoragePolicy)20 StoragePolicyKey (org.finra.herd.model.api.xml.StoragePolicyKey)20 Test (org.junit.Test)19 StoragePolicyEntity (org.finra.herd.model.jpa.StoragePolicyEntity)10 StoragePolicyCreateRequest (org.finra.herd.model.api.xml.StoragePolicyCreateRequest)2 StoragePolicyUpdateRequest (org.finra.herd.model.api.xml.StoragePolicyUpdateRequest)2