@Test
    public void shouldMergeCorrectly() {
        final TraversalSideEffects sideEffects = new DefaultTraversalSideEffects();
        final TraversalSideEffects other =new DefaultTraversalSideEffects();

        sideEffects.register("a", new ConstantSupplier<>("temp"), null);
        sideEffects.register("b", new ConstantSupplier<>(0), Operator.sum);
        sideEffects.register("c", null, Operator.and);

        sideEffects.mergeInto(other);

        assertEquals("temp",other.get("a"));
        assertEquals(0,other.<Integer>get("b").intValue());
        try {
            other.get("c");
            fail("The key was not registered with a supplier: c");
        } catch (final IllegalArgumentException e) {
            assertEquals(TraversalSideEffects.Exceptions.sideEffectKeyDoesNotExist("c").getMessage(), e.getMessage());
        }

        other.set("a", "marko");
        other.set("b", 1);
        other.set("c", true);
        assertFalse(other.exists("blah"));
        assertTrue(other.exists("a"));
        assertEquals("marko", other.get("a"));
        assertTrue(other.exists("b"));
        assertEquals(1, other.<Integer>get("b").intValue());
        assertTrue(other.exists("c"));
        assertEquals(true, other.get("c"));

        assertEquals("temp",sideEffects.get("a"));
        assertEquals(0,sideEffects.<Integer>get("b").intValue());
        try {
            sideEffects.get("c");
            fail("The key was not registered with a supplier: c");
        } catch (final IllegalArgumentException e) {
            assertEquals(TraversalSideEffects.Exceptions.sideEffectKeyDoesNotExist("c").getMessage(), e.getMessage());
        }
    }
@author Marko A. Rodriguez (http://markorodriguez.com)
gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversalSideEffectsTest.java