FunctionStatsManager { public void close() { for (FunctionStats functionstats : functionExecutionStatsMap.values()) { functionstats.close(); } functionServiceStats.close(); } FunctionStatsManager(boolean statsDisabled, StatisticsFactory statisticsFactory,
      Supplier<MeterRegistry> meterRegistrySupplier); @VisibleForTesting  FunctionStatsManager(boolean statsDisabled, StatisticsFactory statisticsFactory,
      FunctionServiceStats functionServiceStats, Supplier<MeterRegistry> meterRegistrySupplier); FunctionServiceStats getFunctionServiceStats(); FunctionStats getFunctionStatsByName(String name); void close(); static FunctionStats getFunctionStats(String functionID, InternalDistributedSystem ds); static FunctionStats getFunctionStats(String functionID);  }
@Test public void close_closesAllCreatedFunctionStats() { FunctionStatsManager functionStatsManager = new FunctionStatsManager(false, statisticsFactory, () -> meterRegistry); List<FunctionStats> functionStats = Stream.of("a", "b", "c") .map(functionStatsManager::getFunctionStatsByName) .collect(toList()); functionStatsManager.close(); assertThat(functionStats) .allMatch(FunctionStats::isClosed, "Function stats is closed"); }
@Test public void close_closesFunctionServiceStats() { FunctionServiceStats functionServiceStats = mock(FunctionServiceStats.class); FunctionStatsManager functionStatsManager = new FunctionStatsManager(false, statisticsFactory, functionServiceStats, () -> meterRegistry); functionStatsManager.close(); verify(functionServiceStats) .close(); }