### Question:
CliTokenImpl implements CliToken { public static List<CliToken> tokenize(String s) { List<CliToken> tokens = new LinkedList<CliToken>(); tokenize(s, 0, tokens); tokens = correctPipeChar(tokens); return tokens; } CliTokenImpl(boolean text, String value);  CliTokenImpl(boolean text, String raw, String value); @Override boolean isText(); @Override boolean isBlank(); String raw(); String value(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); static List<CliToken> tokenize(String s);  }### Answer:
@Test public void testSupportedPipeCharWithoutRegex() { String[] expectedTextTokenValue = new String[]{"thread", "|", "grep", "xxx"}; List<CliToken> actualTokens = CliTokenImpl.tokenize("thread| grep xxx"); assertEquals(expectedTextTokenValue, actualTokens); actualTokens = CliTokenImpl.tokenize("thread | grep xxx"); assertEquals(expectedTextTokenValue, actualTokens); actualTokens = CliTokenImpl.tokenize("thread |grep xxx"); assertEquals(expectedTextTokenValue, actualTokens); }
@Test public void testSupportedPipeCharWithRegex() { String[] expectedTextTokenValue = new String[]{"trace", "-E", "classA|classB", "methodA|methodB", "|", "grep", "classA"}; List<CliToken> actualTokens = CliTokenImpl.tokenize("trace -E classA|classB methodA|methodB| grep classA"); assertEquals(expectedTextTokenValue, actualTokens); actualTokens = CliTokenImpl.tokenize("trace -E classA|classB methodA|methodB | grep classA"); assertEquals(expectedTextTokenValue, actualTokens); actualTokens = CliTokenImpl.tokenize("trace -E classA|classB methodA|methodB |grep classA"); assertEquals(expectedTextTokenValue, actualTokens); }
@Test public void testUnSupportedPipeChar() { String[] expectedTextTokenValue = new String[]{"thread|grep", "xxx"}; List<CliToken> actualTokens = CliTokenImpl.tokenize("thread|grep xxx"); assertEquals(expectedTextTokenValue, actualTokens); expectedTextTokenValue = new String[]{"trace", "-E", "classA|classB", "methodA|methodB|grep", "classA"}; actualTokens = CliTokenImpl.tokenize("trace -E classA|classB methodA|methodB|grep classA"); assertEquals(expectedTextTokenValue, actualTokens); expectedTextTokenValue = new String[]{"trace", "-E", "classA|classB", "|", "methodA|methodB", "|", "grep", "classA"}; actualTokens = CliTokenImpl.tokenize("trace -E classA|classB| methodA|methodB | grep classA"); assertEquals(expectedTextTokenValue, actualTokens); }