mirror of
https://github.com/valitydev/cashreg-adapter-atol.git
synced 2024-11-06 01:15:20 +00:00
parent
69fec82cd2
commit
b39c3ee18d
@ -1 +1 @@
|
||||
Subproject commit 4a09386542ab4b98317a787fd6e06e0d3a1e38d6
|
||||
Subproject commit cf6578dac794859b0495c812761ce5b94c11bbaf
|
24
pom.xml
24
pom.xml
@ -30,10 +30,11 @@
|
||||
<dockerfile.registry>dr2.rbkmoney.com</dockerfile.registry>
|
||||
<shared.resources.version>0.3.6</shared.resources.version>
|
||||
<logstash-logback-encoder.version>5.2</logstash-logback-encoder.version>
|
||||
<nop-rolling.version>1.0.1</nop-rolling.version>
|
||||
<geck.version>0.6.9</geck.version>
|
||||
<lombok.version>1.18.4</lombok.version>
|
||||
<adapter-common-lib.version>0.0.8</adapter-common-lib.version>
|
||||
<error-mapping.version>1.0.5</error-mapping.version>
|
||||
<cashreg-proto.version>1.14-25a9f63</cashreg-proto.version>
|
||||
<adapter-common-lib.version>0.0.23</adapter-common-lib.version>
|
||||
<testcontainers.version>1.10.2</testcontainers.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
@ -44,12 +45,12 @@
|
||||
<dependency>
|
||||
<groupId>com.rbkmoney</groupId>
|
||||
<artifactId>adapter-cashreg-spring-boot-starter</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.rbkmoney</groupId>
|
||||
<artifactId>cashreg-proto</artifactId>
|
||||
<version>1.9-9c79023</version>
|
||||
<version>${cashreg-proto.version}</version>
|
||||
</dependency>
|
||||
<!--Thrirdparty libs-->
|
||||
<dependency>
|
||||
@ -59,7 +60,7 @@
|
||||
<dependency>
|
||||
<groupId>com.rbkmoney</groupId>
|
||||
<artifactId>error-mapping-java</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>${error-mapping.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@ -99,12 +100,7 @@
|
||||
<dependency>
|
||||
<groupId>com.rbkmoney.woody</groupId>
|
||||
<artifactId>woody-thrift</artifactId>
|
||||
<version>1.1.15</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.rbkmoney.logback</groupId>
|
||||
<artifactId>nop-rolling</artifactId>
|
||||
<version>${nop-rolling.version}</version>
|
||||
<version>1.1.16</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.rbkmoney</groupId>
|
||||
@ -115,6 +111,12 @@
|
||||
<groupId>com.rbkmoney</groupId>
|
||||
<artifactId>adapter-common-lib</artifactId>
|
||||
<version>${adapter-common-lib.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.rbkmoney</groupId>
|
||||
<artifactId>error-mapping-java</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.rbkmoney</groupId>
|
||||
|
@ -6,8 +6,8 @@ import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||
|
||||
@ServletComponentScan
|
||||
@SpringBootApplication
|
||||
public class CashRegAtolApplication extends SpringApplication {
|
||||
public class CashregAtolApplication extends SpringApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CashRegAtolApplication.class, args);
|
||||
SpringApplication.run(CashregAtolApplication.class, args);
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package com.rbkmoney.adapter.atol.configuration;
|
||||
|
||||
import com.rbkmoney.adapter.atol.handler.AtolServerHandler;
|
||||
import com.rbkmoney.adapter.cashreg.spring.boot.starter.converter.CashRegAdapterServiceLogDecorator;
|
||||
import com.rbkmoney.damsel.cashreg.provider.CashRegProviderSrv;
|
||||
import com.rbkmoney.adapter.cashreg.spring.boot.starter.converter.CashregAdapterServiceLogDecorator;
|
||||
import com.rbkmoney.damsel.cashreg.adapter.CashregAdapterSrv;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@ -12,8 +12,8 @@ public class HandlerConfiguration {
|
||||
|
||||
@Bean
|
||||
@Autowired
|
||||
public CashRegProviderSrv.Iface serverHandlerLogDecorator(AtolServerHandler atolServerHandler) {
|
||||
return new CashRegAdapterServiceLogDecorator(atolServerHandler);
|
||||
public CashregAdapterSrv.Iface serverHandlerLogDecorator(AtolServerHandler atolServerHandler) {
|
||||
return new CashregAdapterServiceLogDecorator(atolServerHandler);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ import java.security.KeyStoreException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.time.Duration;
|
||||
|
||||
|
||||
@Configuration
|
||||
public class RestTemplateConfiguration {
|
||||
|
||||
|
@ -10,7 +10,7 @@ import com.rbkmoney.adapter.atol.service.atol.model.Receipt;
|
||||
import com.rbkmoney.adapter.atol.service.atol.model.Service;
|
||||
import com.rbkmoney.adapter.atol.service.atol.model.request.CommonRequest;
|
||||
import com.rbkmoney.adapter.atol.service.atol.model.request.RequestWrapper;
|
||||
import com.rbkmoney.adapter.cashreg.spring.boot.starter.config.properties.AdapterCashRegProperties;
|
||||
import com.rbkmoney.adapter.cashreg.spring.boot.starter.config.properties.AdapterCashregProperties;
|
||||
import com.rbkmoney.adapter.cashreg.spring.boot.starter.constant.OptionalField;
|
||||
import com.rbkmoney.adapter.cashreg.spring.boot.starter.model.EntryStateModel;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -27,7 +27,7 @@ public class EntryStateToCommonRequestConverter implements Converter<EntryStateM
|
||||
private final VatsTransformer vatsTransformer;
|
||||
private final PaymentsTransformer paymentsTransformer;
|
||||
private final ItemsTransformer itemsTransformer;
|
||||
private final AdapterCashRegProperties adapterCashRegProperties;
|
||||
private final AdapterCashregProperties adapterCashregProperties;
|
||||
|
||||
@Override
|
||||
public RequestWrapper<CommonRequest> convert(EntryStateModel entryStateModel) {
|
||||
@ -64,7 +64,7 @@ public class EntryStateToCommonRequestConverter implements Converter<EntryStateM
|
||||
|
||||
return new RequestWrapper<>(
|
||||
commonRequest,
|
||||
entryStateModel.getOptions().getOrDefault(OptionalField.URL.getField(), adapterCashRegProperties.getUrl()),
|
||||
entryStateModel.getOptions().getOrDefault(OptionalField.URL.getField(), adapterCashregProperties.getUrl()),
|
||||
entryStateModel.getOptions().get(OptionalField.GROUP.getField()),
|
||||
entryStateModel.getOptions().get(OptionalField.COMPANY_NAME.getField()),
|
||||
entryStateModel.getOptions().get(OptionalField.COMPANY_ADDRESS.getField()),
|
||||
|
@ -4,15 +4,15 @@ package com.rbkmoney.adapter.atol.converter.entry;
|
||||
import com.rbkmoney.adapter.atol.service.atol.constant.PaymentType;
|
||||
import com.rbkmoney.adapter.cashreg.spring.boot.starter.constant.OptionalField;
|
||||
import com.rbkmoney.adapter.cashreg.spring.boot.starter.constant.TargetType;
|
||||
import com.rbkmoney.adapter.cashreg.spring.boot.starter.converter.CashRegAdapterContextConverter;
|
||||
import com.rbkmoney.adapter.cashreg.spring.boot.starter.converter.CashregAdapterContextConverter;
|
||||
import com.rbkmoney.adapter.cashreg.spring.boot.starter.flow.TargetTypeResolver;
|
||||
import com.rbkmoney.adapter.cashreg.spring.boot.starter.model.*;
|
||||
import com.rbkmoney.damsel.cashreg.Cart;
|
||||
import com.rbkmoney.damsel.cashreg.ItemsLine;
|
||||
import com.rbkmoney.damsel.cashreg.provider.CashRegContext;
|
||||
import com.rbkmoney.damsel.cashreg_domain.PaymentInfo;
|
||||
import com.rbkmoney.damsel.cashreg_domain.RussianLegalEntity;
|
||||
import com.rbkmoney.damsel.cashreg_domain.TaxMode;
|
||||
import com.rbkmoney.damsel.cashreg.adapter.CashregContext;
|
||||
import com.rbkmoney.damsel.cashreg.domain.PaymentInfo;
|
||||
import com.rbkmoney.damsel.cashreg.domain.RussianLegalEntity;
|
||||
import com.rbkmoney.damsel.cashreg.domain.TaxMode;
|
||||
import com.rbkmoney.damsel.cashreg.receipt.Cart;
|
||||
import com.rbkmoney.damsel.cashreg.receipt.ItemsLine;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -25,12 +25,12 @@ import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class CtxToEntryModelConverter implements Converter<CashRegContext, EntryStateModel> {
|
||||
public class CtxToEntryModelConverter implements Converter<CashregContext, EntryStateModel> {
|
||||
|
||||
private final CashRegAdapterContextConverter cashRegAdapterContextConveter;
|
||||
private final CashregAdapterContextConverter cashRegAdapterContextConveter;
|
||||
|
||||
@Override
|
||||
public EntryStateModel convert(CashRegContext context) {
|
||||
public EntryStateModel convert(CashregContext context) {
|
||||
AdapterState adapterState = cashRegAdapterContextConveter.convert(context);
|
||||
|
||||
Map<String, String> options = context.getOptions();
|
||||
|
@ -7,9 +7,9 @@ import com.rbkmoney.adapter.cashreg.spring.boot.starter.model.EntryStateModel;
|
||||
import com.rbkmoney.adapter.cashreg.spring.boot.starter.model.ExitStateModel;
|
||||
import com.rbkmoney.adapter.cashreg.spring.boot.starter.model.Step;
|
||||
import com.rbkmoney.adapter.cashreg.spring.boot.starter.state.serializer.AdapterSerializer;
|
||||
import com.rbkmoney.adapter.cashreg.spring.boot.starter.utils.creators.CashRegProviderCreators;
|
||||
import com.rbkmoney.damsel.cashreg.provider.CashRegResult;
|
||||
import com.rbkmoney.damsel.cashreg.provider.Intent;
|
||||
import com.rbkmoney.adapter.cashreg.spring.boot.starter.utils.creators.CashregAdapterCreators;
|
||||
import com.rbkmoney.damsel.cashreg.adapter.CashregResult;
|
||||
import com.rbkmoney.damsel.cashreg.adapter.Intent;
|
||||
import com.rbkmoney.damsel.domain.Failure;
|
||||
import com.rbkmoney.error.mapping.ErrorMapping;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -25,14 +25,14 @@ import static java.time.temporal.ChronoUnit.MINUTES;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class ExitModelToProxyResultConverter implements Converter<ExitStateModel, CashRegResult> {
|
||||
public class ExitModelToProxyResultConverter implements Converter<ExitStateModel, CashregResult> {
|
||||
|
||||
private final ErrorMapping errorMapping;
|
||||
private final TimerProperties timerProperties;
|
||||
private final AdapterSerializer serializer;
|
||||
|
||||
@Override
|
||||
public CashRegResult convert(ExitStateModel exitStateModel) {
|
||||
public CashregResult convert(ExitStateModel exitStateModel) {
|
||||
EntryStateModel entryStateModel = exitStateModel.getEntryStateModel();
|
||||
AdapterState adapterState = entryStateModel.getState().getAdapterContext();
|
||||
if (adapterState.getMaxDateTimePolling() == null) {
|
||||
@ -41,31 +41,31 @@ public class ExitModelToProxyResultConverter implements Converter<ExitStateModel
|
||||
adapterState.setMaxDateTimePolling(maxDateTime);
|
||||
}
|
||||
|
||||
Intent intent = CashRegProviderCreators.createFinishIntentSuccess();
|
||||
Intent intent = CashregAdapterCreators.createFinishIntentSuccess();
|
||||
if (exitStateModel.getErrorCode() != null) {
|
||||
Failure failure = errorMapping.getFailureByCodeAndDescription(
|
||||
Failure failure = errorMapping.mapFailure(
|
||||
exitStateModel.getErrorCode(),
|
||||
exitStateModel.getErrorMessage()
|
||||
);
|
||||
intent = CashRegProviderCreators.createFinishIntentFailure(failure);
|
||||
intent = CashregAdapterCreators.createFinishIntentFailure(failure);
|
||||
}
|
||||
|
||||
if (exitStateModel.getCashRegInfo() == null) {
|
||||
if (exitStateModel.getInfo() == null) {
|
||||
Map<String, String> options = entryStateModel.getOptions();
|
||||
intent = CashRegProviderCreators.createIntentWithSleepIntent(extractPollingDelay(options, timerProperties.getPollingDelay()));
|
||||
intent = CashregAdapterCreators.createIntentWithSleepIntent(extractPollingDelay(options, timerProperties.getPollingDelay()));
|
||||
}
|
||||
|
||||
if (Step.CREATE == adapterState.getNextStep()) {
|
||||
adapterState.setNextStep(Step.CHECK_STATUS);
|
||||
}
|
||||
|
||||
CashRegResult cashRegResult = new CashRegResult()
|
||||
CashregResult cashRegResult = new CashregResult()
|
||||
.setIntent(intent)
|
||||
.setState(serializer.writeByte(adapterState));
|
||||
|
||||
if (exitStateModel.getCashRegInfo() != null) {
|
||||
if (exitStateModel.getInfo() != null) {
|
||||
entryStateModel.getState().getAdapterContext().setNextStep(Step.CHECK_STATUS);
|
||||
cashRegResult.setCashregInfo(exitStateModel.getCashRegInfo());
|
||||
cashRegResult.setInfo(exitStateModel.getInfo());
|
||||
}
|
||||
|
||||
return cashRegResult;
|
||||
|
@ -4,16 +4,16 @@ package com.rbkmoney.adapter.atol.handler;
|
||||
import com.rbkmoney.adapter.atol.converter.entry.CtxToEntryModelConverter;
|
||||
import com.rbkmoney.adapter.atol.converter.exit.ExitModelToProxyResultConverter;
|
||||
import com.rbkmoney.adapter.atol.service.atol.model.response.CommonResponse;
|
||||
import com.rbkmoney.adapter.atol.validator.CashRegContextValidator;
|
||||
import com.rbkmoney.adapter.atol.validator.CashregContextValidator;
|
||||
import com.rbkmoney.adapter.cashreg.spring.boot.starter.exception.UnsupportedMethodException;
|
||||
import com.rbkmoney.adapter.cashreg.spring.boot.starter.flow.StepResolver;
|
||||
import com.rbkmoney.adapter.cashreg.spring.boot.starter.handler.CommonHandler;
|
||||
import com.rbkmoney.adapter.cashreg.spring.boot.starter.model.EntryStateModel;
|
||||
import com.rbkmoney.adapter.cashreg.spring.boot.starter.model.ExitStateModel;
|
||||
import com.rbkmoney.adapter.common.Validator;
|
||||
import com.rbkmoney.damsel.cashreg.provider.CashRegContext;
|
||||
import com.rbkmoney.damsel.cashreg.provider.CashRegProviderSrv;
|
||||
import com.rbkmoney.damsel.cashreg.provider.CashRegResult;
|
||||
import com.rbkmoney.damsel.cashreg.adapter.CashregAdapterSrv;
|
||||
import com.rbkmoney.damsel.cashreg.adapter.CashregContext;
|
||||
import com.rbkmoney.damsel.cashreg.adapter.CashregResult;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.thrift.TException;
|
||||
@ -28,18 +28,18 @@ import java.util.List;
|
||||
@Primary
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class AtolServerHandler implements CashRegProviderSrv.Iface {
|
||||
public class AtolServerHandler implements CashregAdapterSrv.Iface {
|
||||
|
||||
private final CtxToEntryModelConverter ctxToEntryModelConverter;
|
||||
private final ExitModelToProxyResultConverter exitModelToProxyResultConverter;
|
||||
private final StepResolver stepResolver;
|
||||
private final CashRegContextValidator cashRegContextValidator;
|
||||
private final CashregContextValidator cashregContextValidator;
|
||||
private final List<CommonHandler<ExitStateModel, CommonResponse, EntryStateModel>> handlers;
|
||||
|
||||
@Override
|
||||
public CashRegResult register(CashRegContext context) throws TException {
|
||||
public CashregResult register(CashregContext context) throws TException {
|
||||
return handle(
|
||||
cashRegContextValidator,
|
||||
cashregContextValidator,
|
||||
ctxToEntryModelConverter,
|
||||
exitModelToProxyResultConverter,
|
||||
context
|
||||
|
@ -9,7 +9,7 @@ import com.rbkmoney.adapter.cashreg.spring.boot.starter.model.EntryStateModel;
|
||||
import com.rbkmoney.adapter.cashreg.spring.boot.starter.model.ExitStateModel;
|
||||
import com.rbkmoney.adapter.cashreg.spring.boot.starter.model.Step;
|
||||
import com.rbkmoney.adapter.cashreg.spring.boot.starter.processor.Processor;
|
||||
import com.rbkmoney.damsel.cashreg.CashRegInfo;
|
||||
import com.rbkmoney.damsel.cashreg.receipt.ReceiptInfo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@ -25,18 +25,18 @@ public class SuccessProcessor implements Processor<ExitStateModel, EntryStateMod
|
||||
|
||||
AdapterState adapterState = entryStateModel.getState().getAdapterContext();
|
||||
adapterState.setReceiptId(response.getUuid());
|
||||
adapterState.setCashRegId(entryStateModel.getCashRegId());
|
||||
adapterState.setCashregId(entryStateModel.getCashRegId());
|
||||
|
||||
if (Step.CHECK_STATUS.equals(entryStateModel.getState().getAdapterContext().getNextStep())) {
|
||||
if (Status.DONE.getValue().equalsIgnoreCase(response.getStatus())) {
|
||||
CashRegInfo cashRegInfo = new CashRegInfo();
|
||||
cashRegInfo.setReceiptId(response.getUuid());
|
||||
cashRegInfo.setCallbackUrl(response.getCallbackUrl());
|
||||
cashRegInfo.setDaemonCode(response.getDaemonCode());
|
||||
cashRegInfo.setDeviceCode(response.getDeviceCode());
|
||||
cashRegInfo.setGroupCode(response.getGroupCode());
|
||||
cashRegInfo.setTimestamp(response.getTimestamp());
|
||||
exitStateModel.setCashRegInfo(cashRegInfo);
|
||||
ReceiptInfo receiptInfo = new ReceiptInfo()
|
||||
.setReceiptId(response.getUuid())
|
||||
.setCallbackUrl(response.getCallbackUrl())
|
||||
.setDaemonCode(response.getDaemonCode())
|
||||
.setDeviceCode(response.getDeviceCode())
|
||||
.setGroupCode(response.getGroupCode())
|
||||
.setTimestamp(response.getTimestamp());
|
||||
exitStateModel.setInfo(receiptInfo);
|
||||
}
|
||||
} else if (Step.CREATE.equals(entryStateModel.getState().getAdapterContext().getNextStep())) {
|
||||
adapterState.setNextStep(Step.CHECK_STATUS);
|
||||
|
@ -5,7 +5,7 @@ import com.rbkmoney.adapter.atol.service.atol.model.request.CommonRequest;
|
||||
import com.rbkmoney.adapter.atol.service.atol.model.request.RequestWrapper;
|
||||
import com.rbkmoney.adapter.atol.service.atol.model.response.CommonResponse;
|
||||
|
||||
public interface AdapterCashReg {
|
||||
public interface AdapterCashreg {
|
||||
|
||||
CommonResponse debit(RequestWrapper<CommonRequest> request);
|
||||
|
@ -13,7 +13,7 @@ import org.springframework.http.ResponseEntity;
|
||||
@Getter
|
||||
@Setter
|
||||
@RequiredArgsConstructor
|
||||
public class AtolClient implements AdapterCashReg {
|
||||
public class AtolClient implements AdapterCashreg {
|
||||
|
||||
private final AtolApi api;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.rbkmoney.adapter.atol.servlet;
|
||||
|
||||
import com.rbkmoney.damsel.cashreg.provider.CashRegProviderSrv;
|
||||
import com.rbkmoney.damsel.cashreg.adapter.CashregAdapterSrv;
|
||||
import com.rbkmoney.woody.thrift.impl.http.THServiceBuilder;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@ -12,14 +12,14 @@ import java.io.IOException;
|
||||
@WebServlet("/adapter/cashreg/atol")
|
||||
public class AdapterServlet extends GenericServlet {
|
||||
|
||||
private final CashRegProviderSrv.Iface handler;
|
||||
private final CashregAdapterSrv.Iface handler;
|
||||
|
||||
private Servlet servlet;
|
||||
|
||||
@Override
|
||||
public void init(ServletConfig config) throws ServletException {
|
||||
super.init(config);
|
||||
servlet = new THServiceBuilder().build(CashRegProviderSrv.Iface.class, handler);
|
||||
servlet = new THServiceBuilder().build(CashregAdapterSrv.Iface.class, handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,7 +2,7 @@ package com.rbkmoney.adapter.atol.validator;
|
||||
|
||||
import com.rbkmoney.adapter.cashreg.spring.boot.starter.constant.OptionalField;
|
||||
import com.rbkmoney.adapter.common.Validator;
|
||||
import com.rbkmoney.damsel.cashreg.provider.CashRegContext;
|
||||
import com.rbkmoney.damsel.cashreg.adapter.CashregContext;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -11,10 +11,10 @@ import java.util.Objects;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class CashRegContextValidator implements Validator<CashRegContext> {
|
||||
public class CashregContextValidator implements Validator<CashregContext> {
|
||||
|
||||
@Override
|
||||
public void validate(CashRegContext context) {
|
||||
public void validate(CashregContext context) {
|
||||
Map<String, String> options = context.getOptions();
|
||||
validateRequredFields(options);
|
||||
}
|
8
src/main/resources/fixture/errors.json
Normal file
8
src/main/resources/fixture/errors.json
Normal file
@ -0,0 +1,8 @@
|
||||
[
|
||||
{
|
||||
"codeRegex": "003",
|
||||
"descriptionRegex": "Invalid cardholder",
|
||||
"mapping": "authorization_failed:operation_blocked",
|
||||
"state": "payment"
|
||||
}
|
||||
]
|
@ -1,17 +1,17 @@
|
||||
package com.rbkmoney.adapter.atol;
|
||||
|
||||
import com.rbkmoney.adapter.cashreg.spring.boot.starter.constant.OptionalField;
|
||||
import com.rbkmoney.damsel.cashreg.Cart;
|
||||
import com.rbkmoney.damsel.cashreg.ItemsLine;
|
||||
import com.rbkmoney.damsel.cashreg.provider.CashRegContext;
|
||||
import com.rbkmoney.damsel.cashreg.provider.CashRegProviderSrv;
|
||||
import com.rbkmoney.damsel.cashreg.provider.Session;
|
||||
import com.rbkmoney.damsel.cashreg.provider.SourceCreation;
|
||||
import com.rbkmoney.damsel.cashreg.type.Debit;
|
||||
import com.rbkmoney.damsel.cashreg.type.Type;
|
||||
import com.rbkmoney.damsel.cashreg_domain.AccountInfo;
|
||||
import com.rbkmoney.damsel.cashreg_domain.PaymentInfo;
|
||||
import com.rbkmoney.damsel.cashreg_domain.TaxMode;
|
||||
import com.rbkmoney.damsel.cashreg.adapter.CashregAdapterSrv;
|
||||
import com.rbkmoney.damsel.cashreg.adapter.CashregContext;
|
||||
import com.rbkmoney.damsel.cashreg.adapter.Session;
|
||||
import com.rbkmoney.damsel.cashreg.adapter.SourceCreation;
|
||||
import com.rbkmoney.damsel.cashreg.domain.AccountInfo;
|
||||
import com.rbkmoney.damsel.cashreg.domain.PaymentInfo;
|
||||
import com.rbkmoney.damsel.cashreg.domain.TaxMode;
|
||||
import com.rbkmoney.damsel.cashreg.receipt.Cart;
|
||||
import com.rbkmoney.damsel.cashreg.receipt.ItemsLine;
|
||||
import com.rbkmoney.damsel.cashreg.receipt.type.Debit;
|
||||
import com.rbkmoney.damsel.cashreg.receipt.type.Type;
|
||||
import com.rbkmoney.damsel.domain.Cash;
|
||||
import com.rbkmoney.damsel.domain.CurrencyRef;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -32,20 +32,20 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
@Slf4j
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = DEFINED_PORT)
|
||||
@ContextConfiguration(classes = CashRegAtolApplication.class)
|
||||
@ContextConfiguration(classes = CashregAtolApplication.class)
|
||||
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
|
||||
public abstract class IntegrationTest {
|
||||
|
||||
@Autowired
|
||||
protected CashRegProviderSrv.Iface handler;
|
||||
protected CashregAdapterSrv.Iface handler;
|
||||
|
||||
public CashRegContext makeCashRegContext() {
|
||||
CashRegContext context = new CashRegContext();
|
||||
context.setCashregId(TestData.CASHREG_ID);
|
||||
context.setSourceCreation(createSourceCreation());
|
||||
context.setAccountInfo(createAccountInfo());
|
||||
context.setOptions(createAdapterOptions());
|
||||
context.setSession(new Session().setType(Type.debit(new Debit())));
|
||||
public CashregContext makeCashRegContext() {
|
||||
CashregContext context = new CashregContext()
|
||||
.setCashregId(TestData.CASHREG_ID)
|
||||
.setSourceCreation(createSourceCreation())
|
||||
.setAccountInfo(createAccountInfo())
|
||||
.setOptions(createAdapterOptions())
|
||||
.setSession(new Session().setType(Type.debit(new Debit())));
|
||||
return context;
|
||||
}
|
||||
|
||||
@ -69,8 +69,8 @@ public abstract class IntegrationTest {
|
||||
|
||||
protected AccountInfo createAccountInfo() {
|
||||
|
||||
com.rbkmoney.damsel.cashreg_domain.LegalEntity legalEntity = new com.rbkmoney.damsel.cashreg_domain.LegalEntity();
|
||||
com.rbkmoney.damsel.cashreg_domain.RussianLegalEntity russianLegalEntity = new com.rbkmoney.damsel.cashreg_domain.RussianLegalEntity();
|
||||
com.rbkmoney.damsel.cashreg.domain.LegalEntity legalEntity = new com.rbkmoney.damsel.cashreg.domain.LegalEntity();
|
||||
com.rbkmoney.damsel.cashreg.domain.RussianLegalEntity russianLegalEntity = new com.rbkmoney.damsel.cashreg.domain.RussianLegalEntity();
|
||||
|
||||
russianLegalEntity.setActualAddress("ActualAddress");
|
||||
russianLegalEntity.setInn("INN");
|
||||
@ -81,7 +81,7 @@ public abstract class IntegrationTest {
|
||||
russianLegalEntity.setRepresentativePosition("RepresentativePosition");
|
||||
russianLegalEntity.setRegisteredNumber("RegisteredNumber");
|
||||
|
||||
com.rbkmoney.damsel.cashreg_domain.RussianBankAccount russianBankAccount = new com.rbkmoney.damsel.cashreg_domain.RussianBankAccount();
|
||||
com.rbkmoney.damsel.cashreg.domain.RussianBankAccount russianBankAccount = new com.rbkmoney.damsel.cashreg.domain.RussianBankAccount();
|
||||
russianBankAccount.setAccount("Account");
|
||||
russianBankAccount.setBankName("BankName");
|
||||
russianBankAccount.setBankPostAccount("BankPostAccount");
|
||||
@ -113,5 +113,4 @@ public abstract class IntegrationTest {
|
||||
return paymentInfo;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -3,17 +3,15 @@ package com.rbkmoney.adapter.atol.handler;
|
||||
import com.rbkmoney.adapter.atol.IntegrationTest;
|
||||
import com.rbkmoney.adapter.atol.MockUtils;
|
||||
import com.rbkmoney.adapter.atol.service.atol.AtolClient;
|
||||
import com.rbkmoney.damsel.cashreg.provider.CashRegContext;
|
||||
import com.rbkmoney.damsel.cashreg.provider.CashRegResult;
|
||||
import com.rbkmoney.damsel.cashreg.adapter.CashregContext;
|
||||
import com.rbkmoney.damsel.cashreg.adapter.CashregResult;
|
||||
import org.apache.thrift.TException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class AtolServerHandlerTest extends IntegrationTest {
|
||||
|
||||
@ -21,20 +19,20 @@ public class AtolServerHandlerTest extends IntegrationTest {
|
||||
public AtolClient client;
|
||||
|
||||
@Before
|
||||
public void setup() throws URISyntaxException, TException {
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
MockUtils.mockAtolClient(client);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMe() throws TException {
|
||||
CashRegContext cashRegContext = makeCashRegContext();
|
||||
CashRegResult result = handler.register(cashRegContext);
|
||||
CashregContext context = makeCashRegContext();
|
||||
CashregResult result = handler.register(context);
|
||||
assertTrue(result.getIntent().isSetSleep());
|
||||
|
||||
cashRegContext.getSession().setState(result.getState());
|
||||
context.getSession().setState(result.getState());
|
||||
|
||||
result = handler.register(cashRegContext);
|
||||
result = handler.register(context);
|
||||
assertTrue(result.getIntent().isSetFinish());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user