mirror of https://github.com/apache/nifi.git
NIFI-551 checkstyle mods to provided patch. Main issue was extraneous imports. No biggie.
This commit is contained in:
parent
6f32e6e977
commit
5eed335804
|
@ -106,8 +106,7 @@ abstract class AbstractKiteProcessor extends AbstractProcessor {
|
|||
};
|
||||
|
||||
/**
|
||||
* Resolves a {@link Schema} for the given string, either a URI or a JSON
|
||||
* literal.
|
||||
* Resolves a {@link Schema} for the given string, either a URI or a JSON literal.
|
||||
*/
|
||||
protected static Schema getSchema(String uriOrLiteral, Configuration conf) {
|
||||
URI uri;
|
||||
|
|
|
@ -122,7 +122,7 @@ public class ConvertJSONToAvro extends AbstractKiteProcessor {
|
|||
writer.setCodec(CodecFactory.snappyCodec());
|
||||
|
||||
try {
|
||||
successfulRecords = session.write(successfulRecords, new StreamCallback() {
|
||||
successfulRecords = session.write(successfulRecords, new StreamCallback() {
|
||||
@Override
|
||||
public void process(InputStream in, OutputStream out) throws IOException {
|
||||
FlowFile failedRecords = session.create();
|
||||
|
@ -143,8 +143,8 @@ public class ConvertJSONToAvro extends AbstractKiteProcessor {
|
|||
failedRecords = session.append(failedRecords, new OutputStreamCallback() {
|
||||
@Override
|
||||
public void process(OutputStream out) throws IOException {
|
||||
out.write((e.getMessage() + " [" +
|
||||
e.getCause().getMessage() + "]\n").getBytes());
|
||||
out.write((e.getMessage() + " ["
|
||||
+ e.getCause().getMessage() + "]\n").getBytes());
|
||||
}
|
||||
});
|
||||
errors += 1;
|
||||
|
@ -154,7 +154,7 @@ public class ConvertJSONToAvro extends AbstractKiteProcessor {
|
|||
session.adjustCounter("Converted records", written,
|
||||
false /* update only if file transfer is successful */);
|
||||
session.adjustCounter("Conversion errors", errors,
|
||||
false /* update only if file transfer is successful */);
|
||||
false /* update only if file transfer is successful */);
|
||||
|
||||
if (errors > 0L) {
|
||||
getLogger().warn("Failed to convert " + errors + '/' + total + " records from JSON to Avro");
|
||||
|
|
|
@ -18,17 +18,11 @@
|
|||
*/
|
||||
package org.apache.nifi.processors.kite;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.avro.Schema;
|
||||
import org.apache.avro.SchemaBuilder;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.apache.nifi.util.MockFlowFile;
|
||||
import org.apache.nifi.util.TestRunner;
|
||||
import org.apache.nifi.util.TestRunners;
|
||||
import org.junit.Assert;
|
||||
|
@ -50,8 +44,8 @@ public class TestJSONToAvroProcessor {
|
|||
+ "{\"id\": 10, \"color\": 15.23}\n" + // invalid, color as double
|
||||
"{\"id\": 2, \"color\": \"grey\", \"price\": 12.95 }";
|
||||
|
||||
public static final String FAILURE_CONTENT = "Cannot convert field id [Cannot convert to long: \"120V\"]\n" +
|
||||
"Cannot convert field color [Cannot convert to string: 15.23]\n";
|
||||
public static final String FAILURE_CONTENT = "Cannot convert field id [Cannot convert to long: \"120V\"]\n"
|
||||
+ "Cannot convert field color [Cannot convert to string: 15.23]\n";
|
||||
|
||||
@Test
|
||||
public void testBasicConversion() throws IOException {
|
||||
|
@ -72,7 +66,7 @@ public class TestJSONToAvroProcessor {
|
|||
runner.assertTransferCount("failure", 1);
|
||||
|
||||
String failureContent = Bytes.toString(runner.getContentAsByteArray(
|
||||
runner.getFlowFilesForRelationship("failure").get(0)));
|
||||
runner.getFlowFilesForRelationship("failure").get(0)));
|
||||
Assert.assertEquals("Should reject an invalid string and double", FAILURE_CONTENT, failureContent);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue