CallableQuery extends CallableJob implements Callable<Void> { public static String makeAttachmentText(PersistentResultSet results) { StringBuilder sb = new StringBuilder(); for (int i = 0 ; i < results.getColumnNames().size() ; i++) { sb.append(results.getColumnNames().get(i)) .append("(").append(results.getColumnTypes().get(i)).append(")"); if (i != results.getColumnNames().size() - 1) { sb.append('\t'); } } sb.append('\n'); for (int i = 0 ; i < results.getData().size() ; i++) { for (int j = 0 ; j < results.getData().get(i).size() ; j++) { sb.append(results.getData().get(i).get(j)); if (j != results.getData().get(i).size() - 1) { sb.append('\t'); } } sb.append('\n'); } return sb.toString(); } CallableQuery();  CallableQuery(PlannedJob plannedJob, JobDao dao,
                       Reporting reporting, String hostname,
                       MailInfo mailInfo, Session session,
                       SupportedDriver driver, String reportRootPath,
                       int attemptNumber); static String[] cleanupQuery(String[] parts); static String getJobReportDir(String rootPath, PlannedJob plannedJob); static String getJobReportPath(String reportJobPath, PlannedJob plannedJob); @VisibleForTesting static void writeReportToLocal(PersistentResultSet result, String rootPath, PlannedJob plannedJob); @VisibleForTesting static String createMessageContent(PersistentResultSet results, JobSpec spec,
                                             String replacedReportQuery); static StringBuilder createInlineResults(PersistentResultSet results, JobSpec spec); static String makeAttachmentText(PersistentResultSet results); String getReplacedQuery(); String getReplacedReportQuery(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); static Logger LOG; static final String TSV; static final String TAB; static final String ENTER; static final String NULL; static final String QUERY_SPLITTER; }
@Test public void testMakeAttachmentText() { PersistentResultSet results = getPRS(); String actual = CallableQuery.makeAttachmentText(results); String expected = String.format("%s(%s) %s(%s)\n" + "%s %s\n" + "%s %s\n", results.getColumnNames().get(0), results.getColumnTypes().get(0), results.getColumnNames().get(1), results.getColumnTypes().get(1), results.getData().get(0).get(0), results.getData().get(0).get(1), results.getData().get(1).get(0), results.getData().get(1).get(1)); Assert.assertEquals(expected, actual); }