@Test
public void testPlugin() throws Exception {

  DockerRunCommand runCommand = new DockerRunCommand("container_1", "user",
      "fakeimage");
  Map<String, List<String>> originalCommandline = copyCommandLine(
      runCommand.getDockerCommandWithArguments());
  MyNvidiaDockerV2CommandPlugin
      commandPlugin = new MyNvidiaDockerV2CommandPlugin();
  Container nmContainer = mock(Container.class);
  // getResourceMapping is null, so commandline won't be updated
  commandPlugin.updateDockerRunCommand(runCommand, nmContainer);
  Assert.assertTrue(commandlinesEquals(originalCommandline,
      runCommand.getDockerCommandWithArguments()));
  // no GPU resource assigned, so commandline won't be updated
  ResourceMappings resourceMappings = new ResourceMappings();
  when(nmContainer.getResourceMappings()).thenReturn(resourceMappings);
  commandPlugin.updateDockerRunCommand(runCommand, nmContainer);
  Assert.assertTrue(commandlinesEquals(originalCommandline,
      runCommand.getDockerCommandWithArguments()));
  // Assign GPU resource
  ResourceMappings.AssignedResources assigned =
      new ResourceMappings.AssignedResources();
  assigned.updateAssignedResources(
      ImmutableList.of(new GpuDevice(0, 0), new GpuDevice(1, 1)));
  resourceMappings.addAssignedResources(ResourceInformation.GPU_URI,
      assigned);
  commandPlugin.setRequestsGpu(true);
  commandPlugin.updateDockerRunCommand(runCommand, nmContainer);
  Map<String, List<String>> newCommandLine =
      runCommand.getDockerCommandWithArguments();
  // Command line will be updated
  Assert.assertFalse(commandlinesEquals(originalCommandline, newCommandLine));
  // NVIDIA_VISIBLE_DEVICES will be set
  Assert.assertTrue(
      runCommand.getEnv().get("NVIDIA_VISIBLE_DEVICES").equals("0,1"));
  // runtime should exist
  Assert.assertTrue(newCommandLine.containsKey("runtime"));
}