@Test
    public void shouldFailIfTypeSpecifiedIsNotSameTypeInPayload() {
        final OffsetDateTime o = OffsetDateTime.now();
        final ByteArrayOutputStream stream = new ByteArrayOutputStream();
        try {
            mapper.writeValue(stream, o);
            final InputStream inputStream = new ByteArrayInputStream(stream.toByteArray());
            // What has been serialized is a ZoneOffset with the type, but the user explicitly requires another type.
            mapper.readValue(inputStream, Instant.class);
            fail("Should have failed decoding the value");
        } catch (Exception e) {
            if (version.startsWith("v4")) {
                assertThat(e.getMessage(), containsString("Could not deserialize the JSON value as required. Nested exception: java.lang.InstantiationException: Cannot deserialize the value with the detected type contained in the JSON ('" + GraphSONTokens.GREMLIN_TYPE_NAMESPACE + ":DateTime') to the type specified in parameter to the object mapper (class java.time.Instant). Those types are incompatible."));
            } else {
                assertThat(e.getMessage(), containsString("Could not deserialize the JSON value as required. Nested exception: java.lang.InstantiationException: Cannot deserialize the value with the detected type contained in the JSON ('" + GraphSONTokens.GREMLINX_TYPE_NAMESPACE + ":OffsetDateTime') to the type specified in parameter to the object mapper (class java.time.Instant). Those types are incompatible."));
            }
        }
    }
Tests automatic typed serialization/deserialization for GraphSON 2.0+.

@author Kevin Gallardo (https://kgdo.me)
@author Stephen Mallette (http://stephen.genoprime.com)
gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperPartialEmbeddedTypeTest.java