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());
}
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);
}
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;
}
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;
}
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;
}
Aggregations