LiferayBatchFileWriter implements WriterWithFeedback<Result, IndexedRecord, IndexedRecord> { @Override public void write(Object object) throws IOException { if (!(object instanceof IndexedRecord)) { _result.rejectCount++; return; } IndexedRecord indexedRecord = (IndexedRecord)object; try { JsonObject jsonObject = _indexedRecordJsonObjectConverter.toJsonObject(indexedRecord); _outputStreamWriter.write(jsonObject.toString()); _outputStreamWriter.write(System.lineSeparator()); _result.successCount++; if ((_result.successCount % _FLUSH_TRIGGER_WRITES) == 0) { _outputStreamWriter.flush(); } } catch (ConverterException converterException) { _indexedRecordJsonObjectConverter.reject( indexedRecord, converterException); } _result.totalCount++; } LiferayBatchFileWriter(
		WriteOperation<Result> writeOperation,
		RuntimeContainer runtimeContainer); @Override void cleanWrites(); @Override Result close(); @Override Iterable<IndexedRecord> getRejectedWrites(); @Override Iterable<IndexedRecord> getSuccessfulWrites(); @Override WriteOperation<Result> getWriteOperation(); @Override void open(String uId); @Override void write(Object object);  }
@Test public void testWrite() throws Exception { JsonObject oasJsonObject = readObject("openapi_data_types.json"); Schema entitySchema = getEntitySchema("BigDecimal", oasJsonObject); LiferayBatchFileProperties batchFileProperties = new LiferayBatchFileProperties( _testTemporaryDirectory.getAbsolutePath() + "/testOutput.jsonl", entitySchema, "batchFileProperties", oasJsonObject); LiferayMockRuntimeContainer liferayMockRuntimeContainer = new LiferayMockRuntimeContainer(batchFileProperties); LiferayBatchFileWriter liferayBatchFileWriter = new LiferayBatchFileWriter( new LiferayBatchFileWriteOperation(null), liferayMockRuntimeContainer); liferayBatchFileWriter.open("testUid"); IndexedRecord indexedRecord = createIndexedRecordFromFile( "bigdecimal_content.json", entitySchema); Schema.Field idField = entitySchema.getField("id"); idField.pos(); for (int i = 1; i < 10; i++) { indexedRecord.put(idField.pos(), Long.valueOf(i)); liferayBatchFileWriter.write(indexedRecord); } liferayBatchFileWriter.close(); }