Skip to content

Instantly share code, notes, and snippets.

@dhaval201279
Last active March 11, 2018 03:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhaval201279/ba8d30f885e89e8f83b606289b0a55b8 to your computer and use it in GitHub Desktop.
Save dhaval201279/ba8d30f885e89e8f83b606289b0a55b8 to your computer and use it in GitHub Desktop.
2nd version ReservationServiceTest - with mock collaborators and passed test case
@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