Source:
public void testTopicPartitionCommittedFileFilter() throws Exception { Path log = new Path(ROOT_PATH, "log"); Path oldLog = new Path(ROOT_PATH, "log.1"); String tempName = UUID.randomUUID().toString() + "_" + "tmp"; Path tmp = new Path(ROOT_PATH, tempName); Path valid1 = new Path(ROOT_PATH, "topic+1+2+3.abc"); Path valid2 = new Path(ROOT_PATH, "topic+1+55+67.def"); Path validOtherTopic = new Path(ROOT_PATH, "namespace.topic+1+55+67.def"); Path invalid1 = new Path(ROOT_PATH, "1+2+3"); Path invalid2 = new Path(ROOT_PATH, "a_b_c_d"); Path invalid3 = new Path(ROOT_PATH, "tmp"); Path invalid4 = new Path(ROOT_PATH, "a.b"); Path invalid5 = new Path(ROOT_PATH, "topic_234_56_78.ghi"); Path invalid6 = new Path(ROOT_PATH, "topic_34_56_7.hjk"); fs.createNewFile(log); fs.createNewFile(oldLog); fs.createNewFile(tmp); fs.createNewFile(valid1); fs.createNewFile(valid2); fs.createNewFile(validOtherTopic); fs.createNewFile(invalid1); fs.createNewFile(invalid2); fs.createNewFile(invalid3); fs.createNewFile(invalid4); fs.createNewFile(invalid5); fs.createNewFile(invalid6); TopicPartition tp = new TopicPartition("topic", 1); FileStatus[] statuses = fs.listStatus(ROOT_PATH, new TopicPartitionCommittedFileFilter(tp)); Set<String> files = new HashSet<>(); for (FileStatus status : statuses) { files.add(status.getPath().getName()); } assertEquals(2, files.size()); assertTrue(files.contains(valid1.getName())); assertTrue(files.contains(valid2.getName())); FileStatus[] statusesOtherTopic = fs.listStatus( ROOT_PATH, new TopicCommittedFileFilter("namespace.topic")); assertEquals(1, statusesOtherTopic.length); assertEquals(validOtherTopic.getName(), statusesOtherTopic[0].getPath().getName()); fs.deleteOnExit(ROOT_PATH); fs.deleteOnExit(ROOT_PATH); }

Target:
public void testTopicPartitionCommittedFileFilter() throws Exception { Path log = new Path(ROOT_PATH, "log"); Path oldLog = new Path(ROOT_PATH, "log.1"); String tempName = UUID.randomUUID().toString() + "_" + "tmp"; Path tmp = new Path(ROOT_PATH, tempName); Path valid1 = new Path(ROOT_PATH, "topic+1+2+3.abc"); Path valid2 = new Path(ROOT_PATH, "topic+1+55+67.def"); Path validOtherTopic = new Path(ROOT_PATH, "namespace.topic+1+55+67.def"); Path invalid1 = new Path(ROOT_PATH, "1+2+3"); Path invalid2 = new Path(ROOT_PATH, "a_b_c_d"); Path invalid3 = new Path(ROOT_PATH, "tmp"); Path invalid4 = new Path(ROOT_PATH, "a.b"); Path invalid5 = new Path(ROOT_PATH, "topic_234_56_78.ghi"); Path invalid6 = new Path(ROOT_PATH, "topic_34_56_7.hjk"); fs.createNewFile(log); fs.createNewFile(oldLog); fs.createNewFile(tmp); fs.createNewFile(valid1); fs.createNewFile(valid2); fs.createNewFile(validOtherTopic); fs.createNewFile(invalid1); fs.createNewFile(invalid2); fs.createNewFile(invalid3); fs.createNewFile(invalid4); fs.createNewFile(invalid5); fs.createNewFile(invalid6); TopicPartition tp = new TopicPartition("topic", 1); FileStatus[] statuses = fs.listStatus(ROOT_PATH, new TopicPartitionCommittedFileFilter(tp)); Set<String> files = new HashSet<>(); for (FileStatus status : statuses) { files.add(status.getPath().getName()); } assertEquals(2, files.size()); assertTrue(files.contains(valid1.getName())); assertTrue(files.contains(valid2.getName())); TopicPartition tp2 = new TopicPartition("namespace.topic", 1); FileStatus[] statusesOtherTopic = fs.listStatus( ROOT_PATH, new TopicPartitionCommittedFileFilter(tp2)); assertEquals(1, statusesOtherTopic.length); assertEquals(validOtherTopic.getName(), statusesOtherTopic[0].getPath().getName()); fs.deleteOnExit(ROOT_PATH); }