package fr.insee.pogues.transforms;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.nio.charset.StandardCharsets;
import java.util.Map;

@Service
public class StromaeServiceImpl implements StromaeService {

    @Autowired
    Environment env;

    @Autowired
    HttpClient httpClient;

    private String serviceUri;

    @PostConstruct
    public void setUp(){
        serviceUri = env.getProperty("fr.insee.pogues.api.remote.stromae.vis.url");
    }

    @Override
    public String transform(String input, Map<String, Object> params) throws Exception {
        try {
            String uri = String.format("%s/%s", serviceUri,
                    params.get("name"));
            HttpPost post = new HttpPost(uri);
            post.setEntity(new StringEntity(input, StandardCharsets.UTF_8));
            post.setHeader("Content-type", "application/xml");
            HttpResponse response = httpClient.execute(post);
            return EntityUtils.toString(response.getEntity());
        } catch(Exception e) {
            throw e;
        }

    }
}

@@ -336,28 +336,38 @@
 ork.
-core.env.Environment
+beans.factory.annotation.Value
 ;%0Aim
@@ -416,47 +416,8 @@
 e;%0A%0A
-import javax.annotation.PostConstruct;%0A
 impo
@@ -570,183 +570,46 @@
     
-Environment env;%0A%0A    @Autowired%0A    HttpClient httpClient;%0A%0A    private String serviceUri;%0A%0A    @PostConstruct%0A    public void setUp()%7B%0A        serviceUri = env.getProperty(%22
+HttpClient httpClient;%0A%0A    @Value(%22$%7B
 fr.i
@@ -650,17 +650,42 @@
 .url
+%7D
 %22)
-;
 %0A    
-%7D
+private String serviceUri;
 %0A%0A  

Use value declarations instead of env injection