ZookeeperStateRepository implements StateRepository, TreeCacheListener { @Override public FeatureState getFeatureState(Feature feature) { FeatureStateStorageWrapper wrapper = states.get(feature.name()); if (wrapper != null) { return featureStateForWrapper(feature, wrapper); } return null; } private  ZookeeperStateRepository(Builder builder); @Override FeatureState getFeatureState(Feature feature); @Override void setFeatureState(FeatureState featureState); @Override void childEvent(CuratorFramework curatorFramework, TreeCacheEvent event); static Builder newBuilder(CuratorFramework curatorFramework, String featuresZnode);  }
@Test public void testLoadingWithSavedState() throws Exception { Map<String, String> initialData = new HashMap<>(); initialData.put(TEST_ZNODE + "/FEATURE", "{\"enabled\":true,\"strategyId\":null,\"parameters\":{}}"); setupTestWithData(initialData); FeatureState expectedFeatureState = new FeatureState(TestFeature.FEATURE); expectedFeatureState.setEnabled(true); FeatureState loadedFeatureState = stateRepository.getFeatureState(TestFeature.FEATURE); assertTrue(reflectionEquals(expectedFeatureState, loadedFeatureState)); }