@SuppressWarnings("deprecation") @Test public void startRecording() throws BusinessException { String id = "id"; StorageData storageData = new StorageData(); storageData.setId(id); when(storageService.getExistingStorages()).thenReturn(Collections.singletonList(storageData)); restfulService.startOrScheduleRecording(id, 10L, 20L, true, true); ArgumentCaptor<RecordingProperties> propertiesCaptor = ArgumentCaptor.forClass(RecordingProperties.class); verify(storageService, times(1)).startOrScheduleRecording(eq(storageData), propertiesCaptor.capture()); assertThat(propertiesCaptor.getValue().getStartDelay(), is(10L)); assertThat(propertiesCaptor.getValue().getRecordDuration(), is(20L)); assertThat(propertiesCaptor.getValue().isAutoFinalize(), is(true)); assertThat(propertiesCaptor.getValue().getRecordingDataProcessors(), hasItem(is(InvocationExtractorDataProcessor.class))); restfulService.startOrScheduleRecording(id, 10L, 20L, false, false); verify(storageService, times(2)).startOrScheduleRecording(eq(storageData), propertiesCaptor.capture()); assertThat(propertiesCaptor.getValue().isAutoFinalize(), is(false)); assertThat(propertiesCaptor.getValue().getRecordingDataProcessors(), not(hasItem(is(InvocationExtractorDataProcessor.class)))); }
@RequestMapping(method = RequestMethod.GET, value = "start") @ResponseBody public Object startOrScheduleRecording(@RequestParam(value = "id", required = true) String id, @RequestParam(value = "startDelay", required = false) Long startDelay, @RequestParam(value = "recordingDuration", required = false) Long recordingDuration, @RequestParam(value = "extractInvocations", required = false, defaultValue = "true") Boolean extractInvocations, @RequestParam(value = "autoFinalize", required = false, defaultValue = "true") Boolean autoFinalize) throws BusinessException { if (null == getStorageById(id)) { throw new BusinessException("Start or schedule recording on storage with ID=" + id + " via storage REST service.", StorageErrorCodeEnum.STORAGE_DOES_NOT_EXIST); } StorageData storageData = new StorageData(); storageData.setId(id); RecordingProperties recordingProperties = getRecordingProperties(extractInvocations.booleanValue()); recordingProperties.setAutoFinalize(autoFinalize.booleanValue()); if ((null != startDelay) && (startDelay.longValue() > 0)) { recordingProperties.setStartDelay(startDelay.longValue()); } if ((null != recordingDuration) && (recordingDuration.longValue() > 0)) { recordingProperties.setRecordDuration(recordingDuration.longValue()); } StorageData recordingStorage = storageService.startOrScheduleRecording(storageData, recordingProperties); Map<String, Object> resultMap = new HashMap<>(); if (recordingProperties.getStartDelay() > 0) { resultMap.put("message", "Recording scheduled."); } else { resultMap.put("message", "Recording started."); } resultMap.put("recordingStorage", recordingStorage); return resultMap; }
StorageRestfulService { @RequestMapping(method = RequestMethod.GET, value = "start") @ResponseBody public Object startOrScheduleRecording(@RequestParam(value = "id", required = true) String id, @RequestParam(value = "startDelay", required = false) Long startDelay, @RequestParam(value = "recordingDuration", required = false) Long recordingDuration, @RequestParam(value = "extractInvocations", required = false, defaultValue = "true") Boolean extractInvocations, @RequestParam(value = "autoFinalize", required = false, defaultValue = "true") Boolean autoFinalize) throws BusinessException { if (null == getStorageById(id)) { throw new BusinessException("Start or schedule recording on storage with ID=" + id + " via storage REST service.", StorageErrorCodeEnum.STORAGE_DOES_NOT_EXIST); } StorageData storageData = new StorageData(); storageData.setId(id); RecordingProperties recordingProperties = getRecordingProperties(extractInvocations.booleanValue()); recordingProperties.setAutoFinalize(autoFinalize.booleanValue()); if ((null != startDelay) && (startDelay.longValue() > 0)) { recordingProperties.setStartDelay(startDelay.longValue()); } if ((null != recordingDuration) && (recordingDuration.longValue() > 0)) { recordingProperties.setRecordDuration(recordingDuration.longValue()); } StorageData recordingStorage = storageService.startOrScheduleRecording(storageData, recordingProperties); Map<String, Object> resultMap = new HashMap<>(); if (recordingProperties.getStartDelay() > 0) { resultMap.put("message", "Recording scheduled."); } else { resultMap.put("message", "Recording started."); } resultMap.put("recordingStorage", recordingStorage); return resultMap; } }
StorageRestfulService { @RequestMapping(method = RequestMethod.GET, value = "start") @ResponseBody public Object startOrScheduleRecording(@RequestParam(value = "id", required = true) String id, @RequestParam(value = "startDelay", required = false) Long startDelay, @RequestParam(value = "recordingDuration", required = false) Long recordingDuration, @RequestParam(value = "extractInvocations", required = false, defaultValue = "true") Boolean extractInvocations, @RequestParam(value = "autoFinalize", required = false, defaultValue = "true") Boolean autoFinalize) throws BusinessException { if (null == getStorageById(id)) { throw new BusinessException("Start or schedule recording on storage with ID=" + id + " via storage REST service.", StorageErrorCodeEnum.STORAGE_DOES_NOT_EXIST); } StorageData storageData = new StorageData(); storageData.setId(id); RecordingProperties recordingProperties = getRecordingProperties(extractInvocations.booleanValue()); recordingProperties.setAutoFinalize(autoFinalize.booleanValue()); if ((null != startDelay) && (startDelay.longValue() > 0)) { recordingProperties.setStartDelay(startDelay.longValue()); } if ((null != recordingDuration) && (recordingDuration.longValue() > 0)) { recordingProperties.setRecordDuration(recordingDuration.longValue()); } StorageData recordingStorage = storageService.startOrScheduleRecording(storageData, recordingProperties); Map<String, Object> resultMap = new HashMap<>(); if (recordingProperties.getStartDelay() > 0) { resultMap.put("message", "Recording scheduled."); } else { resultMap.put("message", "Recording started."); } resultMap.put("recordingStorage", recordingStorage); return resultMap; }  }
StorageRestfulService { @RequestMapping(method = RequestMethod.GET, value = "start") @ResponseBody public Object startOrScheduleRecording(@RequestParam(value = "id", required = true) String id, @RequestParam(value = "startDelay", required = false) Long startDelay, @RequestParam(value = "recordingDuration", required = false) Long recordingDuration, @RequestParam(value = "extractInvocations", required = false, defaultValue = "true") Boolean extractInvocations, @RequestParam(value = "autoFinalize", required = false, defaultValue = "true") Boolean autoFinalize) throws BusinessException { if (null == getStorageById(id)) { throw new BusinessException("Start or schedule recording on storage with ID=" + id + " via storage REST service.", StorageErrorCodeEnum.STORAGE_DOES_NOT_EXIST); } StorageData storageData = new StorageData(); storageData.setId(id); RecordingProperties recordingProperties = getRecordingProperties(extractInvocations.booleanValue()); recordingProperties.setAutoFinalize(autoFinalize.booleanValue()); if ((null != startDelay) && (startDelay.longValue() > 0)) { recordingProperties.setStartDelay(startDelay.longValue()); } if ((null != recordingDuration) && (recordingDuration.longValue() > 0)) { recordingProperties.setRecordDuration(recordingDuration.longValue()); } StorageData recordingStorage = storageService.startOrScheduleRecording(storageData, recordingProperties); Map<String, Object> resultMap = new HashMap<>(); if (recordingProperties.getStartDelay() > 0) { resultMap.put("message", "Recording scheduled."); } else { resultMap.put("message", "Recording started."); } resultMap.put("recordingStorage", recordingStorage); return resultMap; }  @ExceptionHandler(Exception.class) ModelAndView handleAllException(Exception exception); @RequestMapping(method = GET, value = "") @ResponseBody List<StorageData> getAllStorages(); @RequestMapping(method = GET, value = "{id}") @ResponseBody StorageData getStorageById(@PathVariable String id); @RequestMapping(method = GET, value = "{name}/create") @ResponseBody Object createStorage(@PathVariable String name); @RequestMapping(method = GET, value = "{id}/finalize") @ResponseBody Object finalizeStorage(@PathVariable String id); @RequestMapping(method = GET, value = "{id}/delete") @ResponseBody Object deleteStorage(@PathVariable String id); @RequestMapping(method = GET, value = "state") @ResponseBody Map<String, Object> getRecordingState(); @RequestMapping(method = GET, value = "stop") @ResponseBody Object stopRecording(); @RequestMapping(method = RequestMethod.GET, value = "start") @ResponseBody Object startOrScheduleRecording(@RequestParam(value = "id", required = true) String id, @RequestParam(value = "startDelay", required = false) Long startDelay,
			@RequestParam(value = "recordingDuration", required = false) Long recordingDuration,
			@RequestParam(value = "extractInvocations", required = false, defaultValue = "true") Boolean extractInvocations,
			@RequestParam(value = "autoFinalize", required = false, defaultValue = "true") Boolean autoFinalize); @ModelAttribute void setVaryResponseHeader(HttpServletResponse response); }
