Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Dhaval Shah dhaval201279

🎯
Focusing
Block or report user

Report or block dhaval201279

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dhaval201279
dhaval201279 / ReservationRepository1.java
Last active Mar 11, 2018
1st version of ReservationRepository - for removing compilation error whilst executing test of ReservationService
View ReservationRepository1.java
package com.its.reservation.repository;
import org.springframework.data.repository.CrudRepository;
public interface ReservationRepository extends CrudRepository<Reservation, Long> {
Reservation findByFirstName(String name);
}
@dhaval201279
dhaval201279 / ReservationServiceTest1.java
Last active Mar 11, 2018
1st version of ReservationServiceTest - which fails initially
View ReservationServiceTest1.java
package com.its.reservation;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.its.reservation.repository.Reservation;
import com.its.reservation.service.ReservationService;
@dhaval201279
dhaval201279 / ReservationController3.java
Last active Mar 11, 2018
3rd version of ReservationController with Exception Handler
View ReservationController3.java
@RestController
@RequestMapping("/reservation")
public class ReservationController {
private ReservationService reservationService;
public ReservationController(ReservationService reservationService) {
this.reservationService = reservationService;
}
@RequestMapping(method = RequestMethod.GET, value = "/{name}")
@dhaval201279
dhaval201279 / ReservationControllerTest3.java
Last active Mar 11, 2018
3rd version of ReservationControllerTest
View ReservationControllerTest3.java
@RunWith(SpringRunner.class)
@WebMvcTest(ReservationController.class)
public class ReservationControllerTest {
@Autowired
private MockMvc mockMvc;
@MockBean
ReservationService reservationService;
@Test
@dhaval201279
dhaval201279 / ReservationControllerTest2.java
Last active Mar 11, 2018
2nd Version of ReservationControllerTest
View ReservationControllerTest2.java
@RunWith(SpringRunner.class)
@WebMvcTest(ReservationController.class)
public class ReservationControllerTest {
@Autowired
private MockMvc mockMvc;
@MockBean
ReservationService reservationService;
@Test
@dhaval201279
dhaval201279 / ReservationControllerTest1.java
Last active Mar 11, 2018
1st Version of ReservationControllerTest
View ReservationControllerTest1.java
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 Mar 11, 2018
2nd Version of ReservationController
View ReservationController2.java
@RestController
@RequestMapping("/reservation")
public class ReservationController {
private ReservationService reservationService;
public ReservationController(ReservationService reservationService) {
this.reservationService = reservationService;
}
@dhaval201279
dhaval201279 / ReservationController1.java
Last active Mar 11, 2018
First Version of ReservationController
View ReservationController1.java
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 Mar 11, 2018
Reservation end to end test
View ReservationEndToEndTest.java
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;
You can’t perform that action at this time.