ZenclusiveImpl { protected List<Incentive> getIncentives() { if ( incentives != null ) { return incentives; } HttpEntity entity = null; HttpGet request = new HttpGet(ZENCLUSIVE_INCENTIVES_ADDRESS); request.setHeader("Authorization", authorization); try { HttpResponse response = httpClient.execute(request); entity = response.getEntity(); if (entity == null) { logger.warn("The returned response is null"); return null; } JSONParser parser = new JSONParser(); Object obj = parser.parse(new InputStreamReader(entity.getContent())); JSONObject jsonObject = (JSONObject) obj; boolean success = (Boolean) jsonObject.get("success"); if ( !success ) { logger.warn("The returned result is not marked as success"); return null; } List<Incentive> result = new ArrayList<Incentive>(0); JSONArray incentives = (JSONArray) jsonObject.get("incentives"); for ( Object incentive : incentives ) { JSONObject jsonObject_ = (JSONObject) incentive; String name = (String) jsonObject_.get("incentivename"); long value = (Long) jsonObject_.get("incentivevalue"); result.add(new Incentive(name, value)); } return result; } catch (IOException ex) { logger.error("Exception thrown when trying to request incentives from zenclusive", ex); } catch (ParseException ex) { logger.error("Exception thrown when trying to parse response of incentives from zenclusive", ex); } finally { if (entity != null) { try { EntityUtils.consume(entity); } catch (IOException ex) { logger.error("Exception when consuming entity", ex); } } } return null; }  @PostConstruct void init(); Incentive getIncentiveByParams(String name, String value); boolean sendReward(String email, Incentive incentive); String buildZenclusiveEmail(Long requestId);  }
@Test public void testGetIncentives() { List<ZenclusiveImpl.Incentive> incentives = zenclusiveImpl.getIncentives(); for ( ZenclusiveImpl.Incentive incentive : incentives ) { System.out.println("Incentive:"); System.out.println(" " + incentive.getName()); System.out.println(" " + incentive.getValue()); } }