fixed iterative payload creation
This commit is contained in:
parent
320bde9a39
commit
23a5e9972d
@ -402,10 +402,12 @@ public final class ImqRequest {
|
||||
|
||||
for (int i = 0; i < parts.length - 1; i++) {
|
||||
String part = parts[i];
|
||||
if (!current.containsKey(part)) {
|
||||
current.put(part, new HashMap<String, Object>());
|
||||
Object next = current.get(part);
|
||||
if (!(next instanceof Map)) {
|
||||
next = new HashMap<String, Object>();
|
||||
current.put(part, next);
|
||||
}
|
||||
current = (Map<String, Object>) current.get(part);
|
||||
current = (Map<String, Object>) next;
|
||||
}
|
||||
|
||||
current.put(parts[parts.length - 1], value);
|
||||
@ -417,16 +419,22 @@ public final class ImqRequest {
|
||||
|
||||
for (int i = 0; i < parts.length - 1; i++) {
|
||||
String part = parts[i];
|
||||
if (!current.containsKey(part)) {
|
||||
current.put(part, new ArrayList<Map<String, Object>>());
|
||||
Object next = current.get(part);
|
||||
if (!(next instanceof Map)) {
|
||||
next = new HashMap<String, Object>();
|
||||
current.put(part, next);
|
||||
}
|
||||
current = (Map<String, Object>) current.get(part);
|
||||
current = (Map<String, Object>) next;
|
||||
}
|
||||
|
||||
List<Map<String, Object>> array = (List<Map<String, Object>>) current.get(parts[parts.length - 1]);
|
||||
if (array == null) {
|
||||
String arrayKey = parts[parts.length - 1];
|
||||
Object arrayValue = current.get(arrayKey);
|
||||
List<Map<String, Object>> array;
|
||||
if (arrayValue instanceof List) {
|
||||
array = (List<Map<String, Object>>) arrayValue;
|
||||
} else {
|
||||
array = new ArrayList<>();
|
||||
current.put(parts[parts.length - 1], array);
|
||||
current.put(arrayKey, array);
|
||||
}
|
||||
array.add((Map<String, Object>) value);
|
||||
}
|
||||
|
||||
@ -63,4 +63,20 @@ public class ImqFirstVisionTest {
|
||||
.receiveWhere(msg -> msg.getBody().contains("12345")).withTimeout(15, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@TestCase(name = "Create and send message with incremental payload building")
|
||||
public void createAndSendMessageWithIncrementalPayload(Harness harness) {
|
||||
harness.withImqFirstVision().toQueue(ImqFirstVisionQueue.PAYMENT_NOTIFICATIONS).withPayload("{}")
|
||||
.addField("paymentId", "PAY-456").addField("amount", 15000).addField("currency", "CZK")
|
||||
.addField("beneficiary", new Object()).addField("beneficiary", "name", "Jan Novák")
|
||||
.addField("beneficiary", "accountNumber", "1234567890/0100").send();
|
||||
}
|
||||
|
||||
@TestCase(name = "Receive message with Correlation ID")
|
||||
public void receiveMessageWithCorrelationId(Harness harness) {
|
||||
|
||||
harness.withImqFirstVision().fromQueue(ImqFirstVisionQueue.PAYMENT_NOTIFICATIONS)
|
||||
.withSelector("JMSCorrelationID = 'corr-789'").receiveWhere(msg -> true)
|
||||
.withTimeout(10, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user