StoragePolicyRestController extends HerdBaseController { @RequestMapping(value = STORAGE_POLICIES_URI_PREFIX, method = RequestMethod.POST, consumes = {"application/xml", "application/json"}) @Secured(SecurityFunctions.FN_STORAGE_POLICIES_POST) public StoragePolicy createStoragePolicy(@RequestBody StoragePolicyCreateRequest request) { return storagePolicyService.createStoragePolicy(request); }  @RequestMapping(value = STORAGE_POLICIES_URI_PREFIX, method = RequestMethod.POST, consumes = {"application/xml", "application/json"}) @Secured(SecurityFunctions.FN_STORAGE_POLICIES_POST) StoragePolicy createStoragePolicy(@RequestBody StoragePolicyCreateRequest request); @RequestMapping(value = STORAGE_POLICIES_URI_PREFIX + "/namespaces/{namespace}/storagePolicyNames/{storagePolicyName}", method = RequestMethod.PUT, consumes = {"application/xml", "application/json"}) @Secured(SecurityFunctions.FN_STORAGE_POLICIES_PUT) StoragePolicy updateStoragePolicy(@PathVariable("namespace") String namespace, @PathVariable("storagePolicyName") String storagePolicyName,
        @RequestBody StoragePolicyUpdateRequest request); @RequestMapping(value = STORAGE_POLICIES_URI_PREFIX + "/namespaces/{namespace}/storagePolicyNames/{storagePolicyName}", method = RequestMethod.GET) @Secured(SecurityFunctions.FN_STORAGE_POLICIES_GET) StoragePolicy getStoragePolicy(@PathVariable("namespace") String namespace, @PathVariable("storagePolicyName") String storagePolicyName); static final String STORAGE_POLICIES_URI_PREFIX; }
@Test public void testCreateStoragePolicy() { 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); StoragePolicyCreateRequest request = storagePolicyServiceTestHelper .createStoragePolicyCreateRequest(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); when(storagePolicyService.createStoragePolicy(request)).thenReturn(storagePolicy); StoragePolicy resultStoragePolicy = storagePolicyRestController.createStoragePolicy(request); verify(storagePolicyService).createStoragePolicy(request); verifyNoMoreInteractions(storagePolicyService); assertEquals(storagePolicy, resultStoragePolicy); }