|
@@ -1,6 +1,9 @@
|
1
|
1
|
package fr.sayasoft.fake.zinc;
|
2
|
2
|
|
3
|
3
|
import fr.sayasoft.zinc.sdk.domain.OrderRequest;
|
|
4
|
+import lombok.extern.log4j.Log4j;
|
|
5
|
+import org.apache.commons.lang3.builder.ToStringBuilder;
|
|
6
|
+import org.apache.commons.lang3.builder.ToStringStyle;
|
4
|
7
|
import org.springframework.http.HttpStatus;
|
5
|
8
|
import org.springframework.http.ResponseEntity;
|
6
|
9
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
@@ -13,6 +16,7 @@ import org.springframework.web.bind.annotation.RestController;
|
13
|
16
|
import java.util.concurrent.atomic.AtomicLong;
|
14
|
17
|
|
15
|
18
|
@RestController
|
|
19
|
+@Log4j
|
16
|
20
|
public class FakeZincController {
|
17
|
21
|
|
18
|
22
|
private static final String template = "Hello, %s!";
|
|
@@ -42,8 +46,9 @@ public class FakeZincController {
|
42
|
46
|
" ]\n" +
|
43
|
47
|
"}";
|
44
|
48
|
|
|
49
|
+ public static final String POST_ORDER_RESPONSE_TO_BE_REPLACED = "XXX";
|
45
|
50
|
public static final String POST_ORDER_RESPONSE = "{\n" +
|
46
|
|
- " \"request_id\": \"3f1c939065cf58e7b9f0aea70640dffc\"\n" +
|
|
51
|
+ " \"request_id\": \"fakeRequestIdStart-" + POST_ORDER_RESPONSE_TO_BE_REPLACED + "-fakeRequestIdEnd\"\n" +
|
47
|
52
|
"}";
|
48
|
53
|
|
49
|
54
|
private final AtomicLong counter = new AtomicLong();
|
|
@@ -57,7 +62,7 @@ public class FakeZincController {
|
57
|
62
|
|
58
|
63
|
@SuppressWarnings("unused")
|
59
|
64
|
@RequestMapping(
|
60
|
|
- value = "/order/{request_id}",
|
|
65
|
+ value = "/v1/order/{request_id}",
|
61
|
66
|
method = RequestMethod.GET,
|
62
|
67
|
produces = "application/json; charset=UTF-8"
|
63
|
68
|
)
|
|
@@ -67,11 +72,19 @@ public class FakeZincController {
|
67
|
72
|
|
68
|
73
|
@SuppressWarnings("unused")
|
69
|
74
|
@RequestMapping(
|
70
|
|
- value = "/order",
|
|
75
|
+ value = "/v1/order",
|
71
|
76
|
method = RequestMethod.POST,
|
72
|
77
|
produces = "application/json; charset=UTF-8"
|
73
|
78
|
)
|
74
|
|
- public ResponseEntity<?> postOrder(@RequestBody OrderRequest requestBody) {
|
|
79
|
+ public ResponseEntity<?> postOrder(@RequestBody OrderRequest orderRequest) {
|
|
80
|
+// FIXME: at this point, the orderRequest, for an unknown reason, is not well deserialized
|
|
81
|
+ // (except the field 'retailer'). But it *was* well serialized on the client side...
|
|
82
|
+
|
|
83
|
+// if (log.isDebugEnabled()) {
|
|
84
|
+// log.debug(ToStringBuilder.reflectionToString(orderRequest));
|
|
85
|
+// }
|
|
86
|
+ System.out.println(ToStringBuilder.reflectionToString(orderRequest, ToStringStyle.MULTI_LINE_STYLE));
|
75
|
87
|
return new ResponseEntity<>(POST_ORDER_RESPONSE, HttpStatus.CREATED);
|
|
88
|
+// return new ResponseEntity<>(POST_ORDER_RESPONSE.replace(POST_ORDER_RESPONSE_TO_BE_REPLACED, orderRequest.getIdempotencyKey()), HttpStatus.CREATED);
|
76
|
89
|
}
|
77
|
90
|
}
|