### Question:
DfltSamplerRepositoryServiceV2 implements SamplerRepositoryServiceV2,
    EntityResourceFactoryV2, CacheManagerServiceV2, CacheServiceV2, AgentServiceV2,
    EventServiceV2 { @Override public void clearCache(String cacheManagerName, String cacheName) { cacheManagerSamplerRepoLock.readLock().lock(); SamplerRepoEntry entry = cacheManagerSamplerRepo.get(cacheManagerName); try { enableNonStopFor(entry, false); if (entry != null) { entry.clearCache(cacheName); } } finally { enableNonStopFor(entry, true); cacheManagerSamplerRepoLock.readLock().unlock(); } } DfltSamplerRepositoryServiceV2(ManagementRESTServiceConfiguration configuration,
      RemoteAgentEndpointImpl remoteAgentEndpoint); @Override void dispose(); @Override void register(CacheManager cacheManager); @Override void unregister(CacheManager cacheManager); @Override boolean hasRegistered(); @Override ResponseEntityV2<CacheManagerEntityV2> createCacheManagerEntities(Set<String> cacheManagerNames,
      Set<String> attributes); @Override ResponseEntityV2<CacheManagerConfigEntityV2> createCacheManagerConfigEntities(Set<String> cacheManagerNames); @Override ResponseEntityV2<CacheEntityV2> createCacheEntities(Set<String> cacheManagerNames,
      Set<String> cacheNames,
      Set<String> attributes); @Override ResponseEntityV2<CacheConfigEntityV2> createCacheConfigEntities(Set<String> cacheManagerNames,
      Set<String> cacheNames); @Override ResponseEntityV2<CacheStatisticSampleEntityV2> createCacheStatisticSampleEntity(Set<String> cacheManagerNames,
      Set<String> cacheNames,
      Set<String> sampleNames); @Override void createOrUpdateCache(String cacheManagerName, String cacheName, CacheEntityV2 resource); @Override void clearCache(String cacheManagerName, String cacheName); @Override void updateCacheManager(String cacheManagerName,
      CacheManagerEntityV2 resource); @Override ResponseEntityV2<QueryResultsEntityV2> executeQuery(String cacheManagerName, String queryString); @Override ResponseEntityV2<AgentEntityV2> getAgents(Set<String> ids); @Override ResponseEntityV2<AgentMetadataEntityV2> getAgentsMetadata(Set<String> ids); @Override void registerEventListener(EventListener listener, boolean localOnly); @Override void unregisterEventListener(EventListener listener); static final String AGENCY; }### Answer:
@Test public void testClearCacheDisablesNonStop() throws Exception { repositoryService.clearCache("testCacheManager", "testCache1"); verify(clusteredInstanceFactory, times(2)).enableNonStopForCurrentThread(anyBoolean()); }
@Test public void testClearCacheDisablesNonStop() throws Exception { repositoryService.clearCache("testCacheManager", "testCache1"); verify(clusteredInstanceFactory, times(4)).enableNonStopForCurrentThread(anyBoolean()); }