Skip to content

Instantly share code, notes, and snippets.

@dhaval201279
Last active March 11, 2018 05:23
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/c2585bc931a933f51fc21c60e473fe6b to your computer and use it in GitHub Desktop.
Save dhaval201279/c2585bc931a933f51fc21c60e473fe6b to your computer and use it in GitHub Desktop.
1st version of ReservationRepositoryTest - that passes when tested with CUT
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