JSONIntermediateDataFormat extends IntermediateDataFormat<JSONObject> { @Override public String getCSVTextData() { super.validateSchema(schema); return toCSV(data); } JSONIntermediateDataFormat();  JSONIntermediateDataFormat(Schema schema); @Override void setCSVTextData(String text); @Override String getCSVTextData(); @Override void setObjectData(Object[] data); @Override Object[] getObjectData(); @Override void write(DataOutput out); @Override void read(DataInput in); @Override Set<String> getJars(); @Override String toString();  }
@Test public void testInputAsDataInAndCSVOut() { String csvExpected = "10,34,'54','random data'," + getByteFieldString(new byte[] { (byte) -112, (byte) 54 }) + ",'" + String.valueOf(0x0A) + "','ENUM'," + csvArray + "," + map + ",true," + dateTime + "," + time + "," + date + ",13.44," + csvSet; dataFormat.setData(createJSONObject()); assertEquals(csvExpected, dataFormat.getCSVTextData()); }
@Test(expectedExceptions = SqoopException.class) public void testNotSettingSchemaAndGetCSVData() { dataFormat = new JSONIntermediateDataFormat(); dataFormat.getCSVTextData(); }
@SuppressWarnings("unchecked") @Test public void testNullValueAsDataInAndCSVTextOut() { JSONObject json = new JSONObject(); for (int i = 1; i <= 15; i++) { json.put(String.valueOf(i), null); } dataFormat.setData(json); String csvText = dataFormat.getCSVTextData(); String[] textValues = csvText.split(","); assertEquals(15, textValues.length); for (String text : textValues) { assertEquals(text, NULL_VALUE); } }