### Question:
CommentDetector implements LineDetector<Character> { @Override public ValuesWithConfidence<Character> detect(LineSampler sampler) { ValueWithConfidence<Character> result = new ValueWithConfidence<>(); TCharIntHashMap firstChars = new TCharIntHashMap(); for (String line : sampler.getBeginningSampleLines()) { if (!line.isEmpty()) { char firstChar = line.charAt(0); if (isComment(firstChar)) { if (!firstChars.containsKey(firstChar)) { firstChars.put(firstChar, 0); } firstChars.put(firstChar, firstChars.get(firstChar) + 1); } } } for (char ch : firstChars.keys()) { float confidence = getConfidenceMultiplier(ch); float firstCharLinePercentage = (sampler.getBeginningSampleLines().size() - firstChars.get(ch)) / (float)sampler.getBeginningSampleLines().size(); if (confidence > result.getConfidence() && firstCharLinePercentage > ourCommentThreshold) { result.setValue(Character.valueOf(ch)); result.setConfidence(confidence); } } return new ValuesWithConfidence<Character>(result); } CommentDetector();  CommentDetector(Character delimiter, Character quoteChar); @Override ValuesWithConfidence<Character> detect(LineSampler sampler);  }### Answer:
@Test public void testBasic() { ValuesWithConfidence<Character> result = new CommentDetector() .detect(new ListLineSampler(CsvTestUtils.createBasicDelimitedData(","))); Assert.assertNull(result.getBestValue()); }
@Test public void testBasicWithEmptyLine() { List<String> data = CsvTestUtils.createBasicDelimitedData(",", Character.valueOf('"'), false); data.add(StringUtilities.join(",", new String[] { "", "", "", "", "" })); ValuesWithConfidence<Character> result = new CommentDetector().detect(new ListLineSampler(data)); Assert.assertNull(result.getBestValue()); }
@Test public void testBasicWithQuotes() { ValuesWithConfidence<Character> result = new CommentDetector() .detect(new ListLineSampler(CsvTestUtils.createBasicDelimitedData(",", Character.valueOf('"'), false))); Assert.assertNull(result.getBestValue()); }
@Test public void testHard() { ValuesWithConfidence<Character> result = new CommentDetector().detect(new ListLineSampler(CsvTestUtils.createHardData())); Assert.assertEquals(Character.valueOf('='), result.getBestValue()); }
@Test public void testHashDelimiter() { List<String> data = CsvTestUtils.createBasicDelimitedData("#"); data.add(StringUtilities.join("#", new String[] { "", "", "", "", "" })); ValuesWithConfidence<Character> result = new CommentDetector(Character.valueOf('#'), null) .detect(new ListLineSampler(data)); Assert.assertNull(result.getBestValue()); }