@Test
public void testInvalidAllocationTagNamespace() {

  AllocationTagsManager tm = new AllocationTagsManager(rmContext);
  PlacementConstraintManagerService pcm =
      new MemoryPlacementConstraintManager();
  rmContext.setAllocationTagsManager(tm);
  rmContext.setPlacementConstraintManager(pcm);
  long ts = System.currentTimeMillis();
  ApplicationId application1 = BuilderUtils.newApplicationId(ts, 123);
  RMNode n0r1 = rmNodes.get(0);
  SchedulerNode schedulerNode0 = newSchedulerNode(n0r1.getHostName(),
      n0r1.getRackName(), n0r1.getNodeID());
  PlacementConstraint constraint1 = PlacementConstraints
      .targetNotIn(NODE, allocationTagWithNamespace("unknown_namespace",
          "hbase-m"))
      .build();
  Set<String> srcTags1 = new HashSet<>();
  srcTags1.add("app1");
  try {
    PlacementConstraintsUtil.canSatisfyConstraints(application1,
        createSchedulingRequest(srcTags1, constraint1), schedulerNode0,
        pcm, tm);
    Assert.fail("This should fail because we gave an invalid namespace");
  } catch (Exception e) {
    Assert.assertTrue(e instanceof InvalidAllocationTagsQueryException);
    Assert.assertTrue(e.getMessage()
        .contains("Invalid namespace prefix: unknown_namespace"));
  }
}