Last active
March 11, 2018 05:23
-
-
Save dhaval201279/c2585bc931a933f51fc21c60e473fe6b to your computer and use it in GitHub Desktop.
1st version of ReservationRepositoryTest - that passes when tested with CUT
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
package com.its.reservation; | |
import org.assertj.core.api.Assertions; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; | |
import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager; | |
import org.springframework.test.context.junit4.SpringRunner; | |
import com.its.reservation.repository.Reservation; | |
import com.its.reservation.repository.ReservationRepository; | |
/** | |
* @author Dhaval | |
* | |
*/ | |
@RunWith(SpringRunner.class) | |
@DataJpaTest | |
public class ReservationRepositoryTest { | |
@Autowired | |
TestEntityManager entityManager; | |
@Autowired | |
ReservationRepository reservationRepository; | |
@Test | |
public void getReservation_returnReservationDetails() { | |
Reservation savedReservation = entityManager.persistAndFlush(new Reservation("Dhaval","Shah")); | |
Reservation aReservation = reservationRepository.findByFirstName("Dhaval"); | |
Assertions.assertThat(aReservation.getFirstName()).isEqualTo(savedReservation.getFirstName()); | |
Assertions.assertThat(aReservation.getLastName()).isEqualTo(savedReservation.getLastName()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment