### Question:
BaseCacheResource { private CompletionStage<RestResponse> putInCache(NettyRestResponse.Builder responseBuilder, AdvancedCache<Object, Object> cache, Object key, byte[] data, Long ttl, Long idleTime) { Configuration config = SecurityActions.getCacheConfiguration(cache); final Metadata metadata = CacheOperationsHelper.createMetadata(config, ttl, idleTime); responseBuilder.header("etag", calcETAG(data)); CompletionStage<Object> stage; if (config.indexing().enabled()) { stage = CompletableFuture.supplyAsync(() -> cache.putAsync(key, data, metadata), invocationHelper.getExecutor()) .thenCompose(Function.identity()); } else { stage = cache.putAsync(key, data, metadata); } return stage.thenApply(o -> responseBuilder.build()); } BaseCacheResource(InvocationHelper invocationHelper);   }### Answer:
@Test public void testIntegerKeysXmlToTextValues() { Integer key = 123; String keyContentType = "application/x-java-object;type=java.lang.Integer"; String valueContentType = "application/xml; charset=UTF-8"; String value = "<root>test</root>"; putInCache("default", key, keyContentType, value, valueContentType); RestResponse response = get("default", key, keyContentType, "text/plain"); ResponseAssertion.assertThat(response).hasReturnedText(value); }
@Test public void testIntKeysAndJSONToTextValues() { Integer key = 1234; String keyContentType = "application/x-java-object;type=java.lang.Integer"; String value = "{\"a\": 1}"; putInCache("default", key, keyContentType, value, APPLICATION_JSON_TYPE); RestResponse response = get("default", key, keyContentType, TEXT_PLAIN_TYPE); ResponseAssertion.assertThat(response).hasReturnedText(value); }
@Test public void testIntKeysTextToXMLValues() { Integer key = 12345; String keyContentType = "application/x-java-object;type=java.lang.Integer"; String value = "<foo>bar</foo>"; putInCache("default", key, keyContentType, value, TEXT_PLAIN_TYPE); RestResponse response = get("default", key, keyContentType, APPLICATION_XML_TYPE); ResponseAssertion.assertThat(response).hasReturnedText(value); }
@Test public void testInvalidXMLConversion() throws Exception { String key = "invalid-xml-key"; String invalidXML = "foo"; putInCache("default", key, invalidXML, TEXT_PLAIN_TYPE); CompletionStage<RestResponse> response = client.cache("default").get(key, APPLICATION_XML_TYPE); ResponseAssertion.assertThat(response).containsReturnedText("<string>foo</string>"); }