@Test
public void testGetHomeSubcluster() throws YarnException {

  ApplicationSubmissionContext applicationSubmissionContext =
      mock(ApplicationSubmissionContext.class);
  when(applicationSubmissionContext.getQueue()).thenReturn(queue1);
  // the facade only contains the fallback behavior
  Assert.assertTrue(routerFacade.globalPolicyMap.containsKey(defQueueKey)
      && routerFacade.globalPolicyMap.size() == 1);
  // when invoked it returns the expected SubClusterId.
  SubClusterId chosen =
      routerFacade.getHomeSubcluster(applicationSubmissionContext, null);
  Assert.assertTrue(subClusterIds.contains(chosen));
  // now the caching of policies must have added an entry for this queue
  Assert.assertTrue(routerFacade.globalPolicyMap.size() == 2);
  // after the facade is used the policyMap contains the expected policy type.
  Assert.assertTrue(routerFacade.globalPolicyMap
      .get(queue1) instanceof UniformRandomRouterPolicy);
  // the facade is again empty after reset
  routerFacade.reset();
  // the facade only contains the fallback behavior
  Assert.assertTrue(routerFacade.globalPolicyMap.containsKey(defQueueKey)
      && routerFacade.globalPolicyMap.size() == 1);
}