Im trying to use this dependency for my project. Its a multi-modular project. Im going to write integrations-test and I've seen a few tutorials use the TestRestTemplate object.
my pom-file is like this:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<artifactId>junit-jupiter-engine</artifactId>
<groupId>org.junit.jupiter</groupId>
<version>5.8.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>spring-boot-maven-plugin</artifactId>
<groupId>org.springframework.boot</groupId>
<version>2.3.4.RELEASE</version>
</plugin>
</plugins>
and my IT-class:
package infectiontracer.ui;
import org.junit.jupiter.api.Test;
import org.springframework.boot.SpringApplication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.web.client.RestTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import infectiontracer.core.User;
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class InfectionTracerAppIT {
@Autowired
private TestRestTemplate testRestTemplate = new TestRestTemplate(); // available with Spring Web MVC
@Test
void httpClientExample() {
ResponseEntity<User> response = restTemplate.getForEntity("/infectiontracer/user", User.class);
assertEquals(HttpStatus.OK, response.getStatusCode());
assertNotNull(response.getBody());
}
}
I've been struggling for a couple of hours and I dont know what dependency I would actually need in order for use said class..
I'm getting the error:
cannot find symbol
[ERROR] symbol: class TestRestTemplate
[ERROR] location: class infectiontracer.ui.InfectionTracerAppIT