yangxk1 commented on code in PR #764:
URL: https://github.com/apache/incubator-graphar/pull/764#discussion_r2426494815
##########
maven-projects/info/src/test/java/org/apache/graphar/info/VertexInfoTest.java:
##########
@@ -20,14 +20,71 @@
package org.apache.graphar.info;
import java.net.URI;
+import java.net.URISyntaxException;
import java.util.Arrays;
+import java.util.List;
import org.apache.graphar.info.type.DataType;
import org.apache.graphar.info.type.FileType;
import org.junit.Assert;
import org.junit.Test;
public class VertexInfoTest {
+ private VertexInfo.VertexInfoBuilder b =
+ VertexInfo.builder()
+ .baseUri("test")
+ .type("test")
+ .chunkSize(24)
+ .version("gar/v1")
+ .propertyGroups(new PropertyGroups(List.of(TestUtil.pg3)));
+
+ @Test
+ public void testVertexInfoBasicBuilder() {
+ VertexInfo v = b.build();
+ }
+
+ @Test
+ public void testVertexInfoBuilderDoubleDeclaration() throws
URISyntaxException {
+ VertexInfo v = b.baseUri(new URI("world")).build();
+
+ Assert.assertEquals(new URI("world"), v.getBaseUri());
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void URInullTest() {
+ VertexInfo v =
+ VertexInfo.builder()
+ .type("test")
+ .chunkSize(24)
+ .version("gar/v1")
+ .propertyGroups(new
PropertyGroups(List.of(TestUtil.pg3)))
+ .build();
+ }
+
+ @Test
+ public void propertyGroupAppendTest() {
+ VertexInfo v = b.addPropertyGroup(TestUtil.pg2).build();
+
+ Assert.assertEquals(2, v.getPropertyGroups().size());
+ }
+
+ @Test
+ public void propertyGroupAddOnlyTest() {
+ VertexInfo v =
b.propertyGroups(null).addPropertyGroup(TestUtil.pg2).build();
+
+ Assert.assertEquals(1, v.getPropertyGroups().size());
+ }
+
+ @Test
+ public void invalidChunkSizeTest() {
+ try {
+ b.chunkSize(-1);
+ b.build();
+ Assert.assertThrows(IllegalArgumentException.class, () ->
b.chunkSize(-1));
Review Comment:
An exception was thrown in `build()`, so the subsequent `Assert` was not
executed.
I think a better way to write it is:
```
IllegalArgumentException illegalArgumentException =
Assert.assertThrows(
IllegalArgumentException.class, () -> b.build());
Assert.assertEquals(
"illegal chunk size xxxxxxxxxxxxxxxxxxx",
illegalArgumentException.getMessage());
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]