### Question:
ODataEntityParser { public final UriInfo parseLink(final EdmEntitySet entitySet, final InputStream content, final String contentType) throws ODataJPARuntimeException { String uriString = null; UriInfo uri = null; try { uriString = EntityProvider.readLink(contentType, entitySet, content); ODataContext odataContext = context.getODataContext(); final String svcRoot = odataContext.getPathInfo().getServiceRoot().toString(); final String path = uriString.startsWith(svcRoot.toString()) ? uriString.substring(svcRoot.length()) : uriString; final List<PathSegment> pathSegment = getPathSegment(path); edm = getEdm(); uri = UriParser.parse(edm, pathSegment, Collections.<String, String> emptyMap()); } catch (ODataException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e); } return uri; } ODataEntityParser(final ODataJPAContext context); final ODataEntry parseEntry(final EdmEntitySet entitySet,
      final InputStream content, final String requestContentType, final boolean merge); final UriInfo parseURISegmentWithCustomOptions(final int segmentFromIndex, final int segmentToIndex,
      final Map<String, String> options); final UriInfo parseURISegment(final int segmentFromIndex, final int segmentToIndex); final UriInfo parseLink(final EdmEntitySet entitySet, final InputStream content, final String contentType); UriInfo parseLinkSegments(final List<String> linkSegments, final Map<String, String> options); UriInfo parseBindingLink(final String link, final Map<String, String> options);  }### Answer:
@Test public void testParseLink() { parser = new ODataEntityParser(mock("JPATypeMock(2)")); try { UriInfo uriInfo = parser.parseLink(EdmMockUtilV2.mockEdmEntitySet(JPATypeMock.ENTITY_NAME, false), mockURIContent(0), "application/json"); assertNotNull(uriInfo); } catch (ODataJPARuntimeException e) { fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); } catch (EdmException e) { fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); } }
@Test public void testParseLinkWithoutServiceRoot() { parser = new ODataEntityParser(mock("JPATypeMock(2)")); try { UriInfo uriInfo = parser.parseLink(EdmMockUtilV2.mockEdmEntitySet(JPATypeMock.ENTITY_NAME, false), mockURIContent(1), "application/json"); assertNotNull(uriInfo); } catch (ODataJPARuntimeException e) { fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); } catch (EdmException e) { fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); } }
@Test public void testParseLinkNegative() { parser = new ODataEntityParser(mock("JPATypeMock(2)")); try { parser.parseLink(EdmMockUtilV2.mockEdmEntitySet(JPATypeMock.ENTITY_NAME, false), mockURIContent(2), "application/json"); fail("Exception Expected"); } catch (ODataJPARuntimeException e) { assertEquals(true, true); } catch (EdmException e) { fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); } }