PrettyCliOutput implements CliOutput { @Override public void printWorkflow(Workflow wf, WorkflowState state) { System.out.println("Component: " + wf.componentId()); System.out.println("Workflow: " + wf.workflowId()); System.out.println("Schedule: " + wf.configuration().schedule()); System.out.println("Offset: " + wf.configuration().offset().orElse("")); System.out.println("Docker Image: " + wf.configuration().dockerImage().orElse("")); System.out.println("Docker Arguments: " + wf.configuration().dockerArgs().orElse(Collections.emptyList())); System.out.println("Termination Logging: " + wf.configuration().dockerTerminationLogging()); System.out.println("Secret: " + wf.configuration().secret().map(s -> s.name() + ':' + s.mountPath()).orElse("")); System.out.println("Service Account: " + wf.configuration().serviceAccount().orElse("")); System.out.println("Resources: " + wf.configuration().resources()); System.out.println("Environment: " + Joiner.on(' ').withKeyValueSeparator('=').join(wf.configuration().env())); System.out.println("Timeout: " + wf.configuration().runningTimeout().map(Duration::toString).orElse("")); System.out.println("Commit: " + wf.configuration().commitSha().orElse("")); System.out.println("Retry Condition: " + wf.configuration().retryCondition().orElse("")); System.out.println("Enabled: " + state.enabled().map(Object::toString).orElse("")); System.out.println("Next Trigger: " + state.nextNaturalTrigger().map(Object::toString).orElse("")); System.out.println("Next Trigger (offset): " + state.nextNaturalOffsetTrigger().map(Object::toString).orElse("")); }  @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 shouldPrintWorkflow() { final Workflow workflow = Workflow.create("foo1", WorkflowConfiguration.builder() .id("bar1") .schedule(Schedule.DAYS) .offset("6h") .dockerImage("foo/bar:baz") .dockerArgs(List.of("foo", "the", "bar")) .dockerTerminationLogging(true) .secret(Secret.create("secret-foo", "/foo-secret")) .serviceAccount("foo@bar.baz") .resources("r1", "r2") .env("FOO", "foo", "BAR", "bar") .runningTimeout(Duration.parse("PT23H")) .commitSha("deadbeef") .retryCondition("#tries<2") .build()); final WorkflowState state = WorkflowState.builder() .enabled(true) .nextNaturalTrigger(OffsetDateTime.of(2018, 1, 2, 3, 4, 5, 6, ZoneOffset.UTC).toInstant()) .nextNaturalOffsetTrigger(OffsetDateTime.of(2018, 1, 2, 9, 4, 5, 6, ZoneOffset.UTC).toInstant()) .build(); cliOutput.printWorkflow(workflow, state); assertThat(outContent.toString(), is( "Component: foo1\n" + "Workflow: bar1\n" + "Schedule: DAYS\n" + "Offset: 6h\n" + "Docker Image: foo/bar:baz\n" + "Docker Arguments: [foo, the, bar]\n" + "Termination Logging: true\n" + "Secret: secret-foo:/foo-secret\n" + "Service Account: foo@bar.baz\n" + "Resources: [r1, r2]\n" + "Environment: BAR=bar FOO=foo\n" + "Timeout: PT23H\n" + "Commit: deadbeef\n" + "Retry Condition: #tries<2\n" + "Enabled: true\n" + "Next Trigger: 2018-01-02T03:04:05.000000006Z\n" + "Next Trigger (offset): 2018-01-02T09:04:05.000000006Z\n")); }