Search in sources :

Example 6 with Endpoint

use of io.irontest.models.endpoint.Endpoint in project irontest by zheng-wang.

the class TeststepDAO method update.

@Transaction
public Teststep update(Teststep teststep) throws Exception {
    Teststep oldTeststep = findById_NoTransaction(teststep.getId());
    if (Teststep.TYPE_MQ.equals(teststep.getType()) && teststep.getAction() != null) {
        // newly created MQ test step does not have action and does not need the processing
        processMQTeststep(oldTeststep, teststep);
    }
    Endpoint oldEndpoint = oldTeststep.getEndpoint();
    Endpoint newEndpoint = teststep.getEndpoint();
    Long newEndpointId = newEndpoint == null ? null : newEndpoint.getId();
    String otherProperties = new ObjectMapper().writeValueAsString(teststep.getOtherProperties());
    if (teststep.getRequestType() == TeststepRequestType.FILE) {
        // update teststep without request
        _updateWithoutRequest(teststep.getName(), teststep.getDescription(), teststep.getRequestType().toString(), teststep.getAction(), teststep.getId(), newEndpointId, teststep.getEndpointProperty(), otherProperties);
    } else {
        // update teststep with request
        Object request = teststep.getRequest() instanceof String ? ((String) teststep.getRequest()).getBytes() : teststep.getRequest();
        _update(teststep.getName(), teststep.getDescription(), teststep.getAction(), request, teststep.getRequestType().toString(), teststep.getId(), newEndpointId, teststep.getEndpointProperty(), otherProperties);
    }
    updateEndpointIfExists(oldEndpoint, newEndpoint);
    updateAssertions(teststep);
    return findById_NoTransaction(teststep.getId());
}
Also used : Endpoint(io.irontest.models.endpoint.Endpoint) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 7 with Endpoint

use of io.irontest.models.endpoint.Endpoint in project irontest by zheng-wang.

the class TeststepRunDAO method insert_NoTransaction.

public void insert_NoTransaction(long testcaseRunId, Long testcaseIndividualRunId, TeststepRun teststepRun) throws JsonProcessingException {
    // remove contents that are not to be serialized into the teststep column
    Teststep teststep = teststepRun.getTeststep();
    teststep.getAssertions().clear();
    Endpoint endpoint = teststep.getEndpoint();
    if (endpoint != null) {
        endpoint.setPassword(null);
    }
    ObjectMapper objectMapper = new ObjectMapper();
    long id = _insert(testcaseRunId, testcaseIndividualRunId, objectMapper.writeValueAsString(teststep), objectMapper.writeValueAsString(teststepRun.getResponse()), teststepRun.getInfoMessage(), teststepRun.getErrorMessage(), objectMapper.writeValueAsString(teststepRun.getAssertionVerifications()), teststepRun.getStartTime(), teststepRun.getDuration(), teststepRun.getResult().toString());
    teststepRun.setId(id);
}
Also used : Teststep(io.irontest.models.teststep.Teststep) Endpoint(io.irontest.models.endpoint.Endpoint) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 8 with Endpoint

use of io.irontest.models.endpoint.Endpoint in project irontest by zheng-wang.

the class EndpointMapper method map.

public Endpoint map(int index, ResultSet rs, StatementContext ctx) throws SQLException {
    List<String> fields = IronTestUtils.getFieldsPresentInResultSet(rs);
    Endpoint endpoint = null;
    String type = rs.getString("type");
    if (fields.contains("other_properties") && rs.getString("other_properties") != null) {
        String tempEndpointJSON = "{\"type\":\"" + type + "\",\"otherProperties\":" + rs.getString("other_properties") + "}";
        try {
            endpoint = new ObjectMapper().readValue(tempEndpointJSON, Endpoint.class);
        } catch (IOException e) {
            throw new SQLException("Failed to deserialize other_properties JSON.", e);
        }
    } else {
        endpoint = new Endpoint();
    }
    endpoint.setId(rs.getLong("id"));
    endpoint.setName(rs.getString("name"));
    endpoint.setType(type);
    endpoint.setDescription(rs.getString("description"));
    endpoint.setUrl(fields.contains("url") ? rs.getString("url") : null);
    endpoint.setUsername(fields.contains("username") ? rs.getString("username") : null);
    endpoint.setPassword(fields.contains("password") ? rs.getString("password") : null);
    if (fields.contains("environment_id") && rs.getObject("environment_id") != null) {
        Environment environment = new Environment();
        environment.setId(rs.getLong("environment_id"));
        if (fields.contains("environment_name")) {
            environment.setName(rs.getString("environment_name"));
        }
        endpoint.setEnvironment(environment);
    }
    return endpoint;
}
Also used : Endpoint(io.irontest.models.endpoint.Endpoint) SQLException(java.sql.SQLException) Environment(io.irontest.models.Environment) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 9 with Endpoint

