PrettyCliOutput implements CliOutput { @Override public void printStates(RunStateDataPayload runStateDataPayload) { System.out.println(String.format(" %-20s %-12s %-47s %-7s %s", "WORKFLOW INSTANCE", "STATE", "EXECUTION ID", "TRIES", "PREVIOUS EXECUTION MESSAGE")); CliUtil.groupStates(runStateDataPayload.activeStates()).forEach((key, value) -> { System.out.println(); System.out.println(String.format("%s %s", colored(CYAN, key.componentId()), colored(BLUE, key.id()))); value.forEach(runStateData -> { final StateData stateData = runStateData.stateData(); final Ansi ansiState = getAnsiForState(runStateData); final Message lastMessage = stateData.message().orElse(Message.create(Message.MessageLevel.UNKNOWN, "No info")); final Ansi ansiMessage = colored(messageColor(lastMessage.level()), lastMessage.line()); System.out.println(String.format(" %-20s %-20s %-47s %-7d %s", runStateData.workflowInstance().parameter(), ansiState, stateData.executionId().orElse("<no-execution-id>"), stateData.tries(), ansiMessage)); }); }); }  @Override void printStates(RunStateDataPayload runStateDataPayload); @Override void printEvents(List<EventInfo> eventInfos); @Override void printBackfill(Backfill backfill, boolean noTruncate); @Override void printBackfillPayload(BackfillPayload backfillPayload, boolean noTruncate); @Override void printBackfills(List<BackfillPayload> backfills, boolean noTruncate); @Override void printResources(List<Resource> resources); @Override void printMessage(String message); @Override void printWorkflow(Workflow wf, WorkflowState state); @Override void printWorkflows(List<Workflow> workflows); @Override void printError(String message);  }
@Test public void shouldPrintStates() { final RunStateDataPayload states = RunStateDataPayload.create(List.of( RunStateData.create( WorkflowInstance.create(WorkflowId.create("c0", "w0"), "2016-09-01"), "QUEUED", StateData.newBuilder() .messages(Message.info("foo")) .executionId("e0") .tries(17) .build()), RunStateData.create( WorkflowInstance.create(WorkflowId.create("c1", "w1"), "2016-09-02"), "SUBMITTED", StateData.newBuilder() .messages(Message.warning("baz")) .executionId("e1") .tries(3) .build()))); cliOutput.printStates(states); assertThat(outContent.toString(), is(" WORKFLOW INSTANCE STATE EXECUTION ID TRIES PREVIOUS EXECUTION MESSAGE\n" + "\n" + colored(CYAN, "c0") + " " + colored(BLUE, "w0") + "\n" + " 2016-09-01 " + coloredBright(BLACK, "QUEUED") + " e0 " + " 17 " + colored(GREEN, "foo") + "\n" + "\n" + colored(CYAN, "c1") + " " + colored(BLUE, "w1") + "\n" + " 2016-09-02 " + colored(CYAN, "SUBMITTED") + " e1 " + " 3 " + colored(YELLOW, "baz") + "\n")); }