RequestObjectHelper { public static Long getStartOffset(final JSONObject requestObject) { final Long offset = getOffset(requestObject, Tokens.START); if (null == offset) return 0l; 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 getStartOffsetEmptyRequest() { Assert.assertEquals(new Long(0), RequestObjectHelper.getStartOffset(null)); }
@Test public void getEndOffsetNullRequest() { Assert.assertEquals(new Long(0), RequestObjectHelper.getStartOffset(null)); }
@Test public void getStartOffsetNoOffset() { JSONObject requestObject = buildJSONObjectFromString("{\"rexster\": { \"anyotherproperty\": { \"start\":\"ten\", \"end\":100 }}}"); Assert.assertEquals(new Long(0), RequestObjectHelper.getStartOffset(requestObject)); }
@Test public void getStartOffsetInvalidOffset() { JSONObject requestObject = buildJSONObjectFromString("{\"rexster\": { \"offset\": { \"start\":\"ten\", \"end\":100 }}}"); Assert.assertEquals(0l, (long) RequestObjectHelper.getStartOffset(requestObject)); }
@Test public void getStartOffsetWithNoStart() { JSONObject requestObject = buildJSONObjectFromString("{\"rexster\": { \"offset\": { \"end\":100 }}}"); Assert.assertEquals(0l, (long) RequestObjectHelper.getStartOffset(requestObject)); }
@Test public void getStartOffsetValid() { JSONObject requestObject = buildJSONObjectFromString("{\"rexster\": { \"offset\": { \"start\":10, \"end\":100 }}}"); Assert.assertEquals(10l, (long) RequestObjectHelper.getStartOffset(requestObject)); requestObject = buildJSONObjectFromString("{\"rexster\": { \"offset\": { \"start\":-10, \"end\":10001 }}}"); Assert.assertEquals(-10l, (long) RequestObjectHelper.getStartOffset(requestObject)); }