### Question:
FormatPluginOptionExtractor { @VisibleForTesting Collection<FormatPluginOptionsDescriptor> getOptions() { return optionsByTypeName.values(); } FormatPluginOptionExtractor(ScanResult scanResult);   }### Answer:
@Test public void test() { DrillConfig config = DrillConfig.create(); ScanResult scanResult = RunTimeScan.fromPrescan(config); FormatPluginOptionExtractor e = new FormatPluginOptionExtractor(scanResult); Collection<FormatPluginOptionsDescriptor> options = e.getOptions(); for (FormatPluginOptionsDescriptor d : options) { assertEquals(d.pluginConfigClass.getAnnotation(JsonTypeName.class).value(), d.typeName); switch (d.typeName) { case "text": assertEquals(TextFormatConfig.class, d.pluginConfigClass); assertEquals( "(type: String, lineDelimiter: String, fieldDelimiter: String, quote: String, escape: String, comment: String, skipFirstLine: boolean, extractHeader: boolean)", d.presentParams() ); break; case "named": assertEquals(NamedFormatPluginConfig.class, d.pluginConfigClass); assertEquals("(type: String, name: String)", d.presentParams()); break; case "parquet": assertEquals(d.typeName, "(type: String, autoCorrectCorruptDates: boolean)", d.presentParams()); break; case "json": case "sequencefile": case "pcap": case "avro": assertEquals(d.typeName, "(type: String)", d.presentParams()); break; case "httpd": assertEquals("(type: String, logFormat: String, timestampFormat: String)", d.presentParams()); break; default: fail("add validation for format plugin type " + d.typeName); } } }
@Test public void test() { DrillConfig config = DrillConfig.create(); ScanResult scanResult = RunTimeScan.fromPrescan(config); FormatPluginOptionExtractor e = new FormatPluginOptionExtractor(scanResult); Collection<FormatPluginOptionsDescriptor> options = e.getOptions(); for (FormatPluginOptionsDescriptor d : options) { assertEquals(d.pluginConfigClass.getAnnotation(JsonTypeName.class).value(), d.typeName); switch (d.typeName) { case "text": assertEquals(TextFormatConfig.class, d.pluginConfigClass); assertEquals( "(type: String, lineDelimiter: String, fieldDelimiter: String, quote: String, escape: String, comment: String, skipFirstLine: boolean, extractHeader: boolean)", d.presentParams() ); break; case "named": assertEquals(NamedFormatPluginConfig.class, d.pluginConfigClass); assertEquals("(type: String, name: String)", d.presentParams()); break; case "parquet": assertEquals(d.typeName, "(type: String, autoCorrectCorruptDates: boolean, enableStringsSignedMinMax: boolean)", d.presentParams()); break; case "json": case "sequencefile": case "pcapng": case "avro": assertEquals(d.typeName, "(type: String)", d.presentParams()); break; case "pcap": assertEquals(d.typeName, "(type: String, sessionizeTCPStreams: boolean)", d.presentParams()); break; case "httpd": assertEquals("(type: String, logFormat: String, timestampFormat: String)", d.presentParams()); break; case "image": assertEquals(ImageFormatConfig.class, d.pluginConfigClass); assertEquals( "(type: String, fileSystemMetadata: boolean, descriptive: boolean, timeZone: String)", d.presentParams() ); break; case "logRegex": assertEquals(d.typeName, "(type: String, regex: String, extension: String, maxErrors: int, schema: List)", d.presentParams()); break; default: fail("add validation for format plugin type " + d.typeName); } } }