Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @RunWith(SpringRunner.class)
- public class ClientControllerTest {
- @Autowired
- MockMvc mockMvc;
- @MockBean
- CreateClientService createClientServiceMock;
- @Autowired
- ObjectMapper objectMapper;
- @Test
- public void testCreateClientSuccessfully() throws Exception {
- given(createClientServiceMock.createClient("Foo")).willReturn(new Client("Foo"));
- mockMvc.perform(post("/clients")
- .contentType(MediaType.APPLICATION_JSON)
- .content(objectMapper.writeValueAsBytes(new CreateClientRequest("Foo"))))
- .andExpect(status().isCreated())
- .andExpect(jsonPath("$.name", is("Foo")))
- .andExpect(jsonPath("$.number", notNullValue()));
- }
- ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement