GCloudNaturalLanguageUtil { public static String getDocumentPayload(String content, String type) { return JSONUtil.put( "document", JSONUtil.put( "content", content ).put( "type", type ) ).toString(); }  static String getDocumentPayload(String content, String type); static String getType(String mimeType); static String truncateToSize(String content, int size);  }
@Test public void testGetDocumentPayload() throws Exception { Mockito.when( _fileEntry.getFileVersion() ).thenReturn( _fileVersion ); String randomString = RandomTestUtil.randomString(); Mockito.when( _fileVersion.getContentStream(false) ).thenReturn( new ByteArrayInputStream(randomString.getBytes()) ); Assert.assertEquals( GCloudNaturalLanguageUtil.getDocumentPayload( randomString, StringPool.BLANK), GCloudNaturalLanguageUtil.getDocumentPayload( GCloudNaturalLanguageUtil.truncateToSize( new String( FileUtil.getBytes( _fileVersion.getContentStream(false))), 5000), StringPool.BLANK)); }