RequestObjectHelper { public static Long getEndOffset(final JSONObject requestObject) { final Long offset = getOffset(requestObject, Tokens.END); if (null == offset) return Long.MAX_VALUE; else return offset; }  static JSONObject getRexsterRequest(final JSONObject requestObject); static Set<String> getReturnKeys(final JSONObject requestObject); static Set<String> getReturnKeys(final JSONObject requestObject, final String wildcard); static Set<String> getReturnKeys(final JSONArray arrayOfKeys, final String wildcard); static boolean getShowTypes(final JSONObject requestObject); static Long getStartOffset(final JSONObject requestObject); static Long getEndOffset(final JSONObject requestObject); static boolean hasElementProperties(final JSONObject requestObject); static void buildQueryProperties(final JSONObject requestObject, final VertexQuery query);  }
@Test public void getEndOffsetEmptyRequest() { JSONObject requestObject = buildJSONObjectFromString("{\"rexster\": \"nothing\"}"); Assert.assertEquals(new Long(Long.MAX_VALUE), RequestObjectHelper.getEndOffset(requestObject)); }
@Test public void getEndOffsetEndNull() { Assert.assertEquals(new Long(Long.MAX_VALUE), RequestObjectHelper.getEndOffset(null)); }
@Test public void getEndOffsetStartWithNoEnd() { JSONObject requestObject = buildJSONObjectFromString("{\"rexster\": { \"offset\": { \"start\":10 }}}"); Assert.assertEquals(new Long(Long.MAX_VALUE), RequestObjectHelper.getEndOffset(requestObject)); }
@Test public void getEndOffsetNoOffset() { JSONObject requestObject = buildJSONObjectFromString("{\"rexster\": { \"anyotherproperty\": { \"start\":10, \"end\":100 }}}"); Assert.assertEquals(new Long(Long.MAX_VALUE), RequestObjectHelper.getEndOffset(requestObject)); }
@Test public void getEndOffsetInvalidOffset() { JSONObject requestObject = buildJSONObjectFromString("{\"rexster\": { \"offset\": { \"start\":10, \"end\":\"onehundred\" }}}"); Assert.assertEquals(0l, (long) RequestObjectHelper.getEndOffset(requestObject)); }
@Test public void getEndOffsetValid() { JSONObject requestObject = buildJSONObjectFromString("{\"rexster\": { \"offset\": { \"start\":10, \"end\":100 }}}"); Assert.assertEquals(100l, (long) RequestObjectHelper.getEndOffset(requestObject)); requestObject = buildJSONObjectFromString("{\"rexster\": { \"offset\": { \"start\":-10, \"end\":10001 }}}"); Assert.assertEquals(10001l, (long) RequestObjectHelper.getEndOffset(requestObject)); }