Commit 75ce3730 authored by Kali Padhi's avatar Kali Padhi

Sonar issue resolved

parent 10d431e4
......@@ -31,7 +31,7 @@ public class OfferTransactionController {
private EndOfTransactionService endOfTransactionService;
@PostMapping("offerTransactionCall")
public OfferTransactionResponse getOfferTransactionResponse(@Valid @RequestBody OfferTransactionRequest offerTransactionRequest) throws InterruptedException {
public OfferTransactionResponse getOfferTransactionResponse(@Valid @RequestBody OfferTransactionRequest offerTransactionRequest) {
MDC.put(SWY_RES_UNIQUE_UUID, String.valueOf(offerTransactionRequest.getHhId()));
MDC.put(USER_ID, String.valueOf(offerTransactionRequest.getHhId()));
return offerCallingPEService.getDiscountedItemList(offerTransactionRequest);
......
......@@ -4,12 +4,11 @@ import com.nisum.offertransactionservice.dto.*;
import com.nisum.offertransactionservice.model.OfferLookup;
import com.nisum.offertransactionservice.model.OfferMeta;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@Mapper
public interface OfferConvertion {
OfferConvertion INSTANCE = Mappers.getMapper(OfferConvertion.class);
OfferTransactionResponse map(PEResponse peResponse);
......
......@@ -7,53 +7,62 @@ public class GlobalApiGenericException extends RuntimeException {
private static final long serialVersionUID = -3841677326659278730L;
private String statusCode;
private final String statusCode;
private boolean isHttpError;
private final boolean isHttpError;
private Response response;
private final Response response;
public GlobalApiGenericException(String statusCode, boolean isHttpError,
Response response) {
this.statusCode = statusCode;
this.isHttpError = isHttpError;
this.response = response;
}
public GlobalApiGenericException() {
this.statusCode = "";
this.isHttpError = false;
this.response = null;
}
public GlobalApiGenericException(final Response response,final String statusCode){
this.response=response;
this.statusCode= statusCode;
this.isHttpError = false;
}
public GlobalApiGenericException(Response response,String statusCode){
public GlobalApiGenericException(final Response response,final String statusCode,final boolean isHttpError){
this.response=response;
this.statusCode= statusCode;
this.isHttpError = isHttpError;
}
public GlobalApiGenericException(String debugMessage){
public GlobalApiGenericException(final String debugMessage, boolean isHttpError){
this.statusCode=debugMessage;
this.isHttpError = isHttpError;
this.response=null;
}
public GlobalApiGenericException(String debugMessage, Throwable ex, String statuCode, boolean isHttpError) {
public GlobalApiGenericException(final String debugMessage, final Throwable ex, final String statuCode, final boolean isHttpError) {
super(debugMessage, ex);
this.statusCode =statuCode;
this.isHttpError = isHttpError;
this.response=null;
}
public String getStatusCode() {
return statusCode;
}
public void setStatusCode(String statusCode) {
this.statusCode = statusCode;
}
public boolean isHttpError() {
return isHttpError;
}
public void setHttpError(boolean httpError) {
isHttpError = httpError;
}
public Response getResponse() {
return response;
}
public void setResponse(Response response) {
this.response = response;
}
}
......@@ -9,6 +9,7 @@ import com.nisum.offertransactionservice.dto.*;
import com.nisum.offertransactionservice.genericexception.GlobalApiGenericException;
import com.nisum.offertransactionservice.model.*;
import lombok.extern.slf4j.Slf4j;
import org.mapstruct.factory.Mappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Service;
......@@ -22,6 +23,8 @@ import java.util.stream.Collectors;
@Slf4j
public class OfferCallingPEService {
OfferConvertion INSTANCE = Mappers.getMapper(OfferConvertion.class);
@Autowired
private OfferLookupRepo offerLookupRepo;
......@@ -44,12 +47,12 @@ public class OfferCallingPEService {
}
log.debug("Offer lookup Object {}", offerLookupRepo);
OfferTransactionResponse offerTransactionResponse;
PERequest peRequest = OfferConvertion.INSTANCE.map(offerTransactionRequest);
PERequest peRequest = INSTANCE.map(offerTransactionRequest);
peRequest.setEligibleOffers(offerLookupDTOList);
log.info("Promotional Engine WebClient call Start");
PEResponse peResponseFlux = clientService.getPeResponseFlux(peRequest);
log.debug("Promotional Engine WebClient call End");
offerTransactionResponse = OfferConvertion.INSTANCE.map(peResponseFlux);
offerTransactionResponse = INSTANCE.map(peResponseFlux);
offerTransactionResponse.setTransactionId(offerTransactionRequest.getTransactionId());
log.debug("Offer Transaction Response {}", offerTransactionResponse);
return offerTransactionResponse;
......@@ -63,8 +66,8 @@ public class OfferCallingPEService {
findByOfferIdAndOfferStatusIgnoreCase(offer.getOfferId(), "ACTIVE");
if(optionalOfferMeta.isPresent()){
OfferMetaDTO offerMetaDTO = OfferConvertion.INSTANCE.map(optionalOfferMeta.get());
OfferLookupDTO offerLookupDTO = OfferConvertion.INSTANCE.map(offer);
OfferMetaDTO offerMetaDTO = INSTANCE.map(optionalOfferMeta.get());
OfferLookupDTO offerLookupDTO = INSTANCE.map(offer);
offerLookupDTO.setOfferMetaDTO(offerMetaDTO);
return offerLookupDTO;
}
......
......@@ -11,7 +11,7 @@ import reactor.core.publisher.Mono;
public class ExceptionUtil {
private ExceptionUtil(){
throw new GlobalApiGenericException();
throw new GlobalApiGenericException();
}
public static Mono<Throwable> handleError(ClientResponse clientResponse) {
......
spring.datasource.url=jdbc:postgresql://127.0.0.1:5432/postgres
spring.datasource.username=user
spring.datasource.password=password123
spring.datasource.url=jdbc:postgresql://127.0.0.1:5432/storedb
spring.datasource.username=postgres
spring.datasource.password=dbpwd
endpoint.url.promotionEngineUrl=/promotionEngine/calculateDiscount
endpoint.url.peBaseUrl=http://localhost:7073
endpoint.url.storeProducerUrl=/store/producer
......
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