### Question:
CouchbaseUtils { public static String getStringContent(Bucket bucket, String id) { final LegacyDocument doc = bucket.get(LegacyDocument.create(id)); if (doc == null) { return null; } final Object content = doc.content(); return getStringContent(content); }  static String getStringContent(Bucket bucket, String id); static String getStringContent(Object content);  }### Answer:
@Ignore("This test method requires a live Couchbase Server instance") @Test public void testDocumentTypesAndStringConversion() { final CouchbaseCluster cluster = CouchbaseCluster.fromConnectionString("couchbase: final Bucket bucket = cluster.openBucket("b1", "b1password"); bucket.upsert(JsonDocument.create("JsonDocument", JsonObject.create().put("one", 1))); bucket.upsert(JsonArrayDocument.create("JsonArray", JsonArray.create().add(1).add(2).add(3))); bucket.upsert(JsonDoubleDocument.create("JsonDouble", 0.123)); bucket.upsert(JsonStringDocument.create("JsonString", "value")); bucket.upsert(JsonBooleanDocument.create("JsonBoolean", true)); bucket.upsert(JsonLongDocument.create("JsonLong", 123L)); bucket.upsert(RawJsonDocument.create("RawJsonDocument", "value")); bucket.upsert(StringDocument.create("StringDocument", "value")); bucket.upsert(BinaryDocument.create("BinaryDocument", Unpooled.copiedBuffer("value".getBytes(StandardCharsets.UTF_8)))); bucket.upsert(ByteArrayDocument.create("ByteArrayDocument", "value".getBytes(StandardCharsets.UTF_8))); final String[][] expectations = { {"JsonDocument", "String", "{\"one\":1}"}, {"JsonArray", "String", "[1,2,3]"}, {"JsonDouble", "String", "0.123"}, {"JsonString", "String", "\"value\""}, {"JsonBoolean", "String", "true"}, {"JsonLong", "String", "123"}, {"RawJsonDocument", "String", "value"}, {"StringDocument", "String", "value"}, {"BinaryDocument", "byte[]", "value"}, {"ByteArrayDocument", "byte[]", "value"}, }; for (String[] expectation : expectations) { final LegacyDocument document = bucket.get(LegacyDocument.create(expectation[0])); assertEquals(expectation[1], document.content().getClass().getSimpleName()); assertEquals(expectation[2], CouchbaseUtils.getStringContent(document.content())); } final BinaryDocument binaryDocument = bucket.get(BinaryDocument.create("BinaryDocument")); final String stringFromByteBuff = CouchbaseUtils.getStringContent(binaryDocument.content()); assertEquals("value", stringFromByteBuff); try { bucket.get(BinaryDocument.create("JsonDocument")); fail("Getting a JSON document as a BinaryDocument fails"); } catch (TranscodingException e) { assertTrue(e.getMessage().contains("Flags (0x2000000) indicate non-binary document for id JsonDocument")); } }