ProcessState { static String renderTimeString(long startTime, long currentTime) { long elapsed = currentTime - startTime; StringBuilder sb = new StringBuilder(Long.toString(elapsed/1000)).append('.'); long ms = elapsed % 1000; if (ms < 100) { sb.append('0'); } if (ms < 10) { sb.append('0'); } sb.append(ms).append('s'); return sb.toString(); } private  ProcessState(); synchronized List<ProcessStateMessage> getMessagesAndClear(); boolean isFinished(); static void addMessage(ProcessState state, String message); static void addMessage(ProcessState state, String message, String details); static ProcessState start(String uuid); static void stop(String uuid); static ProcessState getProcessState(String uuid); static final ProcessState NO; }
@Test public void testRenderTimeString() { assertEquals("0.001s", ProcessState.renderTimeString(0, 1)); assertEquals("0.010s", ProcessState.renderTimeString(0, 10)); assertEquals("0.100s", ProcessState.renderTimeString(0, 100)); assertEquals("1.000s", ProcessState.renderTimeString(0, 1000)); assertEquals("1.001s", ProcessState.renderTimeString(0, 1001)); assertEquals("1.010s", ProcessState.renderTimeString(0, 1010)); }