Here we are checking exception for this we we will use thenThrow method when we will call getSingleProduct method it will throw error that we will add in method signature and getSingleProduct method from controller return us the ResponseEntity<ProductResponseSelf>
<p>we wil store in actual variabl and use assert.Equals will test status code and same we will get code from ResponseEntitiy using getStatusCode method. </p>
<p>@Test <br />
public void productNotPresentTest() throws ProductNotPresentException {
Mockito.when(productService.getSingleProduct(25L)).thenThrow(ProductNotPresentException.class) ;
ResponseEntity</p>
<ProductResponseSelf>
actual = productController.getSingleProduct(25L);
Assertions.assertEquals(HttpStatus.NOT_FOUND, actual.getStatusCode());
}
Testing Good Practices, Mocking, Types of Doubles
0/4
Testing demo, annotation and product controller test
0/6
Auth v/s Auth, Tokens, BCrypt
0/5
Authentication : Implementing User Service
0/4
Implementing OAuth 2 authentication using Spring Security
0/2
Creating a Payment Microservice Implementing Razorpay
0/5
Optimizing our APIs using Redis and Kafka for ASync Comm
0/5
Low Level Design Notes
0/1
About Lesson