Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion quickfixj-core/src/main/java/quickfix/FieldMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ public void replaceGroup(int num, Group group) {
}

public void removeGroup(int field) {
getGroups(field).clear();
getGroups().remove(field);
removeField(field);
}

Expand Down
34 changes: 22 additions & 12 deletions quickfixj-core/src/test/java/quickfix/FieldMapTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,27 @@
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneOffset;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import quickfix.field.EffectiveTime;
import quickfix.field.MDEntryTime;
import quickfix.field.converter.UtcTimeOnlyConverter;

import java.util.Iterator;
import java.util.Optional;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;

/**
* Tests the {@link FieldMap} class.
* Specifically, verifies that the setters for {@link UtcTimeStampField} work correctly.
*
* @author toli
* @version $Id$
*/
public class FieldMapTest extends TestCase {
public FieldMapTest(String inName) {
super(inName);
}

public static Test suite() {
return new TestSuite(FieldMapTest.class);
}
public class FieldMapTest {

@Test
public void testSetUtcTimeStampField() throws Exception {
FieldMap map = new Message();
LocalDateTime aDate = LocalDateTime.now();
Expand All @@ -43,6 +38,7 @@ public void testSetUtcTimeStampField() throws Exception {
epochMilliOfLocalDate(map.getField(new EffectiveTime()).getValue()));
}

@Test
public void testSetUtcTimeOnlyField() throws Exception {
FieldMap map = new Message();
LocalTime aDate = LocalTime.now();
Expand All @@ -59,6 +55,7 @@ public void testSetUtcTimeOnlyField() throws Exception {
/**
* Try a subclass of {@link UtcTimeOnlyField} and {@link UtcTimeStampField} directly
*/
@Test
public void testSpecificFields() throws Exception {
FieldMap map = new Message();
LocalDateTime aDate = LocalDateTime.now();
Expand All @@ -80,6 +77,7 @@ private void testOrdering(int[] vals, int[] order, int[] expected) {
assertEquals(String.valueOf(e), it.next().getObject());
}

@Test
public void testOrdering() {
testOrdering(new int[] { 1, 2, 3 }, null, new int[] { 1, 2, 3 });
testOrdering(new int[] { 3, 2, 1 }, null, new int[] { 1, 2, 3 });
Expand All @@ -93,6 +91,7 @@ public void testOrdering() {
testOrdering(new int[] { 3, 2, 1 }, new int[] { 3, 1 }, new int[] { 3, 1, 2 });
}

@Test
public void testOptionalString() {
FieldMap map = new Message();
map.setField(new StringField(128, "bigbank"));
Expand All @@ -102,6 +101,7 @@ public void testOptionalString() {
assertFalse(map.getOptionalString(129).isPresent());
}

@Test
public void testOptionalDecimal() {
FieldMap map = new Message();
map.setField(new DecimalField(44, new BigDecimal("1565.10")));
Expand All @@ -114,4 +114,14 @@ public void testOptionalDecimal() {
private long epochMilliOfLocalDate(LocalDateTime localDateTime) {
return localDateTime.toInstant(ZoneOffset.UTC).toEpochMilli();
}

@Test
public void testRemoveGroup() {
FieldMap map = new Message();
Group group = new Group(73,11);
map.addGroup(group);
assertTrue(map.hasGroup(73));
map.removeGroup(73);
assertFalse(map.hasGroup(73));
}
}