mirror of
https://github.com/valitydev/proxy-mocketbank.git
synced 2024-11-06 01:55:16 +00:00
PROX-46: update damsel (#6)
This commit is contained in:
parent
1e4949902c
commit
230b6d8697
12
README.md
12
README.md
@ -2,7 +2,7 @@
|
||||
|
||||
[![Build Status](http://ci.rbkmoney.com/buildStatus/icon?job=rbkmoney_private/proxy-mocketbank/master)](http://ci.rbkmoney.com/job/rbkmoney_private/proxy-mocketbank/master)
|
||||
|
||||
Сервис предназначен для эмулирования запросов между процессингом и банковском
|
||||
Сервис предназначен для эмулирования запросов между процессингом и банком
|
||||
|
||||
|
||||
### Developers
|
||||
@ -44,12 +44,12 @@ services:
|
||||
--cds.url.storage=http://cds:8022/v1/storage
|
||||
--cds.url.keyring=http://cds:8022/v1/keyring
|
||||
--hellgate.url=http://hellgate:8022/v1/proxyhost/provider
|
||||
--proxy-test.callbackUrl=http://proxy-mocketbank:8080
|
||||
--proxy-test-mpi.url=http://proxy-mocketbank-mpi:8080
|
||||
--proxy-mocketbank.callbackUrl=http://proxy-mocketbank:8080
|
||||
--proxy-mocketbank-mpi.url=http://proxy-mocketbank-mpi:8080
|
||||
working_dir: /opt/proxy-mocketbank
|
||||
restart: on-failure:3
|
||||
|
||||
proxy_test_mpi:
|
||||
proxy_mocketbank_mpi:
|
||||
image: dr.rbkmoney.com/rbkmoney/proxy-mocketbank-mpi:last
|
||||
environment:
|
||||
- SERVICE_NAME=proxy_mocketbank_mpi
|
||||
@ -57,9 +57,9 @@ services:
|
||||
- "8018:8080"
|
||||
command: |
|
||||
-Xms64m -Xmx256m
|
||||
-jar /opt/proxy-test-mpi/proxy-mocketbank-mpi.jar
|
||||
-jar /opt/proxy-mocketbank-mpi/proxy-mocketbank-mpi.jar
|
||||
--logging.file=/var/log/proxy-mocketbank-mpi/proxy-mocketbank-mpi.json
|
||||
--proxy-test-mpi.callbackUrl=http://proxy-mocketbank-mpi:8080
|
||||
--proxy-mocketbank-mpi.callbackUrl=http://proxy-mocketbank-mpi:8080
|
||||
working_dir: /opt/proxy-mocketbank-mpi
|
||||
restart: on-failure:3
|
||||
|
||||
|
4
pom.xml
4
pom.xml
@ -12,7 +12,7 @@
|
||||
</parent>
|
||||
|
||||
<artifactId>proxy-mocketbank</artifactId>
|
||||
<version>1.0.3</version>
|
||||
<version>1.0.4</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>proxy-mocketbank</name>
|
||||
@ -60,7 +60,7 @@
|
||||
<dependency>
|
||||
<groupId>com.rbkmoney</groupId>
|
||||
<artifactId>damsel</artifactId>
|
||||
<version>1.99-557f549</version>
|
||||
<version>1.123-91298f7</version>
|
||||
</dependency>
|
||||
<!--Test libs-->
|
||||
<dependency>
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.rbkmoney.proxy.mocketbank.handler;
|
||||
|
||||
import com.rbkmoney.damsel.base.TryLater;
|
||||
import com.rbkmoney.damsel.cds.CardData;
|
||||
import com.rbkmoney.damsel.domain.TransactionInfo;
|
||||
import com.rbkmoney.damsel.proxy.Intent;
|
||||
@ -9,7 +8,6 @@ import com.rbkmoney.proxy.mocketbank.utils.CardUtils;
|
||||
import com.rbkmoney.proxy.mocketbank.utils.Converter;
|
||||
import com.rbkmoney.proxy.mocketbank.utils.cds.CdsApi;
|
||||
import com.rbkmoney.proxy.mocketbank.utils.damsel.*;
|
||||
import com.rbkmoney.proxy.mocketbank.utils.model.Card;
|
||||
import com.rbkmoney.proxy.mocketbank.utils.mocketbank.MocketBankMpiApi;
|
||||
import com.rbkmoney.proxy.mocketbank.utils.mocketbank.MocketBankMpiUtils;
|
||||
import com.rbkmoney.proxy.mocketbank.utils.mocketbank.constant.MocketBankMpiAction;
|
||||
@ -17,6 +15,7 @@ import com.rbkmoney.proxy.mocketbank.utils.mocketbank.constant.MocketBankMpiEnro
|
||||
import com.rbkmoney.proxy.mocketbank.utils.mocketbank.constant.MocketBankMpiTransactionStatus;
|
||||
import com.rbkmoney.proxy.mocketbank.utils.mocketbank.model.ValidatePaResResponse;
|
||||
import com.rbkmoney.proxy.mocketbank.utils.mocketbank.model.VerifyEnrollmentResponse;
|
||||
import com.rbkmoney.proxy.mocketbank.utils.model.Card;
|
||||
import org.apache.thrift.TException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -62,11 +61,11 @@ public class MocketBankServerHandler implements ProviderProxySrv.Iface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProxyResult processPayment(Context context) throws TryLater, TException {
|
||||
public ProxyResult processPayment(Context context) throws TException {
|
||||
|
||||
options = (context.getOptions().size() > 0) ? context.getOptions() : new HashMap<>();
|
||||
|
||||
Target target = context.getSession().getTarget();
|
||||
TargetInvoicePaymentStatus target = context.getSession().getTarget();
|
||||
|
||||
if (target.isSetProcessed()) {
|
||||
return processed(context);
|
||||
@ -89,7 +88,7 @@ public class MocketBankServerHandler implements ProviderProxySrv.Iface {
|
||||
CardData cardData;
|
||||
TransactionInfo transactionInfo = null;
|
||||
|
||||
com.rbkmoney.damsel.proxy.Intent intent = ProxyWrapper.makeFinishIntentOk();
|
||||
com.rbkmoney.damsel.proxy.Intent intent = ProxyWrapper.makeFinishIntentSuccess();
|
||||
|
||||
try {
|
||||
LOGGER.info("Processed: call CDS. Token {}, session: {}", token, session);
|
||||
@ -218,7 +217,7 @@ public class MocketBankServerHandler implements ProviderProxySrv.Iface {
|
||||
|
||||
context.getSession().setState("confirm".getBytes());
|
||||
|
||||
Intent intent = ProxyWrapper.makeFinishIntentOk();
|
||||
Intent intent = ProxyWrapper.makeFinishIntentSuccess();
|
||||
ProxyResult proxyResult = ProxyProviderWrapper.makeProxyResult(intent, "confirm".getBytes(), transactionInfo);
|
||||
|
||||
LOGGER.info("Captured: proxyResult {}", proxyResult);
|
||||
@ -232,7 +231,7 @@ public class MocketBankServerHandler implements ProviderProxySrv.Iface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallbackResult handlePaymentCallback(ByteBuffer byteBuffer, Context context) throws TryLater, TException {
|
||||
public CallbackResult handlePaymentCallback(ByteBuffer byteBuffer, Context context) throws TException {
|
||||
LOGGER.info("HandlePaymentCallback: start");
|
||||
InvoicePayment invoicePayment = context.getPayment().getPayment();
|
||||
String token = invoicePayment.getPayer().getPaymentTool().getBankCard().getToken();
|
||||
@ -283,7 +282,7 @@ public class MocketBankServerHandler implements ProviderProxySrv.Iface {
|
||||
|
||||
if (validatePaResResponse.getTransactionStatus().equals(MocketBankMpiTransactionStatus.AUTHENTICATION_SUCCESSFUL)) {
|
||||
byte[] callbackResponse = new byte[0];
|
||||
com.rbkmoney.damsel.proxy.Intent intent = ProxyWrapper.makeFinishIntentOk();
|
||||
com.rbkmoney.damsel.proxy.Intent intent = ProxyWrapper.makeFinishIntentSuccess();
|
||||
|
||||
TransactionInfo transactionInfo = DomainWrapper.makeTransactionInfo(
|
||||
MocketBankMpiUtils.generateInvoice(context.getPayment()),
|
||||
|
@ -1,30 +1,26 @@
|
||||
package com.rbkmoney.proxy.mocketbank.utils;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class Converter {
|
||||
|
||||
public static Map<String, String> byteBufferToMap(ByteBuffer byteBuffer) throws IOException {
|
||||
return new ObjectMapper().readValue(
|
||||
new String(byteBuffer.array(), "UTF-8"),
|
||||
new TypeReference<Map<String, String>>() {
|
||||
}
|
||||
);
|
||||
public static Map byteBufferToMap(ByteBuffer byteBuffer) throws IOException {
|
||||
return new ObjectMapper().readValue(new String(byteBuffer.array(), StandardCharsets.UTF_8), HashMap.class);
|
||||
}
|
||||
|
||||
public static ByteBuffer mapToByteBuffer(Map<String, String> map) throws IOException {
|
||||
public static ByteBuffer mapToByteBuffer(Map<String, String> map) throws JsonProcessingException {
|
||||
return ByteBuffer.wrap(new ObjectMapper().writeValueAsString(map).getBytes());
|
||||
}
|
||||
|
||||
public static Map<String, String> mapArrayToMap(Map<String, String[]> map) {
|
||||
if (!Optional.ofNullable(map).isPresent()) {
|
||||
if (map == null) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
Map<String, String> newMap = new HashMap<>();
|
||||
@ -33,18 +29,13 @@ public class Converter {
|
||||
}
|
||||
|
||||
// Convert Map to byte array
|
||||
public static byte[] mapToByteArray(Map<String, String> map) throws IOException {
|
||||
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
|
||||
ObjectOutputStream out = new ObjectOutputStream(byteOut);
|
||||
out.writeObject(map);
|
||||
return byteOut.toByteArray();
|
||||
public static byte[] mapToByteArray(Map<String, String> map) throws JsonProcessingException {
|
||||
return new ObjectMapper().writeValueAsString(map).getBytes();
|
||||
}
|
||||
|
||||
// Parse byte array to Map
|
||||
public static Map<String, String> byteArrayToMap(byte[] data) throws IOException, ClassNotFoundException {
|
||||
ByteArrayInputStream byteIn = new ByteArrayInputStream(data);
|
||||
ObjectInputStream in = new ObjectInputStream(byteIn);
|
||||
return (Map<String, String>) in.readObject();
|
||||
public static Map byteArrayToMap(byte[] data) throws IOException {
|
||||
return new ObjectMapper().readValue(data, HashMap.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,59 +1,14 @@
|
||||
package com.rbkmoney.proxy.mocketbank.utils.damsel;
|
||||
|
||||
|
||||
import com.rbkmoney.damsel.base.*;
|
||||
import com.rbkmoney.damsel.base.Error;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import com.rbkmoney.damsel.base.Timer;
|
||||
|
||||
public class BaseWrapper {
|
||||
|
||||
public static Content makeContent(String type, byte[] data) {
|
||||
Content content = new Content();
|
||||
content.setType(type);
|
||||
content.setData(data);
|
||||
return content;
|
||||
}
|
||||
|
||||
public static Content makeContent(String type, ByteBuffer data) {
|
||||
Content content = new Content();
|
||||
content.setType(type);
|
||||
content.setData(data);
|
||||
return content;
|
||||
}
|
||||
|
||||
public static Rational makeRational(long p, long q) {
|
||||
Rational rational = new Rational();
|
||||
rational.setP(p);
|
||||
rational.setQ(q);
|
||||
return rational;
|
||||
}
|
||||
|
||||
public static Error makeError(String code, String description) {
|
||||
Error error = new Error();
|
||||
error.setCode(code);
|
||||
error.setDescription(description);
|
||||
return error;
|
||||
}
|
||||
|
||||
public static Error makeError(String code) {
|
||||
return BaseWrapper.makeError(code, null);
|
||||
}
|
||||
|
||||
public static Timer makeTimerDeadLine(String deadLine) {
|
||||
Timer timer = new Timer();
|
||||
timer.setDeadline(deadLine);
|
||||
return timer;
|
||||
}
|
||||
|
||||
public static Timer makeTimerTimeout(int timeout) {
|
||||
Timer timer = new Timer();
|
||||
timer.setTimeout(timeout);
|
||||
return timer;
|
||||
}
|
||||
|
||||
public static Ok makeOk() {
|
||||
return new Ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,6 @@
|
||||
package com.rbkmoney.proxy.mocketbank.utils.damsel;
|
||||
|
||||
import com.rbkmoney.damsel.cds.CardData;
|
||||
import com.rbkmoney.damsel.cds.ExpDate;
|
||||
import com.rbkmoney.damsel.cds.PutCardDataResult;
|
||||
import com.rbkmoney.damsel.cds.UnlockStatus;
|
||||
import com.rbkmoney.damsel.cds.*;
|
||||
import com.rbkmoney.damsel.domain.BankCard;
|
||||
|
||||
|
||||
@ -36,9 +33,9 @@ public class CdsWrapper {
|
||||
return putCardDataResult;
|
||||
}
|
||||
|
||||
public static UnlockStatus makeUnlockStatusOk() {
|
||||
public static UnlockStatus makeUnlockStatusUnlocked() {
|
||||
UnlockStatus unlockStatus = new UnlockStatus();
|
||||
unlockStatus.setOk(BaseWrapper.makeOk());
|
||||
unlockStatus.setUnlocked(new Unlocked());
|
||||
return unlockStatus;
|
||||
}
|
||||
|
||||
@ -47,4 +44,5 @@ public class CdsWrapper {
|
||||
unlockStatus.setMoreKeysNeeded(value);
|
||||
return unlockStatus;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,73 +0,0 @@
|
||||
package com.rbkmoney.proxy.mocketbank.utils.damsel;
|
||||
|
||||
|
||||
import com.rbkmoney.damsel.domain.DomainObject;
|
||||
import com.rbkmoney.damsel.domain_config.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class DomainConfigWrapper {
|
||||
|
||||
public static InsertOp makeInsertOp(DomainObject domainObject) {
|
||||
InsertOp insertOp = new InsertOp();
|
||||
insertOp.setObject(domainObject);
|
||||
return insertOp;
|
||||
}
|
||||
|
||||
public static UpdateOp makeUpdateOp(DomainObject newObject, DomainObject oldObject) {
|
||||
UpdateOp updateOp = new UpdateOp();
|
||||
updateOp.setNewObject(newObject);
|
||||
updateOp.setOldObject(oldObject);
|
||||
return updateOp;
|
||||
}
|
||||
|
||||
public static RemoveOp makeRemoveOp(DomainObject domainObject) {
|
||||
RemoveOp removeOp = new RemoveOp();
|
||||
removeOp.setObject(domainObject);
|
||||
return removeOp;
|
||||
}
|
||||
|
||||
public static Operation makeOperationInsert(DomainObject domainObject) {
|
||||
return Operation.insert(DomainConfigWrapper.makeInsertOp(domainObject));
|
||||
}
|
||||
|
||||
public static Operation makeOperationUpdate(DomainObject newObject, DomainObject oldObject) {
|
||||
return Operation.update(DomainConfigWrapper.makeUpdateOp(newObject, oldObject));
|
||||
}
|
||||
|
||||
public static Operation makeOperationRemove(DomainObject domainObject) {
|
||||
return Operation.remove(DomainConfigWrapper.makeRemoveOp(domainObject));
|
||||
}
|
||||
|
||||
public static com.rbkmoney.damsel.domain_config.Reference makeReferenceHead() {
|
||||
Reference reference = new Reference();
|
||||
reference.setHead(DomainConfigWrapper.makeHead());
|
||||
return reference;
|
||||
}
|
||||
|
||||
public static com.rbkmoney.damsel.domain_config.Reference makeReferenceVersion(long version) {
|
||||
Reference reference = new Reference();
|
||||
reference.setVersion(version);
|
||||
return reference;
|
||||
}
|
||||
|
||||
public static Head makeHead() {
|
||||
return new Head();
|
||||
}
|
||||
|
||||
public static Commit makeCommit(List<Operation> operations) {
|
||||
Commit commit = new Commit();
|
||||
commit.setOps(operations);
|
||||
return commit;
|
||||
}
|
||||
|
||||
public static Snapshot makeSnapshot(long version, Map<com.rbkmoney.damsel.domain.Reference, DomainObject> domain) {
|
||||
Snapshot snapshot = new Snapshot();
|
||||
snapshot.setVersion(version);
|
||||
snapshot.setDomain(domain);
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
}
|
@ -1,21 +1,11 @@
|
||||
package com.rbkmoney.proxy.mocketbank.utils.damsel;
|
||||
|
||||
import com.rbkmoney.damsel.base.Rational;
|
||||
import com.rbkmoney.damsel.domain.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class DomainWrapper {
|
||||
|
||||
public static Cash makeCash(Currency currency, Long amount) {
|
||||
Cash cash = new Cash();
|
||||
cash.setAmount(amount);
|
||||
cash.setCurrency(currency);
|
||||
return cash;
|
||||
}
|
||||
|
||||
public static Currency makeCurrency(String name, short numericCode, String SymbolicCode, short exponent) {
|
||||
Currency currency = new Currency();
|
||||
currency.setName(name);
|
||||
@ -34,64 +24,6 @@ public class DomainWrapper {
|
||||
return bankCard;
|
||||
}
|
||||
|
||||
public static InvoicePaymentProcessed makeInvoicePaymentProcessed() {
|
||||
return new InvoicePaymentProcessed();
|
||||
}
|
||||
|
||||
public static InvoicePaymentCaptured makeInvoicePaymentCaptured() {
|
||||
return new InvoicePaymentCaptured();
|
||||
}
|
||||
|
||||
public static InvoicePaymentCancelled makeInvoicePaymentCancelled() {
|
||||
return new InvoicePaymentCancelled();
|
||||
}
|
||||
|
||||
public static InvoicePaymentFailed makeInvoicePaymentFailed() {
|
||||
return new InvoicePaymentFailed();
|
||||
}
|
||||
|
||||
public static InvoicePaymentPending makeInvoicePaymentPending() {
|
||||
return new InvoicePaymentPending();
|
||||
}
|
||||
|
||||
// InvoicePaymentStatus
|
||||
public static InvoicePaymentStatus makeInvoicePaymentStatusPending() {
|
||||
return InvoicePaymentStatus.pending(DomainWrapper.makeInvoicePaymentPending());
|
||||
}
|
||||
|
||||
public static InvoicePaymentStatus makeInvoicePaymentStatusProcessed() {
|
||||
return InvoicePaymentStatus.processed(DomainWrapper.makeInvoicePaymentProcessed());
|
||||
}
|
||||
|
||||
public static InvoicePaymentStatus makeInvoicePaymentStatusCaptured() {
|
||||
return InvoicePaymentStatus.captured(DomainWrapper.makeInvoicePaymentCaptured());
|
||||
}
|
||||
|
||||
public static InvoicePaymentStatus makeInvoicePaymentStatusCanceled() {
|
||||
return InvoicePaymentStatus.cancelled(DomainWrapper.makeInvoicePaymentCancelled());
|
||||
}
|
||||
|
||||
public static InvoicePaymentStatus makeInvoicePaymentStatusFailed() {
|
||||
return InvoicePaymentStatus.failed(DomainWrapper.makeInvoicePaymentFailed());
|
||||
}
|
||||
|
||||
// InvoiceStatus
|
||||
public static InvoiceStatus makeInvoiceStatusUnpaid() {
|
||||
return InvoiceStatus.unpaid(new InvoiceUnpaid());
|
||||
}
|
||||
|
||||
public static InvoiceStatus makeInvoiceStatusPaid() {
|
||||
return InvoiceStatus.paid(new InvoicePaid());
|
||||
}
|
||||
|
||||
public static InvoiceStatus makeInvoiceStatusCancelled() {
|
||||
return InvoiceStatus.cancelled(new InvoiceCancelled());
|
||||
}
|
||||
|
||||
public static InvoiceStatus makeInvoiceStatusFulfilled() {
|
||||
return InvoiceStatus.fulfilled(new InvoiceFulfilled());
|
||||
}
|
||||
|
||||
// TransactionInfo
|
||||
public static TransactionInfo makeTransactionInfo(String paymentId, Map<String, String> extra, String timestamp) {
|
||||
TransactionInfo transactionInfo = new TransactionInfo();
|
||||
@ -109,6 +41,12 @@ public class DomainWrapper {
|
||||
return transactionInfo;
|
||||
}
|
||||
|
||||
public static PaymentTool makePaymentTool(BankCard bankCard) {
|
||||
PaymentTool paymentTool = new PaymentTool();
|
||||
paymentTool.setBankCard(bankCard);
|
||||
return paymentTool;
|
||||
}
|
||||
|
||||
public static Payer makePayer(ContactInfo contactInfo, ClientInfo clientInfo, PaymentTool paymentTool, String session) {
|
||||
Payer payer = new Payer();
|
||||
payer.setContactInfo(contactInfo);
|
||||
@ -132,310 +70,13 @@ public class DomainWrapper {
|
||||
return contactInfo;
|
||||
}
|
||||
|
||||
public static PaymentTool makePaymentTool(BankCard bankCard) {
|
||||
PaymentTool paymentTool = new PaymentTool();
|
||||
paymentTool.setBankCard(bankCard);
|
||||
return paymentTool;
|
||||
public static ShopLocation makeShopLocation(String url) {
|
||||
ShopLocation shopLocation = new ShopLocation();
|
||||
shopLocation.setUrl(url);
|
||||
return shopLocation;
|
||||
}
|
||||
|
||||
public static AmountLimit makeAmountLimit(AmountBound min, AmountBound max) {
|
||||
AmountLimit amountLimit = new AmountLimit();
|
||||
amountLimit.setMin(min);
|
||||
amountLimit.setMax(max);
|
||||
return amountLimit;
|
||||
}
|
||||
|
||||
public static CashVolumeShare makeCashVolumeShare(Rational parts, CashFlowConstant cashFlowConstant) {
|
||||
CashVolumeShare cashVolumeShare = new CashVolumeShare();
|
||||
cashVolumeShare.setParts(parts);
|
||||
cashVolumeShare.setOf(cashFlowConstant);
|
||||
return cashVolumeShare;
|
||||
}
|
||||
|
||||
public static CashVolume makeCashVolumeOnlyShare(CashVolumeShare cashVolumeShare) {
|
||||
CashVolume cashVolume = new CashVolume();
|
||||
cashVolume.setShare(cashVolumeShare);
|
||||
return cashVolume;
|
||||
}
|
||||
|
||||
public static CashVolume makeCashVolumeOnlyFixed(CashVolumeFixed cashVolumeFixed) {
|
||||
CashVolume cashVolume = new CashVolume();
|
||||
cashVolume.setFixed(cashVolumeFixed);
|
||||
return cashVolume;
|
||||
}
|
||||
|
||||
public static TerminalAccountSet makeTerminalAccountSet(CurrencyRef currencyRef, long receipt, long compensation) {
|
||||
TerminalAccountSet terminalAccountSet = new TerminalAccountSet();
|
||||
terminalAccountSet.setCurrency(currencyRef);
|
||||
terminalAccountSet.setReceipt(receipt);
|
||||
terminalAccountSet.setCompensation(compensation);
|
||||
return terminalAccountSet;
|
||||
}
|
||||
|
||||
public static Terminal makeTerminal(String name, String description, CategoryRef categoryRef, PaymentMethodRef paymentMethodRef, List<CashFlowPosting> cashFlowPostings, TerminalAccountSet terminalAccountSet, Map<String, String> options) {
|
||||
Terminal terminal = new Terminal();
|
||||
terminal.setName(name);
|
||||
terminal.setDescription(description);
|
||||
terminal.setCategory(categoryRef);
|
||||
terminal.setPaymentMethod(paymentMethodRef);
|
||||
terminal.setCashFlow(cashFlowPostings);
|
||||
terminal.setAccounts(terminalAccountSet);
|
||||
terminal.setOptions(options);
|
||||
return terminal;
|
||||
}
|
||||
|
||||
public static Provider makeProvider(String name, String description, TerminalSelector terminalSelector, Proxy proxy) {
|
||||
Provider provider = new Provider();
|
||||
provider.setName(name);
|
||||
provider.setDescription(description);
|
||||
provider.setTerminal(terminalSelector);
|
||||
provider.setProxy(proxy);
|
||||
return provider;
|
||||
}
|
||||
|
||||
public static TerminalSelector makeTerminalSelector(Set<TerminalRef> terminalRefs) {
|
||||
TerminalSelector terminalSelector = new TerminalSelector();
|
||||
terminalSelector.setValue(terminalRefs);
|
||||
return terminalSelector;
|
||||
}
|
||||
|
||||
public static Proxy makeProxy(ProxyRef ref, Map<String, String> additional) {
|
||||
Proxy proxy = new Proxy();
|
||||
proxy.setRef(ref);
|
||||
proxy.setAdditional(additional);
|
||||
return proxy;
|
||||
}
|
||||
|
||||
public static Condition makeCondition(CurrencyRef currencyRef) {
|
||||
Condition condition = new Condition();
|
||||
condition.setCurrencyIs(currencyRef);
|
||||
return condition;
|
||||
}
|
||||
|
||||
public static Predicate makePredicate(Condition condition) {
|
||||
Predicate predicate = new Predicate();
|
||||
predicate.setCondition(condition);
|
||||
return predicate;
|
||||
}
|
||||
|
||||
public static CashFlowAccount makeCashFlowAccount(CashFlowParty cashFlowParty, String designation) {
|
||||
CashFlowAccount cashFlowAccount = new CashFlowAccount();
|
||||
cashFlowAccount.setParty(cashFlowParty);
|
||||
cashFlowAccount.setDesignation(designation);
|
||||
return cashFlowAccount;
|
||||
}
|
||||
|
||||
public static CashFlowPosting makeCashFlowPosting(CashFlowAccount source, CashFlowAccount destination, CashVolume cashVolume) {
|
||||
CashFlowPosting cashFlowPosting = new CashFlowPosting();
|
||||
cashFlowPosting.setSource(source);
|
||||
cashFlowPosting.setDestination(destination);
|
||||
cashFlowPosting.setVolume(cashVolume);
|
||||
return cashFlowPosting;
|
||||
}
|
||||
|
||||
public static CashFlowPosting makeCashFlowPosting(CashFlowAccount cashFlowAccount) {
|
||||
CashFlowPosting cashFlowPosting = new CashFlowPosting();
|
||||
cashFlowPosting.setDestination(cashFlowAccount);
|
||||
return cashFlowPosting;
|
||||
}
|
||||
|
||||
public static CashFlowPosting makeCashFlowPostingDestination(CashVolume cashVolume) {
|
||||
CashFlowPosting cashFlowPosting = new CashFlowPosting();
|
||||
cashFlowPosting.setVolume(cashVolume);
|
||||
return cashFlowPosting;
|
||||
}
|
||||
|
||||
|
||||
public static SystemAccountSetSelector makeSystemAccountSetSelector(Set<SystemAccountSetRef> value) {
|
||||
SystemAccountSetSelector systemAccountSetSelector = new SystemAccountSetSelector();
|
||||
systemAccountSetSelector.setValue(value);
|
||||
return systemAccountSetSelector;
|
||||
}
|
||||
|
||||
public static ProviderSelector makeProviderSelector(Set<ProviderRef> value) {
|
||||
ProviderSelector providerSelector = new ProviderSelector();
|
||||
providerSelector.setValue(value);
|
||||
return providerSelector;
|
||||
}
|
||||
|
||||
public static CashFlowSelector makeCashFlowSelectorPredicate(Set<CashFlowPredicate> cashFlowPredicatesList) {
|
||||
CashFlowSelector cashFlowSelector = new CashFlowSelector();
|
||||
cashFlowSelector.setPredicates(cashFlowPredicatesList);
|
||||
return cashFlowSelector;
|
||||
}
|
||||
|
||||
public static CashFlowPredicate makeCashFlowPredicate(Predicate _if, CashFlowSelector then) {
|
||||
CashFlowPredicate cashFlowPredicate = new CashFlowPredicate();
|
||||
cashFlowPredicate.setIf(_if);
|
||||
cashFlowPredicate.setThen(then);
|
||||
return cashFlowPredicate;
|
||||
}
|
||||
|
||||
public static AmountLimitPredicate makeAmountLimitPredicate(Predicate _if, AmountLimitSelector then) {
|
||||
AmountLimitPredicate amountLimitPredicate = new AmountLimitPredicate();
|
||||
amountLimitPredicate.setIf(_if);
|
||||
amountLimitPredicate.setThen(then);
|
||||
return amountLimitPredicate;
|
||||
}
|
||||
|
||||
public static AmountLimitSelector makeAmountLimitSelectorPredicate(Set<AmountLimitPredicate> predicates) {
|
||||
AmountLimitSelector amountLimitSelector = new AmountLimitSelector();
|
||||
amountLimitSelector.setPredicates(predicates);
|
||||
return amountLimitSelector;
|
||||
}
|
||||
|
||||
public static AmountLimitSelector makeAmountLimitSelectorValue(AmountLimit value) {
|
||||
AmountLimitSelector amountLimitSelector = new AmountLimitSelector();
|
||||
amountLimitSelector.setValue(value);
|
||||
return amountLimitSelector;
|
||||
}
|
||||
|
||||
public static PaymentMethodSelector makePaymentMethodSelector(Set<PaymentMethodRef> paymentMethodRefs) {
|
||||
PaymentMethodSelector paymentMethodSelector = new PaymentMethodSelector();
|
||||
paymentMethodSelector.setValue(paymentMethodRefs);
|
||||
return paymentMethodSelector;
|
||||
}
|
||||
|
||||
public static ShopServices makeShopServices(PaymentsService paymentsService) {
|
||||
ShopServices shopServices = new ShopServices();
|
||||
shopServices.setPayments(paymentsService);
|
||||
return shopServices;
|
||||
}
|
||||
|
||||
public static PaymentsService makePaymentsService(long domain_revision, PaymentsServiceTermsRef paymentsServiceTermsRef) {
|
||||
PaymentsService paymentsService = new PaymentsService();
|
||||
paymentsService.setDomainRevision(domain_revision);
|
||||
paymentsService.setTerms(paymentsServiceTermsRef);
|
||||
return paymentsService;
|
||||
}
|
||||
|
||||
public static PaymentsServiceTermsRef makePaymentsServiceTermsRef(int id) {
|
||||
PaymentsServiceTermsRef paymentsServiceTermsRef = new PaymentsServiceTermsRef();
|
||||
paymentsServiceTermsRef.setId(id);
|
||||
return paymentsServiceTermsRef;
|
||||
}
|
||||
|
||||
public static PaymentsServiceTerms makePaymentsServiceTerms(PaymentMethodSelector paymentMethodSelector, AmountLimitSelector amountLimitSelector, CashFlowSelector cashFlowSelector) {
|
||||
PaymentsServiceTerms paymentsServiceTerms = new PaymentsServiceTerms();
|
||||
paymentsServiceTerms.setPaymentMethods(paymentMethodSelector);
|
||||
paymentsServiceTerms.setLimits(amountLimitSelector);
|
||||
paymentsServiceTerms.setFees(cashFlowSelector);
|
||||
return paymentsServiceTerms;
|
||||
}
|
||||
|
||||
|
||||
public static DomainObject makeDomainObjectPaymentsServiceTermsObject(PaymentsServiceTermsRef ref, PaymentsServiceTerms data) {
|
||||
DomainObject domainObject = new DomainObject();
|
||||
PaymentsServiceTermsObject paymentsServiceTermsObject = new PaymentsServiceTermsObject();
|
||||
paymentsServiceTermsObject.setRef(ref);
|
||||
paymentsServiceTermsObject.setData(data);
|
||||
domainObject.setPaymentsServiceTerms(paymentsServiceTermsObject);
|
||||
return domainObject;
|
||||
}
|
||||
|
||||
public static Globals makeGlobals(ProviderSelector providerSelector, PartyPrototypeRef partyPrototypeRef, SystemAccountSetSelector systemAccountSetSelector) {
|
||||
Globals globals = new Globals();
|
||||
globals.setProviders(providerSelector);
|
||||
globals.setPartyPrototype(partyPrototypeRef);
|
||||
globals.setSystemAccounts(systemAccountSetSelector);
|
||||
return globals;
|
||||
}
|
||||
|
||||
public static PartyPrototype makePartyPrototype(ShopPrototype shopPrototype, ShopServices shopServices) {
|
||||
PartyPrototype partyPrototype = new PartyPrototype();
|
||||
partyPrototype.setShop(shopPrototype);
|
||||
partyPrototype.setDefaultServices(shopServices);
|
||||
return partyPrototype;
|
||||
}
|
||||
|
||||
public static ShopPrototype makeShopPrototype(CurrencyRef currencyRef, CategoryRef categoryRef, ShopDetails shopDetails) {
|
||||
ShopPrototype shopPrototype = new ShopPrototype();
|
||||
shopPrototype.setCurrency(currencyRef);
|
||||
shopPrototype.setCategory(categoryRef);
|
||||
shopPrototype.setDetails(shopDetails);
|
||||
return shopPrototype;
|
||||
}
|
||||
|
||||
public static DomainObject makeDomainObjectProxyObject(ProxyRef ref, ProxyDefinition data) {
|
||||
DomainObject domainObject = new DomainObject();
|
||||
ProxyObject proxyObject = new ProxyObject();
|
||||
proxyObject.setRef(ref);
|
||||
proxyObject.setData(data);
|
||||
domainObject.setProxy(proxyObject);
|
||||
return domainObject;
|
||||
}
|
||||
|
||||
public static DomainObject makeDomainObjectProviderObject(ProviderRef ref, Provider data) {
|
||||
DomainObject domainObject = new DomainObject();
|
||||
ProviderObject providerObject = new ProviderObject();
|
||||
providerObject.setRef(ref);
|
||||
providerObject.setData(data);
|
||||
domainObject.setProvider(providerObject);
|
||||
return domainObject;
|
||||
}
|
||||
|
||||
public static DomainObject makeDomainObjectCategoryObject(CategoryRef ref, Category data) {
|
||||
DomainObject domainObject = new DomainObject();
|
||||
CategoryObject categoryObject = new CategoryObject();
|
||||
categoryObject.setRef(ref);
|
||||
categoryObject.setData(data);
|
||||
domainObject.setCategory(categoryObject);
|
||||
return domainObject;
|
||||
}
|
||||
|
||||
public static DomainObject makeDomainObjectCurrencyObject(CurrencyRef ref, Currency data) {
|
||||
DomainObject domainObject = new DomainObject();
|
||||
CurrencyObject currencyObject = new CurrencyObject();
|
||||
currencyObject.setRef(ref);
|
||||
currencyObject.setData(data);
|
||||
domainObject.setCurrency(currencyObject);
|
||||
return domainObject;
|
||||
}
|
||||
|
||||
public static DomainObject makeDomainObjectPartyPrototypeObject(PartyPrototypeRef ref, PartyPrototype data) {
|
||||
DomainObject domainObject = new DomainObject();
|
||||
PartyPrototypeObject partyPrototypeObject = new PartyPrototypeObject();
|
||||
partyPrototypeObject.setRef(ref);
|
||||
partyPrototypeObject.setData(data);
|
||||
domainObject.setPartyPrototype(partyPrototypeObject);
|
||||
return domainObject;
|
||||
}
|
||||
|
||||
public static DomainObject makeDomainObjectGlobalsObject(GlobalsRef ref, Globals data) {
|
||||
DomainObject domainObject = new DomainObject();
|
||||
GlobalsObject globalsObject = new GlobalsObject();
|
||||
globalsObject.setRef(ref);
|
||||
globalsObject.setData(data);
|
||||
domainObject.setGlobals(globalsObject);
|
||||
return domainObject;
|
||||
}
|
||||
|
||||
public static DomainObject makeDomainObjectTerminalObject(TerminalRef ref, Terminal data) {
|
||||
DomainObject domainObject = new DomainObject();
|
||||
TerminalObject terminalObject = new TerminalObject();
|
||||
terminalObject.setRef(ref);
|
||||
terminalObject.setData(data);
|
||||
domainObject.setTerminal(terminalObject);
|
||||
return domainObject;
|
||||
}
|
||||
|
||||
public static GlobalsRef makeGlobalsRef() {
|
||||
return new GlobalsRef();
|
||||
}
|
||||
|
||||
public static TerminalRef makeTerminalRef(int id) {
|
||||
TerminalRef terminalRef = new TerminalRef();
|
||||
terminalRef.setId(id);
|
||||
return terminalRef;
|
||||
}
|
||||
|
||||
public static PaymentMethodRef makePaymentMethodRef(BankCardPaymentSystem bankCardPaymentSystem) {
|
||||
PaymentMethodRef paymentMethodRef = new PaymentMethodRef();
|
||||
paymentMethodRef.setId(DomainWrapper.makePaymentMethod(bankCardPaymentSystem));
|
||||
return paymentMethodRef;
|
||||
}
|
||||
|
||||
public static ShopDetails makeShopDetails(String name, String description, String location) {
|
||||
public static ShopDetails makeShopDetails(String name, String description, ShopLocation location) {
|
||||
ShopDetails shopDetails = new ShopDetails();
|
||||
shopDetails.setName(name);
|
||||
shopDetails.setDescription(description);
|
||||
@ -454,51 +95,4 @@ public class DomainWrapper {
|
||||
return category;
|
||||
}
|
||||
|
||||
public static PaymentMethod makePaymentMethod(BankCardPaymentSystem bankCardPaymentSystem) {
|
||||
PaymentMethod paymentMethod = new PaymentMethod();
|
||||
paymentMethod.setBankCard(bankCardPaymentSystem);
|
||||
return paymentMethod;
|
||||
}
|
||||
|
||||
public static ProxyDefinition makeProxyDefinition(String url, Map<String, String> options) {
|
||||
ProxyDefinition proxyDefinition = new ProxyDefinition();
|
||||
proxyDefinition.setUrl(url);
|
||||
proxyDefinition.setOptions(options);
|
||||
return proxyDefinition;
|
||||
}
|
||||
|
||||
public static ProxyDefinition makeProxyDefinition(String url) {
|
||||
return DomainWrapper.makeProxyDefinition(url, null);
|
||||
}
|
||||
|
||||
public static PartyPrototypeRef makePartyPrototypeRef(int id) {
|
||||
PartyPrototypeRef partyPrototypeRef = new PartyPrototypeRef();
|
||||
partyPrototypeRef.setId(id);
|
||||
return partyPrototypeRef;
|
||||
}
|
||||
|
||||
public static CategoryRef makeCategoryRef(int id) {
|
||||
CategoryRef categoryRef = new CategoryRef();
|
||||
categoryRef.setId(id);
|
||||
return categoryRef;
|
||||
}
|
||||
|
||||
public static ProviderRef makeProviderRef(int id) {
|
||||
ProviderRef providerRef = new ProviderRef();
|
||||
providerRef.setId(id);
|
||||
return providerRef;
|
||||
}
|
||||
|
||||
public static ProxyRef makeProxyRef(int id) {
|
||||
ProxyRef proxyRef = new ProxyRef();
|
||||
proxyRef.setId(id);
|
||||
return proxyRef;
|
||||
}
|
||||
|
||||
public static CurrencyRef makeCurrencyRef(String symbolicCode) {
|
||||
CurrencyRef currencyRef = new CurrencyRef();
|
||||
currencyRef.setSymbolicCode(symbolicCode);
|
||||
return currencyRef;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,37 +0,0 @@
|
||||
package com.rbkmoney.proxy.mocketbank.utils.damsel;
|
||||
|
||||
import com.rbkmoney.damsel.domain.CategoryRef;
|
||||
import com.rbkmoney.damsel.domain.Contractor;
|
||||
import com.rbkmoney.damsel.domain.Payer;
|
||||
import com.rbkmoney.damsel.domain.ShopDetails;
|
||||
import com.rbkmoney.damsel.payment_processing.InvoicePaymentParams;
|
||||
import com.rbkmoney.damsel.payment_processing.ShopParams;
|
||||
import com.rbkmoney.damsel.payment_processing.UserInfo;
|
||||
|
||||
public class PaymentProcessingWrapper {
|
||||
|
||||
public static UserInfo makeUserInfo(String userId) {
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setId(userId);
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
public static ShopParams makeShopParams(ShopDetails shopDetails, CategoryRef categoryRef, Contractor contractor) {
|
||||
ShopParams shopParams = new ShopParams();
|
||||
shopParams.setDetails(shopDetails);
|
||||
shopParams.setContractor(contractor);
|
||||
shopParams.setCategory(categoryRef);
|
||||
return shopParams;
|
||||
}
|
||||
|
||||
public static ShopParams makeShopParams(ShopDetails shopDetails, CategoryRef categoryRef) {
|
||||
return PaymentProcessingWrapper.makeShopParams(shopDetails, categoryRef, null);
|
||||
}
|
||||
|
||||
public static InvoicePaymentParams makeInvoicePaymentParams(Payer payer) {
|
||||
InvoicePaymentParams invoicePaymentParams = new InvoicePaymentParams();
|
||||
invoicePaymentParams.setPayer(payer);
|
||||
return invoicePaymentParams;
|
||||
}
|
||||
|
||||
}
|
@ -14,32 +14,32 @@ import java.util.Map;
|
||||
|
||||
public class ProxyProviderWrapper {
|
||||
|
||||
public static Target makeTargetProcessed() {
|
||||
Target target = new Target();
|
||||
target.setProcessed(DomainWrapper.makeInvoicePaymentProcessed());
|
||||
public static TargetInvoicePaymentStatus makeTargetProcessed() {
|
||||
TargetInvoicePaymentStatus target = new TargetInvoicePaymentStatus();
|
||||
target.setProcessed(new InvoicePaymentProcessed());
|
||||
return target;
|
||||
}
|
||||
|
||||
public static Target makeTargetCaptured() {
|
||||
Target target = new Target();
|
||||
target.setCaptured(DomainWrapper.makeInvoicePaymentCaptured());
|
||||
public static TargetInvoicePaymentStatus makeTargetCaptured() {
|
||||
TargetInvoicePaymentStatus target = new TargetInvoicePaymentStatus();
|
||||
target.setCaptured(new InvoicePaymentCaptured());
|
||||
return target;
|
||||
}
|
||||
|
||||
public static Target makeTargetCancelled() {
|
||||
Target target = new Target();
|
||||
target.setCancelled(DomainWrapper.makeInvoicePaymentCancelled());
|
||||
public static TargetInvoicePaymentStatus makeTargetCancelled() {
|
||||
TargetInvoicePaymentStatus target = new TargetInvoicePaymentStatus();
|
||||
target.setCancelled(new InvoicePaymentCancelled());
|
||||
return target;
|
||||
}
|
||||
|
||||
public static Session makeSession(Target target, byte[] state) {
|
||||
public static Session makeSession(TargetInvoicePaymentStatus target, byte[] state) {
|
||||
Session session = new Session();
|
||||
session.setTarget(target);
|
||||
session.setState(state);
|
||||
return session;
|
||||
}
|
||||
|
||||
public static Session makeSession(Target target) {
|
||||
public static Session makeSession(TargetInvoicePaymentStatus target) {
|
||||
return ProxyProviderWrapper.makeSession(target, null);
|
||||
}
|
||||
|
||||
@ -113,27 +113,21 @@ public class ProxyProviderWrapper {
|
||||
return context;
|
||||
}
|
||||
|
||||
public static Shop makeShop(String shopId, Category category, ShopDetails shopDetails) {
|
||||
public static Shop makeShop(Category category, ShopDetails shopDetails) {
|
||||
Shop shop = new Shop();
|
||||
shop.setId(shopId);
|
||||
shop.setCategory(category);
|
||||
shop.setDetails(shopDetails);
|
||||
return shop;
|
||||
}
|
||||
|
||||
public static Invoice makeInvoice(String invoiceID, String createdAt, String product, com.rbkmoney.damsel.proxy_provider.Cash cost, String description) {
|
||||
public static Invoice makeInvoice(String invoiceID, String createdAt, com.rbkmoney.damsel.proxy_provider.Cash cost) {
|
||||
Invoice invoice = new Invoice();
|
||||
invoice.setId(invoiceID);
|
||||
invoice.setCreatedAt(createdAt);
|
||||
invoice.setProduct(product);
|
||||
invoice.setCost(cost);
|
||||
invoice.setDescription(description);
|
||||
return invoice;
|
||||
}
|
||||
|
||||
public static Invoice makeInvoice(String invoiceId, String createdAt, String product, com.rbkmoney.damsel.proxy_provider.Cash cost) {
|
||||
return ProxyProviderWrapper.makeInvoice(invoiceId, createdAt, product, cost, null);
|
||||
}
|
||||
|
||||
public static InvoicePayment makeInvoicePayment(String invoicePaymentId, String created_at, com.rbkmoney.damsel.domain.Payer payer, com.rbkmoney.damsel.proxy_provider.Cash cost) {
|
||||
InvoicePayment invoicePayment = new InvoicePayment();
|
||||
|
@ -7,9 +7,9 @@ import com.rbkmoney.damsel.user_interaction.UserInteraction;
|
||||
public class ProxyWrapper {
|
||||
|
||||
// FinishIntent
|
||||
public static Intent makeFinishIntentOk() {
|
||||
public static Intent makeFinishIntentSuccess() {
|
||||
FinishIntent finishIntent = new FinishIntent();
|
||||
finishIntent.setStatus(ProxyWrapper.makeFinishStatusOk());
|
||||
finishIntent.setStatus(ProxyWrapper.makeFinishStatusSuccess());
|
||||
Intent intent = new Intent();
|
||||
intent.setFinish(finishIntent);
|
||||
return intent;
|
||||
@ -19,7 +19,7 @@ public class ProxyWrapper {
|
||||
FinishIntent finishIntent = new FinishIntent();
|
||||
finishIntent.setStatus(
|
||||
ProxyWrapper.makeFinishStatusFailure(
|
||||
BaseWrapper.makeError(code, description)
|
||||
makeFailure(code, description)
|
||||
)
|
||||
);
|
||||
Intent intent = new Intent();
|
||||
@ -27,18 +27,6 @@ public class ProxyWrapper {
|
||||
return intent;
|
||||
}
|
||||
|
||||
public static Intent makeIntentWithSleepIntent(Timer timer) {
|
||||
Intent intent = new Intent();
|
||||
intent.setSleep(ProxyWrapper.makeSleepIntent(timer));
|
||||
return intent;
|
||||
}
|
||||
|
||||
public static SleepIntent makeSleepIntent(Timer timer) {
|
||||
SleepIntent sleepIntent = new SleepIntent();
|
||||
sleepIntent.setTimer(timer);
|
||||
return sleepIntent;
|
||||
}
|
||||
|
||||
public static Intent makeIntentWithSuspendIntent(String tag, Timer timer, UserInteraction userInteraction) {
|
||||
Intent intent = new Intent();
|
||||
intent.setSuspend(ProxyWrapper.makeSuspendIntent(tag, timer, userInteraction));
|
||||
@ -57,11 +45,19 @@ public class ProxyWrapper {
|
||||
return suspendIntent;
|
||||
}
|
||||
|
||||
public static FinishStatus makeFinishStatusFailure(com.rbkmoney.damsel.base.Error error) {
|
||||
return FinishStatus.failure(error);
|
||||
public static FinishStatus makeFinishStatusFailure(Failure failure) {
|
||||
return FinishStatus.failure(failure);
|
||||
}
|
||||
|
||||
public static FinishStatus makeFinishStatusOk() {
|
||||
return FinishStatus.ok(BaseWrapper.makeOk());
|
||||
public static FinishStatus makeFinishStatusSuccess() {
|
||||
return FinishStatus.success(new Success());
|
||||
}
|
||||
|
||||
public static Failure makeFailure(String code, String description) {
|
||||
Failure failure = new Failure();
|
||||
failure.setCode(code);
|
||||
failure.setDescription(description);
|
||||
return failure;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.rbkmoney.proxy.mocketbank.utils.damsel;
|
||||
|
||||
import com.rbkmoney.damsel.user_interaction.BrowserGetRequest;
|
||||
import com.rbkmoney.damsel.user_interaction.BrowserHTTPRequest;
|
||||
import com.rbkmoney.damsel.user_interaction.BrowserPostRequest;
|
||||
import com.rbkmoney.damsel.user_interaction.UserInteraction;
|
||||
@ -15,14 +14,6 @@ public class UserInteractionWrapper {
|
||||
return userInteraction;
|
||||
}
|
||||
|
||||
public static BrowserHTTPRequest makeBrowserGetRequest(String url) {
|
||||
BrowserGetRequest browserGetRequest = new BrowserGetRequest();
|
||||
browserGetRequest.setUri(url);
|
||||
BrowserHTTPRequest browserHTTPRequest = new BrowserHTTPRequest();
|
||||
browserHTTPRequest.setGetRequest(browserGetRequest);
|
||||
return browserHTTPRequest;
|
||||
}
|
||||
|
||||
public static BrowserHTTPRequest makeBrowserPostRequest(String url, Map<String, String> form) {
|
||||
BrowserPostRequest browserPostRequest = new BrowserPostRequest();
|
||||
browserPostRequest.setUri(url);
|
||||
|
@ -7,7 +7,7 @@ import com.rbkmoney.damsel.domain.TransactionInfo;
|
||||
import com.rbkmoney.damsel.proxy_provider.Context;
|
||||
import com.rbkmoney.damsel.proxy_provider.PaymentInfo;
|
||||
import com.rbkmoney.damsel.proxy_provider.ProxyResult;
|
||||
import com.rbkmoney.damsel.proxy_provider.Target;
|
||||
import com.rbkmoney.damsel.proxy_provider.TargetInvoicePaymentStatus;
|
||||
import com.rbkmoney.proxy.mocketbank.utils.Converter;
|
||||
import com.rbkmoney.proxy.mocketbank.utils.cds.CdsApi;
|
||||
import com.rbkmoney.proxy.mocketbank.utils.damsel.CdsWrapper;
|
||||
@ -145,12 +145,9 @@ public class MocketBankServerHandlerFailIntegrationTest {
|
||||
ProxyProviderWrapper.makeInvoice(
|
||||
invoiceId,
|
||||
"2016-06-02",
|
||||
"product",
|
||||
getCost(),
|
||||
"Invoice description"
|
||||
getCost()
|
||||
),
|
||||
ProxyProviderWrapper.makeShop(
|
||||
"shopId",
|
||||
DomainWrapper.makeCategory("CategoryName", "Category description"),
|
||||
DomainWrapper.makeShopDetails("ShopName", "Shop description")
|
||||
),
|
||||
@ -173,7 +170,7 @@ public class MocketBankServerHandlerFailIntegrationTest {
|
||||
return Converter.mapToByteArray(Collections.emptyMap());
|
||||
}
|
||||
|
||||
private Context getContext(PutCardDataResult putCardDataResult, Target target, TransactionInfo transactionInfo) throws IOException {
|
||||
private Context getContext(PutCardDataResult putCardDataResult, TargetInvoicePaymentStatus target, TransactionInfo transactionInfo) throws IOException {
|
||||
return ProxyProviderWrapper.makeContext(
|
||||
getPaymentInfo(putCardDataResult, transactionInfo),
|
||||
ProxyProviderWrapper.makeSession(
|
||||
|
@ -142,12 +142,9 @@ public class MocketBankServerHandlerFailWith3DSIntegrationTest {
|
||||
ProxyProviderWrapper.makeInvoice(
|
||||
invoiceId,
|
||||
"2016-06-02",
|
||||
"product",
|
||||
getCost(),
|
||||
"Invoice description"
|
||||
getCost()
|
||||
),
|
||||
ProxyProviderWrapper.makeShop(
|
||||
"shopId",
|
||||
DomainWrapper.makeCategory("CategoryName", "Category description"),
|
||||
DomainWrapper.makeShopDetails("ShopName", "Shop description")
|
||||
),
|
||||
@ -172,7 +169,7 @@ public class MocketBankServerHandlerFailWith3DSIntegrationTest {
|
||||
return Converter.mapToByteArray(extra);
|
||||
}
|
||||
|
||||
private Context getContext(PutCardDataResult putCardDataResult, Target target, TransactionInfo transactionInfo) throws IOException {
|
||||
private Context getContext(PutCardDataResult putCardDataResult, TargetInvoicePaymentStatus target, TransactionInfo transactionInfo) throws IOException {
|
||||
return ProxyProviderWrapper.makeContext(
|
||||
getPaymentInfo(putCardDataResult, transactionInfo),
|
||||
ProxyProviderWrapper.makeSession(
|
||||
|
@ -7,7 +7,7 @@ import com.rbkmoney.damsel.domain.TransactionInfo;
|
||||
import com.rbkmoney.damsel.proxy_provider.Context;
|
||||
import com.rbkmoney.damsel.proxy_provider.PaymentInfo;
|
||||
import com.rbkmoney.damsel.proxy_provider.ProxyResult;
|
||||
import com.rbkmoney.damsel.proxy_provider.Target;
|
||||
import com.rbkmoney.damsel.proxy_provider.TargetInvoicePaymentStatus;
|
||||
import com.rbkmoney.proxy.mocketbank.utils.Converter;
|
||||
import com.rbkmoney.proxy.mocketbank.utils.cds.CdsApi;
|
||||
import com.rbkmoney.proxy.mocketbank.utils.damsel.CdsWrapper;
|
||||
@ -120,9 +120,9 @@ public class MocketBankServerHandlerSuccessIntegrationTest {
|
||||
)
|
||||
);
|
||||
|
||||
assertEquals("Process payment ", ProxyWrapper.makeFinishStatusOk(), processResultPayment.getIntent().getFinish().getStatus());
|
||||
assertEquals("Process payment ", ProxyWrapper.makeFinishStatusSuccess(), processResultPayment.getIntent().getFinish().getStatus());
|
||||
|
||||
if (processResultPayment.getIntent().getFinish().getStatus().equals(ProxyWrapper.makeFinishStatusOk())) {
|
||||
if (processResultPayment.getIntent().getFinish().getStatus().equals(ProxyWrapper.makeFinishStatusSuccess())) {
|
||||
|
||||
LOGGER.info("Call capture payment");
|
||||
// Обрабатываем ответ и вызываем CapturePayment
|
||||
@ -137,7 +137,7 @@ public class MocketBankServerHandlerSuccessIntegrationTest {
|
||||
)
|
||||
);
|
||||
|
||||
assertEquals("Process Capture ", ProxyWrapper.makeFinishStatusOk(), processResultCapture.getIntent().getFinish().getStatus());
|
||||
assertEquals("Process Capture ", ProxyWrapper.makeFinishStatusSuccess(), processResultCapture.getIntent().getFinish().getStatus());
|
||||
|
||||
// Обрабатываем ответ
|
||||
LOGGER.info("Response capture payment {}", processResultCapture.toString());
|
||||
@ -160,12 +160,9 @@ public class MocketBankServerHandlerSuccessIntegrationTest {
|
||||
ProxyProviderWrapper.makeInvoice(
|
||||
invoiceId,
|
||||
"2016-06-02",
|
||||
"product",
|
||||
getCost(),
|
||||
"Invoice description"
|
||||
getCost()
|
||||
),
|
||||
ProxyProviderWrapper.makeShop(
|
||||
"shopId",
|
||||
DomainWrapper.makeCategory("CategoryName", "Category description"),
|
||||
DomainWrapper.makeShopDetails("ShopName", "Shop description")
|
||||
),
|
||||
@ -188,7 +185,7 @@ public class MocketBankServerHandlerSuccessIntegrationTest {
|
||||
return Converter.mapToByteArray(Collections.emptyMap());
|
||||
}
|
||||
|
||||
private Context getContext(PutCardDataResult putCardDataResult, Target target, TransactionInfo transactionInfo) throws IOException {
|
||||
private Context getContext(PutCardDataResult putCardDataResult, TargetInvoicePaymentStatus target, TransactionInfo transactionInfo) throws IOException {
|
||||
return ProxyProviderWrapper.makeContext(
|
||||
getPaymentInfo(putCardDataResult, transactionInfo),
|
||||
ProxyProviderWrapper.makeSession(
|
||||
|
@ -129,7 +129,7 @@ public class MocketBankServerHandlerSuccessWith3DSIntegrationTest {
|
||||
callbackMap, getContext(putCardDataResponse, null, null)
|
||||
);
|
||||
|
||||
assertTrue("CallbackResult ", callbackResult.getResult().getIntent().getFinish().getStatus().isSetOk());
|
||||
assertTrue("CallbackResult ", callbackResult.getResult().getIntent().getFinish().getStatus().isSetSuccess());
|
||||
|
||||
LOGGER.info("Call capture payment");
|
||||
// Обрабатываем ответ и вызываем CapturePayment
|
||||
@ -144,7 +144,7 @@ public class MocketBankServerHandlerSuccessWith3DSIntegrationTest {
|
||||
)
|
||||
);
|
||||
|
||||
assertEquals("Process Capture ", ProxyWrapper.makeFinishStatusOk(), processResultCapture.getIntent().getFinish().getStatus());
|
||||
assertEquals("Process Capture ", ProxyWrapper.makeFinishStatusSuccess(), processResultCapture.getIntent().getFinish().getStatus());
|
||||
|
||||
// Обрабатываем ответ
|
||||
LOGGER.info("Response capture payment {}", processResultCapture.toString());
|
||||
@ -159,12 +159,9 @@ public class MocketBankServerHandlerSuccessWith3DSIntegrationTest {
|
||||
ProxyProviderWrapper.makeInvoice(
|
||||
invoiceId,
|
||||
"2016-06-02",
|
||||
"product",
|
||||
getCost(),
|
||||
"Invoice description"
|
||||
getCost()
|
||||
),
|
||||
ProxyProviderWrapper.makeShop(
|
||||
"shopId",
|
||||
DomainWrapper.makeCategory("CategoryName", "Category description"),
|
||||
DomainWrapper.makeShopDetails("ShopName", "Shop description")
|
||||
),
|
||||
@ -189,7 +186,7 @@ public class MocketBankServerHandlerSuccessWith3DSIntegrationTest {
|
||||
return Converter.mapToByteArray(extra);
|
||||
}
|
||||
|
||||
private Context getContext(PutCardDataResult putCardDataResult, Target target, TransactionInfo transactionInfo) throws IOException {
|
||||
private Context getContext(PutCardDataResult putCardDataResult, TargetInvoicePaymentStatus target, TransactionInfo transactionInfo) throws IOException {
|
||||
return ProxyProviderWrapper.makeContext(
|
||||
getPaymentInfo(putCardDataResult, transactionInfo),
|
||||
ProxyProviderWrapper.makeSession(
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.rbkmoney.proxy.mocketbank.utils.cds;
|
||||
|
||||
import com.rbkmoney.damsel.base.Ok;
|
||||
import com.rbkmoney.damsel.cds.CardData;
|
||||
import com.rbkmoney.damsel.cds.PutCardDataResult;
|
||||
import com.rbkmoney.damsel.cds.UnlockStatus;
|
||||
import com.rbkmoney.damsel.cds.Unlocked;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mock;
|
||||
@ -22,7 +22,7 @@ public class CdsApiTest {
|
||||
private CdsApi cds;
|
||||
|
||||
@Mock
|
||||
private Ok ok;
|
||||
private Unlocked unlocked;
|
||||
|
||||
@Mock
|
||||
private CardData cardData;
|
||||
@ -40,7 +40,7 @@ public class CdsApiTest {
|
||||
@Test
|
||||
public void testUnlock() throws Exception {
|
||||
ByteBuffer bbuf = ByteBuffer.allocate(10);
|
||||
UnlockStatus status = UnlockStatus.ok(ok);
|
||||
UnlockStatus status = UnlockStatus.unlocked(unlocked);
|
||||
|
||||
Mockito.when(cds.unlock(bbuf)).thenReturn(status);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user