use of io.irontest.models.Environment in project irontest by zheng-wang.
the class EnvironmentResource method create.
@POST
@Path("environments")
@PermitAll
public Environment create() {
Environment result = new Environment();
result.setId(environmentDAO.insert());
return result;
}
use of io.irontest.models.Environment 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.Environment 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;
}
use of io.irontest.models.Environment in project irontest by zheng-wang.
the class ManagedEndpointResource method create.
@POST
@Path("environments/{environmentId}/endpoints")
@PermitAll
public Endpoint create(@PathParam("environmentId") long environmentId, Endpoint endpoint) throws JsonProcessingException {
Environment env = new Environment();
env.setId(environmentId);
endpoint.setEnvironment(env);
if (Endpoint.TYPE_SOAP.equals(endpoint.getType())) {
endpoint.setOtherProperties(new SOAPEndpointProperties());
} else if (Endpoint.TYPE_MQ.equals(endpoint.getType())) {
((MQEndpointProperties) endpoint.getOtherProperties()).setConnectionMode(appInfo.getAppMode() == AppMode.LOCAL ? MQConnectionMode.BINDINGS : MQConnectionMode.CLIENT);
}
long id = endpointDAO.insertManagedEndpoint(endpoint);
endpoint.setId(id);
return endpoint;
}
Aggregations