Last active
March 11, 2018 03:00
-
-
Save dhaval201279/ba8d30f885e89e8f83b606289b0a55b8 to your computer and use it in GitHub Desktop.
2nd version ReservationServiceTest - with mock collaborators and passed test case
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(MockitoJUnitRunner.class) | |
public class ReservationServiceTest { | |
ReservationService reservationService; | |
@Mock | |
ReservationRepository reservationRepository; | |
@Before | |
public void setUp() throws Exception { | |
reservationService = new ReservationService(reservationRepository); | |
} | |
@Test | |
public void getReservationDetails_returnsReservationInfo() { | |
BDDMockito.given(reservationRepository.findByFirstName("Dhaval")) | |
.willReturn(new Reservation(Long.valueOf(1), "Dhaval", "Shah")); | |
Reservation aReservation = reservationService.getReservationDetails("Dhaval"); | |
assertThat(aReservation.getFirstName()).isEqualTo("Dhaval"); | |
assertThat(aReservation.getLastName()).isEqualTo("Shah"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment