### Question:
CaptureTag extends AbstractAction<TweetState> { @Override public TweetState processByte(byte b, TweetState currentState) throws Exception { TweetState retVal = currentState; if (b == ' ') { retVal = TweetState.READY; output.build(tagStream.toString(), os); if (!terminating) { super.writeByte(' '); } reset(); } else { buf[0] = b; tagStream.write(buf); } return retVal; } CaptureTag(OutputStream os, OutputStrategy output); @Override TweetState processByte(byte b, TweetState currentState); void reset(); @Override void terminate(TweetState state);  }### Answer:
@Test public void testHashTagCaptureWithSpaceTerminator() throws Exception { TweetState result = TweetState.OFF; String expected = "hashTag "; byte[] bytes = expected.getBytes(); for (byte b : bytes) { result = instance.processByte(b, TweetState.HASHTAG); if (result == TweetState.READY) { break; } } assertEquals(result, TweetState.READY); String resultString = out.toString(); assertEquals(expected, resultString); }
@Test public void testHashTagCaptureWithoutSpaceTerminator() throws Exception { TweetState result = TweetState.READY; byte[] bytes = "hashTag".getBytes(); for (byte b : bytes) { result = instance.processByte(b, TweetState.HASHTAG); } assertEquals(TweetState.HASHTAG, result); String resultString = out.toString(); assertEquals("", resultString); }
@Test public void testNameTagCaptureWithSpaceTerminator() throws Exception { TweetState result = TweetState.OFF; String expected = "nameTag "; byte[] bytes = expected.getBytes(); for (byte b : bytes) { result = instance.processByte(b, TweetState.NAMETAG); if (result == TweetState.READY) { break; } } assertEquals(result, TweetState.READY); String resultString = out.toString(); assertEquals(expected, resultString); }