JobPrinter { public void printJob(GlacierJobDescription job, OutputStream o) { final PrintWriter out = new PrintWriter(o); out.println("Job ID:\t\t\t\t" + job.getJobId()); out.println("Creation date:\t\t\t" + job.getCreationDate()); if (job.getCompleted()) { out.println("Completion date:\t" + job.getCompletionDate()); } out.println("Status:\t\t\t\t" + job.getStatusCode() + (job.getStatusMessage() != null ? " (" + job.getStatusMessage() + ")" : "")); out.println(); out.flush(); }  void printJob(GlacierJobDescription job, OutputStream o);  }
@Test public void printJob() throws Exception { final String jobId = UUID.randomUUID().toString(); final String statusMessage = UUID.randomUUID().toString(); final ByteArrayOutputStream out = new ByteArrayOutputStream(); final GlacierJobDescription job = new GlacierJobDescription(); job.setJobId(jobId); job.setCompleted(true); final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); job.setCompletionDate(dateFormat.format(new Date(0))); job.setStatusCode(StatusCode.Succeeded); job.setStatusMessage(statusMessage); new JobPrinter().printJob(job, out); assertEquals("Job ID:\t\t\t\t" + jobId + LINE_SEPARATOR + "Creation date:\t\t\tnull" + LINE_SEPARATOR + "Completion date:\t1970-01-01 00:00:00" + LINE_SEPARATOR + "Status:\t\t\t\tSucceeded (" + statusMessage + ")" + LINE_SEPARATOR + LINE_SEPARATOR, out.toString()); }