vendredi 27 avril 2018

Create test for rest post method using mock object

i have post method in rest controller and i want to create a test for this method: This is my method:

@PostMapping("/persons")
public ResponseEntity<PersonDto> createPerson(@RequestBody PersonDto personDto) {
    try {
        personService.createPerson(personDto);
        return ResponseEntity.ok(personDto);
    } catch (Exception e) {
        return ResponseEntity.badRequest().build();
    }
}

I have no idea how this test with mock should look like.

Aucun commentaire:

Enregistrer un commentaire