yangxk1 commented on code in PR #739:
URL: https://github.com/apache/incubator-graphar/pull/739#discussion_r2317676308


##########
maven-projects/info/src/test/java/org/apache/graphar/info/VersionInfoTest.java:
##########
@@ -0,0 +1,250 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.graphar.info;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class VersionInfoTest {
+
+    @Test
+    public void testVersionInfoBasicConstruction() {
+        VersionInfo versionInfo = new VersionInfo(1, null);
+
+        Assert.assertEquals(1, versionInfo.getVersion());
+        Assert.assertNull(versionInfo.getUserDefinedTypes());
+        Assert.assertEquals("gar/v1", versionInfo.toString());
+    }
+
+    @Test
+    public void testVersionInfoWithEmptyUserDefinedTypes() {
+        List<String> emptyTypes = Collections.emptyList();
+        VersionInfo versionInfo = new VersionInfo(1, emptyTypes);
+
+        Assert.assertEquals(1, versionInfo.getVersion());
+        Assert.assertEquals(emptyTypes, versionInfo.getUserDefinedTypes());
+        Assert.assertEquals("gar/v1", versionInfo.toString());
+    }
+
+    @Test
+    public void testVersionInfoWithUserDefinedTypes() {
+        List<String> userTypes = Arrays.asList("customType1", "customType2");
+        VersionInfo versionInfo = new VersionInfo(1, userTypes);
+
+        Assert.assertEquals(1, versionInfo.getVersion());
+        Assert.assertEquals(userTypes, versionInfo.getUserDefinedTypes());
+        Assert.assertEquals("gar/v1 (customType1,customType2)", 
versionInfo.toString());
+    }
+
+    @Test
+    public void testVersionInfoWithSingleUserDefinedType() {
+        List<String> userTypes = Arrays.asList("singleType");
+        VersionInfo versionInfo = new VersionInfo(1, userTypes);
+
+        Assert.assertEquals(1, versionInfo.getVersion());
+        Assert.assertEquals(userTypes, versionInfo.getUserDefinedTypes());
+        Assert.assertEquals("gar/v1 (singleType)", versionInfo.toString());
+    }
+
+    @Test
+    public void testVersionInfoCheckTypeBuiltInTypes() {
+        VersionInfo versionInfo = new VersionInfo(1, null);
+
+        // Test built-in types for version 1
+        Assert.assertTrue(versionInfo.checkType("bool"));
+        Assert.assertTrue(versionInfo.checkType("int32"));
+        Assert.assertTrue(versionInfo.checkType("int64"));
+        Assert.assertTrue(versionInfo.checkType("float"));
+        Assert.assertTrue(versionInfo.checkType("double"));
+        Assert.assertTrue(versionInfo.checkType("string"));
+    }
+
+    @Test
+    public void testVersionInfoCheckTypeNonExistentTypes() {
+        VersionInfo versionInfo = new VersionInfo(1, null);
+
+        // Test non-existent types
+        Assert.assertFalse(versionInfo.checkType("date32"));
+        Assert.assertFalse(versionInfo.checkType("timestamp"));
+        Assert.assertFalse(versionInfo.checkType("binary"));
+        Assert.assertFalse(versionInfo.checkType("customType"));
+        Assert.assertFalse(versionInfo.checkType(""));
+    }
+
+    @Test
+    public void testVersionInfoCheckTypeWithUserDefinedTypes() {
+        List<String> userTypes = Arrays.asList("customType1", "customType2");
+        VersionInfo versionInfo = new VersionInfo(1, userTypes);
+
+        // Test built-in types still work
+        Assert.assertTrue(versionInfo.checkType("int32"));
+        Assert.assertTrue(versionInfo.checkType("string"));
+
+        // Test user-defined types
+        Assert.assertTrue(versionInfo.checkType("customType1"));
+        Assert.assertTrue(versionInfo.checkType("customType2"));
+
+        // Test non-existent types
+        Assert.assertFalse(versionInfo.checkType("nonExistentType"));
+        Assert.assertFalse(versionInfo.checkType("date32"));
+    }
+
+    @Test
+    public void testVersionInfoCheckTypeWithNullType() {
+        VersionInfo versionInfo = new VersionInfo(1, null);
+
+        // The current implementation doesn't handle null gracefully, so this 
will throw NPE

Review Comment:
   please add a `todo` to handle NPE situation



##########
maven-projects/info/src/test/java/org/apache/graphar/info/MultiFormatGraphInfoTest.java:
##########
@@ -0,0 +1,341 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.graphar.info;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import org.apache.graphar.info.type.AdjListType;
+import org.apache.graphar.info.type.DataType;
+import org.apache.graphar.info.type.FileType;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class MultiFormatGraphInfoTest {
+
+    @Test
+    public void testGraphInfoWithEmptyVertexAndEdgeInfos() {
+        List<VertexInfo> emptyVertices = new ArrayList<>();
+        List<EdgeInfo> emptyEdges = new ArrayList<>();
+        String version = "gar/v1";
+
+        GraphInfo graphInfo =
+                new GraphInfo("emptyGraph", emptyVertices, emptyEdges, 
"test/", version);
+
+        Assert.assertEquals("emptyGraph", graphInfo.getName());
+        Assert.assertEquals(0, graphInfo.getVertexInfos().size());
+        Assert.assertEquals(0, graphInfo.getEdgeInfos().size());
+        Assert.assertEquals("test/", graphInfo.getPrefix());
+        Assert.assertEquals("gar/v1", graphInfo.getVersion().toString());
+    }
+
+    @Test
+    public void testGraphInfoWithNullPrefix() {
+        List<VertexInfo> vertices = new ArrayList<>();
+        List<EdgeInfo> edges = new ArrayList<>();
+        String version = "gar/v1";
+
+        GraphInfo graphInfo = new GraphInfo("testGraph", vertices, edges, 
null, version);
+
+        Assert.assertEquals("testGraph", graphInfo.getName());
+        Assert.assertNull(graphInfo.getPrefix());
+    }
+
+    @Test
+    public void testVertexInfoWithEmptyPropertyGroups() {
+        PropertyGroup emptyPg = new PropertyGroup(Collections.emptyList(), 
FileType.CSV, "empty/");
+        List<PropertyGroup> propertyGroups = Arrays.asList(emptyPg);
+        String version = "gar/v1";
+
+        VertexInfo vertexInfo =
+                new VertexInfo("testVertex", 100, propertyGroups, "vertex/", 
version);
+
+        Assert.assertEquals("testVertex", vertexInfo.getType());
+        Assert.assertEquals(100, vertexInfo.getChunkSize());
+        Assert.assertEquals(1, vertexInfo.getPropertyGroups().size());
+        Assert.assertEquals(0, vertexInfo.getPropertyGroups().get(0).size());
+    }
+
+    @Test
+    public void testVertexInfoWithZeroChunkSize() {
+        Property prop = new Property("id", DataType.INT32, true, false);
+        PropertyGroup pg = new PropertyGroup(Arrays.asList(prop), 
FileType.CSV, "test/");
+        List<PropertyGroup> propertyGroups = Arrays.asList(pg);
+        String version = "gar/v1";
+
+        VertexInfo vertexInfo = new VertexInfo("testVertex", 0, 
propertyGroups, "vertex/", version);
+
+        Assert.assertEquals("testVertex", vertexInfo.getType());
+        Assert.assertEquals(0, vertexInfo.getChunkSize());
+    }
+
+    @Test
+    public void testVertexInfoWithNegativeChunkSize() {

Review Comment:
   Do we need negative chunk size? May be better to throw Exception.



##########
maven-projects/info/src/test/java/org/apache/graphar/info/BaseFileSystemTest.java:
##########
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.graphar.info;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Comparator;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+/**
+ * Base class for tests that require file system operations. Provides common 
setup and cleanup
+ * functionality.
+ */
+public abstract class BaseFileSystemTest {

Review Comment:
   I think using overwrite is better, If test fails, we may need to look at 
output and log. refer to #728



##########
maven-projects/info/src/test/java/org/apache/graphar/info/MultiFormatGraphInfoTest.java:
##########
@@ -0,0 +1,341 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.graphar.info;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import org.apache.graphar.info.type.AdjListType;
+import org.apache.graphar.info.type.DataType;
+import org.apache.graphar.info.type.FileType;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class MultiFormatGraphInfoTest {
+
+    @Test
+    public void testGraphInfoWithEmptyVertexAndEdgeInfos() {
+        List<VertexInfo> emptyVertices = new ArrayList<>();
+        List<EdgeInfo> emptyEdges = new ArrayList<>();
+        String version = "gar/v1";
+
+        GraphInfo graphInfo =
+                new GraphInfo("emptyGraph", emptyVertices, emptyEdges, 
"test/", version);
+
+        Assert.assertEquals("emptyGraph", graphInfo.getName());
+        Assert.assertEquals(0, graphInfo.getVertexInfos().size());
+        Assert.assertEquals(0, graphInfo.getEdgeInfos().size());
+        Assert.assertEquals("test/", graphInfo.getPrefix());
+        Assert.assertEquals("gar/v1", graphInfo.getVersion().toString());
+    }
+
+    @Test
+    public void testGraphInfoWithNullPrefix() {
+        List<VertexInfo> vertices = new ArrayList<>();
+        List<EdgeInfo> edges = new ArrayList<>();
+        String version = "gar/v1";
+
+        GraphInfo graphInfo = new GraphInfo("testGraph", vertices, edges, 
null, version);
+
+        Assert.assertEquals("testGraph", graphInfo.getName());
+        Assert.assertNull(graphInfo.getPrefix());
+    }
+
+    @Test
+    public void testVertexInfoWithEmptyPropertyGroups() {
+        PropertyGroup emptyPg = new PropertyGroup(Collections.emptyList(), 
FileType.CSV, "empty/");
+        List<PropertyGroup> propertyGroups = Arrays.asList(emptyPg);
+        String version = "gar/v1";
+
+        VertexInfo vertexInfo =
+                new VertexInfo("testVertex", 100, propertyGroups, "vertex/", 
version);
+
+        Assert.assertEquals("testVertex", vertexInfo.getType());
+        Assert.assertEquals(100, vertexInfo.getChunkSize());
+        Assert.assertEquals(1, vertexInfo.getPropertyGroups().size());
+        Assert.assertEquals(0, vertexInfo.getPropertyGroups().get(0).size());
+    }
+
+    @Test
+    public void testVertexInfoWithZeroChunkSize() {
+        Property prop = new Property("id", DataType.INT32, true, false);
+        PropertyGroup pg = new PropertyGroup(Arrays.asList(prop), 
FileType.CSV, "test/");
+        List<PropertyGroup> propertyGroups = Arrays.asList(pg);
+        String version = "gar/v1";
+
+        VertexInfo vertexInfo = new VertexInfo("testVertex", 0, 
propertyGroups, "vertex/", version);
+
+        Assert.assertEquals("testVertex", vertexInfo.getType());
+        Assert.assertEquals(0, vertexInfo.getChunkSize());
+    }
+
+    @Test
+    public void testVertexInfoWithNegativeChunkSize() {
+        Property prop = new Property("id", DataType.INT32, true, false);
+        PropertyGroup pg = new PropertyGroup(Arrays.asList(prop), 
FileType.CSV, "test/");
+        List<PropertyGroup> propertyGroups = Arrays.asList(pg);
+        String version = "gar/v1";
+
+        VertexInfo vertexInfo =
+                new VertexInfo("testVertex", -100, propertyGroups, "vertex/", 
version);
+
+        Assert.assertEquals("testVertex", vertexInfo.getType());
+        Assert.assertEquals(-100, vertexInfo.getChunkSize());
+    }
+
+    @Test
+    public void testEdgeInfoWithEmptyAdjacentLists() {
+        List<AdjacentList> emptyAdjLists = new ArrayList<>();
+        List<PropertyGroup> emptyPropertyGroups = new ArrayList<>();
+        String version = "gar/v1";
+
+        EdgeInfo edgeInfo =
+                new EdgeInfo(
+                        "srcType",
+                        "edgeType",
+                        "dstType",
+                        50,
+                        100,
+                        200,
+                        true,
+                        "edge/",
+                        version,
+                        emptyAdjLists,
+                        emptyPropertyGroups);
+
+        Assert.assertEquals("srcType", edgeInfo.getSrcType());
+        Assert.assertEquals("edgeType", edgeInfo.getEdgeType());
+        Assert.assertEquals("dstType", edgeInfo.getDstType());
+        Assert.assertEquals(50, edgeInfo.getChunkSize());
+        Assert.assertEquals(0, edgeInfo.getAdjacentLists().size());
+        Assert.assertEquals(0, edgeInfo.getPropertyGroupNum());
+    }
+
+    @Test
+    public void testEdgeInfoWithZeroChunkSize() {
+        AdjacentList adjList =
+                new AdjacentList(AdjListType.unordered_by_source, 
FileType.CSV, "adj/");
+        List<AdjacentList> adjLists = Arrays.asList(adjList);
+        List<PropertyGroup> emptyPropertyGroups = new ArrayList<>();
+        String version = "gar/v1";
+
+        EdgeInfo edgeInfo =
+                new EdgeInfo(
+                        "srcType",
+                        "edgeType",
+                        "dstType",
+                        0,
+                        100,
+                        200,
+                        true,
+                        "edge/",
+                        version,
+                        adjLists,
+                        emptyPropertyGroups);
+
+        Assert.assertEquals(0, edgeInfo.getChunkSize());

Review Comment:
   If the test values are all valid, we can merge them into fewer test methods.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@graphar.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@graphar.apache.org
For additional commands, e-mail: commits-h...@graphar.apache.org

Reply via email to