### Question:
UTCTimeOnlyField extends AbstractField<LocalTime> { @Override public byte[] getBytes() { switch (valueLen) { case 8: return TIME_FORMATTER_SECONDS.format(value).getBytes(US_ASCII); case 12: return TIME_FORMATTER_MILLIS.format(value).getBytes(US_ASCII); case 15: return TIME_FORMATTER_MICROS.format(value).getBytes(US_ASCII); case 18: return TIME_FORMATTER_NANOS.format(value).getBytes(US_ASCII); case 21: return TIME_FORMATTER_PICOS.format(value).getBytes(US_ASCII); default: } if (valueLen > TIME_PATTERN_PICOS_LENGTH) { return (TIME_FORMATTER_NANOS.format(value)).getBytes(US_ASCII); } else if (valueLen > TIME_PATTERN_NANOS_LENGTH) { return TIME_FORMATTER_NANOS.format(value).getBytes(US_ASCII); } else if (valueLen > TIME_PATTERN_MICROS_LENGTH) { return TIME_FORMATTER_MICROS.format(value).getBytes(US_ASCII); } else if (valueLen > TIME_PATTERN_MILLIS_LENGTH) { return TIME_FORMATTER_MILLIS.format(value).getBytes(US_ASCII); } else { return TIME_FORMATTER_SECONDS.format(value).getBytes(US_ASCII); } } UTCTimeOnlyField(int tagNum, byte[] bytes);  UTCTimeOnlyField(int tagNum, String timestampString);  UTCTimeOnlyField(int tagNum, LocalTime value); static LocalTime parse(String timestampString); static LocalTime parse(byte[] bytes); @Override LocalTime getValue(); @Override byte[] getBytes(); @Override boolean equals(Object o); @Override int hashCode();  }### Answer:
@Test public void testGetBytesNoMillis() throws Exception { int tag = new Random().nextInt(); byte[] bytes = TIMESTAMP_NO_MILLIS.getBytes(); UTCTimeOnlyField field = new UTCTimeOnlyField(tag, bytes); assertArrayEquals(bytes, field.getBytes()); }
@Test public void testGetBytesWithMillis() throws Exception { int tag = new Random().nextInt(); byte[] bytes = TIMESTAMP_WITH_MILLIS.getBytes(); UTCTimeOnlyField field = new UTCTimeOnlyField(tag, bytes); assertArrayEquals(bytes, field.getBytes()); }
@Test public void testGetBytesWithMicros() throws Exception { int tag = new Random().nextInt(); byte[] bytes = TIMESTAMP_WITH_MICROS.getBytes(); UTCTimeOnlyField field = new UTCTimeOnlyField(tag, bytes); assertArrayEquals(bytes, field.getBytes()); }
@Test public void testGetBytesWithNanos() throws Exception { int tag = new Random().nextInt(); byte[] bytes = TIMESTAMP_WITH_NANOS.getBytes(); UTCTimeOnlyField field = new UTCTimeOnlyField(tag, bytes); assertArrayEquals(bytes, field.getBytes()); }
@Test public void testGetBytesWithPicos() throws Exception { int tag = new Random().nextInt(); byte[] bytes = TIMESTAMP_WITH_PICOS.getBytes(); UTCTimeOnlyField field = new UTCTimeOnlyField(tag, bytes); byte[] nanosBytes = (TIMESTAMP_WITH_NANOS+"000").getBytes(); assertArrayEquals(nanosBytes, field.getBytes()); }