Skip to content

Commit c141074

Browse files
philipwhiukPhilip Whitehousechrjohn
authored
Remove group entry entirely when removing a group (#414)
* Remove group entry entirely when removing a group * Use method to access groups map * converted FieldMapTest to JUnit 4 Co-authored-by: Philip Whitehouse <pwhiteho@flextrade.com> Co-authored-by: Christoph John <christoph.john@macd.com>
1 parent 7ca1cb5 commit c141074

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

quickfixj-core/src/main/java/quickfix/FieldMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ public void replaceGroup(int num, Group group) {
669669
}
670670

671671
public void removeGroup(int field) {
672-
getGroups(field).clear();
672+
getGroups().remove(field);
673673
removeField(field);
674674
}
675675

quickfixj-core/src/test/java/quickfix/FieldMapTest.java

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,27 @@
44
import java.time.LocalDateTime;
55
import java.time.LocalTime;
66
import java.time.ZoneOffset;
7-
import junit.framework.Test;
8-
import junit.framework.TestCase;
9-
import junit.framework.TestSuite;
107
import quickfix.field.EffectiveTime;
118
import quickfix.field.MDEntryTime;
129
import quickfix.field.converter.UtcTimeOnlyConverter;
1310

1411
import java.util.Iterator;
1512
import java.util.Optional;
1613

14+
import static org.junit.Assert.assertEquals;
15+
import static org.junit.Assert.assertFalse;
16+
import static org.junit.Assert.assertTrue;
17+
import org.junit.Test;
18+
1719
/**
1820
* Tests the {@link FieldMap} class.
1921
* Specifically, verifies that the setters for {@link UtcTimeStampField} work correctly.
2022
*
2123
* @author toli
22-
* @version $Id$
2324
*/
24-
public class FieldMapTest extends TestCase {
25-
public FieldMapTest(String inName) {
26-
super(inName);
27-
}
28-
29-
public static Test suite() {
30-
return new TestSuite(FieldMapTest.class);
31-
}
25+
public class FieldMapTest {
3226

27+
@Test
3328
public void testSetUtcTimeStampField() throws Exception {
3429
FieldMap map = new Message();
3530
LocalDateTime aDate = LocalDateTime.now();
@@ -43,6 +38,7 @@ public void testSetUtcTimeStampField() throws Exception {
4338
epochMilliOfLocalDate(map.getField(new EffectiveTime()).getValue()));
4439
}
4540

41+
@Test
4642
public void testSetUtcTimeOnlyField() throws Exception {
4743
FieldMap map = new Message();
4844
LocalTime aDate = LocalTime.now();
@@ -59,6 +55,7 @@ public void testSetUtcTimeOnlyField() throws Exception {
5955
/**
6056
* Try a subclass of {@link UtcTimeOnlyField} and {@link UtcTimeStampField} directly
6157
*/
58+
@Test
6259
public void testSpecificFields() throws Exception {
6360
FieldMap map = new Message();
6461
LocalDateTime aDate = LocalDateTime.now();
@@ -80,6 +77,7 @@ private void testOrdering(int[] vals, int[] order, int[] expected) {
8077
assertEquals(String.valueOf(e), it.next().getObject());
8178
}
8279

80+
@Test
8381
public void testOrdering() {
8482
testOrdering(new int[] { 1, 2, 3 }, null, new int[] { 1, 2, 3 });
8583
testOrdering(new int[] { 3, 2, 1 }, null, new int[] { 1, 2, 3 });
@@ -93,6 +91,7 @@ public void testOrdering() {
9391
testOrdering(new int[] { 3, 2, 1 }, new int[] { 3, 1 }, new int[] { 3, 1, 2 });
9492
}
9593

94+
@Test
9695
public void testOptionalString() {
9796
FieldMap map = new Message();
9897
map.setField(new StringField(128, "bigbank"));
@@ -102,6 +101,7 @@ public void testOptionalString() {
102101
assertFalse(map.getOptionalString(129).isPresent());
103102
}
104103

104+
@Test
105105
public void testOptionalDecimal() {
106106
FieldMap map = new Message();
107107
map.setField(new DecimalField(44, new BigDecimal("1565.10")));
@@ -114,4 +114,14 @@ public void testOptionalDecimal() {
114114
private long epochMilliOfLocalDate(LocalDateTime localDateTime) {
115115
return localDateTime.toInstant(ZoneOffset.UTC).toEpochMilli();
116116
}
117+
118+
@Test
119+
public void testRemoveGroup() {
120+
FieldMap map = new Message();
121+
Group group = new Group(73,11);
122+
map.addGroup(group);
123+
assertTrue(map.hasGroup(73));
124+
map.removeGroup(73);
125+
assertFalse(map.hasGroup(73));
126+
}
117127
}

0 commit comments

Comments
 (0)