CountResult extends JestResult { public Double getCount() { Double count = null; if (isSucceeded) { count = getSourceAsObject(Double.class); } return count; } CountResult(CountResult countResult);  CountResult(Gson gson); @Override @Deprecated T getSourceAsObject(Class<T> clazz); @Override @Deprecated List<T> getSourceAsObjectList(Class<T> type); Double getCount();  }
@Test public void testGetCount() { CountResult countResult = new CountResult(new Gson()); countResult.setSucceeded(true); countResult.setJsonString(json); countResult.setJsonObject(new JsonParser().parse(json).getAsJsonObject()); countResult.setPathToResult("count"); Double count = countResult.getCount(); assertNotNull(count); }
@Test public void testGetCountWhenOperationFails() { CountResult countResult = new CountResult(new Gson()); countResult.setSucceeded(false); Double count = countResult.getCount(); assertNull(count); }