Last active
March 11, 2018 01:41
-
-
Save dhaval201279/c53ad63b95b9f59b7e29d10906ec7739 to your computer and use it in GitHub Desktop.
Reservation end to end test
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.context.SpringBootTest; | |
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; | |
import org.springframework.boot.test.web.client.TestRestTemplate; | |
import org.springframework.http.HttpStatus; | |
import org.springframework.http.ResponseEntity; | |
import org.springframework.test.context.junit4.SpringRunner; | |
import com.its.reservation.repository.Reservation; | |
/** | |
* @author Dhaval | |
* | |
*/ | |
@RunWith(SpringRunner.class) | |
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) | |
public class ReservationEndToEndTest { | |
@Autowired | |
TestRestTemplate testRestTemplate; | |
@Test | |
public void getReservation_shouldReturnReservationDetails() { | |
// Arrange | |
// Act | |
ResponseEntity<Reservation> response = testRestTemplate.getForEntity("/reservation/{name}", Reservation.class, "Dhaval"); | |
// Assert | |
Assertions.assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); | |
Assertions.assertThat(response.getBody().getName()).isEqualTo("Dhaval"); | |
Assertions.assertThat(response.getBody().getId()).isNotNull(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment