diff --git a/.gitignore b/.gitignore
index fa22f587..8053b45a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,3 +19,4 @@ target
gen-java
build
node*
+*.versionsBackup
diff --git a/hugegraph-common/pom.xml b/hugegraph-common/pom.xml
index a188f9fa..862c3d77 100644
--- a/hugegraph-common/pom.xml
+++ b/hugegraph-common/pom.xml
@@ -27,7 +27,7 @@
hugegraph-common
- ${artifactId}
+ ${project.artifactId}
https://github.com/apache/incubator-hugegraph-commons/tree/master/hugegraph-common
hugegraph-common is a common module for HugeGraph and its peripheral components.
@@ -211,7 +211,6 @@
maven-compiler-plugin
- 3.1
${compiler.target}
@@ -226,7 +225,6 @@
org.apache.maven.plugins
maven-jar-plugin
- 2.6
true
@@ -281,7 +279,6 @@
org.apache.maven.plugins
maven-source-plugin
- 2.2.1
attach-sources
@@ -294,7 +291,6 @@
org.apache.maven.plugins
maven-javadoc-plugin
- 2.9.1
attach-javadocs
@@ -307,7 +303,6 @@
org.apache.maven.plugins
maven-gpg-plugin
- 1.5
sign-artifacts
diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/iterator/BatchMapperIterator.java b/hugegraph-common/src/main/java/org/apache/hugegraph/iterator/BatchMapperIterator.java
index 79f9e87b..39be041e 100644
--- a/hugegraph-common/src/main/java/org/apache/hugegraph/iterator/BatchMapperIterator.java
+++ b/hugegraph-common/src/main/java/org/apache/hugegraph/iterator/BatchMapperIterator.java
@@ -25,6 +25,7 @@
import org.apache.hugegraph.util.E;
import org.apache.hugegraph.util.InsertionOrderUtil;
+
import com.google.common.collect.ImmutableList;
public class BatchMapperIterator extends WrappedIterator {
diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/perf/PerfUtil.java b/hugegraph-common/src/main/java/org/apache/hugegraph/perf/PerfUtil.java
index 1918f269..39cface3 100644
--- a/hugegraph-common/src/main/java/org/apache/hugegraph/perf/PerfUtil.java
+++ b/hugegraph-common/src/main/java/org/apache/hugegraph/perf/PerfUtil.java
@@ -361,7 +361,8 @@ public String toECharts() {
sb.append("',");
sb.append("value:");
- sb.append(w.totalCost()); // w.totalCost() - w.totalWasted() ?
+ // w.totalCost() - w.totalWasted() ?
+ sb.append(w.totalCost());
sb.append(',');
sb.append("cost:");
@@ -419,7 +420,7 @@ public String toECharts() {
return c.parent().equals(parent.id());
});
// Fill other cost
- long sumCost = children.mapToLong(c -> c.totalCost()).sum();
+ long sumCost = children.mapToLong(Stopwatch::totalCost).sum();
long otherCost = parent.totalCost() - sumCost;
if (otherCost > 0L) {
Stopwatch other = newStopwatch("~", parent.id());
diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/rest/AbstractRestClient.java b/hugegraph-common/src/main/java/org/apache/hugegraph/rest/AbstractRestClient.java
index 276a8fe0..fd9fdaba 100644
--- a/hugegraph-common/src/main/java/org/apache/hugegraph/rest/AbstractRestClient.java
+++ b/hugegraph-common/src/main/java/org/apache/hugegraph/rest/AbstractRestClient.java
@@ -589,7 +589,7 @@ public ClientConfig build() {
public static class BearerRequestFilter implements ClientRequestFilter {
@Override
- public void filter(ClientRequestContext context) throws IOException {
+ public void filter(ClientRequestContext context) {
String token = context.getClient().getConfiguration()
.getProperty(TOKEN_KEY).toString();
context.getHeaders().add(HttpHeaders.AUTHORIZATION,
diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/util/LongEncoding.java b/hugegraph-common/src/main/java/org/apache/hugegraph/util/LongEncoding.java
index 3488445f..24c857fd 100644
--- a/hugegraph-common/src/main/java/org/apache/hugegraph/util/LongEncoding.java
+++ b/hugegraph-common/src/main/java/org/apache/hugegraph/util/LongEncoding.java
@@ -40,8 +40,7 @@ public static String encodeNumber(Object number) {
public static Number decodeNumber(String str, Class> clazz) {
long value = decodeSortable(str);
- Number number = NumericUtil.sortableLongToNumber(value, clazz);
- return number;
+ return NumericUtil.sortableLongToNumber(value, clazz);
}
public static String encodeSortable(long num) {
@@ -130,10 +129,11 @@ public static long decode(String encoded, String symbols) {
for (char ch : encoded.toCharArray()) {
num *= B;
int pos = symbols.indexOf(ch);
- if (pos < 0)
+ if (pos < 0) {
throw new NumberFormatException(String.format(
"Can't decode symbol '%s' in string '%s'",
ch, encoded));
+ }
num += pos;
}
return num;
diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/util/OrderLimitMap.java b/hugegraph-common/src/main/java/org/apache/hugegraph/util/OrderLimitMap.java
index e286ca93..d8b0cc6f 100644
--- a/hugegraph-common/src/main/java/org/apache/hugegraph/util/OrderLimitMap.java
+++ b/hugegraph-common/src/main/java/org/apache/hugegraph/util/OrderLimitMap.java
@@ -27,7 +27,8 @@
import com.google.common.collect.Ordering;
/**
- * Reference: https://stackoverflow.com/questions/109383/sort-a-mapkey-value-by-values
+ * Reference:
+ * ...
*/
public class OrderLimitMap, V extends Comparable>
extends TreeMap {
diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/util/ReflectionUtil.java b/hugegraph-common/src/main/java/org/apache/hugegraph/util/ReflectionUtil.java
index 85308691..812a962a 100644
--- a/hugegraph-common/src/main/java/org/apache/hugegraph/util/ReflectionUtil.java
+++ b/hugegraph-common/src/main/java/org/apache/hugegraph/util/ReflectionUtil.java
@@ -39,14 +39,11 @@
public final class ReflectionUtil {
public static boolean isSimpleType(Class> type) {
- if (type.isPrimitive() ||
- type.equals(String.class) ||
- type.equals(Boolean.class) ||
- type.equals(Character.class) ||
- NumericUtil.isNumber(type)) {
- return true;
- }
- return false;
+ return type.isPrimitive() ||
+ type.equals(String.class) ||
+ type.equals(Boolean.class) ||
+ type.equals(Character.class) ||
+ NumericUtil.isNumber(type);
}
public static List getMethodsAnnotatedWith(
diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/util/UnitUtil.java b/hugegraph-common/src/main/java/org/apache/hugegraph/util/UnitUtil.java
index 138fed9c..30c1beee 100644
--- a/hugegraph-common/src/main/java/org/apache/hugegraph/util/UnitUtil.java
+++ b/hugegraph-common/src/main/java/org/apache/hugegraph/util/UnitUtil.java
@@ -20,6 +20,7 @@
package org.apache.hugegraph.util;
import java.math.BigDecimal;
+import java.math.RoundingMode;
import java.time.Duration;
public final class UnitUtil {
@@ -34,7 +35,7 @@ public static double bytesToGB(long bytes) {
public static double doubleWith2Scale(double value) {
BigDecimal decimal = new BigDecimal(value);
- return decimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
+ return decimal.setScale(2, RoundingMode.HALF_UP).doubleValue();
}
public static String bytesToReadableString(long bytes) {
diff --git a/hugegraph-common/src/main/java/org/apache/hugegraph/util/VersionUtil.java b/hugegraph-common/src/main/java/org/apache/hugegraph/util/VersionUtil.java
index 4bd76f77..cc98fa1c 100644
--- a/hugegraph-common/src/main/java/org/apache/hugegraph/util/VersionUtil.java
+++ b/hugegraph-common/src/main/java/org/apache/hugegraph/util/VersionUtil.java
@@ -23,6 +23,7 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
+import java.util.Objects;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
@@ -79,7 +80,7 @@ public static String getImplementationVersion(Class> clazz) {
* https://stackoverflow.com/questions/1272648/reading-my-own-jars-manifest
*/
String className = clazz.getSimpleName() + ".class";
- String classPath = clazz.getResource(className).toString();
+ String classPath = Objects.requireNonNull(clazz.getResource(className)).toString();
if (!classPath.startsWith("jar:file:")) {
// Class not from JAR
return null;
diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/testutil/AssertTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/testutil/AssertTest.java
index 7116adc8..0f30bbd2 100644
--- a/hugegraph-common/src/test/java/org/apache/hugegraph/testutil/AssertTest.java
+++ b/hugegraph-common/src/test/java/org/apache/hugegraph/testutil/AssertTest.java
@@ -126,7 +126,7 @@ public void testAssertEqualsOfIntWithError() {
});
Assert.assertThrows(AssertionError.class, () -> {
- Assert.assertEquals(1, (Long) 1l);
+ Assert.assertEquals(1, (Long) 1L);
}, e -> {
Assert.assertContains("expected: java.lang.Integer",
e.getMessage());
@@ -192,9 +192,7 @@ public void testAssertThrowsWithError() {
});
Assert.fail("Expect error");
} catch (AssertionError e) {
- Assert.assertEquals("No exception was thrown" +
- "(expected java.lang.NullPointerException)",
- e.getMessage());
+ Assert.assertContains("java.lang.NullPointerException", e.getMessage());
}
try {
@@ -203,10 +201,8 @@ public void testAssertThrowsWithError() {
});
Assert.fail("Expect error");
} catch (AssertionError e) {
- Assert.assertEquals("Bad exception type " +
- "java.lang.RuntimeException" +
- "(expected java.lang.NullPointerException)",
- e.getMessage());
+ Assert.assertContains("java.lang.NullPointerException", e.getMessage());
+ Assert.assertContains("java.lang.RuntimeException", e.getMessage());
}
}
@@ -254,7 +250,7 @@ public void testAssertGt() {
});
Assert.assertThrows(AssertionError.class, () -> {
- Assert.assertGt(1, Character.valueOf('2'));
+ Assert.assertGt(1, '2');
}, e -> {
Assert.assertContains("Expected: an instance of java.lang.Integer",
e.getMessage());
@@ -312,7 +308,7 @@ public void testAssertGte() {
});
Assert.assertThrows(AssertionError.class, () -> {
- Assert.assertGte(1, Character.valueOf('2'));
+ Assert.assertGte(1, '2');
}, e -> {
Assert.assertContains("Expected: an instance of java.lang.Integer",
e.getMessage());
@@ -342,7 +338,7 @@ public void testAssertLt() {
});
Assert.assertThrows(AssertionError.class, () -> {
- Assert.assertGt(1, Character.valueOf('0'));
+ Assert.assertGt(1, '0');
}, e -> {
Assert.assertContains("Expected: an instance of java.lang.Integer",
e.getMessage());
@@ -379,7 +375,7 @@ public void testAssertLte() {
});
Assert.assertThrows(AssertionError.class, () -> {
- Assert.assertLte(1, Character.valueOf('0'));
+ Assert.assertLte(1, '0');
}, e -> {
Assert.assertContains("Expected: an instance of java.lang.Integer",
e.getMessage());
diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/BarrierEventTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/BarrierEventTest.java
index 64a0d49b..bc69386a 100644
--- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/BarrierEventTest.java
+++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/BarrierEventTest.java
@@ -32,7 +32,7 @@
public class BarrierEventTest {
- private static int WAIT_THREADS_COUNT = 10;
+ private static final int WAIT_THREADS_COUNT = 10;
@Test(timeout = 5000)
public void testAWait() throws InterruptedException {
diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/LockGroupTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/LockGroupTest.java
index 3309a43b..0d0d0643 100644
--- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/LockGroupTest.java
+++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/LockGroupTest.java
@@ -37,7 +37,7 @@ public class LockGroupTest extends BaseUnitTest {
private static final String GROUP = "LockGroupTest-test-group";
- private LockGroup group = new LockGroup(GROUP);
+ private final LockGroup group = new LockGroup(GROUP);
@Test
public void testLock() {
diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/PausableScheduledThreadPoolTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/PausableScheduledThreadPoolTest.java
index fb66741d..a477344d 100644
--- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/PausableScheduledThreadPoolTest.java
+++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/concurrent/PausableScheduledThreadPoolTest.java
@@ -31,7 +31,7 @@
public class PausableScheduledThreadPoolTest {
@Test
- public void testscheduleWithFixedDelay() throws InterruptedException {
+ public void testScheduleWithFixedDelay() throws InterruptedException {
PausableScheduledThreadPool executor =
ExecutorUtil.newPausableScheduledThreadPool("test");
long period = 500L;
@@ -64,7 +64,7 @@ public void testscheduleWithFixedDelay() throws InterruptedException {
}
@Test
- public void testscheduleWithFixedRate() throws InterruptedException {
+ public void testScheduleWithFixedRate() throws InterruptedException {
PausableScheduledThreadPool executor =
ExecutorUtil.newPausableScheduledThreadPool(2, "test");
long period = 500L;
diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/config/HugeConfigTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/config/HugeConfigTest.java
index 01ffb316..7664f784 100644
--- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/config/HugeConfigTest.java
+++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/config/HugeConfigTest.java
@@ -99,8 +99,8 @@ public void testOptionDesc() {
@Test
public void testOptionRequired() {
- Assert.assertEquals(false, TestOptions.text1.required());
- Assert.assertEquals(true, TestSubOptions.text2.required());
+ Assert.assertFalse(TestOptions.text1.required());
+ Assert.assertTrue(TestSubOptions.text2.required());
}
@Test
@@ -670,6 +670,6 @@ protected boolean forList() {
public enum WeekDay {
- SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY;
+ SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY
}
}
diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/event/EventHubTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/event/EventHubTest.java
index c8743e99..b5b15919 100644
--- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/event/EventHubTest.java
+++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/event/EventHubTest.java
@@ -80,12 +80,7 @@ public void testEventGetListenerNonResult() {
public void testEventAddListener() {
final String event = "event-test";
- EventListener listener = new EventListener() {
- @Override
- public Object event(Event arg0) {
- return null;
- }
- };
+ EventListener listener = (Event e) -> null;
this.eventHub.listen(event, listener);
@@ -98,12 +93,7 @@ public Object event(Event arg0) {
public void testEventAddListenerTwice() {
final String event = "event-test";
- EventListener listener = new EventListener() {
- @Override
- public Object event(Event arg0) {
- return null;
- }
- };
+ EventListener listener = (Event e) -> null;
this.eventHub.listen(event, listener);
this.eventHub.listen(event, listener);
@@ -118,12 +108,7 @@ public Object event(Event arg0) {
public void testEventRemoveListener() {
final String event = "event-test";
- EventListener listener = new EventListener() {
- @Override
- public Object event(Event arg0) {
- return null;
- }
- };
+ EventListener listener = (Event e) -> null;
this.eventHub.listen(event, listener);
@@ -141,12 +126,7 @@ public Object event(Event arg0) {
public void testEventRemoveListenerButNonResult() {
final String event = "event-test";
- EventListener listener = new EventListener() {
- @Override
- public Object event(Event arg0) {
- return null;
- }
- };
+ EventListener listener = (Event e) -> null;
this.eventHub.listen(event, listener);
@@ -167,12 +147,7 @@ public void testEventRemoveListenerOfOneInTwo() {
final String event1 = "event-test1";
final String event2 = "event-test2";
- EventListener listener = new EventListener() {
- @Override
- public Object event(Event arg0) {
- return null;
- }
- };
+ EventListener listener = (Event e) -> null;
this.eventHub.listen(event1, listener);
this.eventHub.listen(event2, listener);
@@ -200,19 +175,8 @@ public Object event(Event arg0) {
public void testEventRemoveListenerByEvent() {
final String event = "event-test";
- EventListener listener1 = new EventListener() {
- @Override
- public Object event(Event arg0) {
- return null;
- }
- };
-
- EventListener listener2 = new EventListener() {
- @Override
- public Object event(Event arg0) {
- return null;
- }
- };
+ EventListener listener1 = (Event e) -> null;
+ EventListener listener2 = (Event e) -> null;
this.eventHub.listen(event, listener1);
this.eventHub.listen(event, listener2);
@@ -232,19 +196,8 @@ public Object event(Event arg0) {
public void testEventRemoveListenerByEventButNonResult() {
final String event = "event-test";
- EventListener listener1 = new EventListener() {
- @Override
- public Object event(Event arg0) {
- return null;
- }
- };
-
- EventListener listener2 = new EventListener() {
- @Override
- public Object event(Event arg0) {
- return null;
- }
- };
+ EventListener listener1 = (Event e) -> null;
+ EventListener listener2 = (Event e) -> null;
this.eventHub.listen(event, listener1);
this.eventHub.listen(event, listener2);
@@ -263,12 +216,7 @@ public Object event(Event arg0) {
public void testEventRemoveListenerByEventOf2SameListener() {
final String event = "event-test";
- EventListener listener = new EventListener() {
- @Override
- public Object event(Event arg0) {
- return null;
- }
- };
+ EventListener listener = (Event e) -> null;
this.eventHub.listen(event, listener);
this.eventHub.listen(event, listener);
@@ -446,27 +394,21 @@ public void testEventNotifyWithArg2() {
public void testEventNotifyWithMultiThreads() throws InterruptedException {
final String notify = "event-notify";
- EventListener listener1 = new EventListener() {
- @Override
- public Object event(Event event) {
- Assert.assertEquals(notify, event.name());
- event.checkArgs(Integer.class);
- return null;
- }
+ EventListener listener1 = event -> {
+ Assert.assertEquals(notify, event.name());
+ event.checkArgs(Integer.class);
+ return null;
};
- EventListener listener2 = new EventListener() {
- @Override
- public Object event(Event event) {
- Assert.assertEquals(notify, event.name());
+ EventListener listener2 = event -> {
+ Assert.assertEquals(notify, event.name());
- event.checkArgs(Integer.class);
- int i = (int) event.args()[0];
- if (i % 10000 == 0) {
- System.out.println("On event '" + notify + "': " + i);
- }
- return null;
+ event.checkArgs(Integer.class);
+ int i = (int) event.args()[0];
+ if (i % 10000 == 0) {
+ System.out.println("On event '" + notify + "': " + i);
}
+ return null;
};
Thread listenerUpdateThread = new Thread(() -> {
@@ -503,15 +445,12 @@ public Object event(Event event) {
public void testEventCallWithMultiThreads() {
final String call = "event-call";
- EventListener listener = new EventListener() {
- @Override
- public Object event(Event event) {
- Assert.assertEquals(call, event.name());
+ EventListener listener = event -> {
+ Assert.assertEquals(call, event.name());
- event.checkArgs(Integer.class);
- int i = (int) event.args()[0];
- return i;
- }
+ event.checkArgs(Integer.class);
+ int i = (int) event.args()[0];
+ return i;
};
this.eventHub.listen(call, listener);
diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/BatchMapperIteratorTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/BatchMapperIteratorTest.java
index 40a39a21..78bd08cb 100644
--- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/BatchMapperIteratorTest.java
+++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/BatchMapperIteratorTest.java
@@ -123,12 +123,8 @@ public void testHasNextAndNextWithMultiTimes() {
Assert.assertFalse(results.hasNext());
Assert.assertFalse(results.hasNext());
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results::next);
+ Assert.assertThrows(NoSuchElementException.class, results::next);
}
@Test
@@ -159,9 +155,7 @@ public void testNextWithMultiTimes() {
for (int i = 0; i < 2; i++) {
results.next();
}
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results::next);
}
@Test
@@ -281,12 +275,8 @@ public void testMapperReturnNullThenNext() {
results = new BatchMapperIterator<>(1, DATA3.iterator(), batch -> {
return null;
});
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results::next);
+ Assert.assertThrows(NoSuchElementException.class, results::next);
}
@Test
diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/ExtendableIteratorTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/ExtendableIteratorTest.java
index e753ea8e..fc1e9f3b 100644
--- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/ExtendableIteratorTest.java
+++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/ExtendableIteratorTest.java
@@ -89,9 +89,7 @@ public void testExtendAfterHasNext() {
public void testNext() {
Iterator results = new ExtendableIterator<>(DATA1.iterator());
Assert.assertEquals(1, (int) results.next());
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results::next);
}
@Test
@@ -101,9 +99,7 @@ public void testNextWithMultiTimes() {
Assert.assertEquals(1, (int) results.next());
Assert.assertEquals(2, (int) results.next());
Assert.assertEquals(3, (int) results.next());
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results::next);
}
@Test
@@ -114,9 +110,7 @@ public void testHasNextAndNext() {
Assert.assertEquals(1, (int) results.next());
Assert.assertFalse(results.hasNext());
Assert.assertFalse(results.hasNext());
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results::next);
}
@Test
@@ -143,15 +137,11 @@ public void testRemove() {
@Test
public void testRemoveWithoutResult() {
Iterator results = new ExtendableIterator<>();
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.remove();
- });
+ Assert.assertThrows(NoSuchElementException.class, results::remove);
List list = new ArrayList<>();
Iterator results2 = new ExtendableIterator<>(list.iterator());
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results2.remove();
- });
+ Assert.assertThrows(NoSuchElementException.class, results2::remove);
}
@Test
diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/FilterIteratorTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/FilterIteratorTest.java
index f6c0e175..845c5c64 100644
--- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/FilterIteratorTest.java
+++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/FilterIteratorTest.java
@@ -95,12 +95,8 @@ public void testHasNextAndNextWithMultiTimes() {
Assert.assertFalse(results.hasNext());
Assert.assertFalse(results.hasNext());
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results::next);
+ Assert.assertThrows(NoSuchElementException.class, results::next);
}
@Test
@@ -120,9 +116,7 @@ public void testNextWithMultiTimes() {
for (int i = 0; i < 4; i++) {
results.next();
}
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results::next);
}
@Test
@@ -130,12 +124,8 @@ public void testNextWithMultiTimesWithoutAnyResult() {
Iterator vals = DATA.iterator();
Iterator results = new FilterIterator<>(vals, val -> false);
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results::next);
+ Assert.assertThrows(NoSuchElementException.class, results::next);
}
@Test
diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/FlatMapperFilterIteratorTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/FlatMapperFilterIteratorTest.java
index 536f38a3..5370fe33 100644
--- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/FlatMapperFilterIteratorTest.java
+++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/FlatMapperFilterIteratorTest.java
@@ -94,9 +94,7 @@ public void testHasNext() {
key -> DATA.get(key).iterator(),
val -> false);
Assert.assertFalse(results2.hasNext());
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results2.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results2::next);
}
@Test
@@ -113,12 +111,8 @@ public void testHasNextWithMultiTimes() {
results.next();
}
Assert.assertFalse(results.hasNext());
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results::next);
+ Assert.assertThrows(NoSuchElementException.class, results::next);
Iterator results2 = new FlatMapperFilterIterator<>(keys,
key -> DATA.get(key).iterator(),
@@ -140,9 +134,7 @@ public void testNext() {
Iterator results2 = new FlatMapperFilterIterator<>(keys,
key -> DATA.get(key).iterator(),
val -> false);
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results2.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results2::next);
}
@Test
@@ -155,19 +147,13 @@ public void testNextWithMultiTimes() {
for (int i = 0; i < 10; i++) {
results.next();
}
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results::next);
Iterator results2 = new FlatMapperFilterIterator<>(keys,
key -> DATA.get(key).iterator(),
val -> false);
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results2.next();
- });
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results2.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results2::next);
+ Assert.assertThrows(NoSuchElementException.class, results2::next);
}
@Test
diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/FlatMapperIteratorTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/FlatMapperIteratorTest.java
index 5e5baf46..f286dd47 100644
--- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/FlatMapperIteratorTest.java
+++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/FlatMapperIteratorTest.java
@@ -107,12 +107,8 @@ public void testHasNextAndNextWithMultiTimes() {
Assert.assertFalse(results.hasNext());
Assert.assertFalse(results.hasNext());
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results::next);
+ Assert.assertThrows(NoSuchElementException.class, results::next);
}
@Test
@@ -132,9 +128,7 @@ public void testNextWithMultiTimes() {
for (int i = 0; i < 10; i++) {
results.next();
}
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results::next);
}
@Test
@@ -157,12 +151,8 @@ public void testMapperReturnNullThenNext() {
Assert.assertNull(DATA.get(key));
return null;
});
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results::next);
+ Assert.assertThrows(NoSuchElementException.class, results::next);
}
@Test
diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/LimitIteratorTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/LimitIteratorTest.java
index f806b5e6..9a9f7ca0 100644
--- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/LimitIteratorTest.java
+++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/LimitIteratorTest.java
@@ -95,12 +95,8 @@ public void testHasNextAndNextWithMultiTimes() {
Assert.assertFalse(results.hasNext());
Assert.assertFalse(results.hasNext());
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results::next);
+ Assert.assertThrows(NoSuchElementException.class, results::next);
Iterator results2 = new LimitIterator<>(vals, val -> false);
Assert.assertFalse(results2.hasNext());
@@ -123,9 +119,7 @@ public void testNextWithMultiTimes() {
for (int i = 0; i < 4; i++) {
results.next();
}
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results::next);
}
@Test
@@ -133,12 +127,8 @@ public void testNextWithMultiTimesWithoutAnyResult() {
Iterator vals = DATA.iterator();
Iterator results = new LimitIterator<>(vals, val -> true);
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results::next);
+ Assert.assertThrows(NoSuchElementException.class, results::next);
}
@Test
diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/ListIteratorTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/ListIteratorTest.java
index d8334344..d6949bf5 100644
--- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/ListIteratorTest.java
+++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/ListIteratorTest.java
@@ -100,9 +100,7 @@ public void testHasNext() {
public void testNext() {
Iterator results = new ListIterator<>(-1, DATA1.iterator());
Assert.assertEquals(1, (int) results.next());
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results::next);
}
@Test
@@ -111,9 +109,7 @@ public void testNextAfterList() {
Assert.assertEquals(ImmutableList.of(1),
((ListIterator>) results).list());
Assert.assertEquals(1, (int) results.next());
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results::next);
}
@Test
@@ -121,9 +117,7 @@ public void testNextWithMultiTimes() {
Iterator results = new ListIterator<>(-1, DATA2.iterator());
Assert.assertEquals(2, (int) results.next());
Assert.assertEquals(3, (int) results.next());
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results::next);
}
@Test
@@ -134,9 +128,7 @@ public void testHasNextAndNext() {
Assert.assertEquals(1, (int) results.next());
Assert.assertFalse(results.hasNext());
Assert.assertFalse(results.hasNext());
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results::next);
}
@Test
@@ -147,13 +139,9 @@ public void testRemove() {
Assert.assertEquals(ImmutableList.of(4, 5, 6), list);
Assert.assertEquals(ImmutableList.of(4, 5, 6), results.list());
- Assert.assertThrows(UnsupportedOperationException.class, () -> {
- results.remove();
- });
+ Assert.assertThrows(UnsupportedOperationException.class, results::remove);
results.next();
- Assert.assertThrows(UnsupportedOperationException.class, () -> {
- results.remove();
- });
+ Assert.assertThrows(UnsupportedOperationException.class, results::remove);
Assert.assertEquals(ImmutableList.of(4, 5, 6), list);
Assert.assertEquals(ImmutableList.of(4, 5, 6), results.list());
@@ -162,15 +150,11 @@ public void testRemove() {
@Test
public void testRemoveWithoutResult() {
Iterator results = new ListIterator<>(-1, EMPTY);
- Assert.assertThrows(UnsupportedOperationException.class, () -> {
- results.remove();
- });
+ Assert.assertThrows(UnsupportedOperationException.class, results::remove);
List list0 = new ArrayList<>();
Iterator results2 = new ListIterator<>(-1, list0.iterator());
- Assert.assertThrows(UnsupportedOperationException.class, () -> {
- results2.remove();
- });
+ Assert.assertThrows(UnsupportedOperationException.class, results2::remove);
}
@Test
@@ -207,17 +191,13 @@ public void testListWithConstructFromList() {
public void testHasNextAndNextWithConstructFromList() {
ListIterator results0 = new ListIterator<>(ImmutableList.of());
Assert.assertFalse(results0.hasNext());
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results0.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results0::next);
ListIterator results1 = new ListIterator<>(DATA1);
Assert.assertTrue(results1.hasNext());
Assert.assertEquals(1, results1.next());
Assert.assertFalse(results1.hasNext());
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results1.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results1::next);
ListIterator results3 = new ListIterator<>(DATA3);
Assert.assertTrue(results3.hasNext());
@@ -227,25 +207,19 @@ public void testHasNextAndNextWithConstructFromList() {
Assert.assertTrue(results3.hasNext());
Assert.assertEquals(6, results3.next());
Assert.assertFalse(results3.hasNext());
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results3.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results3::next);
}
@Test
public void testNextWithConstructFromList() {
ListIterator results0 = new ListIterator<>(ImmutableList.of());
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results0.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results0::next);
ListIterator results3 = new ListIterator<>(DATA3);
Assert.assertEquals(4, results3.next());
Assert.assertEquals(5, results3.next());
Assert.assertEquals(6, results3.next());
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results3.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results3::next);
}
@Test
@@ -255,8 +229,6 @@ public void testNextAfterListWithConstructFromList() {
Assert.assertEquals(4, results3.next());
Assert.assertEquals(5, results3.next());
Assert.assertEquals(6, results3.next());
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results3.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results3::next);
}
}
diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/MapperIteratorTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/MapperIteratorTest.java
index 23b2ab07..c8878cab 100644
--- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/MapperIteratorTest.java
+++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/iterator/MapperIteratorTest.java
@@ -46,9 +46,7 @@ public class MapperIteratorTest extends BaseUnitTest {
"forth", 4
);
- private static final Function MAPPER = key -> {
- return DATA.get(key);
- };
+ private static final Function MAPPER = DATA::get;
@Test
public void testMapper() {
@@ -100,12 +98,8 @@ public void testHasNextAndNextWithMultiTimes() {
Assert.assertFalse(results.hasNext());
Assert.assertFalse(results.hasNext());
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results::next);
+ Assert.assertThrows(NoSuchElementException.class, results::next);
}
@Test
@@ -125,9 +119,7 @@ public void testNextWithMultiTimes() {
for (int i = 0; i < 4; i++) {
results.next();
}
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results::next);
}
@Test
@@ -147,9 +139,7 @@ public void testMapperReturnNullThenNext() {
Iterator results = new MapperIterator<>(keys, key -> {
return null;
});
- Assert.assertThrows(NoSuchElementException.class, () -> {
- results.next();
- });
+ Assert.assertThrows(NoSuchElementException.class, results::next);
}
@Test
@@ -157,8 +147,7 @@ public void testClose() throws Exception {
CloseableItor keys = new CloseableItor<>(
ImmutableList.of("fifth").iterator());
- MapperIterator results =
- new MapperIterator<>(keys, k -> null);
+ MapperIterator results = new MapperIterator<>(keys, k -> null);
Assert.assertFalse(keys.closed());
results.close();
diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/perf/StopwatchTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/perf/StopwatchTest.java
index dbbe4823..63ef77d0 100644
--- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/perf/StopwatchTest.java
+++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/perf/StopwatchTest.java
@@ -49,21 +49,21 @@ public void testNormalStopwatchChild() {
Assert.assertEquals(watch4, watch1.child("w4", null));
Assert.assertEquals(watch5, watch1.child("w5", null));
- Assert.assertEquals(null, watch1.child("w2"));
- Assert.assertEquals(null, watch1.child("w3"));
- Assert.assertEquals(null, watch1.child("w4"));
- Assert.assertEquals(null, watch1.child("w5"));
+ Assert.assertNull(watch1.child("w2"));
+ Assert.assertNull(watch1.child("w3"));
+ Assert.assertNull(watch1.child("w4"));
+ Assert.assertNull(watch1.child("w5"));
- Assert.assertEquals(null, watch1.child("w2", watch2));
- Assert.assertEquals(null, watch1.child("w3", watch3));
- Assert.assertEquals(null, watch1.child("w4", watch4));
- Assert.assertEquals(null, watch1.child("w5", watch5));
+ Assert.assertNull(watch1.child("w2", watch2));
+ Assert.assertNull(watch1.child("w3", watch3));
+ Assert.assertNull(watch1.child("w4", watch4));
+ Assert.assertNull(watch1.child("w5", watch5));
watch1.clear();
- Assert.assertEquals(null, watch1.child("w2"));
- Assert.assertEquals(null, watch1.child("w3"));
- Assert.assertEquals(null, watch1.child("w4"));
- Assert.assertEquals(null, watch1.child("w5"));
+ Assert.assertNull(watch1.child("w2"));
+ Assert.assertNull(watch1.child("w3"));
+ Assert.assertNull(watch1.child("w4"));
+ Assert.assertNull(watch1.child("w5"));
}
@Test
@@ -85,20 +85,20 @@ public void testLightStopwatchChild() {
Assert.assertEquals(watch4, watch1.child("w4", null));
Assert.assertEquals(watch5, watch1.child("w5", null));
- Assert.assertEquals(null, watch1.child("w2"));
- Assert.assertEquals(null, watch1.child("w3"));
- Assert.assertEquals(null, watch1.child("w4"));
- Assert.assertEquals(null, watch1.child("w5"));
+ Assert.assertNull(watch1.child("w2"));
+ Assert.assertNull(watch1.child("w3"));
+ Assert.assertNull(watch1.child("w4"));
+ Assert.assertNull(watch1.child("w5"));
- Assert.assertEquals(null, watch1.child("w2", watch2));
- Assert.assertEquals(null, watch1.child("w3", watch3));
- Assert.assertEquals(null, watch1.child("w4", watch4));
- Assert.assertEquals(null, watch1.child("w5", watch5));
+ Assert.assertNull(watch1.child("w2", watch2));
+ Assert.assertNull(watch1.child("w3", watch3));
+ Assert.assertNull(watch1.child("w4", watch4));
+ Assert.assertNull(watch1.child("w5", watch5));
watch1.clear();
- Assert.assertEquals(null, watch1.child("w2"));
- Assert.assertEquals(null, watch1.child("w3"));
- Assert.assertEquals(null, watch1.child("w4"));
- Assert.assertEquals(null, watch1.child("w5"));
+ Assert.assertNull(watch1.child("w2"));
+ Assert.assertNull(watch1.child("w3"));
+ Assert.assertNull(watch1.child("w4"));
+ Assert.assertNull(watch1.child("w5"));
}
}
diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/BytesTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/BytesTest.java
index 0d184a5b..0867a7f7 100644
--- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/BytesTest.java
+++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/BytesTest.java
@@ -63,12 +63,12 @@ public void testBytesPrefixWith() {
@Test
public void testBytesCompare() {
- Assert.assertTrue(Bytes.compare(b("12345678"), b("12345678")) == 0);
+ Assert.assertEquals(0, Bytes.compare(b("12345678"), b("12345678")));
Assert.assertTrue(Bytes.compare(b("12345678"), b("1234567")) > 0);
Assert.assertTrue(Bytes.compare(b("12345678"), b("12345679")) < 0);
- Assert.assertTrue(Bytes.compare(new byte[]{1, 3, 5, 7},
- new byte[]{1, 3, 5, 7}) == 0);
+ Assert.assertEquals(0,
+ Bytes.compare(new byte[]{1, 3, 5, 7}, new byte[]{1, 3, 5, 7}));
Assert.assertTrue(Bytes.compare(new byte[]{1, 3, 5, 7},
new byte[]{1, 3, 5, 6}) > 0);
diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/LongEncodingTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/LongEncodingTest.java
index 7f44340e..a3f1518e 100644
--- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/LongEncodingTest.java
+++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/LongEncodingTest.java
@@ -629,7 +629,7 @@ public void testEncodeSortableThenCompare() {
int cmp = Bytes.compare(encoded1.getBytes(), encoded2.getBytes());
if (num1 == num2) {
- Assert.assertTrue(cmp == 0);
+ Assert.assertEquals(0, cmp);
} else if (num1 > num2) {
Assert.assertTrue(cmp > 0);
} else {
@@ -675,7 +675,7 @@ private static void compareEncodedNumber(Number num1, Number num2) {
int cmp = Bytes.compare(encoded1.getBytes(), encoded2.getBytes());
if (cmpExpected == 0) {
- Assert.assertTrue(cmp == 0);
+ Assert.assertEquals(0, cmp);
} else if (cmpExpected > 0) {
Assert.assertTrue(cmp > 0);
} else {
diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/NumericUtilTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/NumericUtilTest.java
index c6b94b1b..5278427d 100644
--- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/NumericUtilTest.java
+++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/NumericUtilTest.java
@@ -140,7 +140,7 @@ public void testSortableBytesToNumber() {
public void testIntToSortableBytesAndCompare() {
byte[] bytes1 = NumericUtil.numberToSortableBytes(123456);
byte[] bytes2 = NumericUtil.numberToSortableBytes(123456);
- Assert.assertTrue(Bytes.compare(bytes1, bytes2) == 0);
+ Assert.assertEquals(0, Bytes.compare(bytes1, bytes2));
bytes1 = NumericUtil.numberToSortableBytes(1);
bytes2 = NumericUtil.numberToSortableBytes(2);
@@ -156,7 +156,7 @@ public void testIntToSortableBytesAndCompare() {
bytes1 = NumericUtil.numberToSortableBytes(-123456);
bytes2 = NumericUtil.numberToSortableBytes(-123456);
- Assert.assertTrue(Bytes.compare(bytes1, bytes2) == 0);
+ Assert.assertEquals(0, Bytes.compare(bytes1, bytes2));
bytes1 = NumericUtil.numberToSortableBytes(-1);
bytes2 = NumericUtil.numberToSortableBytes(-2);
@@ -191,7 +191,7 @@ public void testIntToSortableBytesAndCompare() {
public void testLongToSortableBytesAndCompare() {
byte[] bytes1 = NumericUtil.numberToSortableBytes(123456L);
byte[] bytes2 = NumericUtil.numberToSortableBytes(123456L);
- Assert.assertTrue(Bytes.compare(bytes1, bytes2) == 0);
+ Assert.assertEquals(0, Bytes.compare(bytes1, bytes2));
bytes1 = NumericUtil.numberToSortableBytes(1L);
bytes2 = NumericUtil.numberToSortableBytes(2L);
@@ -207,7 +207,7 @@ public void testLongToSortableBytesAndCompare() {
bytes1 = NumericUtil.numberToSortableBytes(-123456L);
bytes2 = NumericUtil.numberToSortableBytes(-123456L);
- Assert.assertTrue(Bytes.compare(bytes1, bytes2) == 0);
+ Assert.assertEquals(0, Bytes.compare(bytes1, bytes2));
bytes1 = NumericUtil.numberToSortableBytes(-1L);
bytes2 = NumericUtil.numberToSortableBytes(-2L);
@@ -242,7 +242,7 @@ public void testLongToSortableBytesAndCompare() {
public void testFloatToSortableBytesAndCompare() {
byte[] bytes1 = NumericUtil.numberToSortableBytes(123456F);
byte[] bytes2 = NumericUtil.numberToSortableBytes(123456F);
- Assert.assertTrue(Bytes.compare(bytes1, bytes2) == 0);
+ Assert.assertEquals(0, Bytes.compare(bytes1, bytes2));
bytes1 = NumericUtil.numberToSortableBytes(1F);
bytes2 = NumericUtil.numberToSortableBytes(2F);
@@ -258,7 +258,7 @@ public void testFloatToSortableBytesAndCompare() {
bytes1 = NumericUtil.numberToSortableBytes(-123456F);
bytes2 = NumericUtil.numberToSortableBytes(-123456F);
- Assert.assertTrue(Bytes.compare(bytes1, bytes2) == 0);
+ Assert.assertEquals(0, Bytes.compare(bytes1, bytes2));
bytes1 = NumericUtil.numberToSortableBytes(-1F);
bytes2 = NumericUtil.numberToSortableBytes(-2F);
@@ -293,7 +293,7 @@ public void testFloatToSortableBytesAndCompare() {
public void testDoubleToSortableBytesAndCompare() {
byte[] bytes1 = NumericUtil.numberToSortableBytes(123456D);
byte[] bytes2 = NumericUtil.numberToSortableBytes(123456D);
- Assert.assertTrue(Bytes.compare(bytes1, bytes2) == 0);
+ Assert.assertEquals(0, Bytes.compare(bytes1, bytes2));
bytes1 = NumericUtil.numberToSortableBytes(1D);
bytes2 = NumericUtil.numberToSortableBytes(2D);
@@ -309,7 +309,7 @@ public void testDoubleToSortableBytesAndCompare() {
bytes1 = NumericUtil.numberToSortableBytes(-123456D);
bytes2 = NumericUtil.numberToSortableBytes(-123456D);
- Assert.assertTrue(Bytes.compare(bytes1, bytes2) == 0);
+ Assert.assertEquals(0, Bytes.compare(bytes1, bytes2));
bytes1 = NumericUtil.numberToSortableBytes(-1D);
bytes2 = NumericUtil.numberToSortableBytes(-2D);
@@ -392,28 +392,28 @@ public void testMaxValueOf() {
@Test
public void testIsNumber() {
- Assert.assertEquals(true, NumericUtil.isNumber(byte.class));
- Assert.assertEquals(true, NumericUtil.isNumber(Byte.class));
- Assert.assertEquals(true, NumericUtil.isNumber(short.class));
- Assert.assertEquals(true, NumericUtil.isNumber(Short.class));
- Assert.assertEquals(true, NumericUtil.isNumber(int.class));
- Assert.assertEquals(true, NumericUtil.isNumber(Integer.class));
- Assert.assertEquals(true, NumericUtil.isNumber(long.class));
- Assert.assertEquals(true, NumericUtil.isNumber(Long.class));
- Assert.assertEquals(true, NumericUtil.isNumber(float.class));
- Assert.assertEquals(true, NumericUtil.isNumber(Float.class));
- Assert.assertEquals(true, NumericUtil.isNumber(double.class));
- Assert.assertEquals(true, NumericUtil.isNumber(Double.class));
-
- Assert.assertEquals(false, NumericUtil.isNumber(char.class));
- Assert.assertEquals(false, NumericUtil.isNumber(Character.class));
-
- Assert.assertEquals(true, NumericUtil.isNumber(1));
- Assert.assertEquals(true, NumericUtil.isNumber(1L));
- Assert.assertEquals(true, NumericUtil.isNumber(1.0f));
- Assert.assertEquals(true, NumericUtil.isNumber(1.0d));
- Assert.assertEquals(false, NumericUtil.isNumber('1'));
- Assert.assertEquals(false, NumericUtil.isNumber((Object) null));
+ Assert.assertTrue(NumericUtil.isNumber(byte.class));
+ Assert.assertTrue(NumericUtil.isNumber(Byte.class));
+ Assert.assertTrue(NumericUtil.isNumber(short.class));
+ Assert.assertTrue(NumericUtil.isNumber(Short.class));
+ Assert.assertTrue(NumericUtil.isNumber(int.class));
+ Assert.assertTrue(NumericUtil.isNumber(Integer.class));
+ Assert.assertTrue(NumericUtil.isNumber(long.class));
+ Assert.assertTrue(NumericUtil.isNumber(Long.class));
+ Assert.assertTrue(NumericUtil.isNumber(float.class));
+ Assert.assertTrue(NumericUtil.isNumber(Float.class));
+ Assert.assertTrue(NumericUtil.isNumber(double.class));
+ Assert.assertTrue(NumericUtil.isNumber(Double.class));
+
+ Assert.assertFalse(NumericUtil.isNumber(char.class));
+ Assert.assertFalse(NumericUtil.isNumber(Character.class));
+
+ Assert.assertTrue(NumericUtil.isNumber(1));
+ Assert.assertTrue(NumericUtil.isNumber(1L));
+ Assert.assertTrue(NumericUtil.isNumber(1.0f));
+ Assert.assertTrue(NumericUtil.isNumber(1.0d));
+ Assert.assertFalse(NumericUtil.isNumber('1'));
+ Assert.assertFalse(NumericUtil.isNumber((Object) null));
}
@Test
@@ -421,13 +421,13 @@ public void testConvertToNumber() {
Assert.assertEquals(1, NumericUtil.convertToNumber(1));
Assert.assertEquals(1.2, NumericUtil.convertToNumber(1.2));
- Assert.assertEquals(new BigDecimal(1.25),
+ Assert.assertEquals(new BigDecimal("1.25"),
NumericUtil.convertToNumber("1.25"));
Date date = new Date();
Assert.assertEquals(date.getTime(), NumericUtil.convertToNumber(date));
- Assert.assertEquals(null, NumericUtil.convertToNumber(null));
+ Assert.assertNull(NumericUtil.convertToNumber(null));
}
@Test
diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/ReflectionUtilTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/ReflectionUtilTest.java
index b400f529..6c5e6209 100644
--- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/ReflectionUtilTest.java
+++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/ReflectionUtilTest.java
@@ -122,7 +122,7 @@ public void testNestedClasses() throws NotFoundException {
List classes = ReflectionUtil.nestedClasses(
TestClass.class.getName());
Assert.assertEquals(5, classes.size());
- classes.sort((c1, c2) -> c1.compareTo(c2));
+ classes.sort(String::compareTo);
Assert.assertEquals(Bar.class.getName(), classes.get(0));
Assert.assertEquals(Base.class.getName(), classes.get(1));
Assert.assertEquals(Foo.class.getName(), classes.get(2));
diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/StringUtilTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/StringUtilTest.java
index bd4e962e..d271ae93 100644
--- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/StringUtilTest.java
+++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/StringUtilTest.java
@@ -20,13 +20,14 @@
package org.apache.hugegraph.unit.util;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
-import org.junit.Test;
-
+import org.apache.hugegraph.testutil.Assert;
import org.apache.hugegraph.util.StringUtil;
import org.apache.hugegraph.util.StringUtil.Chars;
-import org.apache.hugegraph.testutil.Assert;
+import org.junit.Test;
+
import com.google.common.base.Splitter;
public class StringUtilTest {
@@ -155,9 +156,7 @@ private static List guavaSplit(String line, String delimiter) {
private static List toStringList(String[] stringArray) {
List results = new ArrayList<>(stringArray.length);
- for (String str : stringArray) {
- results.add(str);
- }
+ Collections.addAll(results, stringArray);
return results;
}
}
diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/UnitUtilTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/UnitUtilTest.java
index fd146b8f..8b383034 100644
--- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/UnitUtilTest.java
+++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/UnitUtilTest.java
@@ -33,7 +33,7 @@ public void testBytesToMB() {
Assert.assertEquals(0d, value, 0d);
// KB
- value = UnitUtil.bytesToMB(Bytes.KB * 1);
+ value = UnitUtil.bytesToMB(1 * Bytes.KB);
Assert.assertEquals(0d, value, 0d);
value = UnitUtil.bytesToMB(Bytes.KB * 10);
@@ -86,7 +86,7 @@ public void testBytesToGB() {
Assert.assertEquals(0d, value, 0d);
// MB
- value = UnitUtil.bytesToGB(Bytes.MB * 1);
+ value = UnitUtil.bytesToGB(1 * Bytes.MB);
Assert.assertEquals(0d, value, 0d);
value = UnitUtil.bytesToGB(Bytes.MB * 10);
diff --git a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/VersionUtilTest.java b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/VersionUtilTest.java
index 6ed04505..b405e7da 100644
--- a/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/VersionUtilTest.java
+++ b/hugegraph-common/src/test/java/org/apache/hugegraph/unit/util/VersionUtilTest.java
@@ -133,8 +133,7 @@ public void testGetImplementationVersion() throws MalformedURLException {
VersionUtil.getImplementationVersion(manifestPath));
manifestPath = "file:./src/test/resources2";
- Assert.assertEquals(null,
- VersionUtil.getImplementationVersion(manifestPath));
+ Assert.assertNull(VersionUtil.getImplementationVersion(manifestPath));
}
@Test
diff --git a/hugegraph-rpc/pom.xml b/hugegraph-rpc/pom.xml
index ba61ba63..2a29065c 100644
--- a/hugegraph-rpc/pom.xml
+++ b/hugegraph-rpc/pom.xml
@@ -27,7 +27,7 @@
hugegraph-rpc
- ${artifactId}
+ ${project.artifactId}
HugeGraph RPC component
@@ -104,7 +104,6 @@
maven-compiler-plugin
- 3.1
${compiler.target}
@@ -119,7 +118,6 @@
org.apache.maven.plugins
maven-jar-plugin
- 2.6
true
@@ -174,7 +172,6 @@
org.apache.maven.plugins
maven-source-plugin
- 2.2.1
attach-sources
@@ -187,7 +184,6 @@
org.apache.maven.plugins
maven-javadoc-plugin
- 2.9.1
attach-javadocs
@@ -200,7 +196,6 @@
org.apache.maven.plugins
maven-gpg-plugin
- 1.5
sign-artifacts
diff --git a/hugegraph-rpc/src/main/java/org/apache/hugegraph/rpc/RpcServiceConfig4Server.java b/hugegraph-rpc/src/main/java/org/apache/hugegraph/rpc/RpcServiceConfig4Server.java
index 03593504..0deabfd2 100644
--- a/hugegraph-rpc/src/main/java/org/apache/hugegraph/rpc/RpcServiceConfig4Server.java
+++ b/hugegraph-rpc/src/main/java/org/apache/hugegraph/rpc/RpcServiceConfig4Server.java
@@ -23,8 +23,7 @@ public interface RpcServiceConfig4Server {
String addService(Class clazz, S serviceImpl);
- String addService(String graph,
- Class clazz, S serviceImpl);
+ String addService(String graph, Class clazz, S serviceImpl);
void removeService(String serviceId);
diff --git a/hugegraph-rpc/src/test/java/org/apache/hugegraph/unit/ServerClientTest.java b/hugegraph-rpc/src/test/java/org/apache/hugegraph/unit/ServerClientTest.java
index 7f73a9af..8daa37e1 100644
--- a/hugegraph-rpc/src/test/java/org/apache/hugegraph/unit/ServerClientTest.java
+++ b/hugegraph-rpc/src/test/java/org/apache/hugegraph/unit/ServerClientTest.java
@@ -54,7 +54,7 @@ public static void init() {
}
@AfterClass
- public static void clear() throws Exception {
+ public static void clear() {
if (rpcClient != null) {
rpcClient.destroy();
}
@@ -711,13 +711,13 @@ public void testInitRpcConfigs() {
RpcCommonConfig.initRpcConfigs(RpcOptions.CONSUMER_RETRIES, 2);
}
- public static interface HelloService {
+ public interface HelloService {
- public String hello(String string);
+ String hello(String string);
- public String echo(String string);
+ String echo(String string);
- public double sum(long a, double b);
+ double sum(long a, double b);
}
public static class HelloServiceImpl implements HelloService {
diff --git a/pom.xml b/pom.xml
index c49e83ec..0f405cff 100644
--- a/pom.xml
+++ b/pom.xml
@@ -60,21 +60,21 @@
${project.basedir}/..
1.8
1.8
- 2.17.0
+ 2.18.0
1.10
- 2.3
+ 2.8.0
1.9.4
3.2.2
2.7
- 1.11
- 25.1-jre
+ 1.13
+ 30.0-jre
1.0
3.0.1
3.28.0-GA
3.0.3
3.0.3
- 2.12.1
- 4.12
+ 2.14.0-rc1
+ 4.13.1
4.1.0
4.0.0-RC2
3.0.2