// Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/store/TenacityPropertyKeysStore.java
// public class TenacityPropertyKeysStore {
//     private static final Logger LOGGER = LoggerFactory.getLogger(TenacityPropertyKeysStore.class);
//     private final Cache<Instance, Collection<String>> tenacityPropertyKeyCache = CacheBuilder
//             .newBuilder()
//             .expireAfterWrite(1, TimeUnit.MINUTES)
//             .build();
//     private final TenacityPoller.Factory tenacityPollerFactory;
// 
//     public TenacityPropertyKeysStore(TenacityPoller.Factory tenacityPollerFactory) {
//         this.tenacityPollerFactory = tenacityPollerFactory;
//     }
// 
//     public Collection<String> getTenacityPropertyKeys(Instance instance) {
//         try {
//             return tenacityPropertyKeyCache.get(instance, () ->
//                     tenacityPollerFactory.create(instance).execute().orElse(null));
//         } catch (CacheLoader.InvalidCacheLoadException err) {
//             //null was returned
//         } catch (Exception err) {
//             LOGGER.warn("Unexpected exception", err);
//         }
//         return ImmutableList.of();
//     }
// 
//     public Set<String> tenacityPropertyKeysFor(Collection<Instance> instances) {
//         return instances
//                 .stream()
//                 .map(this::getTenacityPropertyKeys)
//                 .flatMap(Collection::stream)
//                 .collect(Collectors.toSet());
//     }
// }
// 
// Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/tenacity/TenacityPoller.java
// public class TenacityPoller extends TenacityCommand<Optional<Collection<String>>> {
//     public static class Factory {
//         private final TurbineTenacityClient tenacityClient;
// 
//         public Factory(TurbineTenacityClient tenacityClient) {
//             this.tenacityClient = tenacityClient;
//         }
// 
//         public TenacityPoller create(Instance instance) {
//             return new TenacityPoller(tenacityClient, instance);
//         }
//     }
// 
//     private final TurbineTenacityClient tenacityClient;
//     private final Instance instance;
// 
//     public TenacityPoller(TurbineTenacityClient tenacityClient,
//                           Instance instance) {
//         super(BreakerboxDependencyKey.BRKRBX_SERVICES_PROPERTYKEYS);
//         this.tenacityClient = tenacityClient;
//         this.instance = instance;
//     }
// 
//     @Override
//     protected Optional<Collection<String>> run() throws Exception {
//         return tenacityClient.getTenacityPropertyKeys(instance);
//     }
// 
//     @Override
//     protected Optional<Collection<String>> getFallback() {
//         return Optional.empty();
//     }
// }


import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.netflix.turbine.discovery.Instance;
import com.yammer.breakerbox.service.store.TenacityPropertyKeysStore;
import com.yammer.breakerbox.service.tenacity.TenacityPoller;
import org.junit.Test;
import java.util.Optional;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
package com.yammer.breakerbox.service.store.tests;




