OutputDirFormatter { public String format(long beginNS, long endNS, String query) { return sanitize(Joiner.on("_").join(beginNS, endNS, query, UUID.randomUUID().toString())); }  String format(long beginNS, long endNS, String query);  }
@Test public void formats_directory_name_for_query_filter_types() { long beginNS = TimestampConverters.MILLISECONDS.toNanoseconds(System.currentTimeMillis()); long endNS = TimestampConverters.MILLISECONDS.toNanoseconds(System.currentTimeMillis()); String query = "ip_dst_addr == '207.28.210.1' and protocol == 'PROTOCOL: ICMP(1)"; String queryFilterString = new QueryPcapFilter.Configurator().queryToString(query); OutputDirFormatter formatter = new OutputDirFormatter(); String actual = formatter.format(beginNS, endNS, queryFilterString); assertThat("Formatted directory names did not match.", actual, containsString("_ip_dst_addr_==_207-28-210-1_and_protocol_==_PROTOCOL_ICMP(1)_")); new Path(actual); }
@Test public void formats_directory_name_for_fixed_filter_types() { long beginNS = TimestampConverters.MILLISECONDS.toNanoseconds(System.currentTimeMillis()); long endNS = TimestampConverters.MILLISECONDS.toNanoseconds(System.currentTimeMillis()); Map<String, String> fields = new HashMap<>(); fields.put("ip_src_address", "207.28.210.1"); fields.put("protocol", "PROTOCOL: ICMP(1)"); String fixedFilterString = new FixedPcapFilter.Configurator().queryToString(fields); OutputDirFormatter formatter = new OutputDirFormatter(); String actual = formatter.format(beginNS, endNS, fixedFilterString); assertThat("Formatted directory names did not match.", actual, containsString("PROTOCOL_ICMP(1)_207-28-210-1")); new Path(actual); }