upload-CreditReport (#1567 for FINERACT-1285)

This commit is contained in:
Rahul Pawar
2021-01-24 01:26:37 +01:00
committed by GitHub
parent 1f5d240ddb
commit 7c6c7c1e71
10 changed files with 130 additions and 32 deletions
@@ -101,12 +101,12 @@ public class CommandWrapperBuilder {
return this; return this;
} }
public CommandWrapperBuilder createCreditBureauLoanProductMapping(final long creditBureauId) { public CommandWrapperBuilder createCreditBureauLoanProductMapping(final long organisationCreditBureauId) {
this.actionName = "CREATE"; this.actionName = "CREATE";
this.entityName = "CREDITBUREAU_LOANPRODUCT_MAPPING"; this.entityName = "CREDITBUREAU_LOANPRODUCT_MAPPING";
this.entityId = creditBureauId; this.entityId = creditBureauId;
this.href = "/creditBureauConfiguration/template"; this.href = "/creditBureauConfiguration/template";
this.creditBureauId = creditBureauId; this.organisationCreditBureauId = organisationCreditBureauId;
return this; return this;
} }
@@ -114,7 +114,7 @@ public class CommandWrapperBuilder {
this.actionName = "CREATE"; this.actionName = "CREATE";
this.entityName = "CREDITBUREAU_CONFIGURATION"; this.entityName = "CREDITBUREAU_CONFIGURATION";
this.entityId = creditBureauId; this.entityId = creditBureauId;
this.href = "/creditBureauConfigurationData/"; this.href = "/addCreditBureauConfigurationData/";
return this; return this;
} }
@@ -122,7 +122,7 @@ public class CommandWrapperBuilder {
this.actionName = "UPDATE"; this.actionName = "UPDATE";
this.entityName = "CREDITBUREAU_CONFIGURATION"; this.entityName = "CREDITBUREAU_CONFIGURATION";
this.entityId = configurationId; this.entityId = configurationId;
this.href = "/creditBureauConfigurationData/"; this.href = "/updateCreditBureauConfigurationData/";
return this; return this;
} }
@@ -231,13 +231,13 @@ public class CreditBureauConfigurationAPI {
} }
@POST @POST
@Path("/mappings/{CreditBureauId}") @Path("/mappings/{organisationCreditBureauId}")
@Consumes({ MediaType.APPLICATION_JSON }) @Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON })
public String createCreditBureauLoanProductMapping(@PathParam("CreditBureauId") final Long CreditBureauId, public String createCreditBureauLoanProductMapping(@PathParam("organisationCreditBureauId") final Long organisationCreditBureauId,
final String apiRequestBodyAsJson) { final String apiRequestBodyAsJson) {
final CommandWrapper commandRequest = new CommandWrapperBuilder().createCreditBureauLoanProductMapping(CreditBureauId) final CommandWrapper commandRequest = new CommandWrapperBuilder().createCreditBureauLoanProductMapping(organisationCreditBureauId)
.withJson(apiRequestBodyAsJson).build(); .withJson(apiRequestBodyAsJson).build();
final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
@@ -20,7 +20,11 @@
package org.apache.fineract.infrastructure.creditbureau.api; package org.apache.fineract.infrastructure.creditbureau.api;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.sun.jersey.core.header.FormDataContentDisposition;
import com.sun.jersey.multipart.FormDataParam;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import java.io.File;
import java.io.InputStream;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
@@ -66,6 +70,7 @@ public class CreditBureauIntegrationAPI {
private final DefaultToApiJsonSerializer<CreditReportData> toCreditReportApiJsonSerializer; private final DefaultToApiJsonSerializer<CreditReportData> toCreditReportApiJsonSerializer;
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService; private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
private final ApiRequestParameterHelper apiRequestParameterHelper; private final ApiRequestParameterHelper apiRequestParameterHelper;
private final CreditReportWritePlatformService creditReportWritePlatformService;
private final CreditReportReadPlatformService creditReportReadPlatformService; private final CreditReportReadPlatformService creditReportReadPlatformService;
private final DefaultToApiJsonSerializer<CreditReportData> toApiJsonSerializer; private final DefaultToApiJsonSerializer<CreditReportData> toApiJsonSerializer;
private static final Logger LOG = LoggerFactory.getLogger(CreditBureauIntegrationAPI.class); private static final Logger LOG = LoggerFactory.getLogger(CreditBureauIntegrationAPI.class);
@@ -82,6 +87,7 @@ public class CreditBureauIntegrationAPI {
this.toCreditReportApiJsonSerializer = toCreditReportApiJsonSerializer; this.toCreditReportApiJsonSerializer = toCreditReportApiJsonSerializer;
this.commandsSourceWritePlatformService = commandsSourceWritePlatformService; this.commandsSourceWritePlatformService = commandsSourceWritePlatformService;
this.apiRequestParameterHelper = apiRequestParameterHelper; this.apiRequestParameterHelper = apiRequestParameterHelper;
this.creditReportWritePlatformService = creditReportWritePlatformService;
this.creditReportReadPlatformService = creditReportReadPlatformService; this.creditReportReadPlatformService = creditReportReadPlatformService;
this.toApiJsonSerializer = toApiJsonSerializer; this.toApiJsonSerializer = toApiJsonSerializer;
@@ -102,6 +108,18 @@ public class CreditBureauIntegrationAPI {
} }
// submit loan file of clients to Credit Bureau
@POST
@Path("addCreditReport")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public String addCreditReport(@FormDataParam("file") final File creditReport, @FormDataParam("file") InputStream uploadedInputStream,
@FormDataParam("file") final UriInfo uriInfo, @FormDataParam("file") FormDataContentDisposition fileDetail,
@QueryParam("creditBureauId") @Parameter(description = "creditBureauId") final Long creditBureauId) {
final String responseMessage = this.creditReportWritePlatformService.addCreditReport(creditBureauId, creditReport, fileDetail);
return this.toCreditReportApiJsonSerializer.serialize(responseMessage);
}
// saves fetched-creditreport into database // saves fetched-creditreport into database
@POST @POST
@Path("saveCreditReport") @Path("saveCreditReport")
@@ -41,7 +41,7 @@ public class CreateCreditBureauLoanProductMappingCommandHandler implements NewCo
@Override @Override
public CommandProcessingResult processCommand(JsonCommand command) { public CommandProcessingResult processCommand(JsonCommand command) {
return this.writePlatformService.addCreditBureauLoanProductMapping(command.getCreditBureauId(), command); return this.writePlatformService.addCreditBureauLoanProductMapping(command.getOrganisationCreditBureauId(), command);
} }
} }
@@ -61,14 +61,14 @@ public class CreditBureauLoanProductMappingWritePlatformServiceImpl implements C
@Transactional @Transactional
@Override @Override
public CommandProcessingResult addCreditBureauLoanProductMapping(Long creditBureau_id, JsonCommand command) { public CommandProcessingResult addCreditBureauLoanProductMapping(Long organisationCreditBureauId, JsonCommand command) {
this.context.authenticatedUser(); this.context.authenticatedUser();
this.fromApiJsonDeserializer.validateForCreate(command.json(), creditBureau_id); this.fromApiJsonDeserializer.validateForCreate(command.json(), organisationCreditBureauId);
final long lpid = command.longValueOfParameterNamed("loanProductId"); final long lpid = command.longValueOfParameterNamed("loanProductId");
final OrganisationCreditBureau orgcb = this.organisationCreditBureauRepository.getOne(creditBureau_id); final OrganisationCreditBureau orgcb = this.organisationCreditBureauRepository.getOne(organisationCreditBureauId);
final LoanProduct lp = this.loanProductRepository.getOne(lpid); final LoanProduct lp = this.loanProductRepository.getOne(lpid);
@@ -18,6 +18,8 @@
*/ */
package org.apache.fineract.infrastructure.creditbureau.service; package org.apache.fineract.infrastructure.creditbureau.service;
import com.sun.jersey.core.header.FormDataContentDisposition;
import java.io.File;
import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
@@ -32,4 +34,7 @@ public interface CreditReportWritePlatformService {
// deletes creditReports which are saved in database // deletes creditReports which are saved in database
CommandProcessingResult deleteCreditReport(Long creditBureauId, JsonCommand command); CommandProcessingResult deleteCreditReport(Long creditBureauId, JsonCommand command);
// upload CreditReport to CreditBureau
String addCreditReport(Long creditBureauId, File creditReport, FormDataContentDisposition fileDetail);
} }
@@ -18,6 +18,8 @@
*/ */
package org.apache.fineract.infrastructure.creditbureau.service; package org.apache.fineract.infrastructure.creditbureau.service;
import com.sun.jersey.core.header.FormDataContentDisposition;
import java.io.File;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -98,14 +100,9 @@ public class CreditReportWritePlatformServiceImpl implements CreditReportWritePl
if (Objects.equals(creditBureauName.get(), CreditBureauConfigurations.THITSAWORKS.toString())) { if (Objects.equals(creditBureauName.get(), CreditBureauConfigurations.THITSAWORKS.toString())) {
// CreditBureauToken creditBureauToken = this.thitsaWorksCreditBureauIntegrationWritePlatformService
// .createToken(creditBureauID);
CreditBureauReportData reportobj = this.thitsaWorksCreditBureauIntegrationWritePlatformService CreditBureauReportData reportobj = this.thitsaWorksCreditBureauIntegrationWritePlatformService
.getCreditReportFromThitsaWorks(command); .getCreditReportFromThitsaWorks(command);
// return new
// CommandProcessingResultBuilder().withCreditReport(reportobj).withCreditBureauToken(creditBureauToken).build();
return new CommandProcessingResultBuilder().withCreditReport(reportobj).build(); return new CommandProcessingResultBuilder().withCreditReport(reportobj).build();
} }
@@ -124,6 +121,28 @@ public class CreditReportWritePlatformServiceImpl implements CreditReportWritePl
} }
@Override
@Transactional
public String addCreditReport(Long bureauId, File creditReport, FormDataContentDisposition fileDetail) {
Optional<String> creditBureauName = getCreditBureau(bureauId);
String responseMessage = null;
if (Objects.equals(creditBureauName.get(), CreditBureauConfigurations.THITSAWORKS.toString())) {
responseMessage = this.thitsaWorksCreditBureauIntegrationWritePlatformService.addCreditReport(bureauId, creditReport,
fileDetail);
} else {
baseDataValidator.reset().failWithCode("creditBureau.has.not.been.Integrated");
throw new PlatformApiDataValidationException("creditBureau.has.not.been.Integrated", "creditBureau.has.not.been.Integrated",
dataValidationErrors);
}
return responseMessage;
}
private Optional<String> getCreditBureau(Long creditBureauID) { private Optional<String> getCreditBureau(Long creditBureauID) {
if (creditBureauID != null) { if (creditBureauID != null) {
@@ -18,6 +18,7 @@
*/ */
package org.apache.fineract.infrastructure.creditbureau.service; package org.apache.fineract.infrastructure.creditbureau.service;
import com.sun.jersey.core.header.FormDataContentDisposition;
import java.io.File; import java.io.File;
import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.creditbureau.data.CreditBureauReportData; import org.apache.fineract.infrastructure.creditbureau.data.CreditBureauReportData;
@@ -30,8 +31,10 @@ public interface ThitsaWorksCreditBureauIntegrationWritePlatformService {
Long extractUniqueId(String jsonResult); Long extractUniqueId(String jsonResult);
String okHttpConnectionMethod(String userName, String password, String subscriptionKey, String subscriptionId, String url, String token, String okHttpConnectionMethod(String userName, String password, String subscriptionKey, String subscriptionId, String url, String token,
File report, Long uniqueId, String nrcId, String process); File report, FormDataContentDisposition fileDetail, Long uniqueId, String nrcId, String process);
CreditBureauReportData getCreditReportFromThitsaWorks(JsonCommand command); CreditBureauReportData getCreditReportFromThitsaWorks(JsonCommand command);
String addCreditReport(Long bureauId, File creditReport, FormDataContentDisposition fileDetail);
} }
@@ -24,6 +24,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonNull; import com.google.gson.JsonNull;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import com.sun.jersey.core.header.FormDataContentDisposition;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
@@ -32,6 +33,7 @@ import java.util.Date;
import java.util.List; import java.util.List;
import okhttp3.HttpUrl; import okhttp3.HttpUrl;
import okhttp3.MediaType; import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.RequestBody; import okhttp3.RequestBody;
@@ -94,13 +96,20 @@ public class ThitsaWorksCreditBureauIntegrationWritePlatformServiceImpl implemen
@Override @Override
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public String okHttpConnectionMethod(String userName, String password, String subscriptionKey, String subscriptionId, String url, public String okHttpConnectionMethod(String userName, String password, String subscriptionKey, String subscriptionId, String url,
String token, File file, Long uniqueId, String nrcId, String process) { String token, File file, FormDataContentDisposition fileData, Long uniqueId, String nrcId, String process) {
String reponseMessage = null; String reponseMessage = null;
RequestBody requestBody = null; RequestBody requestBody = null;
OkHttpClient client = new OkHttpClient(); OkHttpClient client = new OkHttpClient();
if (process.equals("token")) { if (process.equals("UploadCreditReport")) {
String fileName = fileData.getFileName();
requestBody = RequestBody.create(file, MediaType.parse("multipart/form-data"));
requestBody = new MultipartBody.Builder().setType(MultipartBody.FORM).addFormDataPart("file", fileName, requestBody)
.addFormDataPart("BODY", "formdata").addFormDataPart("userName", userName).build();
} else if (process.equals("token")) {
final MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); final MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
String jsonBody = "" + "BODY=x-www-form-urlencoded&\r" + "grant_type=password&\r" + "userName=" + userName + "&\r" + "password=" String jsonBody = "" + "BODY=x-www-form-urlencoded&\r" + "grant_type=password&\r" + "userName=" + userName + "&\r" + "password="
@@ -130,6 +139,12 @@ public class ThitsaWorksCreditBureauIntegrationWritePlatformServiceImpl implemen
request = new Request.Builder().header("mcix-subscription-key", subscriptionKey) request = new Request.Builder().header("mcix-subscription-key", subscriptionKey)
.header("mcix-subscription-id", subscriptionId).header("Content-Type", "application/x-www-form-urlencoded") .header("mcix-subscription-id", subscriptionId).header("Content-Type", "application/x-www-form-urlencoded")
.header("Authorization", "Bearer " + token).url(urlokhttp).get().build(); .header("Authorization", "Bearer " + token).url(urlokhttp).get().build();
} else if (process.equals("UploadCreditReport")) { // POST for uploading Credit-Report(multipart/form-data)
// To ThitsaWork
request = new Request.Builder().header("mcix-subscription-key", subscriptionKey)
.header("mcix-subscription-id", subscriptionId).header("Content-Type", "multipart/form-data")
.header("Authorization", "Bearer " + token).url(urlokhttp).post(requestBody).build();
} else { // POST method for application/x-www-form-urlencoded } else { // POST method for application/x-www-form-urlencoded
request = new Request.Builder().header("mcix-subscription-key", subscriptionKey) request = new Request.Builder().header("mcix-subscription-key", subscriptionKey)
@@ -153,6 +168,12 @@ public class ThitsaWorksCreditBureauIntegrationWritePlatformServiceImpl implemen
this.httpResponse(responseCode, reponseMessage); this.httpResponse(responseCode, reponseMessage);
} }
if (process.equals("UploadCreditReport")) { // to show the Response on frontEnd
JsonObject reportObject = JsonParser.parseString(reponseMessage).getAsJsonObject();
String ResponseMessageJson = reportObject.get("ResponseMessage").getAsString();
this.handleAPIIntegrityIssues(ResponseMessageJson);
}
return reponseMessage; return reponseMessage;
} }
@@ -201,8 +222,8 @@ public class ThitsaWorksCreditBureauIntegrationWritePlatformServiceImpl implemen
String nrcUrl = url + nrcId; String nrcUrl = url + nrcId;
String searchResult = this.okHttpConnectionMethod(userName, password, subscriptionKey, subscriptionId, nrcUrl, token, null, 0L, String searchResult = this.okHttpConnectionMethod(userName, password, subscriptionKey, subscriptionId, nrcUrl, token, null, null,
nrcId, process); 0L, nrcId, process);
if (process.equals("NRC")) { if (process.equals("NRC")) {
Long uniqueID = this.extractUniqueId(searchResult); Long uniqueID = this.extractUniqueId(searchResult);
@@ -213,7 +234,7 @@ public class ThitsaWorksCreditBureauIntegrationWritePlatformServiceImpl implemen
String creditReportUrl = url + uniqueID; String creditReportUrl = url + uniqueID;
searchResult = this.okHttpConnectionMethod(userName, password, subscriptionKey, subscriptionId, creditReportUrl, token, null, searchResult = this.okHttpConnectionMethod(userName, password, subscriptionKey, subscriptionId, creditReportUrl, token, null,
uniqueID, null, process); null, uniqueID, null, process);
} }
@@ -270,6 +291,31 @@ public class ThitsaWorksCreditBureauIntegrationWritePlatformServiceImpl implemen
writeoffLoanStringArray); writeoffLoanStringArray);
} }
@Override
@Transactional
public String addCreditReport(Long bureauId, File creditReport, FormDataContentDisposition fileDetail) {
Integer creditBureauId = bureauId.intValue();
String userName = this.getCreditBureauConfiguration(creditBureauId, CreditBureauConfigurations.USERNAME.toString());
String password = this.getCreditBureauConfiguration(creditBureauId, CreditBureauConfigurations.PASSWORD.toString());
String subscriptionId = this.getCreditBureauConfiguration(creditBureauId, CreditBureauConfigurations.SUBSCRIPTIONID.toString());
String subscriptionKey = this.getCreditBureauConfiguration(creditBureauId, CreditBureauConfigurations.SUBSCRIPTIONKEY.toString());
CreditBureauToken creditbureautoken = this.createToken(creditBureauId.longValue());
String token = creditbureautoken.getCurrentToken();
CreditBureauConfiguration addReportURL = this.configDataRepository.getCreditBureauConfigData(creditBureauId, "addCreditReporturl");
String url = addReportURL.getValue();
String process = "UploadCreditReport";
String responseMessage = this.okHttpConnectionMethod(userName, password, subscriptionKey, subscriptionId, url, token, creditReport,
fileDetail, 0L, null, process);
return responseMessage;
}
private String[] convertArrayintoStringArray(JsonArray jsonResult) { private String[] convertArrayintoStringArray(JsonArray jsonResult) {
String[] loanAccounts = new String[jsonResult.size()]; String[] loanAccounts = new String[jsonResult.size()];
@@ -391,8 +437,8 @@ public class ThitsaWorksCreditBureauIntegrationWritePlatformServiceImpl implemen
String process = "token"; String process = "token";
String nrcId = null; String nrcId = null;
Long uniqueID = 0L; Long uniqueID = 0L;
String result = this.okHttpConnectionMethod(userName, password, subscriptionKey, subscriptionId, url, null, null, uniqueID, String result = this.okHttpConnectionMethod(userName, password, subscriptionKey, subscriptionId, url, null, null, null,
nrcId, process); uniqueID, nrcId, process);
// created token will be storing it into database // created token will be storing it into database
final CommandWrapper wrapper = new CommandWrapperBuilder().withJson(result).build(); final CommandWrapper wrapper = new CommandWrapperBuilder().withJson(result).build();
final String json = wrapper.getJson(); final String json = wrapper.getJson();
@@ -434,10 +480,11 @@ public class ThitsaWorksCreditBureauIntegrationWritePlatformServiceImpl implemen
creditBureauConfigurationValue = configurationParameterValue.getValue(); creditBureauConfigurationValue = configurationParameterValue.getValue();
if (creditBureauConfigurationValue.isEmpty()) { if (creditBureauConfigurationValue.isEmpty()) {
baseDataValidator.reset().failWithCode("creditBureau.configuration." + configurationParameterName + ".is.not.available"); baseDataValidator.reset().failWithCode("creditBureau.configuration." + configurationParameterName + ".is.not.available");
throw new PlatformApiDataValidationException(
"creditBureau.Configuration." + configurationParameterName + ".is.not.available", throw new PlatformDataIntegrityException("creditBureau.Configuration." + configurationParameterName + ".is.not.available",
"creditBureau.Configuration.is.not.available", dataValidationErrors); "creditBureau.Configuration." + configurationParameterName + ".is.not.available");
} }
} catch (NullPointerException ex) { } catch (NullPointerException ex) {
@@ -23,7 +23,9 @@ import static org.mockito.Mockito.when;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import com.sun.jersey.core.header.FormDataContentDisposition;
import java.io.File; import java.io.File;
import javax.ws.rs.core.UriInfo;
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper; import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
import org.apache.fineract.infrastructure.creditbureau.service.CreditReportWritePlatformServiceImpl; import org.apache.fineract.infrastructure.creditbureau.service.CreditReportWritePlatformServiceImpl;
import org.apache.fineract.infrastructure.creditbureau.service.ThitsaWorksCreditBureauIntegrationWritePlatformServiceImpl; import org.apache.fineract.infrastructure.creditbureau.service.ThitsaWorksCreditBureauIntegrationWritePlatformServiceImpl;
@@ -60,7 +62,11 @@ public class ThitsaworksCreditBureauTest {
static String url = "url"; static String url = "url";
static String token = "token"; static String token = "token";
static Long uniqueId = 8113399260L; static Long uniqueId = 8113399260L;
static File file; static byte[] file;
static File report;
static String fileName;
static UriInfo uriInfo;
static FormDataContentDisposition fileData;
static String testresult = "{ 'Data': {'BorrowerInfo': {'MainIdentifier': '2113439293', 'Name': 'Aung Khant Min'," static String testresult = "{ 'Data': {'BorrowerInfo': {'MainIdentifier': '2113439293', 'Name': 'Aung Khant Min',"
+ " 'NRC': '13/MiFoS(N)163525', 'Gender': '', 'DOB': '1990-01-20', 'FatherName': '', 'Address': ''," + " 'NRC': '13/MiFoS(N)163525', 'Gender': '', 'DOB': '1990-01-20', 'FatherName': '', 'Address': '',"
@@ -86,10 +92,10 @@ public class ThitsaworksCreditBureauTest {
String searchResult = "{\"Data\":[{\"UniqueID\":\"8113399260\",\"NRC\":\"12/KaMaRa(N)253426\",\"FullName\":\"Aye Aye\",\"DOB\":\"1990-05-22,1991-05-22\",\"FatherFullName\":\"U Aye Myint Maung\",\"Location\":\"Yangon-Thongwa,Twantay,Yankin\",\"Flag\":\"[{\\\"WriteOff\\\":1}]\",\"Active\":\"Y\"}],\"MessageDtm\":\"8/1/2020 6:39:00 PM UTC\",\"SubscriptionID\":\"317A1FF8-625D-41BA-BE0F-F8ED8A644A7C\",\"CallerIP\":\"207.46.228.155\",\"URI\":\"https://qa-mmcix-api.azurewebsites.net/20200324/api/Search/SimpleSearch?nrc=253426\",\"ResponseMessage\":\"Record found\"}"; String searchResult = "{\"Data\":[{\"UniqueID\":\"8113399260\",\"NRC\":\"12/KaMaRa(N)253426\",\"FullName\":\"Aye Aye\",\"DOB\":\"1990-05-22,1991-05-22\",\"FatherFullName\":\"U Aye Myint Maung\",\"Location\":\"Yangon-Thongwa,Twantay,Yankin\",\"Flag\":\"[{\\\"WriteOff\\\":1}]\",\"Active\":\"Y\"}],\"MessageDtm\":\"8/1/2020 6:39:00 PM UTC\",\"SubscriptionID\":\"317A1FF8-625D-41BA-BE0F-F8ED8A644A7C\",\"CallerIP\":\"207.46.228.155\",\"URI\":\"https://qa-mmcix-api.azurewebsites.net/20200324/api/Search/SimpleSearch?nrc=253426\",\"ResponseMessage\":\"Record found\"}";
when(this.thitsaWorksCreditBureauIntegrationWritePlatformServiceImpl.okHttpConnectionMethod(userName, password, subscriptionKey, when(this.thitsaWorksCreditBureauIntegrationWritePlatformServiceImpl.okHttpConnectionMethod(userName, password, subscriptionKey,
subscriptionId, url, token, file, uniqueId, nrcID, process)).thenReturn(searchResult); subscriptionId, url, token, report, fileData, uniqueId, nrcID, process)).thenReturn(searchResult);
final String search = thitsaWorksCreditBureauIntegrationWritePlatformServiceImpl.okHttpConnectionMethod(userName, password, final String search = thitsaWorksCreditBureauIntegrationWritePlatformServiceImpl.okHttpConnectionMethod(userName, password,
subscriptionKey, subscriptionId, url, token, file, uniqueId, nrcID, process); subscriptionKey, subscriptionId, url, token, report, fileData, uniqueId, nrcID, process);
when(thitsaWorksCreditBureauIntegrationWritePlatformServiceImpl.extractUniqueId(search)).thenCallRealMethod(); when(thitsaWorksCreditBureauIntegrationWritePlatformServiceImpl.extractUniqueId(search)).thenCallRealMethod();
@@ -105,10 +111,10 @@ public class ThitsaworksCreditBureauTest {
String curentNrc = "13/MiFoS(N)163525"; String curentNrc = "13/MiFoS(N)163525";
when(this.thitsaWorksCreditBureauIntegrationWritePlatformServiceImpl.okHttpConnectionMethod(userName, password, subscriptionKey, when(this.thitsaWorksCreditBureauIntegrationWritePlatformServiceImpl.okHttpConnectionMethod(userName, password, subscriptionKey,
subscriptionId, url, token, file, uniqueId, nrcID, process)).thenReturn(testresult); subscriptionId, url, token, report, fileData, uniqueId, nrcID, process)).thenReturn(testresult);
String creditReport = thitsaWorksCreditBureauIntegrationWritePlatformServiceImpl.okHttpConnectionMethod(userName, password, String creditReport = thitsaWorksCreditBureauIntegrationWritePlatformServiceImpl.okHttpConnectionMethod(userName, password,
subscriptionKey, subscriptionId, url, token, file, uniqueId, nrcID, process); subscriptionKey, subscriptionId, url, token, report, fileData, uniqueId, nrcID, process);
JsonObject resultObject = JsonParser.parseString(creditReport).getAsJsonObject(); JsonObject resultObject = JsonParser.parseString(creditReport).getAsJsonObject();
String data = resultObject.get("Data").toString(); String data = resultObject.get("Data").toString();