@Test
public void testRecoverNumaResource() throws Exception {

  @SuppressWarnings("unchecked")
  ConcurrentHashMap<ContainerId, Container> mockContainers = mock(
      ConcurrentHashMap.class);
  Context mockContext = mock(Context.class);
  Container mockContainer = mock(Container.class);
  ResourceMappings value = new ResourceMappings();
  AssignedResources assignedResources = new AssignedResources();
  assignedResources.updateAssignedResources(
      Arrays.asList(new NumaResourceAllocation("0", 70000, "0", 4)));
  value.addAssignedResources("numa", assignedResources);
  when(mockContainer.getResourceMappings()).thenReturn(value);
  when(mockContainers.get(any())).thenReturn(mockContainer);
  when(mockContext.getContainers()).thenReturn(mockContainers);
  NMStateStoreService mock = mock(NMStateStoreService.class);
  when(mockContext.getNMStateStore()).thenReturn(mock);
  numaResourceAllocator = new NumaResourceAllocator(mockContext);
  numaResourceAllocator.init(conf);
  // Recover the resources
  numaResourceAllocator.recoverNumaResource(
      ContainerId.fromString("container_1481156246874_0001_01_000001"));
  // Request resources based on the availability
  NumaResourceAllocation numaNode = numaResourceAllocator
      .allocateNumaNodes(getContainer(
          ContainerId.fromString("container_1481156246874_0001_01_000005"),
          Resource.newInstance(2048, 1)));
  assertEquals("1", String.join(",", numaNode.getMemNodes()));
  assertEquals("1", String.join(",", numaNode.getCpuNodes()));
  // Request resources more than the available
  numaNode = numaResourceAllocator.allocateNumaNodes(getContainer(
      ContainerId.fromString("container_1481156246874_0001_01_000006"),
      Resource.newInstance(2048, 4)));
  assertNull(numaNode);
}