@Test public void forJsonRepresentation() throws IOException { jsonRepresentation = new JsonRepresentation(readJson("map.json")); final Iterable<Entry<String, JsonRepresentation>> mapIterable = jsonRepresentation.mapIterable(); final Iterator<Entry<String, JsonRepresentation>> mapIterator = mapIterable.iterator(); for (int i = 0; i < jsonRepresentation.asJsonNode().size(); i++) { assertThat(mapIterator.hasNext(), is(true)); assertThat(mapIterator.next().getKey(), is(not(nullValue()))); } assertThat(mapIterator.hasNext(), is(false)); }
@Before public void setUp() throws Exception { jsonRepresentation = new JsonRepresentation(readJson("map.json")); }
@Before public void setUp() throws Exception { representation = new DomainObjectRepresentation(readJson("domainObjectRepresentation.json")); }
@Test public void forString() throws JsonParseException, JsonMappingException, IOException { jsonRepresentation = new JsonRepresentation(readJson("listOfStrings.json")); final Iterator<String> arrayIterator = jsonRepresentation.arrayIterator(String.class); assertThat(arrayIterator.hasNext(), is(true)); assertThat(arrayIterator.next(), is("a")); assertThat(arrayIterator.hasNext(), is(true)); assertThat(arrayIterator.next(), is("b")); assertThat(arrayIterator.hasNext(), is(true)); assertThat(arrayIterator.next(), is("c")); assertThat(arrayIterator.hasNext(), is(false)); }
@Before public void setUp() throws Exception { jsonRepresentation = new JsonRepresentation(readJson("map.json")); }
@Before public void setUp() throws Exception { jsonRepresentation = new JsonRepresentation(readJson("map.json")); }
@Before public void setUp() throws Exception { jsonRepresentation = new JsonRepresentation(readJson("map.json")); }
@Before public void setUp() throws Exception { jsonRepresentation = new JsonRepresentation(readJson("map.json")); }
@Before public void setUp() throws Exception { jsonRepresentation = new JsonRepresentation(readJson("map.json")); }
@Before public void setUp() throws Exception { jsonRepresentation = new JsonRepresentation(readJson("map.json")); }
@Before public void setUp() throws Exception { jsonRepresentation = new JsonRepresentation(readJson("map.json")); }
@Before public void setUp() throws Exception { jsonRepresentation = new JsonRepresentation(readJson("map.json")); }
@Before public void setUp() throws Exception { representation = new DomainObjectRepresentation(readJson("domainObjectRepresentation.json")); }
@Test public void forString() throws IOException { jsonRepresentation = new JsonRepresentation(readJson("listOfStrings.json")); final Iterator<String> arrayIterator = jsonRepresentation.arrayIterator(String.class); assertThat(arrayIterator.hasNext(), is(true)); assertThat(arrayIterator.next(), is("a")); assertThat(arrayIterator.hasNext(), is(true)); assertThat(arrayIterator.next(), is("b")); assertThat(arrayIterator.hasNext(), is(true)); assertThat(arrayIterator.next(), is("c")); assertThat(arrayIterator.hasNext(), is(false)); }
@Test public void forJsonRepresentation() throws JsonParseException, JsonMappingException, IOException { jsonRepresentation = new JsonRepresentation(readJson("list.json")); final Iterator<JsonRepresentation> arrayIterator = jsonRepresentation.arrayIterator(JsonRepresentation.class); assertThat(arrayIterator.hasNext(), is(true)); assertThat(arrayIterator.next().getString("a"), is("a1")); assertThat(arrayIterator.hasNext(), is(true)); assertThat(arrayIterator.next().getString("b"), is("b1")); assertThat(arrayIterator.hasNext(), is(false)); }
@Test(expected = IllegalStateException.class) public void forList() throws IOException { jsonRepresentation = new JsonRepresentation(readJson("list.json")); jsonRepresentation.mapHas("aString"); }
@Test(expected = IllegalArgumentException.class) public void arraySetElementAt_forAttemptingToSetElementToArray() throws IOException { jsonRepresentation = new JsonRepresentation(readJson("list.json")); jsonRepresentation.arraySetElementAt(0, arrayRepr); }
@Test(expected = IndexOutOfBoundsException.class) public void arrayGet_outOfBounds() throws JsonParseException, JsonMappingException, IOException { jsonRepresentation = new JsonRepresentation(readJson("emptyList.json")); jsonRepresentation.arrayGet(0); }
@Test public void arraySetElementAt_happyCaseWhenSetElementToObject() throws JsonParseException, JsonMappingException, IOException { jsonRepresentation = new JsonRepresentation(readJson("list.json")); jsonRepresentation.arraySetElementAt(0, objectRepr); }
@Test(expected = IndexOutOfBoundsException.class) public void arraySetElementAt_outOfBounds() throws IOException { jsonRepresentation = new JsonRepresentation(readJson("emptyList.json")); jsonRepresentation.arraySetElementAt(0, objectRepr); }