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