### Question:
JStormDebugger implements Refreshable { public static boolean isDebug(Long root_id) { return isDebug && sample(root_id); } private  JStormDebugger(); static JStormDebugger getInstance(); static boolean isDebug(Long root_id); static boolean isDebug(Set<Long> rootIds); static boolean isDebug(Collection<Tuple> anchors); static boolean isDebug(Object id); static boolean isDebugRecv(MessageId msgId); static boolean isDebugRecv(Set<Long> rootIds); static boolean isDebugRecv(Collection<Tuple> anchors); static boolean isDebugRecv(Object id); static void update(Map conf); @Override void refresh(Map conf); static volatile boolean isDebug; static volatile boolean isDebugRecv; static volatile double sampleRate; }### Answer:
@Test public void testIsDebugForLong() throws Exception { int tries = 50000; double expected = tries * SAMPLE_RATE; int lottery = 0; int num = tries; while (num-- > 0) { Long root_id = random.nextLong(); if (JStormDebugger.isDebug(root_id)) { lottery++; } } assertEquals(expected, lottery, expected * 0.05); }
@Test public void testIsDebugForObject() throws Exception { boolean actual = JStormDebugger.isDebug("abc"); assertEquals(false, actual); actual = JStormDebugger.isDebug((Object) null); assertEquals(false, actual); int tries = 50000; double expected = tries * SAMPLE_RATE; int lottery = 0; int num = tries; while (num-- > 0) { Long root_id = random.nextLong(); if (JStormDebugger.isDebug((Object) root_id)) { lottery++; } } assertEquals(expected, lottery, expected * 0.1); }