@Test
    public void shouldOperateCorrectly() {
        final TraversalSideEffects sideEffects = new DefaultTraversalSideEffects();
        try {
            sideEffects.set("a", "marko");
            fail("The key was not registered: a");
        } catch (final IllegalArgumentException e) {
            assertEquals(TraversalSideEffects.Exceptions.sideEffectKeyDoesNotExist("a").getMessage(), e.getMessage());
        }
        for (final String key : Arrays.asList("a", "b", "c")) {
            try {
                sideEffects.get(key);
                fail("The key was not registered: " + key);
            } catch (final IllegalArgumentException e) {
                assertEquals(TraversalSideEffects.Exceptions.sideEffectKeyDoesNotExist(key).getMessage(), e.getMessage());
            }
        }

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

        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());
        }

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

        sideEffects.add("a", "rodriguez");
        sideEffects.add("b", 2);
        sideEffects.add("c", false);
        assertTrue(sideEffects.exists("a"));
        assertEquals("rodriguez", sideEffects.get("a"));
        assertTrue(sideEffects.exists("b"));
        assertEquals(3, sideEffects.<Integer>get("b").intValue());
        assertTrue(sideEffects.exists("c"));
        assertEquals(false, sideEffects.get("c"));

        sideEffects.set("c", true);
        assertEquals(true, sideEffects.get("c"));
    }
@author Marko A. Rodriguez (http://markorodriguez.com)
gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversalSideEffectsTest.java