Created
June 30, 2022 13:31
-
-
Save atesibrahim/e58a833a486049fc122aa4b68452ea43 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void it_should_test_when_product_id_is_valid() throws Exception { | |
//given | |
ProductRequest productRequest = ProductRequest.builder().id(1).build(); | |
ArgumentCaptor<ProductRequest> argumentCaptor = ArgumentCaptor.forClass(ProductRequest.class); | |
//when | |
ResultActions result = mockMvc.perform(post("/products") | |
.content(objectMapper.writeValueAsString(productRequest)) | |
.contentType(MediaType.APPLICATION_JSON)); | |
//then | |
verify(productService).dispense(argumentCaptor.capture()); | |
result.andExpect(status().isOk()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment