How do i pass 2 parameters using TestRestTemplate? In postman it works, but when I send it using testRestTemplate it doesn't.
Postman: http://localhost:8080/pauta/votos-por-pauta/Pauta - Juros/sim
Test class: ResponseEntity<Pauta> pauta = this.testRestTemplate.getForEntity("/pauta/votos-por-pauta/Pauta - Juros/sim", Pauta.class);
//Controller Class
@GetMapping("/votos-por-pauta/{nome}/{voto}")
public List<Pauta> listarPorVotoPorPauta(@PathVariable String nome, @PathVariable String voto) {
return pautaService.listarPorVotosPorPauta(nome, voto);
}
//Controller Test
@Test
public void deveSelecionar_PorNomePautaVoto() {
ResponseEntity<Pauta> pauta = this.testRestTemplate.getForEntity("/pauta/votos-por-pauta/Pauta - Juros/sim", Pauta.class);
assertEquals("Dani da Silva", pauta.getBody().getAssociado().getNome());
assertEquals(HttpStatus.OK, pauta.getStatusCode());
}
Aucun commentaire:
Enregistrer un commentaire