Skip to content

Instantly share code, notes, and snippets.

View dhaval201279's full-sized avatar
🎯
Focusing

Dhaval Shah dhaval201279

🎯
Focusing
View GitHub Profile
@dhaval201279
dhaval201279 / ReservationControllerTest2.java
Last active March 11, 2018 02:42
2nd Version of ReservationControllerTest
@RunWith(SpringRunner.class)
@WebMvcTest(ReservationController.class)
public class ReservationControllerTest {
@Autowired
private MockMvc mockMvc;
@MockBean
ReservationService reservationService;
@Test
@dhaval201279
dhaval201279 / ReservationControllerTest1.java
Last active March 11, 2018 02:27
1st Version of ReservationControllerTest
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import com.its.reservation.web.ReservationController;
@dhaval201279
dhaval201279 / ReservationController2.java
Last active March 11, 2018 02:37
2nd Version of ReservationController
@RestController
@RequestMapping("/reservation")
public class ReservationController {
private ReservationService reservationService;
public ReservationController(ReservationService reservationService) {
this.reservationService = reservationService;
}
@dhaval201279
dhaval201279 / ReservationController1.java
Last active March 11, 2018 02:30
First Version of ReservationController
package com.its.reservation.web;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.its.reservation.repository.Reservation;
/**
@dhaval201279
dhaval201279 / ReservationEndToEndTest.java
Last active March 11, 2018 01:41
Reservation end to end test
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;