StorageRestfulService { @RequestMapping(method = RequestMethod.GET, value = "start") @ResponseBody public Object startOrScheduleRecording(@RequestParam(value = "id", required = true) String id, @RequestParam(value = "startDelay", required = false) Long startDelay, @RequestParam(value = "recordingDuration", required = false) Long recordingDuration, @RequestParam(value = "extractInvocations", required = false, defaultValue = "true") Boolean extractInvocations, @RequestParam(value = "autoFinalize", required = false, defaultValue = "true") Boolean autoFinalize) throws BusinessException { if (null == getStorageById(id)) { throw new BusinessException("Start or schedule recording on storage with ID=" + id + " via storage REST service.", StorageErrorCodeEnum.STORAGE_DOES_NOT_EXIST); } StorageData storageData = new StorageData(); storageData.setId(id); RecordingProperties recordingProperties = getRecordingProperties(extractInvocations.booleanValue()); recordingProperties.setAutoFinalize(autoFinalize.booleanValue()); if ((null != startDelay) && (startDelay.longValue() > 0)) { recordingProperties.setStartDelay(startDelay.longValue()); } if ((null != recordingDuration) && (recordingDuration.longValue() > 0)) { recordingProperties.setRecordDuration(recordingDuration.longValue()); } StorageData recordingStorage = storageService.startOrScheduleRecording(storageData, recordingProperties); Map<String, Object> resultMap = new HashMap<>(); if (recordingProperties.getStartDelay() > 0) { resultMap.put("message", "Recording scheduled."); } else { resultMap.put("message", "Recording started."); } resultMap.put("recordingStorage", recordingStorage); return resultMap; }  @ExceptionHandler(Exception.class) ModelAndView handleAllException(Exception exception); @RequestMapping(method = GET, value = "") @ResponseBody List<StorageData> getAllStorages(); @RequestMapping(method = GET, value = "{id}") @ResponseBody StorageData getStorageById(@PathVariable String id); @RequestMapping(method = GET, value = "{name}/create") @ResponseBody Object createStorage(@PathVariable String name); @RequestMapping(method = GET, value = "{id}/finalize") @ResponseBody Object finalizeStorage(@PathVariable String id); @RequestMapping(method = GET, value = "{id}/delete") @ResponseBody Object deleteStorage(@PathVariable String id); @RequestMapping(method = GET, value = "state") @ResponseBody Map<String, Object> getRecordingState(); @RequestMapping(method = GET, value = "stop") @ResponseBody Object stopRecording(); @RequestMapping(method = RequestMethod.GET, value = "start") @ResponseBody Object startOrScheduleRecording(@RequestParam(value = "id", required = true) String id, @RequestParam(value = "startDelay", required = false) Long startDelay,
			@RequestParam(value = "recordingDuration", required = false) Long recordingDuration,
			@RequestParam(value = "extractInvocations", required = false, defaultValue = "true") Boolean extractInvocations,
			@RequestParam(value = "autoFinalize", required = false, defaultValue = "true") Boolean autoFinalize); @ModelAttribute void setVaryResponseHeader(HttpServletResponse response);  }