RequestObjectHelper { public static Set<String> getReturnKeys(final JSONObject requestObject) { return getReturnKeys(requestObject, Tokens.WILDCARD); }  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 getReturnKeysNullRequestObject() { Assert.assertNull(RequestObjectHelper.getReturnKeys(null)); }
@Test public void getReturnKeysWildcarded() { JSONObject jsonWithWildcard = buildJSONObjectFromString("{\"rexster\": { \"returnKeys\": [\"" + Tokens.WILDCARD + "\"]}}"); Assert.assertNull(RequestObjectHelper.getReturnKeys(jsonWithWildcard)); }
@Test public void getReturnKeysNoneSpecified() { JSONObject jsonWithNoReturnKeysKey = new JSONObject(); Assert.assertNull(RequestObjectHelper.getReturnKeys(jsonWithNoReturnKeysKey)); }
@Test public void getReturnKeysNonArrayBased() { JSONObject jsonWithNonArrayReturnKeyValue = buildJSONObjectFromString("{\"rexster\": { \"" + Tokens.RETURN_KEYS + "\": \"" + Tokens.WILDCARD + "\"}}"); Assert.assertNull(RequestObjectHelper.getReturnKeys(jsonWithNonArrayReturnKeyValue)); }
@Test public void getReturnKeysValid() { JSONObject jsonWithTwoKeys = buildJSONObjectFromString("{\"rexster\": { \"" + Tokens.RETURN_KEYS + "\": [\"k1\",\"k2\"]}}"); Set<String> keys = RequestObjectHelper.getReturnKeys(jsonWithTwoKeys); Assert.assertNotNull(keys); Assert.assertEquals(2, keys.size()); List<String> listKeys = new ArrayList<String>(keys); Assert.assertEquals("k1", listKeys.get(0)); Assert.assertEquals("k2", listKeys.get(1)); }
@Test public void getReturnKeysNoKeys() throws Exception { JSONObject json = buildJSONObjectFromString("{\"rexster\": { \"someproperty\": [ \"key\" ]}}"); Assert.assertNull(RequestObjectHelper.getReturnKeys(json)); }