I have written a service for which integration testing is being carried out. The service internally calls an external rest service and populates the value.

Service class
-------------

```
import org.springframework.web.client.RestTemplate;

class Service {
    final static RestTemplate TEMPLATE = new RestTemplate()

    def getList() {
        final String info = TEMPLATE.getForObject(getHostUrl(), String.class,[:])
        return info
    }

```

To avoid the actual external service call, I am trying to mock it as below.

```
class ServiceIntegrationSpec extends IntegrationSpec {

    void testList() {
        setup:
            List<Employee> list = new ArrayList<>()
            list.add(new Employee(id:"123", name: "test1"))
            list.add(new Employee(id:"146", name: "test2"))
            def clazz = String.class
            def url  = ""
            def emptyMap = [:]
            rackService.TEMPLATE.metaClass.getForObject = {String url, Class clazz,
            Map emptyMap ->list}

        when:
            def val = service.getList()

        then:
            val != null
    }
}

```

When the integration test is run with the command: grails test-app integration:, I get the following errors:

1. The current scope already contains a variable url
2. The current scope already contains a variable clazz
3. The current scope already contains a variable emptyMap