Search in sources :

Example 11 with ExistsBuilder

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);
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) GetChildrenBuilder(org.apache.curator.framework.api.GetChildrenBuilder) ExistsBuilder(org.apache.curator.framework.api.ExistsBuilder) GetDataBuilder(org.apache.curator.framework.api.GetDataBuilder) Test(org.junit.jupiter.api.Test)

Example 12 with ExistsBuilder

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;
}
Also used : CreateBuilder(org.apache.curator.framework.api.CreateBuilder) ExistsBuilder(org.apache.curator.framework.api.ExistsBuilder) DeleteBuilder(org.apache.curator.framework.api.DeleteBuilder)

Aggregations

ExistsBuilder (org.apache.curator.framework.api.ExistsBuilder)12 CreateBuilder (org.apache.curator.framework.api.CreateBuilder)6 SetDataBuilder (org.apache.curator.framework.api.SetDataBuilder)6 BeforeTest (org.testng.annotations.BeforeTest)6 Test (org.testng.annotations.Test)6 Stat (org.apache.zookeeper.data.Stat)5 CuratorFramework (org.apache.curator.framework.CuratorFramework)4 TimeUnit (java.util.concurrent.TimeUnit)3 Test (org.junit.Test)3 Matchers.anyBoolean (org.mockito.Matchers.anyBoolean)3 Matchers.anyString (org.mockito.Matchers.anyString)3 DeleteBuilder (org.apache.curator.framework.api.DeleteBuilder)2 ACL (org.apache.zookeeper.data.ACL)2 Id (org.apache.zookeeper.data.Id)2 GetChildrenBuilder (org.apache.curator.framework.api.GetChildrenBuilder)1 GetDataBuilder (org.apache.curator.framework.api.GetDataBuilder)1 Test (org.junit.jupiter.api.Test)1