StoragePlatformRestController extends HerdBaseController { @RequestMapping(value = "/storagePlatforms/{name}", method = RequestMethod.GET) @Secured(SecurityFunctions.FN_STORAGE_PLATFORMS_GET) public StoragePlatform getStoragePlatform(@PathVariable("name") String name) { return storagePlatformService.getStoragePlatform(name); }  @RequestMapping(value = "/storagePlatforms/{name}", method = RequestMethod.GET) @Secured(SecurityFunctions.FN_STORAGE_PLATFORMS_GET) StoragePlatform getStoragePlatform(@PathVariable("name") String name); @RequestMapping(value = "/storagePlatforms", method = RequestMethod.GET) @Secured(SecurityFunctions.FN_STORAGE_PLATFORMS_ALL_GET) StoragePlatforms getStoragePlatforms();  }
@Test public void testGetStoragePlatform() throws Exception { StoragePlatform storagePlatform = new StoragePlatform(StoragePlatformEntity.S3); when(storagePlatformService.getStoragePlatform(StoragePlatformEntity.S3)).thenReturn(storagePlatform); StoragePlatform resultStoragePlatform = storagePlatformRestController.getStoragePlatform(StoragePlatformEntity.S3); assertNotNull(storagePlatform); assertTrue(StoragePlatformEntity.S3.equals(storagePlatform.getName())); logger.info("Storage platform name: " + storagePlatform.getName()); verify(storagePlatformService).getStoragePlatform(StoragePlatformEntity.S3); verifyNoMoreInteractions(storagePlatformService); assertEquals(storagePlatform, resultStoragePlatform); }
@Test(expected = ObjectNotFoundException.class) public void testGetStoragePlatformInvalidName() throws Exception { ObjectNotFoundException exception = new ObjectNotFoundException("not found"); String platform = "invalid" + getRandomSuffix(); when(storagePlatformService.getStoragePlatform(platform)).thenThrow(exception); storagePlatformRestController.getStoragePlatform(platform); }