You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2015/05/22 17:53:50 UTC
[1/2] incubator-tinkerpop git commit: Extract out helper function to
validate that a utility class is properly defined.
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/master f069cdf6a -> 0d2bdb0c8
Extract out helper function to validate that a utility class is properly defined.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/0d2bdb0c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/0d2bdb0c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/0d2bdb0c
Branch: refs/heads/master
Commit: 0d2bdb0c82d71e7fc6d6d578aa898fe0f2013d6d
Parents: a016642
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri May 22 11:52:20 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri May 22 11:53:35 2015 -0400
----------------------------------------------------------------------
.../apache/tinkerpop/gremlin/TestHelper.java | 37 ++++++++++++++++++++
.../util/iterator/IteratorUtilsTest.java | 8 ++---
.../gremlin/util/tools/MultiMapTest.java | 8 +++++
3 files changed, 48 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/0d2bdb0c/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/TestHelper.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/TestHelper.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/TestHelper.java
new file mode 100644
index 0000000..c3d7def
--- /dev/null
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/TestHelper.java
@@ -0,0 +1,37 @@
+/*
+ * 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.tinkerpop.gremlin;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+
+import static org.junit.Assert.assertTrue;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public final class TestHelper {
+ public static void assertIsUtilityClass(final Class<?> utilityClass) throws Exception {
+ final Constructor constructor = utilityClass.getDeclaredConstructor();
+ assertTrue(Modifier.isFinal(utilityClass.getModifiers()));
+ assertTrue(Modifier.isPrivate(constructor.getModifiers()));
+ constructor.setAccessible(true);
+ constructor.newInstance();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/0d2bdb0c/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/iterator/IteratorUtilsTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/iterator/IteratorUtilsTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/iterator/IteratorUtilsTest.java
index 7aacbce..47f99dc 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/iterator/IteratorUtilsTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/iterator/IteratorUtilsTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.tinkerpop.gremlin.util.iterator;
+import org.apache.tinkerpop.gremlin.TestHelper;
import org.apache.tinkerpop.gremlin.process.traversal.util.FastNoSuchElementException;
import org.junit.Test;
@@ -55,11 +56,8 @@ public class IteratorUtilsTest {
}
@Test
- public void shouldHavePrivateConstructor() throws Exception {
- final Constructor<IteratorUtils> constructor = IteratorUtils.class.getDeclaredConstructor();
- assertTrue(Modifier.isPrivate(constructor.getModifiers()));
- constructor.setAccessible(true);
- constructor.newInstance();
+ public void shouldBeUtilityClass() throws Exception {
+ TestHelper.assertIsUtilityClass(IteratorUtils.class);
}
@Test
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/0d2bdb0c/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/tools/MultiMapTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/tools/MultiMapTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/tools/MultiMapTest.java
index 6f65bb0..0c2ad17 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/tools/MultiMapTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/tools/MultiMapTest.java
@@ -18,6 +18,8 @@
*/
package org.apache.tinkerpop.gremlin.util.tools;
+import org.apache.tinkerpop.gremlin.TestHelper;
+import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
import org.junit.Test;
import java.util.Collections;
@@ -34,6 +36,12 @@ import static org.junit.Assert.assertEquals;
* @author Stephen Mallette (http://stephen.genoprime.com)
*/
public class MultiMapTest {
+
+ @Test
+ public void shouldBeUtilityClass() throws Exception {
+ TestHelper.assertIsUtilityClass(MultiMap.class);
+ }
+
@Test
public void shouldPutValueInNewSet() {
final Map<String,Set<Object>> multi = new HashMap<>();
[2/2] incubator-tinkerpop git commit: Finalize MultiMap and add
private constructor since it is a utility class.
Posted by sp...@apache.org.
Finalize MultiMap and add private constructor since it is a utility class.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/a016642a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/a016642a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/a016642a
Branch: refs/heads/master
Commit: a016642ace8f20bb9519924c3e930269feaef762
Parents: f069cdf
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri May 22 11:51:41 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri May 22 11:53:35 2015 -0400
----------------------------------------------------------------------
.../java/org/apache/tinkerpop/gremlin/util/tools/MultiMap.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a016642a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/tools/MultiMap.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/tools/MultiMap.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/tools/MultiMap.java
index 27ba192..749fa43 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/tools/MultiMap.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/tools/MultiMap.java
@@ -30,7 +30,9 @@ import java.util.Set;
*
* @author Matthias Broecheler (me@matthiasb.com)
*/
-public class MultiMap {
+public final class MultiMap {
+
+ private MultiMap() {}
public static <K, V> boolean putAll(final Map<K, Set<V>> map, final K key, final Collection<V> values) {
return getMapSet(map, key).addAll(values);