public class TenacityPropertyKeysStoreTest {
    @Test
    public void tenacityPropertyKeysForUris() {
        final TenacityPoller.Factory mockFactory = mock(TenacityPoller.Factory.class);
        final TenacityPoller mockPoller = mock(TenacityPoller.class);
        final TenacityPoller mockPoller2 = mock(TenacityPoller.class);
        final Instance firstInstance = new Instance("http://localhost:1234", "ignored", true);
        final Instance secondInstance = new Instance("http://another:8080", "ignored", true);

        when(mockFactory.create(firstInstance)).thenReturn(mockPoller);
        when(mockFactory.create(secondInstance)).thenReturn(mockPoller2);
        when(mockPoller.execute()).thenReturn(Optional.of(ImmutableList.of("things", "stuff")));
        when(mockPoller2.execute()).thenReturn(Optional.of(ImmutableList.of("morethings", "stuff")));

// Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/store/TenacityPropertyKeysStore.java
// public class TenacityPropertyKeysStore {
//     private static final Logger LOGGER = LoggerFactory.getLogger(TenacityPropertyKeysStore.class);
//     private final Cache<Instance, Collection<String>> tenacityPropertyKeyCache = CacheBuilder
//             .newBuilder()
//             .expireAfterWrite(1, TimeUnit.MINUTES)
//             .build();
//     private final TenacityPoller.Factory tenacityPollerFactory;
// 
//     public TenacityPropertyKeysStore(TenacityPoller.Factory tenacityPollerFactory) {
//         this.tenacityPollerFactory = tenacityPollerFactory;
//     }
// 
//     public Collection<String> getTenacityPropertyKeys(Instance instance) {
//         try {
//             return tenacityPropertyKeyCache.get(instance, () ->
//                     tenacityPollerFactory.create(instance).execute().orElse(null));
//         } catch (CacheLoader.InvalidCacheLoadException err) {
//             //null was returned
//         } catch (Exception err) {
//             LOGGER.warn("Unexpected exception", err);
//         }
//         return ImmutableList.of();
//     }
// 
//     public Set<String> tenacityPropertyKeysFor(Collection<Instance> instances) {
//         return instances
//                 .stream()
//                 .map(this::getTenacityPropertyKeys)
//                 .flatMap(Collection::stream)
//                 .collect(Collectors.toSet());
//     }
// }
// 
// Path: breakerbox-service/src/main/java/com/yammer/breakerbox/service/tenacity/TenacityPoller.java
// public class TenacityPoller extends TenacityCommand<Optional<Collection<String>>> {
//     public static class Factory {
//         private final TurbineTenacityClient tenacityClient;
// 
//         public Factory(TurbineTenacityClient tenacityClient) {
//             this.tenacityClient = tenacityClient;
//         }
// 
//         public TenacityPoller create(Instance instance) {
//             return new TenacityPoller(tenacityClient, instance);
//         }
//     }
// 
//     private final TurbineTenacityClient tenacityClient;
//     private final Instance instance;
// 
//     public TenacityPoller(TurbineTenacityClient tenacityClient,
//                           Instance instance) {
//         super(BreakerboxDependencyKey.BRKRBX_SERVICES_PROPERTYKEYS);
//         this.tenacityClient = tenacityClient;
//         this.instance = instance;
//     }
// 
//     @Override
//     protected Optional<Collection<String>> run() throws Exception {
//         return tenacityClient.getTenacityPropertyKeys(instance);
//     }
// 
//     @Override
//     protected Optional<Collection<String>> getFallback() {
//         return Optional.empty();
//     }
// }


// Path: breakerbox-service/src/test/java/com/yammer/breakerbox/service/store/tests/TenacityPropertyKeysStoreTest.java
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.netflix.turbine.discovery.Instance;
import com.yammer.breakerbox.service.store.TenacityPropertyKeysStore;
import com.yammer.breakerbox.service.tenacity.TenacityPoller;
import org.junit.Test;
import java.util.Optional;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

package com.yammer.breakerbox.service.store.tests;




public class TenacityPropertyKeysStoreTest {
    @Test
    public void tenacityPropertyKeysForUris() {
        final TenacityPoller.Factory mockFactory = mock(TenacityPoller.Factory.class);
        final TenacityPoller mockPoller = mock(TenacityPoller.class);
        final TenacityPoller mockPoller2 = mock(TenacityPoller.class);
        final Instance firstInstance = new Instance("http://localhost:1234", "ignored", true);
        final Instance secondInstance = new Instance("http://another:8080", "ignored", true);

        when(mockFactory.create(firstInstance)).thenReturn(mockPoller);
        when(mockFactory.create(secondInstance)).thenReturn(mockPoller2);
        when(mockPoller.execute()).thenReturn(Optional.of(ImmutableList.of("things", "stuff")));
        when(mockPoller2.execute()).thenReturn(Optional.of(ImmutableList.of("morethings", "stuff")));

        final TenacityPropertyKeysStore tenacityPropertyKeysStore = new TenacityPropertyKeysStore(mockFactory);