BatchProfilerCLI implements Serializable { public static void main(String[] args) throws IOException, org.apache.commons.cli.ParseException, Exception { CommandLine commandLine = parseCommandLine(args); profiles = Preconditions.checkNotNull(handleProfileDefinitions(commandLine), "An error occurred while reading profile data"); profilerProps = handleProfilerProperties(commandLine); globals = handleGlobals(commandLine); readerProps = handleReaderProperties(commandLine); if(!profiles.getTimestampField().isPresent()) { throw new IllegalArgumentException("The Batch Profiler must use event time. The 'timestampField' must be defined in the profile definitions file or via the --timestampField argument."); } if(profiles.getProfiles().size() == 0) { throw new IllegalArgumentException("No profile definitions found."); } SparkSession spark = SparkSession .builder() .config(new SparkConf()) .getOrCreate(); BatchProfiler profiler = new BatchProfiler(); long count = profiler.run(spark, profilerProps, globals, readerProps, profiles); LOG.info("Profiler produced {} profile measurement(s)", count); }  static void main(String[] args); static Properties getGlobals(); static Properties getProfilerProps(); static ProfilerConfig getProfiles(); static Properties getReaderProps(); static Properties globals; static Properties profilerProps; static Properties readerProps; static ProfilerConfig profiles; }
@Test public void mustDefineTimestampField() throws Exception { String[] args = new String[] { "--profiles", "src/test/resources/profiles-no-timestamp-field.json" }; assertThrows(IllegalArgumentException.class, () -> BatchProfilerCLI.main(args)); }
@Test public void mustDefineProfilesOption() { String[] args = new String[] {}; assertThrows(MissingOptionException.class, () -> BatchProfilerCLI.main(args)); }
@Test public void mustDefineOnlyOneProfilesOption() { String[] args = new String[] { "--profiles", "src/test/resources/profiles-no-timestamp-field.json", "--zookeeper", "node1:2181" }; assertThrows(IllegalArgumentException.class, () -> BatchProfilerCLI.main(args)); }
@Test public void mustDefineFieldnametoGoWithTimestamp() { String[] args = new String[] { "--timestampfield" }; assertThrows(MissingArgumentException.class, () -> BatchProfilerCLI.main(args)); }
@Test public void mustDefineProfiles() throws Exception { String[] args = new String[] { "--profiles", "src/test/resources/profiles-empty.json" }; assertThrows(IllegalArgumentException.class, () -> BatchProfilerCLI.main(args)); }