@Test
public void testFallbacks() throws YarnException {

  // this tests the behavior of the system when the queue requested is
  // not configured (or null) and there is no default policy configured
  // for DEFAULT_FEDERATION_POLICY_KEY (*). This is our second line of
  // defense.
  ApplicationSubmissionContext applicationSubmissionContext =
      mock(ApplicationSubmissionContext.class);
  // The facade answers also for non-initialized policies (using the
  // defaultPolicy)
  String uninitQueue = "non-initialized-queue";
  when(applicationSubmissionContext.getQueue()).thenReturn(uninitQueue);
  SubClusterId chosen =
      routerFacade.getHomeSubcluster(applicationSubmissionContext, null);
  Assert.assertTrue(subClusterIds.contains(chosen));
  Assert.assertFalse(routerFacade.globalPolicyMap.containsKey(uninitQueue));
  // empty string
  when(applicationSubmissionContext.getQueue()).thenReturn("");
  chosen = routerFacade.getHomeSubcluster(applicationSubmissionContext, null);
  Assert.assertTrue(subClusterIds.contains(chosen));
  Assert.assertFalse(routerFacade.globalPolicyMap.containsKey(uninitQueue));
  // null queue also falls back to default
  when(applicationSubmissionContext.getQueue()).thenReturn(null);
  chosen = routerFacade.getHomeSubcluster(applicationSubmissionContext, null);
  Assert.assertTrue(subClusterIds.contains(chosen));
  Assert.assertFalse(routerFacade.globalPolicyMap.containsKey(uninitQueue));
}