~raymond-borgan/gephi/0.7alpha4

« back to all changes in this revision

Viewing changes to ImportPlugin/test/unit/src/org/gephi/io/importer/plugin/file/ImporterGEXF2Test.java

  • Committer: Mathieu Bastian
  • Date: 2010-07-27 10:32:36 UTC
  • Revision ID: mathieu.bastian@gmail.com-20100727103236-pslsvtw6cely2e6t
Debug dynamic attributes parsing and import in ImportAPI. Debug and test ImporterGEXF2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
import java.net.URL;
26
26
import java.util.List;
27
27
import javax.xml.datatype.DatatypeConfigurationException;
 
28
import org.gephi.data.attributes.api.AttributeColumn;
28
29
import org.gephi.data.attributes.api.AttributeType;
29
30
import org.gephi.data.attributes.api.AttributeValue;
 
31
import org.gephi.data.attributes.type.DynamicType;
30
32
import org.gephi.data.attributes.type.StringList;
31
33
import org.gephi.dynamic.DynamicUtilities;
32
34
import org.gephi.io.importer.api.Container;
135
137
        assertNotNull(n7);
136
138
        assertNotNull(n8);
137
139
        assertNotNull(n9);
 
140
 
 
141
        ContainerUnloader unloader = container.getUnloader();
 
142
        AttributeColumn col0 = unloader.getAttributeModel().getNodeTable().getColumn("0");
 
143
        AttributeColumn col1 = unloader.getAttributeModel().getNodeTable().getColumn("1");
 
144
        AttributeColumn col2 = unloader.getAttributeModel().getNodeTable().getColumn("2");
 
145
        AttributeColumn col3 = unloader.getAttributeModel().getNodeTable().getColumn("3");
 
146
        AttributeColumn col4 = unloader.getAttributeModel().getNodeTable().getColumn("4");
 
147
 
138
148
        try {
139
149
            assertEquals("Node 1", n1.getLabel());
140
150
            assertEquals("2000-01-01", DynamicUtilities.getXMLDateStringFromDouble(n1.getTimeInterval().getValues().get(0)[0]));
141
151
            assertEquals("2000-12-31", DynamicUtilities.getXMLDateStringFromDouble(n1.getTimeInterval().getValues().get(0)[1]));
142
152
 
143
153
            AttributeValue[] values1 = n1.getAttributeRow().getValues();
144
 
            assertEquals("0", values1[0].getColumn().getId());
145
 
            assertEquals("3", values1[1].getColumn().getId());
146
 
            assertEquals("Author", values1[0].getValue());
147
 
            assertEquals(new Float(1), values1[1].getValue());
 
154
            assertEquals("0", values1[col0.getIndex()].getColumn().getId());
 
155
            assertEquals("3", values1[col3.getIndex()].getColumn().getId());
 
156
            assertEquals("Author", ((DynamicType) values1[col0.getIndex()].getValue()).getValue());
 
157
            assertEquals(new Float(1), ((DynamicType) values1[col3.getIndex()].getValue()).getValue());
148
158
 
149
159
            AttributeValue[] values2 = n2.getAttributeRow().getValues();
150
 
            assertEquals("0", values2[0].getColumn().getId());
151
 
            assertEquals("2", values2[1].getColumn().getId());
152
 
            assertEquals("Author", values2[0].getValue());
153
 
            assertEquals(new StringList("String1, String2, String 3"), values2[1].getValue());
 
160
            assertEquals("0", values2[col0.getIndex()].getColumn().getId());
 
161
            assertEquals("2", values2[col2.getIndex()].getColumn().getId());
 
162
            assertEquals("Author", ((DynamicType) values2[col0.getIndex()].getValue()).getValue());
 
163
            assertEquals(new StringList("String1, String2, String 3"), values2[col2.getIndex()].getValue());
 
164
 
 
165
            AttributeValue[] values3 = n3.getAttributeRow().getValues();
 
166
            DynamicType val4 = (DynamicType) values3[col4.getIndex()].getValue();
 
167
            double low = DynamicUtilities.getDoubleFromXMLDateString("2009-01-01");
 
168
            double high = DynamicUtilities.getDoubleFromXMLDateString("2009-12-31");
 
169
            assertEquals(new Float(3f), val4.getValue(low, high));
154
170
 
155
171
            assertEquals("2000-01-01", DynamicUtilities.getXMLDateStringFromDouble(n3.getTimeInterval().getValues().get(0)[0]));
156
172
            assertEquals("2000-01-15", DynamicUtilities.getXMLDateStringFromDouble(n3.getTimeInterval().getValues().get(0)[1]));
158
174
            assertEquals("2001-02-01", DynamicUtilities.getXMLDateStringFromDouble(n3.getTimeInterval().getValues().get(1)[1]));
159
175
            assertEquals(2, n3.getTimeInterval().getValues().size());
160
176
        } catch (Exception e) {
 
177
            e.printStackTrace();
161
178
            fail(e.getMessage());
162
179
        }
163
180