use of org.apache.curator.framework.api.ExistsBuilder in project metron by apache.
the class ConfigurationTest method testCanReadFromZookeeper.
@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);
}
use of org.apache.curator.framework.api.ExistsBuilder in project incubator-atlas by apache.
the class SetupStepsTest method setupSetupInProgressPathMocks.
private Pair<CreateBuilder, DeleteBuilder> setupSetupInProgressPathMocks(List<ACL> acls, Stat stat) throws Exception {
when(curatorFactory.clientInstance()).thenReturn(client);
CreateBuilder createBuilder = mock(CreateBuilder.class);
when(createBuilder.withACL(acls)).thenReturn(createBuilder);
when(client.create()).thenReturn(createBuilder);
DeleteBuilder deleteBuilder = mock(DeleteBuilder.class);
when(client.delete()).thenReturn(deleteBuilder);
Pair<CreateBuilder, DeleteBuilder> pair = Pair.of(createBuilder, deleteBuilder);
ExistsBuilder existsBuilder = mock(ExistsBuilder.class);
when(client.checkExists()).thenReturn(existsBuilder);
when(existsBuilder.forPath(HAConfiguration.ATLAS_SERVER_ZK_ROOT_DEFAULT + SetupSteps.SETUP_IN_PROGRESS_NODE)).thenReturn(stat);
return pair;
}
Aggregations