## Notas
Spring Boot starters are a collection of pre-chosen dependencies that make it easy to get started developing applications. Starter POMs aggregate common dependencies for different application patterns.
## Web Starter
Lots of options for web services:
- Tomcat
- Jackson
- Spring MVC
One starter can cover all of the general dependencies:
```xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
```
And for the REST controller code
```java
@RestController
public class GenericEntityController {
private List<GenericEntity> entityList = new ArrayList<>();
@RequestMapping("/entity/all")
public List<GenericEntity> findAll() {
return entityList;
}
@RequestMapping(value = "/entity", method = RequestMethod.POST)
public GenericEntity addEntity(GenericEntity entity) {
entityList.add(entity);
return entity;
}
@RequestMapping("/entity/{id}")
public GenericEntity findById(@PathVariable Long id) {
return entityList.stream()
.filter(entity -> entity.getId().equals(id))
.findFirst()
.get();
}
}
```
## Test Starter
Use the following starter to include common testing dependencies: Spring Test, JUnit, Hamcrest, Mockito
```xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-foot-starter-test</artifactId>
<scope>test</scope>
</dependency>
```
And then test the above controller
```java
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Application.class)
@WebAppConfiguration
public class SpringBootApplicationIntegrationTest {
@Autowired
private WebApplicationContext webApplicationContext;
private MockMvc mockMvc;
@BeforeEach
public void setupMockMvc() {
mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
}
@Test
public void givenRequestHasBeenMade_whenMeetsAllOfGivenConditions_thenCorrect() throws Exception {
mockMvc.perform(MockMvcRequestBuilders.get("/entity/all"))
.addExpect(MockMvcResultMatchers.status().isOk())
.addExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON))
.addExpect(jsonPath("