/** * Creates a new file type. * * @param request the information needed to create the file type * * @return the created file type */ @RequestMapping(value = "/fileTypes", method = RequestMethod.POST, consumes = {"application/xml", "application/json"}) @Secured(SecurityFunctions.FN_FILE_TYPES_POST) public FileType createFileType(@RequestBody FileTypeCreateRequest request) { return fileTypeService.createFileType(request); }
/** * Creates a new file type. * * @param request the information needed to create the file type * * @return the created file type */ @RequestMapping(value = "/fileTypes", method = RequestMethod.POST, consumes = {"application/xml", "application/json"}) @Secured(SecurityFunctions.FN_FILE_TYPES_POST) public FileType createFileType(@RequestBody FileTypeCreateRequest request) { return fileTypeService.createFileType(request); }
@Test public void testCreateFileType() throws Exception { FileTypeCreateRequest fileTypeCreateRequest = new FileTypeCreateRequest(FORMAT_FILE_TYPE_CODE); // Create a file type. FileType fileType = new FileType(FORMAT_FILE_TYPE_CODE); when(fileTypeService.createFileType(fileTypeCreateRequest)).thenReturn(fileType); FileType resultFileType = fileTypeRestController.createFileType(new FileTypeCreateRequest(FORMAT_FILE_TYPE_CODE)); // Validate the returned object. assertEquals(new FileType(FORMAT_FILE_TYPE_CODE), resultFileType); // Verify the external calls. verify(fileTypeService).createFileType(fileTypeCreateRequest); verifyNoMoreInteractions(fileTypeService); // Validate the returned object. assertEquals(fileType, resultFileType); }