/** * Either returns a {@link JsonRepresentation} that indicates that the * wrapped node has <tt>null</tt> value (ie * {@link JsonRepresentation#isNull()}), or returns <tt>null</tt> if there * was no node with the provided path. * * <p> * Use {@link #isNull(String)} to check first, if required. */ public JsonRepresentation getNull(final String path) { return getNull(path, getNode(path)); }
/** * Either returns a {@link JsonRepresentation} that indicates that the * wrapped node has <tt>null</tt> value (ie * {@link JsonRepresentation#isNull()}), or returns <tt>null</tt> if there * was no node with the provided path. * * <p> * Use {@link #isNull()} to check first, if required. */ public JsonRepresentation asNull() { return getNull(null, asJsonNode()); }
@Test public void forMap() { try { jsonRepresentation.getNull("aSubMap"); fail(); } catch (final IllegalArgumentException e) { assertThat(e.getMessage(), is("'aSubMap' is not the null value")); } }
@Test public void getNull_forArray() { try { jsonRepresentation.getNull("anEmptyArray"); fail(); } catch (final IllegalArgumentException e) { assertThat(e.getMessage(), is("'anEmptyArray' is not the null value")); } }
@Test public void getNull_forArray() { try { jsonRepresentation.getNull("anEmptyArray"); fail(); } catch (final IllegalArgumentException e) { assertThat(e.getMessage(), is("'anEmptyArray' is not the null value")); } }
@Test public void forMap() { try { jsonRepresentation.getNull("aSubMap"); fail(); } catch (final IllegalArgumentException e) { assertThat(e.getMessage(), is("'aSubMap' is not the null value")); } }
@Test public void forNullValue() throws IOException { final JsonRepresentation nullValue = jsonRepresentation.getNull("aNull"); assertThat(nullValue, is(not(nullValue()))); assertThat(nullValue.isNull(), is(true)); final Boolean isNull = jsonRepresentation.isNull("aNull"); assertThat(isNull, is(true)); }
@Test public void forNullValue() throws JsonParseException, JsonMappingException, IOException { final JsonRepresentation nullValue = jsonRepresentation.getNull("aNull"); assertThat(nullValue, is(not(nullValue()))); assertThat(nullValue.isNull(), is(true)); final Boolean isNull = jsonRepresentation.isNull("aNull"); assertThat(isNull, is(true)); }