|
54 | 54 | import quickfix.field.TargetCompID; |
55 | 55 | import quickfix.field.TimeInForce; |
56 | 56 | import quickfix.field.TransactTime; |
| 57 | +import quickfix.fix44.NewOrderMultileg; |
57 | 58 | import quickfix.fix44.NewOrderSingle; |
58 | 59 | import quickfix.fix44.Quote; |
59 | 60 | import quickfix.fix44.QuoteRequest; |
|
78 | 79 | import static org.junit.Assert.assertNotNull; |
79 | 80 | import static org.junit.Assert.assertTrue; |
80 | 81 | import static org.junit.Assert.fail; |
| 82 | +import static org.junit.Assert.assertThrows; |
81 | 83 |
|
82 | 84 | public class DataDictionaryTest { |
83 | 85 |
|
@@ -1493,6 +1495,55 @@ private String getCommonDataDictionaryString(String data) { |
1493 | 1495 | return data; |
1494 | 1496 | } |
1495 | 1497 |
|
| 1498 | + @Test |
| 1499 | + public void testFirstFieldInGroupIsDelimiter() throws Exception { |
| 1500 | + |
| 1501 | + final DataDictionary dataDictionary = new DataDictionary(getDictionary()); |
| 1502 | + dataDictionary.setCheckUnorderedGroupFields(false); |
| 1503 | + dataDictionary.setFirstFieldInGroupIsDelimiter(true); |
| 1504 | + |
| 1505 | + String fixMsg = "8=FIX.4.4\u00019=688\u000135=AB\u000149=AAA\u000156=BBB\u000134=21133\u000150=ABCABC" + |
| 1506 | + "\u000152=20230905-13:24:37.022\u000155=AAPL\u00011=ACC1\u000111=123456abcedf\u000121=1\u000138=5\u000154=1\u000140=2\u000144=-0.8" + |
| 1507 | + "\u000159=0\u000160=20230905-13:24:36.984\u0001100=ALGO\u0001167=MLEG\u0001555=3\u0001602=111\u0001600=AAA" + |
| 1508 | + "\u0001602=222\u0001654=231\u0001600=BBB\u0001602=333\u0001654=332\u0001600=CCC\u000158=TEXT\u000110=168\u0001"; |
| 1509 | + |
| 1510 | + String byDictFixMsg = "8=FIX.4.4\u00019=688\u000135=AB\u000149=AAA\u000156=BBB\u000134=21133\u000150=ABCABC" + |
| 1511 | + "\u000152=20230905-13:24:37.022\u000155=AAPL\u00011=ACC1\u000111=123456abcedf\u000121=1\u000138=5\u000154=1\u000140=2\u000144=-0.8" + |
| 1512 | + "\u000159=0\u000160=20230905-13:24:36.984\u0001100=ALGO\u0001167=MLEG\u0001555=3\u0001600=AAA\u0001602=111" + |
| 1513 | + "\u0001600=BBB\u0001602=222\u0001654=231\u0001600=CCC\u0001602=333\u0001654=332\u000158=TEXT\u000110=168\u0001"; |
| 1514 | + |
| 1515 | + //doValidation and firstFieldInGroupIsDelimiter -> should NOT fail |
| 1516 | + final NewOrderMultileg noml1 = new NewOrderMultileg(); |
| 1517 | + noml1.fromString(fixMsg, dataDictionary, true); |
| 1518 | + dataDictionary.validate(noml1); |
| 1519 | + assertTrue(noml1.hasGroup(555)); |
| 1520 | + assertEquals(3, noml1.getGroupCount(555)); |
| 1521 | + //delimiter should be first tag in group |
| 1522 | + assertEquals(602, noml1.getGroup(1, 555).delim()); |
| 1523 | + |
| 1524 | + dataDictionary.setFirstFieldInGroupIsDelimiter(false); |
| 1525 | + dataDictionary.setCheckUnorderedGroupFields(true); |
| 1526 | + final NewOrderMultileg noml2 = new NewOrderMultileg(); |
| 1527 | + noml2.fromString(fixMsg, dataDictionary, true); |
| 1528 | + //when firstFieldInGroupIsDelimiter = false and setCheckUnorderedGroupFields = true - exception is thrown |
| 1529 | + assertThrows(FieldException.class, () -> dataDictionary.validate(noml2)); |
| 1530 | + |
| 1531 | + final NewOrderMultileg noml3 = new NewOrderMultileg(); |
| 1532 | + noml3.fromString(fixMsg, dataDictionary, true); |
| 1533 | + //when firstFieldInGroupIsDelimiter = true and setCheckUnorderedGroupFields = true - exception is thrown |
| 1534 | + assertThrows(FieldException.class, () -> dataDictionary.validate(noml3)); |
| 1535 | + |
| 1536 | + dataDictionary.setCheckUnorderedGroupFields(true); |
| 1537 | + final NewOrderMultileg noml4 = new NewOrderMultileg(); |
| 1538 | + noml4.fromString(byDictFixMsg, dataDictionary, true); |
| 1539 | + //when firstFieldInGroupIsDelimiter = true and setCheckUnorderedGroupFields = true, message aligns with dictionary - do NOT fail |
| 1540 | + dataDictionary.validate(noml4); |
| 1541 | + assertTrue(noml4.hasGroup(555)); |
| 1542 | + assertEquals(3, noml4.getGroupCount(555)); |
| 1543 | + //delimiter should be dictionary first tag = 600 |
| 1544 | + assertEquals(600, noml4.getGroup(1, 555).delim()); |
| 1545 | + } |
| 1546 | + |
1496 | 1547 |
|
1497 | 1548 | // |
1498 | 1549 | // Group Validation Tests in RepeatingGroupTest |
|
0 commit comments