Skip to content

Commit

Permalink
test: parse empty id throws IllegalArgumentException
Browse files Browse the repository at this point in the history
  • Loading branch information
diaohancai committed Mar 3, 2024
1 parent 6510424 commit d55c7c7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");

Check warning on line 32 in computer-api/src/main/java/org/apache/hugegraph/computer/core/util/IdUtil.java

View check run for this annotation

Codecov / codecov/patch

computer-api/src/main/java/org/apache/hugegraph/computer/core/util/IdUtil.java#L32

Added line #L32 was not covered by tests
}


try {
if (idStr.startsWith("U\"")) {
return IdFactory.parseId(IdType.UUID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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, () -> {
Expand Down

0 comments on commit d55c7c7

Please sign in to comment.