@Test
public void testOptObject() {

    assertFalse("empty object returns empty object for any key",
            optObject(JsonValue.EMPTY_JSON_OBJECT, "someKey").isPresent());
    assertFalse("object returns empty object for present key with non-object value",
            optObject(key("someKey", arr()).get(), "someKey").isPresent());
    assertFalse("object returns empty object for present key with null value",
            optObject(key("someKey", null).get(), "someKey").isPresent());
    assertTrue("object returns present object for present key with object value",
            optObject(key("someKey", key("foo", "bar")).get(), "someKey").isPresent());
    assertEquals("object returns correct object value for key with object value",
            "bar",
            optObject(obj()
                    .key("someKey",
                            key("foo", "bar"))
                    .key("otherKey",
                            key("bar", "foo")).get(), "someKey")
                    .map(object -> object.getString("foo")).orElse(""));
}