### Question:
ODataEntityParser { public final UriInfo parseURISegment(final int segmentFromIndex, final int segmentToIndex) throws ODataJPARuntimeException { UriInfo uriInfo = null; if (segmentFromIndex == segmentToIndex || segmentFromIndex > segmentToIndex || segmentFromIndex < 0) { return uriInfo; } try { edm = getEdm(); List<PathSegment> pathSegments = context.getODataContext().getPathInfo().getODataSegments(); List<PathSegment> subPathSegments = pathSegments.subList(segmentFromIndex, segmentToIndex); uriInfo = UriParser.parse(edm, subPathSegments, Collections.<String, String> emptyMap()); } catch (ODataException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e); } return uriInfo; } 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 testParseURISegment() { try { parser = new ODataEntityParser(mock("JPATypeMock(2)")); UriInfo uriInfo = parser.parseURISegment(0, 1); assertNotNull(uriInfo); } catch (ODataJPARuntimeException e) { fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); } }
@Test public void testParseURISegmentInvalidIndex00() { try { parser = new ODataEntityParser(mock("JPATypeMock(2)")); UriInfo uriInfo = parser.parseURISegment(0, 0); assertNull(uriInfo); } catch (ODataJPARuntimeException e) { fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); } }
@Test public void testParseURISegmentInvalidIndex01() { try { parser = new ODataEntityParser(mock("JPATypeMock(2)")); UriInfo uriInfo = parser.parseURISegment(-1, -1); assertNull(uriInfo); } catch (ODataJPARuntimeException e) { fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); } }
@Test public void testParseURISegmentInvalidIndex02() { try { parser = new ODataEntityParser(mock("JPATypeMock(2)")); UriInfo uriInfo = parser.parseURISegment(3, -1); assertNull(uriInfo); } catch (ODataJPARuntimeException e) { fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2); } }
@Test public void testParseURISegmentInvalidEntityType() { try { parser = new ODataEntityParser(mock("JPATypeMockInvalid(2)")); parser.parseURISegment(0, 1); fail("Exception Expected"); } catch (ODataJPARuntimeException e) { assertEquals(true, true); } }