Search in sources :

Example 1 with APIResponse

use of io.irontest.core.teststep.APIResponse in project irontest by zheng-wang.

the class TeststepRunMapper method map.

public TeststepRun map(ResultSet rs, StatementContext ctx) throws SQLException {
    TeststepRun teststepRun = new TeststepRun();
    ObjectMapper objectMapper = new ObjectMapper();
    teststepRun.setId(rs.getLong("id"));
    teststepRun.setStartTime(rs.getTimestamp("starttime"));
    teststepRun.setDuration(rs.getLong("duration"));
    teststepRun.setResult(TestResult.getByText(rs.getString("result")));
    Teststep teststep;
    try {
        teststep = objectMapper.readValue(rs.getString("teststep"), Teststep.class);
    } catch (IOException e) {
        throw new SQLException("Failed to deserialize teststep JSON.", e);
    }
    teststepRun.setTeststep(teststep);
    APIResponse response;
    try {
        response = objectMapper.readValue(rs.getString("response"), APIResponse.class);
    } catch (IOException e) {
        throw new SQLException("Failed to deserialize response JSON.", e);
    }
    teststepRun.setResponse(response);
    teststepRun.setInfoMessage(rs.getString("info_message"));
    teststepRun.setErrorMessage(rs.getString("error_message"));
    List<AssertionVerification> assertionVerifications;
    try {
        assertionVerifications = new ObjectMapper().readValue(rs.getString("assertion_verifications"), new TypeReference<List<AssertionVerification>>() {
        });
    } catch (IOException e) {
        throw new SQLException("Failed to deserialize stepruns JSON.", e);
    }
    teststepRun.setAssertionVerifications(assertionVerifications);
    return teststepRun;
}
Also used : Teststep(io.irontest.models.teststep.Teststep) TeststepRun(io.irontest.models.testrun.TeststepRun) APIResponse(io.irontest.core.teststep.APIResponse) SQLException(java.sql.SQLException) IOException(java.io.IOException) AssertionVerification(io.irontest.models.assertion.AssertionVerification) TypeReference(com.fasterxml.jackson.core.type.TypeReference) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 APIResponse (io.irontest.core.teststep.APIResponse)1 AssertionVerification (io.irontest.models.assertion.AssertionVerification)1 TeststepRun (io.irontest.models.testrun.TeststepRun)1 Teststep (io.irontest.models.teststep.Teststep)1 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1