use of io.irontest.models.endpoint.Endpoint in project irontest by zheng-wang.

the class EndpointDAO method createUnmanagedEndpoint_NoTransaction.

public Endpoint createUnmanagedEndpoint_NoTransaction(String teststepType, AppMode appMode) throws JsonProcessingException {
    Endpoint endpoint = null;
    if (!Teststep.TYPE_WAIT.equals(teststepType)) {
        endpoint = new Endpoint();
        endpoint.setName("Unmanaged Endpoint");
        if (Teststep.TYPE_SOAP.equals(teststepType)) {
            endpoint.setType(Endpoint.TYPE_SOAP);
            endpoint.setOtherProperties(new SOAPEndpointProperties());
        } else if (Teststep.TYPE_DB.equals(teststepType)) {
            endpoint.setType(Endpoint.TYPE_DB);
        } else if (Teststep.TYPE_MQ.equals(teststepType)) {
            endpoint.setType(Endpoint.TYPE_MQ);
            MQEndpointProperties endpointProperties = new MQEndpointProperties();
            endpointProperties.setConnectionMode(appMode == AppMode.LOCAL ? MQConnectionMode.BINDINGS : MQConnectionMode.CLIENT);
            endpoint.setOtherProperties(endpointProperties);
        } else if (Teststep.TYPE_IIB.equals(teststepType)) {
            endpoint.setType(Endpoint.TYPE_IIB);
        }
        long id = insertUnmanagedEndpoint_NoTransaction(endpoint);
        endpoint.setId(id);
    }
    return endpoint;
}
Also used : MQEndpointProperties(io.irontest.models.endpoint.MQEndpointProperties) Endpoint(io.irontest.models.endpoint.Endpoint) SOAPEndpointProperties(io.irontest.models.endpoint.SOAPEndpointProperties)

Example 10 with Endpoint

use of io.irontest.models.endpoint.Endpoint in project irontest by zheng-wang.

the class EnvironmentDAO method findById_EnvironmentEditView.

/**
 * @param id
 * @return environment with all endpoints in it
 */
@Transaction
public Environment findById_EnvironmentEditView(long id) {
    Environment environment = _findById(id);
    List<Endpoint> endpoints = endpointDAO().findByEnvironmentId_EnvironmentEditView(id);
    environment.setEndpoints(endpoints);
    return environment;
}
Also used : Endpoint(io.irontest.models.endpoint.Endpoint) Environment(io.irontest.models.Environment)

Aggregations

Endpoint (io.irontest.models.endpoint.Endpoint)16 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 Teststep (io.irontest.models.teststep.Teststep)3 SQLException (java.sql.SQLException)3 Environment (io.irontest.models.Environment)2 IOException (java.io.IOException)2 DataTable (io.irontest.models.DataTable)1 Testcase (io.irontest.models.Testcase)1 UserDefinedProperty (io.irontest.models.UserDefinedProperty)1 Assertion (io.irontest.models.assertion.Assertion)1 MQEndpointProperties (io.irontest.models.endpoint.MQEndpointProperties)1 SOAPEndpointProperties (io.irontest.models.endpoint.SOAPEndpointProperties)1 HTTPHeader (io.irontest.models.teststep.HTTPHeader)1 SOAPTeststepProperties (io.irontest.models.teststep.SOAPTeststepProperties)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSetMetaData (java.sql.ResultSetMetaData)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1