@Test
  public void testInitializeAtHaHDFSCluster() throws AmbariException {

    ClusterImpl cluster = createMock(ClusterImpl.class);
    expect(cluster.getService("GLUSTERFS")).andReturn(null);
    expect(cluster.getClusterId()).andReturn(1L);
    Service hdfsService = createMock(Service.class);
    ServiceComponent journalnodeSC = createMock(ServiceComponent.class);

    expect(cluster.getService("HDFS")).andReturn(hdfsService).atLeastOnce();
    expect(cluster.getService("YARN")).andReturn(null);
    expect(hdfsService.getServiceComponent("JOURNALNODE")).andReturn(journalnodeSC);
    expect(hdfsService.getDesiredStackId()).andReturn(new StackId("HDP", "2.0.6"));
//    expect(cluster.getCurrentStackVersion()).andReturn(new StackId("HDP", "2.0.6"));
    expect(cluster.getServices()).andReturn(ImmutableMap.<String, Service>builder()
        .put("HDFS", hdfsService)
        .build()).anyTimes();

    replay(cluster, hdfsService);

    RoleCommandOrder rco = roleCommandOrderProvider.getRoleCommandOrder(cluster);
    Map<RoleCommandPair, Set<RoleCommandPair>> deps = rco.getDependencies();
    assertTrue("Dependencies are loaded after initialization", deps.size() > 0);
    verify(cluster);
    verify(hdfsService);
    // Check that GLUSTERFS components are not present in dependencies
    // Checking blocked roles
    assertFalse(dependenciesContainBlockedRole(deps, Role.PEERSTATUS));
    assertFalse(dependenciesContainBlockedRole(deps, Role.GLUSTERFS_SERVICE_CHECK));
    assertFalse(dependenciesContainBlockedRole(deps, Role.GLUSTERFS_CLIENT));
    // Checking blocker roles
    assertFalse(dependenciesContainBlockerRole(deps, Role.PEERSTATUS));
    assertFalse(dependenciesContainBlockerRole(deps, Role.GLUSTERFS_SERVICE_CHECK));
    assertFalse(dependenciesContainBlockerRole(deps, Role.GLUSTERFS_CLIENT));

    // And that some HDFS components are present (section has been loaded)
    assertTrue(dependenciesContainBlockerRole(deps, Role.DATANODE));
    // Check that some HA NN dependencies are present
    assertTrue(dependenciesContainBlockerRole(deps, Role.JOURNALNODE));
    assertTrue(dependenciesContainBlockedRole(deps, Role.ZKFC));
  }
Tests building dependencies in HA-enabled HDFS cluster. Uses real
dependency mapping file (role_command_order.json)
ambari-server/src/test/java/org/apache/ambari/server/metadata/RoleCommandOrderTest.java