Notes
![]() ![]() Notes - notes.io |
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
public class TestBase {
public Properties prop;
public TestBase(){
try {
prop = new Properties();
FileInputStream ip = new FileInputStream(System.getProperty("user.dir")+"/src/com/config/config.properties");
prop.load(ip);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
************************************
package com.client;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
public class RestClient {
//1. GET Method without Headers:
public CloseableHttpResponse get(String url) throws ClientProtocolException, IOException{
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpGet httpget = new HttpGet(url); //http get request
CloseableHttpResponse closebaleHttpResponse = httpClient.execute(httpget); //hit the GET URL
return closebaleHttpResponse;
}
//2. GET Method with Headers:
public CloseableHttpResponse get(String url, HashMap<String, String> headerMap) throws ClientProtocolException, IOException{
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpGet httpget = new HttpGet(url); //http get request
for(Map.Entry<String,String> entry : headerMap.entrySet()){
httpget.addHeader(entry.getKey(), entry.getValue());
}
CloseableHttpResponse closebaleHttpResponse = httpClient.execute(httpget); //hit the GET URL
return closebaleHttpResponse;
}
//3. POST Method:
public CloseableHttpResponse post(String url, String entityString, HashMap<String, String> headerMap) throws ClientProtocolException, IOException{
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httppost = new HttpPost(url); //http post request
httppost.setEntity(new StringEntity(entityString)); //for payload
//for headers:
for(Map.Entry<String,String> entry : headerMap.entrySet()){
httppost.addHeader(entry.getKey(), entry.getValue());
}
CloseableHttpResponse closebaleHttpResponse = httpClient.execute(httppost);
return closebaleHttpResponse;
}
public CloseableHttpResponse post(String url, String entityString) throws ClientProtocolException, IOException{
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httppost = new HttpPost(url); //http post request
httppost.setEntity(new StringEntity(entityString)); //for payload
CloseableHttpResponse closebaleHttpResponse = httpClient.execute(httppost);
return closebaleHttpResponse;
}
}
********************************************************
getPaymentRef = http://10.20.239.143:8182/s2b/global/corporate/api/payment/v1.0/paymentTransaction/initiate/getPaymentReference
validatePaymentTransaction = http://10.20.239.143:8182/s2b/global/corporate/api/payment/v1.0/paymentTransaction/initiate/validatePaymentTransaction
submitPaymentTransaction = http://10.20.239.143:8182/s2b/global/corporate/api/payment/v1.0/paymentTransaction/initiate/submitPaymentTransaction
************************************************
package com.json;
import java.io.StringWriter;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.model.Header;
import com.model.ServiceContext;
public class JacksonObjectMapper {
public static String Mapper(String context) throws Exception {
//create ObjectMapper instance
ObjectMapper objectMapper = new ObjectMapper();
//convert Object to json string
Header header = createHeader();
//configure Object mapper for pretty print
objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true);
//writing to console, can write to any output stream such as file
StringWriter stringHeader = new StringWriter();
objectMapper.writeValue(stringHeader, header);
return stringHeader.toString();
}
public static Header createHeader() {
Header header = new Header();
ServiceContext sv = new ServiceContext();
sv.setSessionId("fa2f6fd6-63fc-495b-801d-0fdc37dba8c2");
sv.setPlexId("SCB");
sv.setGroupId("UATSGEE1");
sv.setUserId("USER000002");
sv.setProfileId("OPR1");
sv.setChannelType("Web");
sv.setDeviceType("DES");
sv.setCorrelationId("06b2df33-c65c-41bb-a896-a3185b2ad750");
sv.setLanguage("en");
header.setServiceContext(sv);
return header;
}
}
**********************************************
package com.model;
import io.restassured.response.ResponseBody;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import com.resources.EndPoint;
@SuppressWarnings("rawtypes")
public class GenericMethods {
private static final String PATH_JSON_FILE = "src/com/resources/";
public static JSONObject jsonFromResponse(ResponseBody responseBody) {
return (new JSONObject(responseBody.prettyPrint()));
}
public static JSONArray jsonArrayFromResponse(ResponseBody responseBody, String key) {
return jsonFromResponse(responseBody).getJSONArray(key);
}
public static JSONObject getJsonRequestPayload(Class clazz, String fileName) throws FileNotFoundException {
return new JSONObject(getJsonFile(clazz, fileName));
}
@SuppressWarnings("resource")
public static String getJsonFile(Class clazz, String fileName) throws FileNotFoundException {
return new Scanner(new File(String.format("%s%s.json", PATH_JSON_FILE, clazz.getSimpleName()))).useDelimiter("\Z").next();
}
@SuppressWarnings("resource")
public static String getHeaderContext(String fileName) throws FileNotFoundException {
return new Scanner(new File(String.format("%s%s.json", PATH_JSON_FILE, fileName))).useDelimiter("\Z").next();
}
public static String fetchTheEndPointUrl(String Key) throws IllegalAccessException, NoSuchFieldException {
return EndPoint.class.getField(Key).get(Key).toString();
}
}
***********************************
package com.model;
public class Header {
private ServiceContext serviceContext;
public ServiceContext getServiceContext() {
return serviceContext;
}
public void setServiceContext(ServiceContext serviceContext) {
this.serviceContext = serviceContext;
}
@Override
public String toString(){
StringBuilder sb = new StringBuilder();
sb.append("***** Header Details *****n");
sb.append("ServiceContext= "+getServiceContext()+"n");
sb.append("*****************************");
return sb.toString();
}
}
******************************************
package com.model;
public class ServiceContext {
private String sessionId;
private String plexId;
private String groupId;
private String userId;
private String profileId;
private String channelType;
private String deviceType;
private String correlationId;
private String language;
public String getSessionId() {
return sessionId;
}
public void setSessionId(String sessionId) {
this.sessionId = sessionId;
}
public String getPlexId() {
return plexId;
}
public void setPlexId(String plexId) {
this.plexId = plexId;
}
public String getGroupId() {
return groupId;
}
public void setGroupId(String groupId) {
this.groupId = groupId;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getProfileId() {
return profileId;
}
public void setProfileId(String profileId) {
this.profileId = profileId;
}
public String getChannelType() {
return channelType;
}
public void setChannelType(String channelType) {
this.channelType = channelType;
}
public String getDeviceType() {
return deviceType;
}
public void setDeviceType(String deviceType) {
this.deviceType = deviceType;
}
public String getCorrelationId() {
return correlationId;
}
public void setCorrelationId(String correlationId) {
this.correlationId = correlationId;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
@Override
public String toString(){
StringBuilder sb = new StringBuilder();
sb.append("***** Service Context Details *****n");
sb.append("Session Id= "+getSessionId()+"n");
sb.append("Plex Id= "+getPlexId()+"n");
sb.append("Group Id= "+getGroupId()+"n");
sb.append("User Id= "+getUserId()+"n");
sb.append("Profile Id= "+getProfileId()+"n");
sb.append("Channel Type= "+getChannelType()+"n");
sb.append("Device Type= "+getDeviceType()+"n");
sb.append("Correlation Id= "+getCorrelationId()+"n");
sb.append("language= "+getLanguage()+"n");
sb.append("*****************************");
return sb.toString();
}
}
***************************
package com.resources;
public interface EndPoint {
String ServiceContext="ServiceContext";
String POST_getPreferredPayees="/paymentTransaction/initiate/getPreferredPayees";
String POST_getPreferredDebitAccounts="/paymentTransaction/initiate/getPreferredDebitAccounts";
String POST_getPaymentReference="/paymentTransaction/initiate/getPaymentReference";
String POST_validatePaymentTransaction="/paymentTransaction/initiate/validatePaymentTransaction";
String POST_submitPaymentTransaction="/paymentTransaction/initiate/submitPaymentTransaction";
String POST_SubmitPayee="/payee/create/submitPayee";
}
*********************
{
"serviceContext":{
"sessionId":"fa2f6fd6-63fc-495b-801d-0fdc37dba8c2",
"plexId":"SCB",
"groupId":"UATSGEE1",
"userId":"USER000002",
"profileId":"OPR1",
"channelType":"Web",
"deviceType":"DES",
"correlationId":"06b2df33-c65c-41bb-a896-a3185b2ad750",
"language":"en"
}
}
*************************
{
"serviceContext":{
"plexId":"SCB",
"groupId":"UATSGEE1",
"userId":"USER000002",
"sessionId":"0a429b0f-dd22-4643-8be5-7af96851347f",
"journeyId":null,
"correlationId":"060401dc-96e6-43cc-b9dd-03dfd7d883b5",
"channelType":"Web",
"profileId":"CONTTSTAU1",
"nounce":null,
"addnContext":null,
"deviceType":"DES"
},
"payloadRequest":{
"paymentTransaction":{
"channelPayRef":"Q6211146",
"customerReferenceNumber":"PIUATSGEE1A10915",
"isOBOPayerSelected":false,
"debitAccount":{
"accountNo":"0101328923",
"currencyCode":"SGD",
"accountName":"0224733 Title..",
"nickName":"",
"countryCode":"SG",
"cityCode":"SIN",
"bankCode":"SCBLSG22XXX",
"companyName":"NAMEGB GBNAME",
"qlId":21206,
"isFavorite":false,
"scbFlag":"Y",
"countryName":"SINGAPORE",
"status":"",
"accModes":[
{
"srchCst":"payee.payeeNickName|payee.payeeAccounts.0.accountNo|payee.firstName|payee.payeeAccounts.0.bank.bankCode|payee.payeeAccounts.0.bank.bankName|payee.payeeAccounts.0.bank.bankCountryCode",
"mode":"ACCOUNT",
"subPymtType":null,
"supportedPymtTypes":"IBFT"
},
{
"srchCst":"payee.payeeNickName|payee.payeeAccounts.0.accountNo|payee.firstName|payee.payeeAccounts.0.bank.bankCode|payee.payeeAccounts.0.bank.bankCountryCode",
"mode":"SELF",
"subPymtType":null,
"supportedPymtTypes":null
},
{
"srchCst":"payee.PayeeNickName|payee.firstName|payee.payeeAddlDtls.0.fldValues.0.value1|payee.payeeCountryCode",
"mode":"MOBILENO",
"subPymtType":"PTM",
"supportedPymtTypes":"IBFT|RTGS|ACH|PAY"
},
{
"srchCst":"payee.payeeNickName|payee.firstName|payee.payeeAddlDtls.0.fldValues.0.value1|payee.payeeCountryCode",
"mode":"NRIC",
"subPymtType":"PTN",
"supportedPymtTypes":"IBFT|RTGS|ACH|PAY"
},
{
"srchCst":"payee.payeeNickName|payee.firstName|payee.payeeAddlDtls.0.fldValues.0.value1|payee.payeeCountryCode",
"mode":"UEN",
"subPymtType":"PTU",
"supportedPymtTypes":"IBFT|RTGS|ACH"
}
]
},
"paymentMode":"ACCOUNT",
"payee":{
"payeeId":667492801,
"payeeAccounts":[
{
"bank":{
"bankCode":"KWHKSGSGXXX",
"bankName":"China CITIC Bank International Limited",
"bankAddress1":"8 Marina View 28-02",
"bankAddress2":"Asia Square Tower 1",
"bankBranchAddress1":"8 Marina View 28-02",
"bankBranchAddress2":"Asia Square Tower 1",
"bankLocalCode1":"9423091",
"bankLocalCode2":"KWHKSGSGXXX",
"bankBranchCode":"091",
"bankBranchName":"Singapore Branch",
"bankCountryCode":"SG",
"bankCountryName":"SINGAPORE",
"bankCityCode":"SIN",
"bankACHCode":"Y",
"bankTTCode":"KWHKSGSGXXX",
"bankPAYCode":"Y",
"bankRTGSCode":"9423/091",
"bankSwiftCode":"KWHKSGSGXXX",
"bankRoutingCode":"9423091",
"partnerBank":"N"
},
"lastUsedDate":"10/10/2016",
"isAdditionalAccountNo":"N",
"accountNo":"2121212121212"
}
],
"payeeNickName":"BISINGLEACC",
"firstName":"BISINGLEACC",
"payeeAddress1":"ADDRESS",
"payeeCountryCode":"SG",
"payeeTaxId":"123123",
"payeeMobileCtry":"65",
"payeeMobileNo":"123123222",
"payeeFaxNo":"312312322",
"payeeFaxCtry":"65",
"payeeStatus":"FULLY AUTHORIZED",
"lastUseDate":null,
"payeeCountryName":"SINGAPORE",
"payeeBankName":null,
"hashVersionNum":0,
"payeeAddlDtls":[
],
"getPayeeModelDtls":[
]
},
"amtPriority":"PAYMENT",
"debitAmount":{
"value":"500.00",
"currency":"SGD"
},
"paymentAmount":{
"value":"500.00",
"currency":"SGD"
},
"paymentType":{
"paymentTypeCode":"ACH",
"isDefaultPaymentType":false,
"debitDate":1530537896000,
"paymentDate":1530624296000,
"paymentProcessingCutoffDate":1530527700000,
"creditDate":1530624296000,
"debitCutoffDate":1530527700000,
"paymentTypetimeZone":"SGT",
"isDebitAmtPrioritySupported":true,
"backdatingAllowed":"",
"noOfForwardDaysAllowed":30,
"noOfBackwardDaysAllowed":"",
"isSwiftPaymentType":"",
"t1paymentDate":"",
"t2paymentDate":"",
"t1debitDate":"",
"t2debitDate":"",
"holidayexclusionAllowed":false
},
"datePriority":"PAYMENT",
"overseasChargeTo":"PAYER",
"regulatoryDtls":{
"purposeOfPayment":"COMM~COMM-Commission"
},
"regulatoryHeader":[
{
"sequenceNo":1,
"uiLabel":"Purpose of Payment",
"fieldType":"regulatoryDtls.purposeOfPayment",
"component":"ALPHANUMERIC",
"translationValue":"PURPOSE_OF_PAYMENT"
}
],
"regulatoryFlag":true,
"channelReferenceNumber":"PIUATSGEE1A10915",
"initContext":"MANUAL_PAYMENT",
"threatMetrixId":"3f50487a-77d6-40ce-aa35-a6e2c0c7929e",
"pymtHashedValue":"e70712110f8ce8595d0b06fee92bb129a2e49834955b04991ff98ba9e0db952764bbf897f80254e9bf434474c1968614c7489f7389e5dca7142a0651945e187a"
},
"journeyContextEnum":"MANUAL_PAYMENT"
}
}
******************************
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team