@Test public void serializeStatistics() { Statistics stats = new Statistics("test", 0, 1, 2, 3, 4, 5, 6, 7, 8, "duke", 9); String result = this.cut.serializeStatistics(stats); assertNotNull(result); }
public String serializeStatistics(Statistics statistics) { JsonObjectBuilder stats = Json.createObjectBuilder(); stats.add("pipelineName", statistics.getPipelineName()); final String handlerName = statistics.getRejectedExecutionHandlerName(); if (handlerName != null) { stats.add("rejectedExecutionHandlerName", handlerName); } stats.add("activeThreadCount", statistics.getActiveThreadCount()); stats.add("completedTaskCount", statistics.getCompletedTaskCount()); stats.add("corePoolSize", statistics.getCorePoolSize()); stats.add("currentThreadPoolSize", statistics.getCurrentThreadPoolSize()); stats.add("largestThreadPoolSize", statistics.getLargestThreadPoolSize()); stats.add("maximumPoolSize", statistics.getMaximumPoolSize()); stats.add("rejectedTasks", statistics.getRejectedTasks()); stats.add("remainingQueueCapacity", statistics.getRemainingQueueCapacity()); stats.add("minQueueCapacity", statistics.getMinQueueCapacity()); stats.add("totalNumberOfTasks", statistics.getTotalNumberOfTasks()); StringWriter writer = new StringWriter(); try (JsonWriter outputWriter = Json.createWriter(writer)) { outputWriter.writeObject(stats.build()); } return writer.toString(); }
HttpHeaderStatisticInjector implements WriterInterceptor { public String serializeStatistics(Statistics statistics) { JsonObjectBuilder stats = Json.createObjectBuilder(); stats.add("pipelineName", statistics.getPipelineName()); final String handlerName = statistics.getRejectedExecutionHandlerName(); if (handlerName != null) { stats.add("rejectedExecutionHandlerName", handlerName); } stats.add("activeThreadCount", statistics.getActiveThreadCount()); stats.add("completedTaskCount", statistics.getCompletedTaskCount()); stats.add("corePoolSize", statistics.getCorePoolSize()); stats.add("currentThreadPoolSize", statistics.getCurrentThreadPoolSize()); stats.add("largestThreadPoolSize", statistics.getLargestThreadPoolSize()); stats.add("maximumPoolSize", statistics.getMaximumPoolSize()); stats.add("rejectedTasks", statistics.getRejectedTasks()); stats.add("remainingQueueCapacity", statistics.getRemainingQueueCapacity()); stats.add("minQueueCapacity", statistics.getMinQueueCapacity()); stats.add("totalNumberOfTasks", statistics.getTotalNumberOfTasks()); StringWriter writer = new StringWriter(); try (JsonWriter outputWriter = Json.createWriter(writer)) { outputWriter.writeObject(stats.build()); } return writer.toString(); } }
HttpHeaderStatisticInjector implements WriterInterceptor { public String serializeStatistics(Statistics statistics) { JsonObjectBuilder stats = Json.createObjectBuilder(); stats.add("pipelineName", statistics.getPipelineName()); final String handlerName = statistics.getRejectedExecutionHandlerName(); if (handlerName != null) { stats.add("rejectedExecutionHandlerName", handlerName); } stats.add("activeThreadCount", statistics.getActiveThreadCount()); stats.add("completedTaskCount", statistics.getCompletedTaskCount()); stats.add("corePoolSize", statistics.getCorePoolSize()); stats.add("currentThreadPoolSize", statistics.getCurrentThreadPoolSize()); stats.add("largestThreadPoolSize", statistics.getLargestThreadPoolSize()); stats.add("maximumPoolSize", statistics.getMaximumPoolSize()); stats.add("rejectedTasks", statistics.getRejectedTasks()); stats.add("remainingQueueCapacity", statistics.getRemainingQueueCapacity()); stats.add("minQueueCapacity", statistics.getMinQueueCapacity()); stats.add("totalNumberOfTasks", statistics.getTotalNumberOfTasks()); StringWriter writer = new StringWriter(); try (JsonWriter outputWriter = Json.createWriter(writer)) { outputWriter.writeObject(stats.build()); } return writer.toString(); }  }
HttpHeaderStatisticInjector implements WriterInterceptor { public String serializeStatistics(Statistics statistics) { JsonObjectBuilder stats = Json.createObjectBuilder(); stats.add("pipelineName", statistics.getPipelineName()); final String handlerName = statistics.getRejectedExecutionHandlerName(); if (handlerName != null) { stats.add("rejectedExecutionHandlerName", handlerName); } stats.add("activeThreadCount", statistics.getActiveThreadCount()); stats.add("completedTaskCount", statistics.getCompletedTaskCount()); stats.add("corePoolSize", statistics.getCorePoolSize()); stats.add("currentThreadPoolSize", statistics.getCurrentThreadPoolSize()); stats.add("largestThreadPoolSize", statistics.getLargestThreadPoolSize()); stats.add("maximumPoolSize", statistics.getMaximumPoolSize()); stats.add("rejectedTasks", statistics.getRejectedTasks()); stats.add("remainingQueueCapacity", statistics.getRemainingQueueCapacity()); stats.add("minQueueCapacity", statistics.getMinQueueCapacity()); stats.add("totalNumberOfTasks", statistics.getTotalNumberOfTasks()); StringWriter writer = new StringWriter(); try (JsonWriter outputWriter = Json.createWriter(writer)) { outputWriter.writeObject(stats.build()); } return writer.toString(); }  @Override void aroundWriteTo(WriterInterceptorContext context); String serializeStatistics(Statistics statistics); }
HttpHeaderStatisticInjector implements WriterInterceptor { public String serializeStatistics(Statistics statistics) { JsonObjectBuilder stats = Json.createObjectBuilder(); stats.add("pipelineName", statistics.getPipelineName()); final String handlerName = statistics.getRejectedExecutionHandlerName(); if (handlerName != null) { stats.add("rejectedExecutionHandlerName", handlerName); } stats.add("activeThreadCount", statistics.getActiveThreadCount()); stats.add("completedTaskCount", statistics.getCompletedTaskCount()); stats.add("corePoolSize", statistics.getCorePoolSize()); stats.add("currentThreadPoolSize", statistics.getCurrentThreadPoolSize()); stats.add("largestThreadPoolSize", statistics.getLargestThreadPoolSize()); stats.add("maximumPoolSize", statistics.getMaximumPoolSize()); stats.add("rejectedTasks", statistics.getRejectedTasks()); stats.add("remainingQueueCapacity", statistics.getRemainingQueueCapacity()); stats.add("minQueueCapacity", statistics.getMinQueueCapacity()); stats.add("totalNumberOfTasks", statistics.getTotalNumberOfTasks()); StringWriter writer = new StringWriter(); try (JsonWriter outputWriter = Json.createWriter(writer)) { outputWriter.writeObject(stats.build()); } return writer.toString(); }  @Override void aroundWriteTo(WriterInterceptorContext context); String serializeStatistics(Statistics statistics);  }