@Test public void saveConfiguration_Exception() throws Exception { TranscribeConfiguration configuration = new TranscribeConfiguration(); configuration.setEnabled(true); configuration.setAutomaticEnabled(true); configuration.setNewTranscriptionForNewVersion(false); configuration.setCopyTranscriptionForNewVersion(true); configuration.setCost(new BigDecimal("0.001")); configuration.setConfidence(80); configuration.setNumberOfFilesForProcessing(10); configuration.setWordCountPerItem(30); configuration.setProvider(TranscribeServiceProvider.AWS); configuration.setProviders(Arrays.asList(TranscribeServiceProvider.AWS)); ObjectMapper objectMapper = new ObjectMapper(); SaveConfigurationException exception = new SaveConfigurationException("error"); when(mockAuthentication.getName()).thenReturn("user"); when(mockArkCaseTranscribeService.saveConfiguration(any(TranscribeConfiguration.class))).thenThrow(exception); try { mockMvc.perform(post("/api/v1/plugin/admin/transcribe/configuration") .accept(MediaType.parseMediaType("application/json;charset=UTF-8")) .contentType(MediaType.APPLICATION_JSON) .principal(mockAuthentication) .content(objectMapper.writeValueAsString(configuration))) .andReturn(); } catch (Exception e) { assertNotNull(e); assertTrue(e.getCause() instanceof SaveConfigurationException); assertEquals("error", e.getCause().getMessage()); } }
@RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public TranscribeConfiguration saveConfiguration(@RequestBody TranscribeConfiguration configuration) throws SaveConfigurationException { return getArkCaseTranscribeService().saveConfiguration(configuration); }
SaveTranscribeConfigurationAPIController { @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public TranscribeConfiguration saveConfiguration(@RequestBody TranscribeConfiguration configuration) throws SaveConfigurationException { return getArkCaseTranscribeService().saveConfiguration(configuration); } }
SaveTranscribeConfigurationAPIController { @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public TranscribeConfiguration saveConfiguration(@RequestBody TranscribeConfiguration configuration) throws SaveConfigurationException { return getArkCaseTranscribeService().saveConfiguration(configuration); }  }
SaveTranscribeConfigurationAPIController { @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public TranscribeConfiguration saveConfiguration(@RequestBody TranscribeConfiguration configuration) throws SaveConfigurationException { return getArkCaseTranscribeService().saveConfiguration(configuration); }  @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody TranscribeConfiguration saveConfiguration(@RequestBody TranscribeConfiguration configuration); ArkCaseTranscribeService getArkCaseTranscribeService(); void setArkCaseTranscribeService(ArkCaseTranscribeService arkCaseTranscribeService); }
SaveTranscribeConfigurationAPIController { @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public TranscribeConfiguration saveConfiguration(@RequestBody TranscribeConfiguration configuration) throws SaveConfigurationException { return getArkCaseTranscribeService().saveConfiguration(configuration); }  @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody TranscribeConfiguration saveConfiguration(@RequestBody TranscribeConfiguration configuration); ArkCaseTranscribeService getArkCaseTranscribeService(); void setArkCaseTranscribeService(ArkCaseTranscribeService arkCaseTranscribeService);  }