Last active
March 11, 2018 02:42
-
-
Save dhaval201279/1c67fa80c0572d4a610f02aadbd6a208 to your computer and use it in GitHub Desktop.
2nd Version of ReservationControllerTest
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
@RunWith(SpringRunner.class) | |
@WebMvcTest(ReservationController.class) | |
public class ReservationControllerTest { | |
@Autowired | |
private MockMvc mockMvc; | |
@MockBean | |
ReservationService reservationService; | |
@Test | |
public void getReservation_shouldReturnReservationInfo() { | |
BDDMockito.given(reservationService.getReservationDetails(ArgumentMatchers.anyString())) | |
.willReturn(new Reservation(Long.valueOf(1), "Dhaval", "Shah")); | |
try { | |
mockMvc.perform(MockMvcRequestBuilders.get("/reservation/Dhaval")) | |
.andExpect(MockMvcResultMatchers.status().isOk()) | |
.andExpect(MockMvcResultMatchers.jsonPath("firstName").value("Dhaval")) | |
.andExpect(MockMvcResultMatchers.jsonPath("lastName").value("Shah")); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment