public JsonRepresentation asArray() { return getArray(null, asJsonNode()); }
public JsonRepresentation getArray(final String path) { return getArray(path, getNode(path)); }
/** * Will lazily create links array as required */ protected JsonRepresentation getLinks() { JsonRepresentation links = representation.getArray("links"); if (links == null) { links = JsonRepresentation.newArray(); representation.mapPut("links", links); } return links; }
private JsonRepresentation getTypeActions() { JsonRepresentation typeActions = representation.getArray("typeActions"); if (typeActions == null) { typeActions = JsonRepresentation.newArray(); representation.mapPut("typeActions", typeActions); } return typeActions; }
private JsonRepresentation getTypeActions() { JsonRepresentation typeActions = representation.getArray("typeActions"); if (typeActions == null) { typeActions = JsonRepresentation.newArray(); representation.mapPut("typeActions", typeActions); } return typeActions; }
/** * Will lazily create links array as required */ protected JsonRepresentation getLinks() { JsonRepresentation links = representation.getArray("links"); if (links == null) { links = JsonRepresentation.newArray(); representation.mapPut("links", links); } return links; }
private JsonRepresentation getTypeActions() { JsonRepresentation typeActions = representation.getArray("typeActions"); if (typeActions == null) { typeActions = JsonRepresentation.newArray(); representation.mapPut("typeActions", typeActions); } return typeActions; }
/** * Will lazily create links array as required */ protected JsonRepresentation getLinks() { JsonRepresentation links = representation.getArray("links"); if (links == null) { links = JsonRepresentation.newArray(); representation.mapPut("links", links); } return links; }
@Test public void getNull_forNonExistent() { assertThat(jsonRepresentation.getArray("doesNotExist"), is(nullValue())); }
@Test public void forNonExistent() throws JsonParseException, JsonMappingException, IOException { assertThat(jsonRepresentation.getArray("doesNotExist"), is(nullValue())); }
@Test public void forNonExistent() throws IOException { assertThat(jsonRepresentation.getArray("doesNotExist"), is(nullValue())); }
@Test public void getNull_forNonExistent() { assertThat(jsonRepresentation.getArray("doesNotExist"), is(nullValue())); }
@Test public void forValue() throws IOException { try { jsonRepresentation.getArray("aString"); fail(); } catch (final IllegalArgumentException e) { assertThat(e.getMessage(), is("'aString' is not an array")); } }
@Test public void emptyArray() throws IOException { final JsonRepresentation array = jsonRepresentation.getArray("anEmptyArray"); assertThat(array, is(not(nullValue()))); assertThat(array.size(), is(0)); }
@Test public void forMap() throws IOException { try { jsonRepresentation.getArray("aSubMap"); fail(); } catch (final IllegalArgumentException e) { assertThat(e.getMessage(), is("'aSubMap' is not an array")); } }
@Test public void nonEmptyArray() throws IOException { final JsonRepresentation array = jsonRepresentation.getArray("aStringArray"); assertThat(array, is(not(nullValue()))); assertThat(array.size(), is(3)); }
@Test public void emptyArray() throws JsonParseException, JsonMappingException, IOException { final JsonRepresentation array = jsonRepresentation.getArray("anEmptyArray"); assertThat(array, is(not(nullValue()))); assertThat(array.size(), is(0)); }
@Test public void forValue() throws JsonParseException, JsonMappingException, IOException { try { jsonRepresentation.getArray("aString"); fail(); } catch (final IllegalArgumentException e) { assertThat(e.getMessage(), is("'aString' is not an array")); } }
@Test public void nonEmptyArray() throws JsonParseException, JsonMappingException, IOException { final JsonRepresentation array = jsonRepresentation.getArray("aStringArray"); assertThat(array, is(not(nullValue()))); assertThat(array.size(), is(3)); }
@Test public void forMap() throws JsonParseException, JsonMappingException, IOException { try { jsonRepresentation.getArray("aSubMap"); fail(); } catch (final IllegalArgumentException e) { assertThat(e.getMessage(), is("'aSubMap' is not an array")); } }