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/21 21:55:15 UTC
[01/11] incubator-tinkerpop git commit: Add test for HashMapSupplier.
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/master f0f6d0fa5 -> 65de05dd4
Add test for HashMapSupplier.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/efd895c3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/efd895c3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/efd895c3
Branch: refs/heads/master
Commit: efd895c31029b2cdefec9f700444621ad41c5be8
Parents: 9fd4c55
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 21 14:42:34 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu May 21 15:55:03 2015 -0400
----------------------------------------------------------------------
.../util/function/HashMapSupplierTest.java | 55 ++++++++++++++++++++
1 file changed, 55 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/efd895c3/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/HashMapSupplierTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/HashMapSupplierTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/HashMapSupplierTest.java
new file mode 100644
index 0000000..069f78f
--- /dev/null
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/HashMapSupplierTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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.util.function;
+
+import org.junit.Test;
+
+import java.util.HashMap;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class HashMapSupplierTest {
+ @Test
+ public void shouldSupplyHashMap() {
+ assertEquals(0, HashMapSupplier.instance().get().size());
+ }
+
+ @Test
+ public void shouldSupplyHashMapInstance() {
+ assertEquals(0, HashMapSupplier.instance().get().size());
+ assertThat(HashMapSupplier.instance().get(), instanceOf(HashMap.class));
+ }
+
+ @Test
+ public void shouldSupplyNewHashMapOnEachInvocation() {
+ final HashMap<Object,Object> l1 = HashMapSupplier.instance().get();
+ final HashMap<Object,Object> l2 = HashMapSupplier.instance().get();
+ final HashMap<Object,Object> l3 = HashMapSupplier.instance().get();
+
+ assertNotSame(l1, l2);
+ assertNotSame(l1, l3);
+ assertNotSame(l2, l3);
+ }
+}
[09/11] incubator-tinkerpop git commit: Add tests for FunctionUtils.
Posted by sp...@apache.org.
Add tests for FunctionUtils.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/fe83dc8d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/fe83dc8d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/fe83dc8d
Branch: refs/heads/master
Commit: fe83dc8d1818842b19ae3802d4591eb1959950f3
Parents: 63e3e5a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 21 15:35:54 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu May 21 15:55:04 2015 -0400
----------------------------------------------------------------------
.../util/function/FunctionUtilsTest.java | 135 +++++++++++++++++++
1 file changed, 135 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/fe83dc8d/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/FunctionUtilsTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/FunctionUtilsTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/FunctionUtilsTest.java
new file mode 100644
index 0000000..4a8778d
--- /dev/null
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/FunctionUtilsTest.java
@@ -0,0 +1,135 @@
+/*
+ * 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.util.function;
+
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class FunctionUtilsTest {
+ @Test
+ public void shouldWrapInRuntimeIfFunctionThrows() {
+ final Exception t = new Exception();
+ try {
+ FunctionUtils.wrapFunction(FunctionUtilsTest::throwIt).apply(t);
+ } catch (Exception ex) {
+ assertThat(ex, instanceOf(RuntimeException.class));
+ assertSame(t, ex.getCause());
+ }
+ }
+
+ @Test
+ public void shouldNoReWrapInRuntimeIfFunctionThrows() {
+ final Exception t = new RuntimeException();
+ try {
+ FunctionUtils.wrapFunction(FunctionUtilsTest::throwIt).apply(t);
+ } catch (Exception ex) {
+ assertThat(ex, instanceOf(RuntimeException.class));
+ assertNull(ex.getCause());
+ }
+ }
+
+ @Test
+ public void shouldWrapInRuntimeIfConsumerThrows() {
+ final Exception t = new Exception();
+ try {
+ FunctionUtils.wrapConsumer((Exception a) -> {
+ throw a;
+ }).accept(t);
+ } catch (Exception ex) {
+ assertThat(ex, instanceOf(RuntimeException.class));
+ assertSame(t, ex.getCause());
+ }
+ }
+
+ @Test
+ public void shouldNoReWrapInRuntimeIfConsumerThrows() {
+ final Exception t = new RuntimeException();
+ try {
+ FunctionUtils.wrapConsumer((Exception a) -> {
+ throw a;
+ }).accept(t);
+ } catch (Exception ex) {
+ assertThat(ex, instanceOf(RuntimeException.class));
+ assertNull(ex.getCause());
+ }
+ }
+
+ @Test
+ public void shouldWrapInRuntimeIfBiConsumerThrows() {
+ final Exception t = new Exception();
+ try {
+ FunctionUtils.wrapBiConsumer((Exception a, String x) -> {
+ throw a;
+ }).accept(t, "test");
+ } catch (Exception ex) {
+ assertThat(ex, instanceOf(RuntimeException.class));
+ assertSame(t, ex.getCause());
+ }
+ }
+
+ @Test
+ public void shouldNoReWrapInRuntimeIfBiConsumerThrows() {
+ final Exception t = new RuntimeException();
+ try {
+ FunctionUtils.wrapBiConsumer((Exception a, String x) -> {
+ throw a;
+ }).accept(t, "test");
+ } catch (Exception ex) {
+ assertThat(ex, instanceOf(RuntimeException.class));
+ assertNull(ex.getCause());
+ }
+ }
+
+ @Test
+ public void shouldWrapInRuntimeIfSupplierThrows() {
+ final Exception t = new Exception();
+ try {
+ FunctionUtils.wrapSupplier(() -> {
+ throw t;
+ }).get();
+ } catch (Exception ex) {
+ assertThat(ex, instanceOf(RuntimeException.class));
+ assertSame(t, ex.getCause());
+ }
+ }
+
+ @Test
+ public void shouldNoReWrapInRuntimeIfSupplierThrows() {
+ final Exception t = new RuntimeException();
+ try {
+ FunctionUtils.wrapSupplier(() -> {
+ throw t;
+ }).get();
+ } catch (Exception ex) {
+ assertThat(ex, instanceOf(RuntimeException.class));
+ assertNull(ex.getCause());
+ }
+ }
+
+ static int throwIt(final Exception t) throws Exception {
+ throw t;
+ }
+}
[10/11] incubator-tinkerpop git commit: Author tag was not in the
right place.
Posted by sp...@apache.org.
Author tag was not in the right place.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/e874ecbd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/e874ecbd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/e874ecbd
Branch: refs/heads/master
Commit: e874ecbdea62fcaa9090d54c03bfa48f289f8b79
Parents: 367c7f9
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 21 14:56:50 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu May 21 15:55:04 2015 -0400
----------------------------------------------------------------------
.../gremlin/util/function/MeanNumberSupplier.java | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e874ecbd/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/MeanNumberSupplier.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/MeanNumberSupplier.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/MeanNumberSupplier.java
index dbc47eb..3f8b8d6 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/MeanNumberSupplier.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/MeanNumberSupplier.java
@@ -18,22 +18,19 @@
*/
package org.apache.tinkerpop.gremlin.util.function;
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-
import org.apache.tinkerpop.gremlin.process.traversal.step.map.MeanGlobalStep;
import java.io.Serializable;
import java.util.function.Supplier;
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
public final class MeanNumberSupplier implements Supplier<MeanGlobalStep.MeanNumber>, Serializable {
private static final MeanNumberSupplier INSTANCE = new MeanNumberSupplier();
- private MeanNumberSupplier() {
-
- }
+ private MeanNumberSupplier() {}
@Override
public MeanGlobalStep.MeanNumber get() {
[02/11] incubator-tinkerpop git commit: Add tests for HashSetSupplier.
Posted by sp...@apache.org.
Add tests for HashSetSupplier.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/9fd4c551
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/9fd4c551
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/9fd4c551
Branch: refs/heads/master
Commit: 9fd4c55129ad0e6f528594894bb6d53438c8a0e1
Parents: 214a54d
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 21 14:40:05 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu May 21 15:55:03 2015 -0400
----------------------------------------------------------------------
.../util/function/HashSetSupplierTest.java | 55 ++++++++++++++++++++
1 file changed, 55 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/9fd4c551/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/HashSetSupplierTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/HashSetSupplierTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/HashSetSupplierTest.java
new file mode 100644
index 0000000..b583c94
--- /dev/null
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/HashSetSupplierTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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.util.function;
+
+import org.junit.Test;
+
+import java.util.HashSet;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class HashSetSupplierTest {
+ @Test
+ public void shouldSupplyHashSet() {
+ assertEquals(0, HashSetSupplier.instance().get().size());
+ }
+
+ @Test
+ public void shouldSupplyHashSetInstance() {
+ assertEquals(0, HashSetSupplier.instance().get().size());
+ assertThat(HashSetSupplier.instance().get(), instanceOf(HashSet.class));
+ }
+
+ @Test
+ public void shouldSupplyNewHashSetOnEachInvocation() {
+ final HashSet<Object> l1 = HashSetSupplier.instance().get();
+ final HashSet<Object> l2 = HashSetSupplier.instance().get();
+ final HashSet<Object> l3 = HashSetSupplier.instance().get();
+
+ assertNotSame(l1, l2);
+ assertNotSame(l1, l3);
+ assertNotSame(l2, l3);
+ }
+}
[03/11] incubator-tinkerpop git commit: Corrected bug in test and
adjusted test names.
Posted by sp...@apache.org.
Corrected bug in test and adjusted test names.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/214a54db
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/214a54db
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/214a54db
Branch: refs/heads/master
Commit: 214a54dbb311602c7082b0bbcf67cc39d440baff
Parents: d57326c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 21 14:39:15 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu May 21 15:55:03 2015 -0400
----------------------------------------------------------------------
.../gremlin/util/function/BulkSetSupplierTest.java | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/214a54db/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/BulkSetSupplierTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/BulkSetSupplierTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/BulkSetSupplierTest.java
index 4a91798..b49b766 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/BulkSetSupplierTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/BulkSetSupplierTest.java
@@ -21,9 +21,6 @@ package org.apache.tinkerpop.gremlin.util.function;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.BulkSet;
import org.junit.Test;
-import java.util.ArrayList;
-import java.util.List;
-
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
@@ -34,18 +31,18 @@ import static org.junit.Assert.assertNotSame;
*/
public class BulkSetSupplierTest {
@Test
- public void shouldSupplyEmptyList() {
+ public void shouldSupplyBulkSet() {
assertEquals(0, BulkSetSupplier.instance().get().size());
}
@Test
- public void shouldSupplyAnArrayListInstance() {
+ public void shouldSupplyBulkSetInstance() {
assertEquals(0, BulkSetSupplier.instance().get().size());
- assertThat(ArrayListSupplier.instance().get(), instanceOf(BulkSet.class));
+ assertThat(BulkSetSupplier.instance().get(), instanceOf(BulkSet.class));
}
@Test
- public void shouldSupplyNewListOnEachInvocation() {
+ public void shouldSupplyNewBulkSetOnEachInvocation() {
final BulkSet<Object> l1 = BulkSetSupplier.instance().get();
final BulkSet<Object> l2 = BulkSetSupplier.instance().get();
final BulkSet<Object> l3 = BulkSetSupplier.instance().get();
[11/11] incubator-tinkerpop git commit: This class is no longer used.
Posted by sp...@apache.org.
This class is no longer used.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/65de05dd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/65de05dd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/65de05dd
Branch: refs/heads/master
Commit: 65de05dd40dce3402ebb56e9d798e9d752d0c18f
Parents: fe83dc8
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 21 15:44:31 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu May 21 15:55:04 2015 -0400
----------------------------------------------------------------------
.../util/function/CloningUnaryOperator.java | 49 --------------------
1 file changed, 49 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/65de05dd/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/CloningUnaryOperator.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/CloningUnaryOperator.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/CloningUnaryOperator.java
deleted file mode 100644
index 85df187..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/function/CloningUnaryOperator.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.util.function;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.function.UnaryOperator;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public final class CloningUnaryOperator<A> implements UnaryOperator<A>, Serializable {
-
- private static final CloningUnaryOperator INSTANCE = new CloningUnaryOperator();
-
- private CloningUnaryOperator() {
- }
-
- @Override
- public A apply(final A a) {
- if (a instanceof HashMap)
- return (A) ((HashMap) a).clone();
- else if (a instanceof HashSet)
- return (A) ((HashSet) a).clone();
- else
- throw new IllegalArgumentException("The provided class is not registered for cloning: " + a.getClass());
- }
-
- public static <A> CloningUnaryOperator<A> instance() {
- return INSTANCE;
- }
-}
[06/11] incubator-tinkerpop git commit: Add tests for
ConstantSupplier.
Posted by sp...@apache.org.
Add tests for ConstantSupplier.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/8f92f41f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/8f92f41f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/8f92f41f
Branch: refs/heads/master
Commit: 8f92f41f4da8a1a1e4cb347a29eae026ecfde727
Parents: efd895c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 21 14:47:31 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu May 21 15:55:04 2015 -0400
----------------------------------------------------------------------
.../util/function/ConstantSupplierTest.java | 47 ++++++++++++++++++++
1 file changed, 47 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/8f92f41f/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/ConstantSupplierTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/ConstantSupplierTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/ConstantSupplierTest.java
new file mode 100644
index 0000000..6863d8d
--- /dev/null
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/ConstantSupplierTest.java
@@ -0,0 +1,47 @@
+/*
+ * 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.util.function;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class ConstantSupplierTest {
+ private final ConstantSupplier<String> constant = new ConstantSupplier<>("test");
+
+ @Test
+ public void shouldSupplyConstant() {
+ assertEquals("test", constant.get());
+ }
+
+ @Test
+ public void shouldSupplySameConstantOnEachInvocation() {
+ final String l1 = constant.get();
+ final String l2 = constant.get();
+ final String l3 = constant.get();
+
+ assertSame(l1, l2);
+ assertSame(l1, l3);
+ assertSame(l2, l3);
+ }
+}
[07/11] incubator-tinkerpop git commit: Add tests for
MeanNumberSupplier.
Posted by sp...@apache.org.
Add tests for MeanNumberSupplier.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/367c7f96
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/367c7f96
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/367c7f96
Branch: refs/heads/master
Commit: 367c7f966bace51e7fdbb4c1a883cce83d9e6c20
Parents: 8f92f41
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 21 14:56:06 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu May 21 15:55:04 2015 -0400
----------------------------------------------------------------------
.../util/function/MeanNumberSupplierTest.java | 50 ++++++++++++++++++++
1 file changed, 50 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/367c7f96/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/MeanNumberSupplierTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/MeanNumberSupplierTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/MeanNumberSupplierTest.java
new file mode 100644
index 0000000..08b3e56
--- /dev/null
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/MeanNumberSupplierTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.util.function;
+
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.MeanGlobalStep;
+import org.junit.Test;
+
+import java.util.HashSet;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class MeanNumberSupplierTest {
+ @Test
+ public void shouldSupplyMeanNumberInstance() {
+ assertThat(MeanNumberSupplier.instance().get(), instanceOf(MeanGlobalStep.MeanNumber.class));
+ }
+
+ @Test
+ public void shouldSupplyNewMeanNumberOnEachInvocation() {
+ final MeanGlobalStep.MeanNumber l1 = MeanNumberSupplier.instance().get();
+ final MeanGlobalStep.MeanNumber l2 = MeanNumberSupplier.instance().get();
+ final MeanGlobalStep.MeanNumber l3 = MeanNumberSupplier.instance().get();
+
+ assertNotSame(l1, l2);
+ assertNotSame(l1, l3);
+ assertNotSame(l2, l3);
+ }
+}
[05/11] incubator-tinkerpop git commit: Add tests for
ScriptEngineLambdaSupplier.
Posted by sp...@apache.org.
Add tests for ScriptEngineLambdaSupplier.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/63e3e5a3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/63e3e5a3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/63e3e5a3
Branch: refs/heads/master
Commit: 63e3e5a34a5a421402e3a03aedc49694298e257b
Parents: e88ce99
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 21 15:17:50 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu May 21 15:55:04 2015 -0400
----------------------------------------------------------------------
.../util/function/ScriptEngineLambdaTest.java | 93 ++++++++++++++++++++
1 file changed, 93 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/63e3e5a3/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/ScriptEngineLambdaTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/ScriptEngineLambdaTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/ScriptEngineLambdaTest.java
new file mode 100644
index 0000000..5e70c6a
--- /dev/null
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/ScriptEngineLambdaTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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.util.function;
+
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class ScriptEngineLambdaTest {
+
+ @Test
+ public void shouldCallAsFunction() {
+ final ScriptEngineLambda lambda = new ScriptEngineLambda("nashorn", "1+a");
+ assertEquals(11.0, lambda.apply(10));
+ }
+
+ @Test
+ public void shouldCallAsSupplier() {
+ final ScriptEngineLambda lambda = new ScriptEngineLambda("nashorn", "11");
+ assertEquals(11, lambda.get());
+ }
+
+ @Test
+ public void shouldCallAsPredicate() {
+ final ScriptEngineLambda lambda = new ScriptEngineLambda("nashorn", "a > 10");
+ assertThat(lambda.test(100), is(true));
+ }
+
+ @Test
+ public void shouldCallAsConsumer() {
+ final ScriptEngineLambda lambda = new ScriptEngineLambda("nashorn", "a.setData('test')");
+ final Junk junk = new Junk();
+ lambda.accept(junk);
+ assertEquals("test", junk.getData());
+ }
+
+ @Test
+ public void shouldCallAsBiConsumer() {
+ final ScriptEngineLambda lambda = new ScriptEngineLambda("nashorn", "a.setData('testa');b.setData('testb')");
+ final Junk junkA = new Junk();
+ final Junk junkB = new Junk();
+ lambda.accept(junkA, junkB);
+
+ assertEquals("testa", junkA.getData());
+ assertEquals("testb", junkB.getData());
+ }
+
+ @Test
+ public void shouldCallAsTriConsumer() {
+ final ScriptEngineLambda lambda = new ScriptEngineLambda("nashorn", "a.setData('testa');b.setData('testb');c.setData('testc')");
+ final Junk junkA = new Junk();
+ final Junk junkB = new Junk();
+ final Junk junkC = new Junk();
+ lambda.accept(junkA, junkB, junkC);
+
+ assertEquals("testa", junkA.getData());
+ assertEquals("testb", junkB.getData());
+ assertEquals("testc", junkC.getData());
+ }
+
+ public static class Junk {
+ private String data = "";
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(final String x) {
+ data = x;
+ }
+ }
+}
[04/11] incubator-tinkerpop git commit: Add tests for BulkSetSupplier.
Posted by sp...@apache.org.
Add tests for BulkSetSupplier.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/d57326c9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/d57326c9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/d57326c9
Branch: refs/heads/master
Commit: d57326c9d5581826a543e8ad774aa853bfe0e9b0
Parents: f0f6d0f
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 21 14:35:18 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu May 21 15:55:03 2015 -0400
----------------------------------------------------------------------
.../util/function/BulkSetSupplierTest.java | 57 ++++++++++++++++++++
1 file changed, 57 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/d57326c9/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/BulkSetSupplierTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/BulkSetSupplierTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/BulkSetSupplierTest.java
new file mode 100644
index 0000000..4a91798
--- /dev/null
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/BulkSetSupplierTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.util.function;
+
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.BulkSet;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class BulkSetSupplierTest {
+ @Test
+ public void shouldSupplyEmptyList() {
+ assertEquals(0, BulkSetSupplier.instance().get().size());
+ }
+
+ @Test
+ public void shouldSupplyAnArrayListInstance() {
+ assertEquals(0, BulkSetSupplier.instance().get().size());
+ assertThat(ArrayListSupplier.instance().get(), instanceOf(BulkSet.class));
+ }
+
+ @Test
+ public void shouldSupplyNewListOnEachInvocation() {
+ final BulkSet<Object> l1 = BulkSetSupplier.instance().get();
+ final BulkSet<Object> l2 = BulkSetSupplier.instance().get();
+ final BulkSet<Object> l3 = BulkSetSupplier.instance().get();
+
+ assertNotSame(l1, l2);
+ assertNotSame(l1, l3);
+ assertNotSame(l2, l3);
+ }
+}
[08/11] incubator-tinkerpop git commit: Add tests for TreeSupplier.
Posted by sp...@apache.org.
Add tests for TreeSupplier.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/e88ce996
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/e88ce996
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/e88ce996
Branch: refs/heads/master
Commit: e88ce99677a668105fa11896db6216a9c241d3ee
Parents: e874ecb
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 21 14:59:13 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu May 21 15:55:04 2015 -0400
----------------------------------------------------------------------
.../gremlin/util/function/TreeSupplierTest.java | 56 ++++++++++++++++++++
1 file changed, 56 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/e88ce996/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/TreeSupplierTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/TreeSupplierTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/TreeSupplierTest.java
new file mode 100644
index 0000000..e22a719
--- /dev/null
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/function/TreeSupplierTest.java
@@ -0,0 +1,56 @@
+/*
+ * 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.util.function;
+
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
+import org.junit.Test;
+
+import java.util.HashSet;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class TreeSupplierTest {
+ @Test
+ public void shouldSupplyTree() {
+ assertEquals(0, TreeSupplier.instance().get().size());
+ }
+
+ @Test
+ public void shouldSupplyTreeInstance() {
+ assertEquals(0, TreeSupplier.instance().get().size());
+ assertThat(TreeSupplier.instance().get(), instanceOf(Tree.class));
+ }
+
+ @Test
+ public void shouldSupplyNewTreeOnEachInvocation() {
+ final Tree<Object> l1 = TreeSupplier.instance().get();
+ final Tree<Object> l2 = TreeSupplier.instance().get();
+ final Tree<Object> l3 = TreeSupplier.instance().get();
+
+ assertNotSame(l1, l2);
+ assertNotSame(l1, l3);
+ assertNotSame(l2, l3);
+ }
+}