### Question:
SchemaGuesser { public static String requestProbabilitiesString(Object[] objects) { String httpRequestBody = GsonSerializer.getGsonWithIds() .toJson(objects); String httpResp = "{\"result\": []}"; try { httpResp = Request.Post("http: .addHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8") .bodyForm(Form.form().add("X", httpRequestBody).build()).execute().returnContent().asString(); } catch (IOException e) { e.printStackTrace(); } return httpResp; }  static GuessSchema guessSchma(EventSchema eventSchema, List<Map<String, Object>> nElements); static PropertyGuessResults requestProbabilitiesObject(Object[] objects); static String requestProbabilitiesString(Object[] objects); static DomainPropertyProbabilityList getDomainPropertyProbability(Object[] sampleData); static int port; }### Answer:
@Test public void requestProbabilitiesStringTest() { String expected = "{\"result\": []}"; stubFor(post(urlEqualTo("/predict")) .willReturn(aResponse() .withStatus(200) .withBody(expected))); SchemaGuesser schemaGuesser = new SchemaGuesser(); Double[] data = {1.1, 2.0}; String result = schemaGuesser.requestProbabilitiesString(data); assertEquals(expected, result); }
@Test public void requestProbabilitiesStringEndpointNotAvailableTest() { String expected = "{\"result\": []}"; stubFor(post(urlEqualTo("/predict")) .willReturn(aResponse() .withStatus(404))); SchemaGuesser schemaGuesser = new SchemaGuesser(); Double[] data = {1.1, 2.0}; String result = schemaGuesser.requestProbabilitiesString(data); assertEquals(expected, result); }