Search in sources :

Example 1 with ResultInfo

use of jp.ne.paypay.model.ResultInfo in project paypayopa-sdk-java by paypay.

the class PaymentApiTest method setUp.

@BeforeEach
public void setUp() {
    apiClient = Mockito.mock(ApiClient.class);
    api.setApiClient(apiClient);
    resultInfo = new ResultInfo();
    resultInfo.setMessage("SUCCESS");
    payment = new Payment();
    payment.setAmount(new MoneyAmount().amount(10).currency(MoneyAmount.CurrencyEnum.JPY));
    payment.merchantPaymentId("merchantPaymentId").userAuthorizationId("userAuthorizationId").requestedAt(Instant.now().getEpochSecond()).storeId(RandomStringUtils.randomAlphabetic(8)).terminalId(RandomStringUtils.randomAlphanumeric(8)).orderReceiptNumber(RandomStringUtils.randomAlphanumeric(8)).orderDescription("Payment for Order ID:" + UUID.randomUUID().toString());
    MerchantOrderItem merchantOrderItem = new MerchantOrderItem().category("Dessert").name("Red Velvet Cake").productId(RandomStringUtils.randomAlphanumeric(8)).quantity(1).unitPrice(new MoneyAmount().amount(10).currency(MoneyAmount.CurrencyEnum.JPY));
    List<MerchantOrderItem> merchantOrderItems = new ArrayList<>();
    merchantOrderItems.add(merchantOrderItem);
    payment.orderItems(merchantOrderItems);
}
Also used : Payment(jp.ne.paypay.model.Payment) MerchantOrderItem(jp.ne.paypay.model.MerchantOrderItem) ArrayList(java.util.ArrayList) MoneyAmount(jp.ne.paypay.model.MoneyAmount) ApiClient(jp.ne.paypay.ApiClient) ResultInfo(jp.ne.paypay.model.ResultInfo) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with ResultInfo

use of jp.ne.paypay.model.ResultInfo in project paypayopa-sdk-java by paypay.

the class PendingPaymentApiTest method setUp.

@BeforeEach
public void setUp() {
    apiClient = Mockito.mock(ApiClient.class);
    api.setApiClient(apiClient);
    paymentApi.setApiClient(apiClient);
    resultInfo = new ResultInfo();
    resultInfo.setMessage("SUCCESS");
    payment = new Payment();
    payment.setAmount(new MoneyAmount().amount(10).currency(MoneyAmount.CurrencyEnum.JPY));
    payment.merchantPaymentId("merchantPaymentId").userAuthorizationId("userAuthorizationId").requestedAt(Instant.now().getEpochSecond()).storeId(RandomStringUtils.randomAlphabetic(8)).terminalId(RandomStringUtils.randomAlphanumeric(8)).orderReceiptNumber(RandomStringUtils.randomAlphanumeric(8)).orderDescription("Payment for Order ID:" + UUID.randomUUID().toString());
    MerchantOrderItem merchantOrderItem = new MerchantOrderItem().category("Dessert").name("Red Velvet Cake").productId(RandomStringUtils.randomAlphanumeric(8)).quantity(1).unitPrice(new MoneyAmount().amount(10).currency(MoneyAmount.CurrencyEnum.JPY));
    List<MerchantOrderItem> merchantOrderItems = new ArrayList<>();
    merchantOrderItems.add(merchantOrderItem);
    payment.orderItems(merchantOrderItems);
}
Also used : Payment(jp.ne.paypay.model.Payment) MerchantOrderItem(jp.ne.paypay.model.MerchantOrderItem) ArrayList(java.util.ArrayList) MoneyAmount(jp.ne.paypay.model.MoneyAmount) ApiClient(jp.ne.paypay.ApiClient) ResultInfo(jp.ne.paypay.model.ResultInfo) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with ResultInfo

use of jp.ne.paypay.model.ResultInfo in project paypayopa-sdk-java by paypay.

the class UserApiTest method setUp.

@BeforeEach
public void setUp() {
    apiClient = Mockito.mock(ApiClient.class);
    api.setApiClient(apiClient);
    resultInfo = new ResultInfo();
    resultInfo.setMessage("SUCCESS");
}
Also used : ApiClient(jp.ne.paypay.ApiClient) ResultInfo(jp.ne.paypay.model.ResultInfo) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with ResultInfo

use of jp.ne.paypay.model.ResultInfo in project paypayopa-sdk-java by paypay.

