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.service; | |
import org.springframework.stereotype.Service; | |
import com.its.reservation.repository.Reservation; | |
import com.its.reservation.repository.ReservationRepository; | |
@Service | |
public class ReservationService { | |
private ReservationRepository reservationRepository; |
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
@RunWith(MockitoJUnitRunner.class) | |
public class ReservationServiceTest { | |
ReservationService reservationService; | |
@Mock | |
ReservationRepository reservationRepository; | |
@Before | |
public void setUp() throws Exception { | |
reservationService = new ReservationService(reservationRepository); |
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
@RunWith(MockitoJUnitRunner.class) | |
public class ReservationServiceTest { | |
ReservationService reservationService; | |
@Mock | |
ReservationRepository reservationRepository; | |
@Before | |
public void setUp() throws Exception { | |
reservationService = new ReservationService(reservationRepository); |
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
@Service | |
public class ReservationService { | |
private ReservationRepository reservationRepository; | |
public ReservationService(ReservationRepository reservationRepository) { | |
this.reservationRepository = reservationRepository; | |
} | |
public Reservation getReservationDetails(String name) { | |
System.out.println("Entering and leaving ReservationService : getReservationDetails " |
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; |
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.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.mockito.ArgumentMatchers; | |
import org.mockito.BDDMockito; | |
import org.mockito.Mockito; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; | |
import org.springframework.boot.test.context.SpringBootTest; |
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
@RunWith(SpringRunner.class) | |
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) | |
public class ReservationEndToEndTest { | |
@Autowired | |
TestRestTemplate testRestTemplate; | |
@Test | |
public void getReservation_shouldReturnReservationDetails() { | |
// Arrange | |
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
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import org.springframework.cache.annotation.EnableCaching; | |
@SpringBootApplication | |
@EnableCaching | |
public class BootifulTddApplication { | |
public static void main(String[] args) { | |
SpringApplication.run(BootifulTddApplication.class, args); |
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
@Service | |
public class ReservationService { | |
private ReservationRepository reservationRepository; | |
public ReservationService(ReservationRepository reservationRepository) { | |
this.reservationRepository = reservationRepository; | |
} | |
@Cacheable("reservation") |
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
private RequestConfig prepareHttpClientRequestConfig() { | |
RequestConfig requestConfig = RequestConfig | |
.custom() | |
.setConnectTimeout(CONNECT_TIMEOUT) | |
.setConnectionRequestTimeout(CONNECTION_REQUEST_TIMEOUT) | |
.setSocketTimeout(SOCKET_TIMEOUT) | |
.build(); | |
return requestConfig; | |
} |