public ResolvedLaunchParams buildContainerLaunchContext(
      AbstractLauncher launcher,
      Service service, ComponentInstance instance,
      SliderFileSystem fileSystem, Configuration yarnConf, Container container,
      ContainerLaunchService.ComponentLaunchContext compLaunchContext)
      throws IOException, SliderException {
    ResolvedLaunchParams resolved = new ResolvedLaunchParams();
    processArtifact(launcher, instance, fileSystem, service, compLaunchContext);

    ServiceContext context =
        instance.getComponent().getScheduler().getContext();
    // Generate tokens (key-value pair) for config substitution.
    Map<String, String> tokensForSubstitution =
        buildContainerTokens(instance, container, compLaunchContext);

    // Setup launch context environment
    buildContainerEnvironment(launcher, service, instance,
        fileSystem, yarnConf, container, compLaunchContext,
        tokensForSubstitution);

    // create config file on hdfs and addResolvedRsrcPath local resource
    ProviderUtils.createConfigFileAndAddLocalResource(launcher, fileSystem,
        compLaunchContext, tokensForSubstitution, instance, context, resolved);

    // handles static files (like normal file / archive file) for localization.
    ProviderUtils.handleStaticFilesForLocalization(launcher, fileSystem,
        compLaunchContext, resolved);

    // replace launch command with token specific information
    buildContainerLaunchCommand(launcher, service, instance, fileSystem,
        yarnConf, container, compLaunchContext, tokensForSubstitution);

    // Setup container retry settings
    buildContainerRetry(launcher, yarnConf, compLaunchContext, instance);

    return resolved;
  }
@Test
  public void testBuildContainerLaunchContext() throws Exception {
    AbstractProviderService providerService = new DockerProviderService();
    Component component = serviceContext.scheduler.getAllComponents().entrySet()
        .iterator().next().getValue();
    ContainerLaunchService.ComponentLaunchContext clc =
        createEntryPointCLCFor(testService, component, "sleep,9000");

    ComponentInstance instance = component.getAllComponentInstances().iterator()
        .next();
    Container container = mock(Container.class);
    ContainerId containerId = ContainerId.newContainerId(
        ApplicationAttemptId.newInstance(ApplicationId.newInstance(
            System.currentTimeMillis(), 1), 1), 1L);
    when(container.getId()).thenReturn(containerId);
    providerService.buildContainerLaunchContext(launcher, testService, instance,
        rule.getFs(), serviceContext.scheduler.getConfig(), container, clc);

    Assert.assertEquals("artifact", clc.getArtifact().getId(),
        launcher.getDockerImage());
  }