xtern commented on a change in pull request #7648: IGNITE-12857 Put custom objects via REST URL: https://github.com/apache/ignite/pull/7648#discussion_r409892029
########## File path: modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java ########## @@ -2778,6 +2991,87 @@ protected void initCache() { assertEquals(2, personCache.query(qry).getAll().size()); } + /** + * @param cacheName Cache name. + * @param key Cache key. + * @param obj Cache value. + * @throws Exception If failed. + */ + private void putObject(String cacheName, String key, Object obj) throws Exception { + putObject(cacheName, key, obj, obj.getClass().getName()); + } + + /** + * @param cacheName Cache name. + * @param key Cache key. + * @param obj Cache value. + * @param type Cache value type. + * @throws Exception If failed. + */ + private void putObject(String cacheName, String key, Object obj, String type) throws Exception { + String json = JSON_MAPPER.writeValueAsString(obj); + + info("Put: " + json); + + String ret = content(cacheName, GridRestCommand.CACHE_PUT, + "keyType", "int", + "key", key, + "valueType", type, + "val", json + ); + + info("Put command result: " + ret); + + assertResponseSucceeded(ret, false); + } + + /** + * @param cacheName Cache name. + * @param key Cache key. + * @param cls Cache value class. + * @param <T> Cache value type. + * @return Deserialized object of type {@code T}. + * @throws Exception If failed. + */ + private <T> T getObject(String cacheName, String key, Class<T> cls) throws Exception { + String ret = content(cacheName, GridRestCommand.CACHE_GET, "keyType", "int", "key", key); + + info("Get command result: " + ret); + + JsonNode res = assertResponseSucceeded(ret, false); + + return JSON_MAPPER.treeToValue(res, cls); + } + + /** + * @param cacheName Cache name. + * @param params Query parameters. + * @return Json query result. + * @throws Exception If failed. + */ + private JsonNode queryObject(String cacheName, String ... params) throws Exception { Review comment: Done ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services