GenericEntityServiceResource { public GenericServiceAPIResponseEntity updateDatabase(Statement<ModifyResult<String>> statement) { GenericServiceAPIResponseEntity<String> response = new GenericServiceAPIResponseEntity<>(); Map<String,Object> meta = new HashMap<>(); StopWatch stopWatch = new StopWatch(); try { stopWatch.start(); DataStorage dataStorage = DataStorageManager.getDataStorageByEagleConfig(); if(dataStorage == null){ LOG.error("Data storage is null"); throw new IllegalDataStorageException("Data storage is null"); } ModifyResult<String> result = statement.execute(dataStorage); if(result.isSuccess()) { List<String> keys =result.getIdentifiers(); if(keys != null) { response.setObj(keys, String.class); meta.put(TOTAL_RESULTS, keys.size()); } else { meta.put(TOTAL_RESULTS, 0); } meta.put(ELAPSEDMS,stopWatch.getTime()); response.setMeta(meta); response.setSuccess(true); } } catch (Exception e) { LOG.error(e.getMessage(), e); response.setException(e); }finally { stopWatch.stop(); } return response; }  GenericServiceAPIResponseEntity updateDatabase(Statement<ModifyResult<String>> statement); GenericServiceAPIResponseEntity updateEntities(List<? extends TaggedLogAPIEntity> entities, String serviceName); @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) GenericServiceAPIResponseEntity create(InputStream inputStream,
                                                 @QueryParam("serviceName") String serviceName); @POST @Consumes({MediaType.MULTIPART_FORM_DATA}) @Produces(MediaType.APPLICATION_JSON) GenericServiceAPIResponseEntity create(@FormDataParam("file") InputStream fileInputStream,
                                                  @FormDataParam("file") FormDataContentDisposition cdh,
                                                  @QueryParam("serviceName") String serviceName); @PUT @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) GenericServiceAPIResponseEntity update(InputStream inputStream,
                                                 @QueryParam("serviceName") String serviceName); @PUT @Consumes({MediaType.MULTIPART_FORM_DATA}) @Produces(MediaType.APPLICATION_JSON) GenericServiceAPIResponseEntity update(@FormDataParam("file") InputStream fileInputStream,
                                                  @FormDataParam("file") FormDataContentDisposition cdh,
                                                  @QueryParam("serviceName") String serviceName); @GET @Path(ROWKEY_PATH) @Produces(MediaType.APPLICATION_JSON) GenericServiceAPIResponseEntity search(@QueryParam("value") String value,@QueryParam("serviceName") String serviceName); @POST @Path(ROWKEY_PATH) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) GenericServiceAPIResponseEntity search(InputStream inputStream,@QueryParam("serviceName") String serviceName); @GET @Produces(MediaType.APPLICATION_JSON) @SuppressWarnings("unchecked") GenericServiceAPIResponseEntity search(@QueryParam("query") String query,
                                                 @QueryParam("startTime") String startTime, @QueryParam("endTime") String endTime,
                                                 @QueryParam("pageSize") int pageSize, @QueryParam("startRowkey") String startRowkey,
                                                 @QueryParam("treeAgg") boolean treeAgg, @QueryParam("timeSeries") boolean timeSeries,
                                                 @QueryParam("intervalmin") long intervalmin, @QueryParam("top") int top,
                                                 @QueryParam("filterIfMissing") boolean filterIfMissing,
                                                 @QueryParam("parallel") int parallel,
                                                 @QueryParam("metricName") String metricName,
                                                 @QueryParam("verbose") Boolean verbose); @GET @Path(JSONP_PATH) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) JSONWithPadding searchWithJsonp(@QueryParam("query") String query,
                                           @QueryParam("startTime") String startTime, @QueryParam("endTime") String endTime,
                                           @QueryParam("pageSize") int pageSize, @QueryParam("startRowkey") String startRowkey,
                                           @QueryParam("treeAgg") boolean treeAgg, @QueryParam("timeSeries") boolean timeSeries,
                                           @QueryParam("intervalmin") long intervalmin, @QueryParam("top") int top,
                                           @QueryParam("filterIfMissing") boolean filterIfMissing,
                                           @QueryParam("parallel") int parallel,
                                           @QueryParam("metricName") String metricName,
                                           @QueryParam("verbose") Boolean verbose,
                                           @QueryParam("callback") String callback); @DELETE @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) GenericServiceAPIResponseEntity deleteByQuery(@QueryParam("query") String query,
                                                 @QueryParam("startTime") String startTime, @QueryParam("endTime") String endTime,
                                                 @QueryParam("pageSize") int pageSize, @QueryParam("startRowkey") String startRowkey,
                                                 @QueryParam("treeAgg") boolean treeAgg, @QueryParam("timeSeries") boolean timeSeries,
                                                 @QueryParam("intervalmin") long intervalmin, @QueryParam("top") int top,
                                                 @QueryParam("filterIfMissing") boolean filterIfMissing,
                                                 @QueryParam("parallel") int parallel,
                                                 @QueryParam("metricName") String metricName,
                                                 @QueryParam("verbose") Boolean verbose); @POST @Path(DELETE_ENTITIES_PATH) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) GenericServiceAPIResponseEntity deleteEntities(InputStream inputStream,
                                                 @QueryParam("serviceName") String serviceName,
                                                 @QueryParam("byId") Boolean deleteById); final static String ROOT_PATH; final static String JSONP_PATH; final static String DELETE_ENTITIES_PATH; final static String ROWKEY_PATH; final static String FIRST_TIMESTAMP; final static String LAST_TIMESTAMP; final static String ELAPSEDMS; final static String TOTAL_RESULTS; }
@Test public void testGenericEntityServiceResourceupdateDatabaseNullDataStorage() throws IllegalDataStorageTypeException { when(DataStorageManager.getDataStorageByEagleConfig()).thenReturn(null); GenericServiceAPIResponseEntity responseEntity = genericEntityServiceResource.updateDatabase(null); Assert.assertFalse(responseEntity.isSuccess()); Assert.assertEquals(null, responseEntity.getMeta()); Assert.assertEquals(null, responseEntity.getType()); Assert.assertEquals(null, responseEntity.getObj()); Assert.assertTrue(responseEntity.getException().startsWith("org.apache.eagle.storage.exception.IllegalDataStorageException: Data storage is null")); }