### Question:
JsonFunctions { public static <T> Function<JsonElement,T> getPath(final String path) { return new GetPath<T>(path); } private  JsonFunctions(); static Function<String, JsonElement> asJson(); static Function<JsonElement, List<T>> forEach(final Function<JsonElement, T> func); static Function<JsonElement, JsonElement> walk(String elementOrDotSeparatedElements); static Function<JsonElement, JsonElement> walk(final String... elements); static Function<JsonElement, JsonElement> walk(final Iterable<String> elements); static Function<JsonElement, JsonElement> walkN(@Nullable String elements); static Function<JsonElement, JsonElement> walkN(final String... elements); static Function<JsonElement, JsonElement> walkN(final Iterable<String> elements); static Function<Maybe<JsonElement>, Maybe<JsonElement>> walkM(@Nullable String elements); static Function<Maybe<JsonElement>, Maybe<JsonElement>> walkM(final String... elements); static Function<Maybe<JsonElement>, Maybe<JsonElement>> walkM(final Iterable<String> elements); static Function<JsonElement,T> getPath(final String path); static Function<JsonElement, T> cast(final Class<T> expected); static Function<Maybe<JsonElement>, T> castM(final Class<T> expected); static Function<Maybe<JsonElement>, T> castM(final Class<T> expected, final T defaultValue);  }### Answer:
@Test public void testGetPath1(){ Integer obj = (Integer) JsonFunctions.getPath("$.europe.uk.edinburgh.population").apply(europeMap()); Assert.assertEquals((int) obj, 500*1000); }
@Test public void testGetPath2(){ String obj = (String) JsonFunctions.getPath("$.europe.uk.edinburgh.lighting").apply(europeMap()); Assert.assertEquals(obj, "dark"); }
@Test public void testGetMissingPathIsNullOrThrows(){ try { Object obj = JsonFunctions.getPath("$.europe.spain.malaga").apply(europeMap()); Assert.assertNull(obj); } catch (PathNotFoundException e) { } }
@Test public void testGetPathWithNullReturnsNull(){ Integer obj = (Integer) JsonFunctions.getPath("$.europe.uk.edinburgh.population").apply(null); Assert.assertNull(obj); }