diff --git a/build_utils b/build_utils
index e89b885..f42e059 160000
--- a/build_utils
+++ b/build_utils
@@ -1 +1 @@
-Subproject commit e89b885839df8013df804d48ff24dff10c9c451e
+Subproject commit f42e059d9ec93826ba4ad23232eed8ce67bd5486
diff --git a/pom.xml b/pom.xml
index d1049c8..dd51b0f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
com.rbkmoney
spring-boot-starter-parent
- 2.3.2.RELEASE
+ 2.3.4.RELEASE
@@ -26,7 +26,7 @@
${server.port}
Anatoly Cherkasov <a.cherkasov@rbkmoney.com>
GENERATED DOCKER FILE
- bc95d0d6dc13c693acd2b274531a7d604b877bf3
+ 57e26d8ee999d7b0b50248c22afc63e6f926d276
dr2.rbkmoney.com
0.3.8
5.2
@@ -102,6 +102,11 @@
+
+ com.rbkmoney.geck
+ serializer
+ ${geck.version}
+
org.projectlombok
diff --git a/src/main/java/com/rbkmoney/adapter/starrys/handler/cashreg/StatusCommonHandler.java b/src/main/java/com/rbkmoney/adapter/starrys/handler/cashreg/StatusCommonHandler.java
deleted file mode 100644
index 231fa79..0000000
--- a/src/main/java/com/rbkmoney/adapter/starrys/handler/cashreg/StatusCommonHandler.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.rbkmoney.adapter.starrys.handler.cashreg;
-
-import com.rbkmoney.adapter.cashreg.spring.boot.starter.handler.CommonHandlerImpl;
-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.adapter.starrys.service.starrys.StarRysClient;
-import com.rbkmoney.adapter.starrys.service.starrys.model.request.ComplexRequest;
-import com.rbkmoney.adapter.starrys.service.starrys.model.request.RequestWrapper;
-import com.rbkmoney.adapter.starrys.service.starrys.model.response.FullResponse;
-import org.springframework.core.convert.converter.Converter;
-import org.springframework.http.ResponseEntity;
-import org.springframework.stereotype.Component;
-
-@Component
-public class StatusCommonHandler extends CommonHandlerImpl, ResponseEntity, EntryStateModel> {
-
- public StatusCommonHandler(
- StarRysClient client,
- Converter> converter,
- Processor> responseProcessorChain
- ) {
- super(client::status, converter, responseProcessorChain);
- }
-
- @Override
- public boolean isHandler(EntryStateModel entryStateModel) {
- return Step.CHECK_STATUS.equals(entryStateModel.getState().getAdapterContext().getNextStep());
- }
-
-}
diff --git a/src/main/java/com/rbkmoney/adapter/starrys/processor/ErrorProcessor.java b/src/main/java/com/rbkmoney/adapter/starrys/processor/ErrorProcessor.java
index 5d4bc47..03320d3 100644
--- a/src/main/java/com/rbkmoney/adapter/starrys/processor/ErrorProcessor.java
+++ b/src/main/java/com/rbkmoney/adapter/starrys/processor/ErrorProcessor.java
@@ -19,8 +19,13 @@ public class ErrorProcessor implements Processor response, EntryStateModel entryStateModel) {
ExitStateModel exitStateModel = new ExitStateModel();
+ exitStateModel.setEntryStateModel(entryStateModel);
+ if (entryStateModel.getState().getAdapterContext() != null) {
+ exitStateModel.setAdapterContext(entryStateModel.getState().getAdapterContext());
+ }
if (ErrorUtils.hasError(response)) {
- exitStateModel.setEntryStateModel(entryStateModel);
+ exitStateModel.setErrorCode(response.getBody().getResponse().getError().toString());
+ exitStateModel.setErrorMessage(response.getBody().getResponse().getDescription());
} else {
log.error("Unknown result code for response: {}!", response);
exitStateModel.setErrorCode(UNKNOWN.getCode());
diff --git a/src/main/java/com/rbkmoney/adapter/starrys/processor/SuccessProcessor.java b/src/main/java/com/rbkmoney/adapter/starrys/processor/SuccessProcessor.java
index 0d354ad..c458c23 100644
--- a/src/main/java/com/rbkmoney/adapter/starrys/processor/SuccessProcessor.java
+++ b/src/main/java/com/rbkmoney/adapter/starrys/processor/SuccessProcessor.java
@@ -48,7 +48,7 @@ public class SuccessProcessor implements Processor entity) {
FullResponse fullResponse = entity.getBody();
- return HttpStatus.SC_OK == entity.getStatusCode().value() && fullResponse != null && fullResponse.getResponse().getError() == 0;
+ return HttpStatus.SC_OK == entity.getStatusCode().value() && fullResponse != null && fullResponse.getResponse().getError() == 0;
}
}
\ No newline at end of file
diff --git a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/AdapterCashReg.java b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/AdapterCashReg.java
index e3dea96..d496dae 100644
--- a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/AdapterCashReg.java
+++ b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/AdapterCashReg.java
@@ -15,6 +15,4 @@ public interface AdapterCashReg {
ResponseEntity refundCredit(RequestWrapper request);
- ResponseEntity status(RequestWrapper request);
-
}
diff --git a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/StarRysClient.java b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/StarRysClient.java
index 3e57fb1..10500b9 100644
--- a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/StarRysClient.java
+++ b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/StarRysClient.java
@@ -38,9 +38,4 @@ public class StarRysClient implements AdapterCashReg {
return api.complex(requestWrapper);
}
- @Override
- public ResponseEntity status(RequestWrapper request) {
- throw new RuntimeException();
- }
-
}
diff --git a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/Date.java b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/Date.java
index 8019fbd..323041c 100644
--- a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/Date.java
+++ b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/Date.java
@@ -3,13 +3,12 @@ package com.rbkmoney.adapter.starrys.service.starrys.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
-@Getter
-@Setter
-@ToString
+@Data
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Date {
diff --git a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/DateTime.java b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/DateTime.java
index e4f8377..4fddf5e 100644
--- a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/DateTime.java
+++ b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/DateTime.java
@@ -3,13 +3,12 @@ package com.rbkmoney.adapter.starrys.service.starrys.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
-@Getter
-@Setter
-@ToString
+@Data
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DateTime {
diff --git a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/Device.java b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/Device.java
index f15e33a..217911d 100644
--- a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/Device.java
+++ b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/Device.java
@@ -3,13 +3,12 @@ package com.rbkmoney.adapter.starrys.service.starrys.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
-@Getter
-@Setter
-@ToString
+@Data
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Device {
diff --git a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/FirstRequest.java b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/FirstRequest.java
index e35af56..d3188fa 100644
--- a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/FirstRequest.java
+++ b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/FirstRequest.java
@@ -3,13 +3,12 @@ package com.rbkmoney.adapter.starrys.service.starrys.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
-@Getter
-@Setter
-@ToString
+@Data
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class FirstRequest {
diff --git a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/FiscalDocument.java b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/FiscalDocument.java
index 01804a5..0e4b52d 100644
--- a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/FiscalDocument.java
+++ b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/FiscalDocument.java
@@ -3,15 +3,14 @@ package com.rbkmoney.adapter.starrys.service.starrys.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.List;
-@Getter
-@Setter
-@ToString
+@Data
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class FiscalDocument {
diff --git a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/FiscalDocumentValue.java b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/FiscalDocumentValue.java
index 6752898..11a0b4c 100644
--- a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/FiscalDocumentValue.java
+++ b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/FiscalDocumentValue.java
@@ -4,13 +4,12 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
+import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
-@Getter
-@Setter
-@ToString
+@Data
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class FiscalDocumentValue {
diff --git a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/Lines.java b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/Lines.java
index 860741e..15dabb3 100644
--- a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/Lines.java
+++ b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/Lines.java
@@ -3,15 +3,14 @@ package com.rbkmoney.adapter.starrys.service.starrys.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.math.BigInteger;
-@Getter
-@Setter
-@ToString
+@Data
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Lines {
diff --git a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/Time.java b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/Time.java
index c90fead..b568a9f 100644
--- a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/Time.java
+++ b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/Time.java
@@ -3,13 +3,12 @@ package com.rbkmoney.adapter.starrys.service.starrys.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
-@Getter
-@Setter
-@ToString
+@Data
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Time {
diff --git a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/request/ComplexRequest.java b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/request/ComplexRequest.java
index 47a15f0..f41e83b 100644
--- a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/request/ComplexRequest.java
+++ b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/request/ComplexRequest.java
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.rbkmoney.adapter.starrys.service.starrys.constant.*;
import com.rbkmoney.adapter.starrys.service.starrys.model.Lines;
+import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@@ -12,9 +13,7 @@ import lombok.ToString;
import java.math.BigInteger;
import java.util.List;
-@Getter
-@Setter
-@ToString
+@Data
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ComplexRequest {
diff --git a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/response/FullResponse.java b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/response/FullResponse.java
index 22b7504..51a2c47 100644
--- a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/response/FullResponse.java
+++ b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/response/FullResponse.java
@@ -5,15 +5,14 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.rbkmoney.adapter.starrys.service.starrys.model.Device;
import com.rbkmoney.adapter.starrys.service.starrys.model.FirstRequest;
+import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.List;
-@Getter
-@Setter
-@ToString
+@Data
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class FullResponse {
diff --git a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/response/Response.java b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/response/Response.java
index d8b54fd..09b3081 100644
--- a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/response/Response.java
+++ b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/response/Response.java
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.rbkmoney.adapter.starrys.service.starrys.model.DateTime;
import com.rbkmoney.adapter.starrys.service.starrys.model.FiscalDocument;
+import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@@ -12,9 +13,7 @@ import lombok.ToString;
import java.math.BigInteger;
import java.util.List;
-@Getter
-@Setter
-@ToString
+@Data
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Response {
diff --git a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/response/Responses.java b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/response/Responses.java
index da63531..e67164a 100644
--- a/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/response/Responses.java
+++ b/src/main/java/com/rbkmoney/adapter/starrys/service/starrys/model/response/Responses.java
@@ -3,13 +3,12 @@ package com.rbkmoney.adapter.starrys.service.starrys.model.response;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
-@Getter
-@Setter
-@ToString
+@Data
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Responses {
diff --git a/src/main/java/com/rbkmoney/adapter/starrys/validator/CashregContextValidator.java b/src/main/java/com/rbkmoney/adapter/starrys/validator/CashregContextValidator.java
index ee80940..532b9a7 100644
--- a/src/main/java/com/rbkmoney/adapter/starrys/validator/CashregContextValidator.java
+++ b/src/main/java/com/rbkmoney/adapter/starrys/validator/CashregContextValidator.java
@@ -26,5 +26,5 @@ public class CashregContextValidator implements Validator {
Objects.requireNonNull(options.get(OptionalField.COMPANY_ADDRESS.getField()), "Option 'companyAddress' must be set");
Objects.requireNonNull(options.get(OptionalField.PASS.getField()), "Option 'pass' must be set");
}
-
+
}
diff --git a/src/main/resources/fixture/errors.json b/src/main/resources/fixture/errors.json
new file mode 100644
index 0000000..cf3b57d
--- /dev/null
+++ b/src/main/resources/fixture/errors.json
@@ -0,0 +1,7 @@
+[
+ {
+ "codeRegex": "1",
+ "descriptionRegex": "test",
+ "mapping": "authorization_failed:operation_blocked"
+ }
+]
diff --git a/src/test/java/com/rbkmoney/adapter/starrys/handler/StarrysServerHandlerTest.java b/src/test/java/com/rbkmoney/adapter/starrys/handler/StarrysServerHandlerTest.java
index c0c768c..6c905a3 100644
--- a/src/test/java/com/rbkmoney/adapter/starrys/handler/StarrysServerHandlerTest.java
+++ b/src/test/java/com/rbkmoney/adapter/starrys/handler/StarrysServerHandlerTest.java
@@ -3,6 +3,8 @@ package com.rbkmoney.adapter.starrys.handler;
import com.rbkmoney.adapter.starrys.AbstractIntegrationTest;
import com.rbkmoney.adapter.starrys.MockUtils;
import com.rbkmoney.adapter.starrys.service.starrys.StarRysClient;
+import com.rbkmoney.adapter.starrys.service.starrys.model.response.FullResponse;
+import com.rbkmoney.adapter.starrys.service.starrys.model.response.Response;
import com.rbkmoney.damsel.cashreg.adapter.CashregContext;
import com.rbkmoney.damsel.cashreg.adapter.CashregResult;
import com.rbkmoney.damsel.cashreg.receipt.type.Debit;
@@ -11,10 +13,15 @@ import org.apache.thrift.TException;
import org.junit.Before;
import org.junit.Test;
import org.mockito.MockitoAnnotations;
+import org.mockito.stubbing.Answer;
import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
import org.springframework.test.annotation.DirtiesContext;
import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doAnswer;
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
public class StarrysServerHandlerTest extends AbstractIntegrationTest {
@@ -35,4 +42,19 @@ public class StarrysServerHandlerTest extends AbstractIntegrationTest {
assertTrue(result.getIntent().isSetFinish());
}
+ @Test
+ public void failureTest() throws TException {
+ doAnswer((Answer>) invocation -> {
+ ResponseEntity response = new ResponseEntity(new FullResponse(), HttpStatus.ACCEPTED);
+ response.getBody().setResponse(new Response());
+ response.getBody().getResponse().setError(1);
+ response.getBody().getResponse().setDescription("test");
+ return response;
+ }).when(client).debit(any());
+
+ CashregContext context = makeCashregContext(Type.debit(new Debit()));
+ CashregResult result = handler.register(context);
+ assertTrue(result.getIntent().getFinish().getStatus().isSetFailure());
+ }
+
}
\ No newline at end of file