From d55c7c7bb5b2c6e5d5612d9b39d3cfc98eea3be7 Mon Sep 17 00:00:00 2001 From: diaohancai <550630588@qq.com> Date: Sun, 3 Mar 2024 13:55:17 +0800 Subject: [PATCH] test: parse empty id throws IllegalArgumentException --- .../java/org/apache/hugegraph/computer/core/util/IdUtil.java | 4 +--- .../org/apache/hugegraph/computer/core/util/IdUtilTest.java | 5 ++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/computer-api/src/main/java/org/apache/hugegraph/computer/core/util/IdUtil.java b/computer-api/src/main/java/org/apache/hugegraph/computer/core/util/IdUtil.java index f3820dc4a..1963909e4 100644 --- a/computer-api/src/main/java/org/apache/hugegraph/computer/core/util/IdUtil.java +++ b/computer-api/src/main/java/org/apache/hugegraph/computer/core/util/IdUtil.java @@ -20,7 +20,6 @@ import java.util.UUID; import org.apache.commons.lang3.StringUtils; -import org.apache.hugegraph.computer.core.common.exception.ComputerException; import org.apache.hugegraph.computer.core.graph.id.Id; import org.apache.hugegraph.computer.core.graph.id.IdFactory; import org.apache.hugegraph.computer.core.graph.id.IdType; @@ -30,10 +29,9 @@ public class IdUtil { public static Id parseId(String idStr) { if (StringUtils.isBlank(idStr)) { - throw new ComputerException("Can't parse Id for empty string"); + throw new IllegalArgumentException("Can't parse Id for empty string"); } - try { if (idStr.startsWith("U\"")) { return IdFactory.parseId(IdType.UUID, diff --git a/computer-test/src/main/java/org/apache/hugegraph/computer/core/util/IdUtilTest.java b/computer-test/src/main/java/org/apache/hugegraph/computer/core/util/IdUtilTest.java index 65f0361a1..739690820 100644 --- a/computer-test/src/main/java/org/apache/hugegraph/computer/core/util/IdUtilTest.java +++ b/computer-test/src/main/java/org/apache/hugegraph/computer/core/util/IdUtilTest.java @@ -17,7 +17,6 @@ package org.apache.hugegraph.computer.core.util; -import org.apache.hugegraph.computer.core.common.exception.ComputerException; import org.apache.hugegraph.computer.core.graph.id.IdType; import org.apache.hugegraph.testutil.Assert; import org.junit.Test; @@ -41,10 +40,10 @@ public void testParseId() { Assert.assertEquals(IdType.LONG, IdUtil.parseId(idLong).idType()); Assert.assertEquals(IdType.UUID, IdUtil.parseId(idUuid).idType()); - Assert.assertThrows(ComputerException.class, () -> { + Assert.assertThrows(IllegalArgumentException.class, () -> { IdUtil.parseId(idNull).idType(); }); - Assert.assertThrows(ComputerException.class, () -> { + Assert.assertThrows(IllegalArgumentException.class, () -> { IdUtil.parseId(idEmpty).idType(); }); Assert.assertThrows(IllegalArgumentException.class, () -> {