@Test
public void testPlacementRuleUpdationOrder() throws Exception {

  List<QueueMapping> queueMappings = new ArrayList<>();
  QueueMapping userQueueMapping = QueueMappingBuilder.create()
      .type(MappingType.USER).source(USER1)
      .queue(getQueueMapping(PARENT_QUEUE, USER1)).build();
  UserGroupMappingPlacementRule ugRule = new UserGroupMappingPlacementRule(
      false, Arrays.asList(userQueueMapping), null);
  // Configure placement rule
  conf.set(YarnConfiguration.QUEUE_PLACEMENT_RULES, ugRule.getName());
  queueMappings.add(userQueueMapping);
  conf.setQueueMappings(queueMappings);
  mockRM = new MockRM(conf);
  CapacityScheduler cs = (CapacityScheduler) mockRM.getResourceScheduler();
  mockRM.start();
  PlacementManager pm = cs.getRMContext().getQueuePlacementManager();
  // As we are setting placement rule, It shouldn't update default
  // placement rule ie user-group. Number of placemnt rules should be 1.
  Assert.assertEquals(1, pm.getPlacementRules().size());
  // Verifying if placement rule set is same as the one we configured
  Assert.assertEquals(ugRule.getName(),
      pm.getPlacementRules().get(0).getName());
}