### Question:
RedPenResource { @Path("/language") @POST @Produces(MediaType.APPLICATION_JSON) @WinkAPIDescriber.Description("Detect language of document") public JSONObject detectLanguage(@FormParam("document") @DefaultValue("") String document) throws JSONException { String language = new LanguageDetector().detectLanguage(document); return new JSONObject().put("key", language); }  @Path("/language") @POST @Produces(MediaType.APPLICATION_JSON) @WinkAPIDescriber.Description("Detect language of document") JSONObject detectLanguage(@FormParam("document") @DefaultValue("") String document); @Path("/validate") @POST @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN}) @WinkAPIDescriber.Description("Validate a document and return any redpen errors") Response validateDocument(@FormParam("document") @DefaultValue("") String document,
                                     @FormParam("documentParser") @DefaultValue(DEFAULT_DOCUMENT_PARSER) String documentParser,
                                     @FormParam("lang") @DefaultValue(DEFAULT_CONFIGURATION) String lang,
                                     @FormParam("format") @DefaultValue(DEFAULT_FORMAT) String format,
                                     @FormParam("config") String config); @Path("/validate/json") @POST @Consumes(MediaType.APPLICATION_JSON) @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN}) @WinkAPIDescriber.Description("Process a redpen JSON validation request and returns any redpen errors") Response validateDocumentJSON(JSONObject requestJSON); @Path("/tokenize") @POST @Produces(MediaType.APPLICATION_JSON) @WinkAPIDescriber.Description("Tokenize a document") JSONObject tokenize(@FormParam("document") @DefaultValue("") String document,
                               @FormParam("lang") @DefaultValue(DEFAULT_CONFIGURATION) String lang);  }### Answer:
@Test void testDetectLanguage() throws Exception { assertEquals("en", new RedPenResource().detectLanguage("Hello World").getString("key")); assertEquals("ja", new RedPenResource().detectLanguage("こんにちは世界").getString("key")); }