InternalCacheBuilder { public InternalCacheBuilder addMeterSubregistry(MeterRegistry subregistry) { requireNonNull(subregistry, "meter registry"); metricsSessionBuilder.addPersistentMeterRegistry(subregistry); return this; } InternalCacheBuilder();  InternalCacheBuilder(Properties configProperties);  InternalCacheBuilder(CacheConfig cacheConfig); private  InternalCacheBuilder(Properties configProperties, CacheConfig cacheConfig); @VisibleForTesting  InternalCacheBuilder(Properties configProperties,
      CacheConfig cacheConfig,
      MetricsService.Builder metricsSessionBuilder,
      Supplier<InternalDistributedSystem> singletonSystemSupplier,
      InternalDistributedSystemConstructor internalDistributedSystemConstructor,
      Supplier<InternalCache> singletonCacheSupplier,
      InternalCacheConstructor internalCacheConstructor); InternalCache create(); InternalCache create(InternalDistributedSystem internalDistributedSystem); InternalCacheBuilder set(String name, String value); InternalCacheBuilder setPdxReadSerialized(boolean readSerialized); InternalCacheBuilder setSecurityManager(SecurityManager securityManager); InternalCacheBuilder setPostProcessor(PostProcessor postProcessor); InternalCacheBuilder setPdxSerializer(PdxSerializer serializer); InternalCacheBuilder setPdxDiskStore(String diskStoreName); InternalCacheBuilder setPdxPersistent(boolean isPersistent); InternalCacheBuilder setPdxIgnoreUnreadFields(boolean ignore); InternalCacheBuilder setCacheXMLDescription(String cacheXML); InternalCacheBuilder setIsExistingOk(boolean isExistingOk); InternalCacheBuilder setIsClient(boolean isClient); InternalCacheBuilder setUseAsyncEventListeners(boolean useAsyncEventListeners); InternalCacheBuilder setPoolFactory(PoolFactory poolFactory); InternalCacheBuilder setTypeRegistry(TypeRegistry typeRegistry); InternalCacheBuilder addMeterSubregistry(MeterRegistry subregistry);  }
@Test public void addMeterSubregistry_addsGivenRegistryToMetricsServiceBuilder() { InternalCacheBuilder internalCacheBuilder = new InternalCacheBuilder( new Properties(), new CacheConfig(), metricsServiceBuilder, nullSingletonSystemSupplier, constructorOf(constructedSystem()), nullSingletonCacheSupplier, constructorOf(constructedCache())); SimpleMeterRegistry addedMeterRegistry = new SimpleMeterRegistry(); internalCacheBuilder.addMeterSubregistry(addedMeterRegistry); verify(metricsServiceBuilder).addPersistentMeterRegistry(same(addedMeterRegistry)); }
@Test public void addMeterSubregistry_throwsNullPointerExceptionIfTheGivenRegistryIsNull() { InternalCacheBuilder internalCacheBuilder = new InternalCacheBuilder( new Properties(), new CacheConfig(), metricsServiceBuilder, nullSingletonSystemSupplier, constructorOf(constructedSystem()), nullSingletonCacheSupplier, constructorOf(constructedCache())); assertThatThrownBy(() -> internalCacheBuilder.addMeterSubregistry(null)) .isInstanceOf(NullPointerException.class); }