Configuration extends Configurations { public void update() throws Exception { if( null != curatorFramework ) { ConfigurationsUtils.updateConfigsFromZookeeper(this, this.curatorFramework); } else { updateGlobalConfig(ConfigurationsUtils.readGlobalConfigFromFile(configFileRoot.toAbsolutePath().toString())); } } Configuration(CuratorFramework curatorFramework);  Configuration(Path configFileRoot); void update();  }
@Test public void testCanReadFromFile() throws Exception { Configuration configuration = new Configuration(Paths.get("./src/test/resources/config/")); configuration.update(); checkResult(configuration); }
@Test public void testCanReadFromZookeeper() throws Exception { CuratorFramework curatorFramework = mock(CuratorFramework.class); ExistsBuilder existsBuilder = mock(ExistsBuilder.class); GetDataBuilder getDataBuilder = mock(GetDataBuilder.class); GetChildrenBuilder getChildrenBuilder = mock(GetChildrenBuilder.class); when(getDataBuilder.forPath(ConfigurationType.GLOBAL.getZookeeperRoot())).thenReturn(mockGlobalData()); when(curatorFramework.checkExists()).thenReturn(existsBuilder); when(curatorFramework.getData()).thenReturn(getDataBuilder); when(curatorFramework.getChildren()).thenReturn(getChildrenBuilder); when(getChildrenBuilder.forPath(any())).thenReturn(Collections.emptyList()); Configuration configuration = new Configuration(Paths.get("foo")); configuration.curatorFramework = curatorFramework; configuration.update(); checkResult(configuration); }