I do classic Event Driven Development Testing.
// given
// when
// then
then(response.getStatus()).isEqualTo(HttpStatus.OK.value());
then(response.getContentAsString()).isEqualTo(
jsonRequestProduct.write(List.of(newProduct)).getJson());
And I will get response from second line of code.
org.opentest4j.AssertionFailedError: Expecting: ... but was not.
Expected :"[{"id":1,"description":"iPhone 33","price":599.99}]"
Actual :"{"id":1,"description":"iPhone 33","price":599.99}"
Question: How do i get rid of "[ ]" so my test will pass?
Thanks for advice.
UPDATE:
Required type: List<xxx.demo.model.Product>
Provided: Product
This is how my controller looks like.
@PutMapping("/update")
public ResponseEntity<Product> updateProduct(@RequestBody Product product) {
return ResponseEntity.ok(productServiceImpl.updateProduct(product));
}
Aucun commentaire:
Enregistrer un commentaire