@Test
public void testSetMaxShare() {

  FSQueueMetrics metrics = setupMetrics(RESOURCE_NAME);
  Resource res = Resource.newInstance(2048L, 4, ImmutableMap.of(RESOURCE_NAME,
      20L));
  metrics.setMaxShare(res);
  assertEquals(getErrorMessage("maxShareMB"),
      2048L, metrics.getMaxShareMB());
  assertEquals(getErrorMessage("maxShareVcores"),
      4L, metrics.getMaxShareVirtualCores());
  assertEquals(getErrorMessage("maxShareMB"),
      2048L, metrics.getMaxShare().getMemorySize());
  assertEquals(getErrorMessage("maxShareVcores"),
      4L, metrics.getMaxShare().getVirtualCores());
  assertEquals(getErrorMessage("maxShare for resource: " + RESOURCE_NAME),
      20L, metrics.getMaxShare().getResourceValue(RESOURCE_NAME));
  res = Resource.newInstance(2049L, 5);
  metrics.setMaxShare(res);
  assertEquals(getErrorMessage("maxShareMB"),
      2049L, metrics.getMaxShareMB());
  assertEquals(getErrorMessage("maxShareVcores"),
      5L, metrics.getMaxShareVirtualCores());
  assertEquals(getErrorMessage("maxShareMB"),
      2049L, metrics.getMaxShare().getMemorySize());
  assertEquals(getErrorMessage("maxShareVcores"),
      5L, metrics.getMaxShare().getVirtualCores());
  assertEquals(getErrorMessage("maxShare for resource: " + RESOURCE_NAME),
      0, metrics.getMaxShare().getResourceValue(RESOURCE_NAME));
}