@Test
public void testNodeInABlacklistSubCluster() throws YarnException {

  // Blacklist SubCluster3
  String subClusterToBlacklist = "subcluster3";
  // Remember the current value of subcluster3
  Float value =
      getPolicyInfo().getRouterPolicyWeights().get(subClusterToBlacklist);
  getPolicyInfo().getRouterPolicyWeights()
      .put(new SubClusterIdInfo(subClusterToBlacklist), 0.0f);
  initializePolicy(new YarnConfiguration());
  FederationPoliciesTestUtil
      .initializePolicyContext(getFederationPolicyContext(), getPolicy(),
          getPolicyInfo(), getActiveSubclusters(), new Configuration());
  List<ResourceRequest> requests = new ArrayList<ResourceRequest>();
  boolean relaxLocality = true;
  requests.add(ResourceRequest
      .newInstance(Priority.UNDEFINED, "node4", Resource.newInstance(10, 1),
          1, relaxLocality));
  requests.add(ResourceRequest
      .newInstance(Priority.UNDEFINED, "rack1", Resource.newInstance(10, 1),
          1));
  requests.add(ResourceRequest
      .newInstance(Priority.UNDEFINED, ResourceRequest.ANY,
          Resource.newInstance(10, 1), 1));
  ApplicationSubmissionContext asc = ApplicationSubmissionContext
      .newInstance(null, null, null, null, null, false, false, 0,
          Resources.none(), null, false, null, null);
  asc.setAMContainerResourceRequests(requests);
  try {
    SubClusterId targetId =
        ((FederationRouterPolicy) getPolicy()).getHomeSubcluster(asc, null);
    // The selected subcluster HAS no to be the same as the one blacklisted.
    Assert.assertNotEquals(targetId.getId(), subClusterToBlacklist);
  } catch (FederationPolicyException e) {
    Assert.fail();
  }
  // Set again the previous value for the other tests
  getPolicyInfo().getRouterPolicyWeights()
      .put(new SubClusterIdInfo(subClusterToBlacklist), value);
}