### Question:
Throttling { int getThrottlingLevel(Map<String, Object> systemStatistics) { if (systemStatistics == null) { logger.error("systemStatistics should not be null"); return 0; } StatisticsExpressionContext context = new StatisticsExpressionContext(systemStatistics); try { Object val = enginee.evaluate(expression, context); if (val instanceof Number) { return ((Number)val).intValue(); } } catch (Exception e) { logger.error("failed to eval throttling expression", e); } return 0; } Throttling(String expression);   }### Answer:
@Test public void testGetHealthyStatus() throws IOException { String expression = FileUtils.readFile(ThrottlingTest.class.getResource("/throttlingExpression.js").getPath(), Charset .forName("utf-8")); Throttling throttling = new Throttling(expression); Assert.assertEquals(0, throttling.getThrottlingLevel(null)); Map<String, Object> stat = new HashMap<String, Object>(); Assert.assertEquals(0, throttling.getThrottlingLevel(stat)); stat.put("currentTimestamp", System.currentTimeMillis()); stat.put("fullGCTimestamp", System.currentTimeMillis() - 21 * 60000); stat.put("currentPercent", 0.9); stat.put("currentThrottlingLevel", 100); Assert.assertEquals(0, throttling.getThrottlingLevel(stat)); stat.put("currentTimestamp", System.currentTimeMillis()); stat.put("fullGCTimestamp", System.currentTimeMillis() - 10 * 60000); stat.put("currentPercent", 0.91); stat.put("currentThrottlingLevel", 100); Assert.assertEquals(10000, throttling.getThrottlingLevel(stat)); stat.put("currentTimestamp", System.currentTimeMillis()); stat.put("fullGCTimestamp", System.currentTimeMillis() - 19 * 60000); stat.put("currentPercent", 0.82); stat.put("currentThrottlingLevel", 100); Assert.assertEquals(100, throttling.getThrottlingLevel(stat)); stat.put("currentTimestamp", System.currentTimeMillis()); stat.put("fullGCTimestamp", System.currentTimeMillis() - 19 * 60000); stat.put("currentPercent", 0.79); stat.put("currentThrottlingLevel", 100); Assert.assertEquals(10, throttling.getThrottlingLevel(stat)); }