@Test public void stopRecording() throws IOException, SerializationException, BusinessException { storageData = new StorageData(); storageData.setName("Test"); RecordingProperties recordingProperties = mock(RecordingProperties.class); when(recordingProperties.isAutoFinalize()).thenReturn(true); storageManager.startOrScheduleRecording(storageData, recordingProperties); when(storageRecorder.isRecordingOn()).thenReturn(true); when(storageRecorder.getRecordingState()).thenReturn(RecordingState.ON); when(storageRecorder.getRecordingProperties()).thenReturn(recordingProperties); when(storageRecorder.getStorageWriter()).thenReturn(storageWriter); doAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { when(storageRecorder.isRecordingOn()).thenReturn(false); when(storageRecorder.getRecordingState()).thenReturn(RecordingState.OFF); return null; } }).when(storageRecorder).stopRecording(); storageManager.stopRecording(); verify(storageRecorder, times(1)).stopRecording(); assertThat(storageManager.isStorageClosed(storageData), is(true)); assertThat(storageManager.getRecordingState(), is(RecordingState.OFF)); }
public void stopRecording() throws IOException, SerializationException, BusinessException { synchronized (this) { if (storageRecorder.isRecordingOn() || storageRecorder.isRecordingScheduled()) { boolean autoFinalize = storageRecorder.getRecordingProperties().isAutoFinalize(); StorageWriter storageWriter = storageRecorder.getStorageWriter(); storageRecorder.stopRecording(); recorderStorageData.markOpened(); openedStoragesMap.put(recorderStorageData, storageWriter); if (autoFinalize) { this.closeStorage(recorderStorageData); } writeStorageDataToDisk(recorderStorageData); recorderStorageData = null; } } }
CmrStorageManager extends StorageManager implements ApplicationListener<ContextClosedEvent> { public void stopRecording() throws IOException, SerializationException, BusinessException { synchronized (this) { if (storageRecorder.isRecordingOn() || storageRecorder.isRecordingScheduled()) { boolean autoFinalize = storageRecorder.getRecordingProperties().isAutoFinalize(); StorageWriter storageWriter = storageRecorder.getStorageWriter(); storageRecorder.stopRecording(); recorderStorageData.markOpened(); openedStoragesMap.put(recorderStorageData, storageWriter); if (autoFinalize) { this.closeStorage(recorderStorageData); } writeStorageDataToDisk(recorderStorageData); recorderStorageData = null; } } } }
CmrStorageManager extends StorageManager implements ApplicationListener<ContextClosedEvent> { public void stopRecording() throws IOException, SerializationException, BusinessException { synchronized (this) { if (storageRecorder.isRecordingOn() || storageRecorder.isRecordingScheduled()) { boolean autoFinalize = storageRecorder.getRecordingProperties().isAutoFinalize(); StorageWriter storageWriter = storageRecorder.getStorageWriter(); storageRecorder.stopRecording(); recorderStorageData.markOpened(); openedStoragesMap.put(recorderStorageData, storageWriter); if (autoFinalize) { this.closeStorage(recorderStorageData); } writeStorageDataToDisk(recorderStorageData); recorderStorageData = null; } } }  }
CmrStorageManager extends StorageManager implements ApplicationListener<ContextClosedEvent> { public void stopRecording() throws IOException, SerializationException, BusinessException { synchronized (this) { if (storageRecorder.isRecordingOn() || storageRecorder.isRecordingScheduled()) { boolean autoFinalize = storageRecorder.getRecordingProperties().isAutoFinalize(); StorageWriter storageWriter = storageRecorder.getStorageWriter(); storageRecorder.stopRecording(); recorderStorageData.markOpened(); openedStoragesMap.put(recorderStorageData, storageWriter); if (autoFinalize) { this.closeStorage(recorderStorageData); } writeStorageDataToDisk(recorderStorageData); recorderStorageData = null; } } }  void createStorage(StorageData storageData); StorageWriter openStorage(StorageData storageData); void closeStorage(StorageData storageData); void deleteStorage(StorageData storageData); StorageData getRecordingStorage(); RecordingProperties getRecordingProperties(); RecordingState getRecordingState(); WritingStatus getRecordingStatus(); void startOrScheduleRecording(StorageData storageData, RecordingProperties recordingProperties); void stopRecording(); void record(DefaultData dataToRecord); void writeToStorage(StorageData storageData, Collection<? extends DefaultData> dataToWrite, Collection<AbstractDataProcessor> dataProcessors, boolean synchronously); void copyBufferToStorage(StorageData storageData, List<Long> platformIdents, Collection<AbstractDataProcessor> dataProcessors, boolean autoFinalize); void copyDataToStorage(StorageData storageData, Collection<Long> elementIds, long platformIdent, Set<Long> traceIds, Collection<AbstractDataProcessor> dataProcessors, boolean autoFinalize); StorageData getStorageData(String id); List<StorageData> getExistingStorages(); List<StorageData> getOpenedStorages(); List<StorageData> getReadableStorages(); boolean isStorageOpen(StorageData storageData); boolean isStorageExisting(StorageData storageData); boolean isStorageClosed(StorageData storageData); long getStorageQueuedWriteTaskCount(StorageData storageData); @Override Path getStoragePath(IStorageData storageData); Map<String, Long> getFilesHttpLocation(StorageData storageData, final String extension); void addLabelToStorage(StorageData storageData, AbstractStorageLabel<?> storageLabel, boolean doOverwrite); boolean removeLabelFromStorage(StorageData storageData, AbstractStorageLabel<?> storageLabel); void updateStorageData(StorageData storageData); Map<StorageData, String> getWritersStatus(); void unpackUploadedStorage(final IStorageData packedStorageData); void createStorageFromUploadedDir(final IStorageData localStorageData); String getCachedStorageDataFileLocation(StorageData storageData, int hash); @PostConstruct void postConstruct(); @Override void onApplicationEvent(ContextClosedEvent event); @Override String toString(); }
CmrStorageManager extends StorageManager implements ApplicationListener<ContextClosedEvent> { public void stopRecording() throws IOException, SerializationException, BusinessException { synchronized (this) { if (storageRecorder.isRecordingOn() || storageRecorder.isRecordingScheduled()) { boolean autoFinalize = storageRecorder.getRecordingProperties().isAutoFinalize(); StorageWriter storageWriter = storageRecorder.getStorageWriter(); storageRecorder.stopRecording(); recorderStorageData.markOpened(); openedStoragesMap.put(recorderStorageData, storageWriter); if (autoFinalize) { this.closeStorage(recorderStorageData); } writeStorageDataToDisk(recorderStorageData); recorderStorageData = null; } } }  void createStorage(StorageData storageData); StorageWriter openStorage(StorageData storageData); void closeStorage(StorageData storageData); void deleteStorage(StorageData storageData); StorageData getRecordingStorage(); RecordingProperties getRecordingProperties(); RecordingState getRecordingState(); WritingStatus getRecordingStatus(); void startOrScheduleRecording(StorageData storageData, RecordingProperties recordingProperties); void stopRecording(); void record(DefaultData dataToRecord); void writeToStorage(StorageData storageData, Collection<? extends DefaultData> dataToWrite, Collection<AbstractDataProcessor> dataProcessors, boolean synchronously); void copyBufferToStorage(StorageData storageData, List<Long> platformIdents, Collection<AbstractDataProcessor> dataProcessors, boolean autoFinalize); void copyDataToStorage(StorageData storageData, Collection<Long> elementIds, long platformIdent, Set<Long> traceIds, Collection<AbstractDataProcessor> dataProcessors, boolean autoFinalize); StorageData getStorageData(String id); List<StorageData> getExistingStorages(); List<StorageData> getOpenedStorages(); List<StorageData> getReadableStorages(); boolean isStorageOpen(StorageData storageData); boolean isStorageExisting(StorageData storageData); boolean isStorageClosed(StorageData storageData); long getStorageQueuedWriteTaskCount(StorageData storageData); @Override Path getStoragePath(IStorageData storageData); Map<String, Long> getFilesHttpLocation(StorageData storageData, final String extension); void addLabelToStorage(StorageData storageData, AbstractStorageLabel<?> storageLabel, boolean doOverwrite); boolean removeLabelFromStorage(StorageData storageData, AbstractStorageLabel<?> storageLabel); void updateStorageData(StorageData storageData); Map<StorageData, String> getWritersStatus(); void unpackUploadedStorage(final IStorageData packedStorageData); void createStorageFromUploadedDir(final IStorageData localStorageData); String getCachedStorageDataFileLocation(StorageData storageData, int hash); @PostConstruct void postConstruct(); @Override void onApplicationEvent(ContextClosedEvent event); @Override String toString();  }