@Test
public void testAllocationStored() throws Exception {

  initializeGpus();
  /* Start container 1, asks 3 containers */
  Container container = mockContainerWithGpuRequest(1,
      createResourceRequest(3));
  gpuResourceHandler.preStart(container);
  verify(mockNMStateStore).storeAssignedResources(container,
      ResourceInformation.GPU_URI, Arrays
          .asList(new GpuDevice(0, 0), new GpuDevice(1, 1),
              new GpuDevice(2, 3)));
  // Only device=4 will be blocked.
  verifyDeniedDevices(getContainerId(1),
      Collections.singletonList(new GpuDevice(3, 4)));
  /* Start container 2, ask 0 container, succeeded */
  container = mockContainerWithGpuRequest(2, createResourceRequest(0));
  gpuResourceHandler.preStart(container);
  verifyDeniedDevices(getContainerId(2), Arrays
      .asList(new GpuDevice(0, 0), new GpuDevice(1, 1), new GpuDevice(2, 3),
          new GpuDevice(3, 4)));
  assertEquals("Number of GPU device allocations is not the expected!", 0,
      container.getResourceMappings()
      .getAssignedResources(ResourceInformation.GPU_URI).size());
  // Store assigned resource will not be invoked.
  verify(mockNMStateStore, never()).storeAssignedResources(
      eq(container), eq(ResourceInformation.GPU_URI), anyList());
}