@Override protected void callInternal() throws BackendException { JobSpec currJob = plannedJob.getJobSpec(); String jobName = currJob.getName(); try (Connection conn = getConnectionForJobSpec(currJob)) { int step = 0; try (Statement statement = conn.createStatement()) { while (step < parts.length) { doStep(currJob, parts[step], statement); step++; } } catch (SQLException ex) { throw new BackendException(ex); } if (replacedReportQuery != null && !replacedReportQuery.isEmpty()) { PersistentResultSet results = doReportStep(conn, replacedReportQuery); String content = createMessageContent (results, currJob, this.getReplacedReportQuery()); DataSource attachment = createAttachment(results); if (reportRootPath != null) { writeReportToLocal(results, reportRootPath, plannedJob); } sendEmail(mailInfo, attachment, content, currJob); } } catch (Exception ex) { throw new RuntimeException(ex); } reporting.mark("chronos.query." + jobName + "." + "passed"); setStatus(0); }
results.getData().get(0).get(0), results.getData().get(0).get(1), results.getData().get(1).get(0), results.getData().get(1).get(1), cq.getReplacedReportQuery()); String actual = CallableQuery.createMessageContent(results, aJob, cq.getReplacedReportQuery()); Assert.assertEquals(expected, actual);
@Test public void testReplacedReportQuery() { JobSpec aJob = TestAgent.getTestJob("Mark Rothko", dao); aJob.setResultQuery("select * from blah where dt=${YYYMMDDHH}"); dao.createJob(aJob); PlannedJob pj = new PlannedJob(aJob, Utils.getCurrentTime()); CallableQuery cq = new CallableQuery(pj, dao, null, "example.com", null, null, null, null, 1); String expected = "select * from blah where dt=1970010100"; Assert.assertEquals(expected, cq.getReplacedReportQuery()); }