TabletRowAdapter { public static String toDebugOutput(TabletId tid) { StringJoiner joiner = new StringJoiner(", ", "[", "]"); Text endRow = tid.getEndRow(); if (null != endRow) { Optional<String> prefix = decodeRowPrefix(endRow); OptionalLong offset = decodeRowOffset(endRow); prefix.ifPresent(s -> joiner.add("prefix: " + s)); if (offset.isPresent()) { LocalDateTime date = Instant.ofEpochMilli(offset.getAsLong()).atZone(ZoneId.of("UTC")) .toLocalDateTime(); joiner.add("date: " + date.toString()); joiner.add("millis: " + offset.getAsLong()); } } return joiner.toString(); }  static OptionalLong decodeRowOffset(Text row); static Optional<String> decodeRowPrefix(Text row); static String toDebugOutput(TabletId tid);  }
@Test public void debugOutputTest() { long offset = 1554962382848L; ComparablePair<String, Long> p = new ComparablePair<>("sys.disk.disk_octets", offset); byte[] bytes = pairCoder.encode(p); TabletId tid = EasyMock.createMock(TabletId.class); EasyMock.expect(tid.getEndRow()).andReturn(new Text(bytes)); EasyMock.replay(tid); String debug = TabletRowAdapter.toDebugOutput(tid); assertThat(debug, CoreMatchers.containsString("prefix: sys.disk.disk_octets")); assertThat(debug, CoreMatchers.containsString("date: 2019-04-11T05:59:42.848")); assertThat(debug, CoreMatchers.containsString("millis: 1554962382848")); }