Search in sources :

Example 1 with Environment

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;
}
Also used : Environment(io.irontest.models.Environment) PermitAll(javax.annotation.security.PermitAll)

Example 2 with Environment

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;
}
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 3 with Environment

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;
}
Also used : Endpoint(io.irontest.models.endpoint.Endpoint) Environment(io.irontest.models.Environment)

Example 4 with 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;
}
Also used : SOAPEndpointProperties(io.irontest.models.endpoint.SOAPEndpointProperties) Environment(io.irontest.models.Environment) PermitAll(javax.annotation.security.PermitAll)

Aggregations

Environment (io.irontest.models.Environment)4 Endpoint (io.irontest.models.endpoint.Endpoint)2 PermitAll (javax.annotation.security.PermitAll)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 SOAPEndpointProperties (io.irontest.models.endpoint.SOAPEndpointProperties)1 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1