Skip to content
Snippets Groups Projects
Commit 3c038c1b authored by Nicola Fulvio Calabria's avatar Nicola Fulvio Calabria
Browse files

Added missing lines to getJob for error summary retrieval

and extended tests.
parent c4d6f0b5
No related branches found
No related tags found
No related merge requests found
Pipeline #1504 passed
......@@ -48,8 +48,8 @@ public class JobDAO {
String sql =
"INSERT INTO job(job_id, owner_id, job_type, phase, job_info,"
+ " error_message, error_type, error_has_detail) "
+ "VALUES (?, ?, ?, ?, ?, ? ,? ,?)";
+ " error_message, error_type, error_has_detail, error_detail) "
+ "VALUES (?, ?, ?, ?, ?, ? ,? ,? ,?)";
jdbcTemplate.update(sql, ps -> {
int i = 0;
......@@ -64,10 +64,12 @@ public class JobDAO {
ps.setString(++i, errorSummary.getMessage());
ps.setObject(++i, errorSummary.getType().value(), Types.OTHER);
ps.setBoolean(++i, errorSummary.isHasDetail());
ps.setString(++i, errorSummary.getDetailMessage());
} else {
ps.setNull(++i, Types.VARCHAR);
ps.setNull(++i, Types.OTHER);
ps.setNull(++i, Types.BOOLEAN);
ps.setNull(++i, Types.VARCHAR);
}
});
}
......@@ -127,6 +129,8 @@ public class JobDAO {
errorSummary.setType(ErrorType.fromValue(rs.getString("error_type")));
}
errorSummary.setHasDetail(rs.getBoolean("error_has_detail"));
errorSummary.setDetailMessage(rs.getString("error_detail"));
jobSummary.setErrorSummary(errorSummary);
return jobSummary;
......@@ -258,14 +262,14 @@ public class JobDAO {
ErrorSummary errorSummary = job.getErrorSummary();
if(errorSummary != null)
{
sql += ", error_message, error_type, error_has_detail";
sql += ", error_message, error_type, error_has_detail, error_detail";
}
sql += ") = (?, ?";
if(errorSummary != null)
{
sql += ", ?, ?, ?";
sql += ", ?, ?, ?, ?";
}
sql += ") WHERE job_id = ?";
......@@ -279,6 +283,7 @@ public class JobDAO {
ps.setString(++i, errorSummary.getMessage());
ps.setObject(++i, errorSummary.getType().value(), Types.OTHER);
ps.setBoolean(++i, errorSummary.isHasDetail());
ps.setString(++i, errorSummary.getDetailMessage());
}
ps.setString(++i, job.getJobId());
});
......
......@@ -22,7 +22,7 @@ import java.time.Month;
import net.ivoa.xml.uws.v1.ErrorSummary;
import net.ivoa.xml.uws.v1.Jobs;
import it.inaf.oats.vospace.exception.ErrorSummaryFactory;
import it.inaf.oats.vospace.exception.VOSpaceFaultEnum;
import it.inaf.oats.vospace.exception.PermissionDeniedException;
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = {DataSourceConfig.class})
......@@ -58,7 +58,8 @@ public class JobDAOTest {
private boolean areEqual(ErrorSummary a, ErrorSummary b) {
return (a.getMessage().equals(b.getMessage())
&& a.getType().equals(b.getType())
&& a.isHasDetail() == b.isHasDetail());
&& a.isHasDetail() == b.isHasDetail()
&& a.getDetailMessage().equals(b.getDetailMessage()));
}
@Test
......@@ -83,10 +84,14 @@ public class JobDAOTest {
job.setPhase(ExecutionPhase.ERROR);
// A generic picked randomly
// Generate it from exception
ErrorSummary errorSummary
= ErrorSummaryFactory.newErrorSummary(
VOSpaceFaultEnum.PERMISSION_DENIED);
new PermissionDeniedException("/pippo1/pippo2"));
// Check if properly generated
assertTrue(errorSummary.isHasDetail());
assertEquals("PermissionDenied. Path: /pippo1/pippo2", errorSummary.getDetailMessage());
job.setErrorSummary(errorSummary);
......@@ -109,10 +114,14 @@ public class JobDAOTest {
dao.createJob(job);
job.setPhase(ExecutionPhase.ERROR);
// A generic picked randomly
// Generate it from exception
ErrorSummary errorSummary
= ErrorSummaryFactory.newErrorSummary(
VOSpaceFaultEnum.PERMISSION_DENIED);
new PermissionDeniedException("/pippo1/pippo2"));
// Check if properly generated
assertTrue(errorSummary.isHasDetail());
assertEquals("PermissionDenied. Path: /pippo1/pippo2", errorSummary.getDetailMessage());
job.setErrorSummary(errorSummary);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment