RulesResource { @ApiOperation(notes = "Retrieves the Rules", value = "get") @ApiResponses({ @ApiResponse(code = 503, message = "") }) @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN }) public String get() { try { String rules = rulesCurator.getRules().getRules(); if ((rules != null) && (rules.length() > 0)) { return Base64.encodeBase64String(rules.getBytes()); } return ""; } catch (CuratorException e) { log.error("couldn't read rules file", e); throw new ServiceUnavailableException(i18n.tr("couldn''t read rules file")); } } @Inject  RulesResource(RulesCurator rulesCurator,
        I18n i18n, EventSink sink, JsRunnerProvider jsProvider); @ApiOperation(notes = "Uploads the Rules Returns a copy of the uploaded rules.", value = "upload") @ApiResponses({ @ApiResponse(code = 400, message = "") }) @POST @Consumes({ MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN }) @Produces({ MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON }) String upload(String rulesBuffer); @ApiOperation(notes = "Retrieves the Rules", value = "get") @ApiResponses({ @ApiResponse(code = 503, message = "") }) @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN }) String get(); @ApiOperation(notes = "Removes the Rules Deletes any uploaded rules, uses bundled rules instead", value = "delete") @DELETE @Produces(MediaType.APPLICATION_JSON) void delete();  }
@Test public void testGet() { String rulesBuffer = new String(Base64.encodeBase64String(( TestUtil.createRulesBlob(10000).getBytes()))); rulesResource.upload(rulesBuffer); String rulesBlob = rulesResource.get(); assertEquals(rulesBlob, rulesBuffer); }