Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. @RunWith(SpringRunner.class)
  2. public class ClientControllerTest {
  3.  
  4. @Autowired
  5. MockMvc mockMvc;
  6.  
  7. @MockBean
  8. CreateClientService createClientServiceMock;
  9.  
  10. @Autowired
  11. ObjectMapper objectMapper;
  12.  
  13. @Test
  14. public void testCreateClientSuccessfully() throws Exception {
  15. given(createClientServiceMock.createClient("Foo")).willReturn(new Client("Foo"));
  16.  
  17. mockMvc.perform(post("/clients")
  18. .contentType(MediaType.APPLICATION_JSON)
  19. .content(objectMapper.writeValueAsBytes(new CreateClientRequest("Foo"))))
  20. .andExpect(status().isCreated())
  21. .andExpect(jsonPath("$.name", is("Foo")))
  22. .andExpect(jsonPath("$.number", notNullValue()));
  23. }
  24. ...
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement