### Question:
KinesisRecorder extends AbstractKinesisRecorder { void upgrade(File directory) { synchronized (KinesisRecorder.this) { final File recordsDir = new File(directory, Constants.RECORDS_DIRECTORY); final File oldRecordsFile = new File(recordsDir, Constants.RECORDS_FILE_NAME); if (!oldRecordsFile.isFile()) { return; } final FileRecordStore frs = new FileRecordStore(directory, Constants.RECORDS_FILE_NAME, Long.MAX_VALUE); final RecordIterator iterator = frs.iterator(); while (iterator.hasNext()) { try { final JSONObject json = new JSONObject(iterator.next()); saveRecord(JSONRecordAdapter.getData(json).array(), JSONRecordAdapter.getStreamName(json)); } catch (final JSONException e) { LOGGER.debug("caught exception", e); continue; } } try { iterator.close(); } catch (final IOException e) { LOGGER.debug("caught exception", e); } oldRecordsFile.delete(); } } KinesisRecorder(File directory, Regions region,
            AWSCredentialsProvider credentialsProvider);  KinesisRecorder(File directory, Regions region,
            AWSCredentialsProvider credentialsProvider, KinesisRecorderConfig config);   KinesisRecorder(KinesisStreamRecordSender sender, FileRecordStore recordStore,
            KinesisRecorderConfig config); @Override void saveRecord(byte[] data, String streamName);  }### Answer:
@SuppressWarnings("deprecation") @Test public void testUpgrade() throws Exception { File directory = temp.newFolder(); FileRecordStore recordStore = new FileRecordStore(directory, Constants.RECORDS_FILE_NAME, 5 * 1024 * 1024); String streamName = "stream"; int length = 1024; JSONRecordAdapter adapter = new JSONRecordAdapter(); for (int i = 0; i < 10; i++) { PutRecordRequest req = new PutRecordRequest(); req.setStreamName(streamName); byte[] bytes = randomBytes(length); req.setData(ByteBuffer.wrap(bytes)); req.setPartitionKey(UUID.randomUUID().toString()); recordStore.put(adapter.translateFromRecord(req).toString()); } recorder = new KinesisRecorder(directory, Regions.US_EAST_1, provider); Thread.sleep(1000); RecordIterator iterator = recorder.recordStore.iterator(); FileRecordParser frp = new FileRecordParser(); int count = 0; while (iterator.hasNext()) { count++; frp.parse(iterator.next()); assertEquals("same stream", streamName, frp.streamName); assertEquals("same data length", length, frp.bytes.length); } assertEquals("has 10 records from upgrade", 10, count); }