Commit 94ffb6c5 authored by sgandhi@nisum.com's avatar sgandhi@nisum.com

EPE-006 : Added integration test cases

parent aebddc48
/*
package com.nisum.offertransactionservice.controller;
import com.github.tomakehurst.wiremock.junit.WireMockRule;
import com.nisum.offertransactionservice.client.PromotionEngineFeignClient;
import com.nisum.offertransactionservice.config.FeignClientConfig;
import com.nisum.offertransactionservice.dto.*;
import com.nisum.offertransactionservice.model.OfferLookup;
import org.junit.ClassRule;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.mockito.Mock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpMethod;
import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import java.net.URI;
import java.util.ArrayList;
......@@ -32,18 +26,16 @@ import java.util.stream.Collectors;
import static com.github.tomakehurst.wiremock.client.WireMock.*;
@SpringBootTest
@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.DEFINED_PORT)
@AutoConfigureWireMock
//@EnableFeignClients(clients = OfferTransactionControllerIntegrationTest.PromotionEngineFeignClient.class)
public class OfferTransactionControllerIntegrationTest{
@RegisterExtension
@ClassRule
public WireMockRule wireMockRule = new WireMockRule();
public WireMockRule wireMockRule = new WireMockRule(9090);
@Autowired
private TestRestTemplate testRestTemplate;
@Mock
PromotionEngineFeignClient feignClientService;
@BeforeEach
public void setUp() {
......@@ -51,8 +43,13 @@ public class OfferTransactionControllerIntegrationTest{
mockForEndOfSale();
mockForEndOfTransaction();
}
@AfterEach
public void setWireMockRule(){
wireMockRule.stop();
}
private void mockForOfferTransactionCall() {
wireMockRule.start();
wireMockRule.stubFor(post(urlEqualTo("/promotionEngine/calculateDiscount"))
.willReturn(aResponse()
.withStatus(200)
......@@ -62,6 +59,7 @@ public class OfferTransactionControllerIntegrationTest{
}
private void mockForEndOfSale() {
wireMockRule.start();
wireMockRule.stubFor(post(urlEqualTo("/endOfSale"))
.willReturn(aResponse()
.withStatus(200)
......@@ -71,6 +69,7 @@ public class OfferTransactionControllerIntegrationTest{
}
private void mockForEndOfTransaction() {
wireMockRule.start();
wireMockRule.stubFor(post(urlEqualTo("/endOfTransaction"))
.willReturn(aResponse()
.withStatus(200)
......@@ -81,19 +80,15 @@ public class OfferTransactionControllerIntegrationTest{
@Test
public void getOfferTransactionResponseTest() {
*/
/*URI uri = URI.create("http://localhost:7072/offer-service/offerTransactionCall");
URI uri = URI.create("http://localhost:7072/offer-service/offerTransactionCall");
RequestEntity requestEntity = new RequestEntity(getOfferTransactionRequest(),HttpMethod.POST,uri);
ResponseEntity<OfferTransactionResponse> responseEntity = feignClientService.exchange("http://localhost:7072/offer-service/offerTransactionCall", HttpMethod.POST,requestEntity,
ResponseEntity<OfferTransactionResponse> responseEntity = testRestTemplate.exchange("http://localhost:7072/offer-service/offerTransactionCall", HttpMethod.POST,requestEntity,
new ParameterizedTypeReference<OfferTransactionResponse>(){}
);
OfferTransactionResponse offerTransactionResponse = responseEntity.getBody();
System.out.println(offerTransactionResponse);
Assertions.assertNotNull(offerTransactionResponse.getTransactionId());*//*
Assertions.assertNotNull(offerTransactionResponse.getTransactionId());
}
......@@ -172,4 +167,3 @@ public class OfferTransactionControllerIntegrationTest{
return itemList;
}
}
*/
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment