@Test(expected = EntityProviderException.class) public void wrongTagName() throws Exception { final String link = "{\"URI\":\"http: JsonReader reader = new JsonReader(new InputStreamReader(createContentAsStream(link))); new JsonLinkConsumer().readLink(reader, null); }
public String readLink(final JsonReader reader, final EdmEntitySet entitySet) throws EntityProviderException { try { String result; reader.beginObject(); String nextName = reader.nextName(); final boolean wrapped = FormatJson.D.equals(nextName); if (wrapped) { reader.beginObject(); nextName = reader.nextName(); } if (FormatJson.URI.equals(nextName) && reader.peek() == JsonToken.STRING) { result = reader.nextString(); } else { throw new EntityProviderException(EntityProviderException.INVALID_CONTENT.addContent( FormatJson.D + " or " + FormatJson.URI).addContent(nextName)); } reader.endObject(); if (wrapped) { reader.endObject(); } reader.peek(); return result; } catch (final IOException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } catch (final IllegalStateException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }
JsonLinkConsumer { public String readLink(final JsonReader reader, final EdmEntitySet entitySet) throws EntityProviderException { try { String result; reader.beginObject(); String nextName = reader.nextName(); final boolean wrapped = FormatJson.D.equals(nextName); if (wrapped) { reader.beginObject(); nextName = reader.nextName(); } if (FormatJson.URI.equals(nextName) && reader.peek() == JsonToken.STRING) { result = reader.nextString(); } else { throw new EntityProviderException(EntityProviderException.INVALID_CONTENT.addContent( FormatJson.D + " or " + FormatJson.URI).addContent(nextName)); } reader.endObject(); if (wrapped) { reader.endObject(); } reader.peek(); return result; } catch (final IOException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } catch (final IllegalStateException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } } }
JsonLinkConsumer { public String readLink(final JsonReader reader, final EdmEntitySet entitySet) throws EntityProviderException { try { String result; reader.beginObject(); String nextName = reader.nextName(); final boolean wrapped = FormatJson.D.equals(nextName); if (wrapped) { reader.beginObject(); nextName = reader.nextName(); } if (FormatJson.URI.equals(nextName) && reader.peek() == JsonToken.STRING) { result = reader.nextString(); } else { throw new EntityProviderException(EntityProviderException.INVALID_CONTENT.addContent( FormatJson.D + " or " + FormatJson.URI).addContent(nextName)); } reader.endObject(); if (wrapped) { reader.endObject(); } reader.peek(); return result; } catch (final IOException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } catch (final IllegalStateException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }  }
JsonLinkConsumer { public String readLink(final JsonReader reader, final EdmEntitySet entitySet) throws EntityProviderException { try { String result; reader.beginObject(); String nextName = reader.nextName(); final boolean wrapped = FormatJson.D.equals(nextName); if (wrapped) { reader.beginObject(); nextName = reader.nextName(); } if (FormatJson.URI.equals(nextName) && reader.peek() == JsonToken.STRING) { result = reader.nextString(); } else { throw new EntityProviderException(EntityProviderException.INVALID_CONTENT.addContent( FormatJson.D + " or " + FormatJson.URI).addContent(nextName)); } reader.endObject(); if (wrapped) { reader.endObject(); } reader.peek(); return result; } catch (final IOException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } catch (final IllegalStateException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }  String readLink(final JsonReader reader, final EdmEntitySet entitySet); List<String> readLinks(final JsonReader reader, final EdmEntitySet entitySet); }
JsonLinkConsumer { public String readLink(final JsonReader reader, final EdmEntitySet entitySet) throws EntityProviderException { try { String result; reader.beginObject(); String nextName = reader.nextName(); final boolean wrapped = FormatJson.D.equals(nextName); if (wrapped) { reader.beginObject(); nextName = reader.nextName(); } if (FormatJson.URI.equals(nextName) && reader.peek() == JsonToken.STRING) { result = reader.nextString(); } else { throw new EntityProviderException(EntityProviderException.INVALID_CONTENT.addContent( FormatJson.D + " or " + FormatJson.URI).addContent(nextName)); } reader.endObject(); if (wrapped) { reader.endObject(); } reader.peek(); return result; } catch (final IOException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } catch (final IllegalStateException e) { throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass() .getSimpleName()), e); } }  String readLink(final JsonReader reader, final EdmEntitySet entitySet); List<String> readLinks(final JsonReader reader, final EdmEntitySet entitySet);  }