use the LinkedHashMap instead of HashMap to make sure the retrive order

This commit is contained in:
QI CUI 2015-01-30 14:02:49 -05:00
parent 38f0ac868d
commit 3ff3700125
2 changed files with 7 additions and 7 deletions

View File

@ -1,6 +1,6 @@
package com.google.refine.importers.tree;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
@ -9,8 +9,8 @@ import org.apache.commons.lang.StringUtils;
* A column group describes a branch in tree structured data
*/
public class ImportColumnGroup extends ImportVertical {
public Map<String, ImportColumnGroup> subgroups = new HashMap<String, ImportColumnGroup>();
public Map<String, ImportColumn> columns = new HashMap<String, ImportColumn>();
public Map<String, ImportColumnGroup> subgroups = new LinkedHashMap<String, ImportColumnGroup>();
public Map<String, ImportColumn> columns = new LinkedHashMap<String, ImportColumn>();
public int nextRowIndex; // TODO: this can be hoisted into superclass
@Override

View File

@ -264,10 +264,10 @@ public class XmlImportUtilitiesTests extends RefineTest {
XmlImportUtilitiesStub.createColumnsFromImport(project, columnGroup);
log(project);
assertProjectCreated(project, 4, 0);
Assert.assertEquals(project.columnModel.columns.get(0).getName(), "world");
Assert.assertEquals(project.columnModel.columns.get(1).getName(), "hello");
Assert.assertEquals(project.columnModel.columns.get(2).getName(), "bar");
Assert.assertEquals(project.columnModel.columns.get(3).getName(), "foo");
Assert.assertEquals(project.columnModel.columns.get(0).getName(), "hello");
Assert.assertEquals(project.columnModel.columns.get(1).getName(), "world");
Assert.assertEquals(project.columnModel.columns.get(2).getName(), "foo");
Assert.assertEquals(project.columnModel.columns.get(3).getName(), "bar");
Assert.assertEquals(project.columnModel.columnGroups.get(0).keyColumnIndex, 2);
Assert.assertEquals(project.columnModel.columnGroups.get(0).startColumnIndex, 2);
Assert.assertEquals(project.columnModel.columnGroups.get(0).columnSpan, 2);