the class WalletApiTest method setUp.

@BeforeEach
public void setUp() {
    ApiClient apiClient = Mockito.mock(ApiClient.class);
    api.setApiClient(apiClient);
    resultInfo = new ResultInfo();
    resultInfo.setMessage("SUCCESS");
}
Also used : ApiClient(jp.ne.paypay.ApiClient) ResultInfo(jp.ne.paypay.model.ResultInfo) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with ResultInfo

use of jp.ne.paypay.model.ResultInfo in project paypayopa-sdk-java by paypay.

the class ApiClientTest method deserializeTest.

@Test
public void deserializeTest() throws ApiException {
    Request.Builder requestBuild = new Request.Builder();
    requestBuild.url("http://paypay.ne.jp/v2/qrcode");
    requestBuild.header("content-type", "application/json");
    RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), "{\"merchantPaymentId\":'paymentId'}");
    requestBuild.post(requestBody);
    Request request = requestBuild.build();
    Response.Builder builder = new Response.Builder();
    builder.header("content-type", "application/json");
    builder.request(request);
    builder.code(200);
    builder.protocol(Protocol.HTTP_2);
    ResultInfo resultInfo = new ResultInfo();
    resultInfo.setMessage("SUCCESS");
    QRCodeDetails qrCodeDetails = new QRCodeDetails();
    qrCodeDetails.setResultInfo(resultInfo);
    JSON json = new JSON();
    builder.body(ResponseBody.create(MediaType.parse("application/json"), json.serialize(qrCodeDetails)));
    Response response = builder.build();
    Type localVarReturnType = new TypeToken<QRCodeDetails>() {
    }.getType();
    Object result = apiClient.deserialize(response, localVarReturnType);
    Assert.assertTrue(result instanceof QRCodeDetails);
    localVarReturnType = new TypeToken<File>() {
    }.getType();
    result = apiClient.deserialize(response, localVarReturnType);
    Assert.assertTrue(result instanceof File);
    json.setLenientOnJson(true);
    builder.body(ResponseBody.create(MediaType.parse("application/json"), json.serialize(qrCodeDetails)));
    response = builder.build();
    result = apiClient.deserialize(response, localVarReturnType);
    Assert.assertTrue(result instanceof File);
    result = apiClient.deserialize(null, localVarReturnType);
    Assert.assertNull(result);
    builder.header("content-disposition", "filename=test.json");
    response = builder.build();
    result = apiClient.deserialize(response, localVarReturnType);
    Assert.assertNotNull(result);
    Assert.assertTrue(result.toString().endsWith(".json"));
}
Also used : QRCodeDetails(jp.ne.paypay.model.QRCodeDetails) Request(com.squareup.okhttp.Request) JSON(jp.ne.paypay.JSON) Response(com.squareup.okhttp.Response) NotDataResponse(jp.ne.paypay.model.NotDataResponse) ApiResponse(jp.ne.paypay.ApiResponse) MediaType(com.squareup.okhttp.MediaType) Type(java.lang.reflect.Type) TypeToken(com.google.gson.reflect.TypeToken) ResultInfo(jp.ne.paypay.model.ResultInfo) File(java.io.File) RequestBody(com.squareup.okhttp.RequestBody) Test(org.junit.jupiter.api.Test)

Aggregations

ResultInfo (jp.ne.paypay.model.ResultInfo)9 ApiClient (jp.ne.paypay.ApiClient)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 RequestBody (com.squareup.okhttp.RequestBody)4 QRCodeDetails (jp.ne.paypay.model.QRCodeDetails)4 Test (org.junit.jupiter.api.Test)4 MediaType (com.squareup.okhttp.MediaType)3 Request (com.squareup.okhttp.Request)3 Response (com.squareup.okhttp.Response)3 Type (java.lang.reflect.Type)3 ApiResponse (jp.ne.paypay.ApiResponse)3 JSON (jp.ne.paypay.JSON)3 MoneyAmount (jp.ne.paypay.model.MoneyAmount)3 NotDataResponse (jp.ne.paypay.model.NotDataResponse)3 TypeToken (com.google.gson.reflect.TypeToken)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 MerchantOrderItem (jp.ne.paypay.model.MerchantOrderItem)2 Payment (jp.ne.paypay.model.Payment)2 ResponseParameters (jp.ne.paypay.model.ResponseParameters)2