void downloadInterpreter(
      InterpreterInstallationRequest request,
      DependencyResolver dependencyResolver,
      Path interpreterDir,
      ServiceCallback<String> serviceCallback) {
    try {
      LOGGER.info("Start to download a dependency: {}", request.getName());
      if (null != serviceCallback) {
        serviceCallback.onStart("Starting to download " + request.getName() + " interpreter", null);
      }

      dependencyResolver.load(request.getArtifact(), interpreterDir.toFile());
      interpreterSettingManager.refreshInterpreterTemplates();
      LOGGER.info(
          "Finish downloading a dependency {} into {}",
          request.getName(),
          interpreterDir);
      if (null != serviceCallback) {
        serviceCallback.onSuccess(request.getName() + " downloaded", null);
      }
    } catch (RepositoryException | IOException e) {
      LOGGER.error("Error while downloading dependencies", e);
      try {
        FileUtils.deleteDirectory(interpreterDir.toFile());
      } catch (IOException e1) {
        LOGGER.error(
            "Error while removing directory. You should handle it manually: {}",
            interpreterDir,
            e1);
      }
      if (null != serviceCallback) {
        try {
          serviceCallback.onFailure(
              new Exception("Error while downloading " + request.getName() + " as " +
                  e.getMessage()), null);
        } catch (IOException e1) {
          LOGGER.error("ServiceCallback failure", e1);
        }
      }
    }
  }
@Test
  void downloadInterpreter() throws IOException {
    final String interpreterName = "test-interpreter";
    String artifactName = "junit:junit:4.11";
    Path specificInterpreterPath =
        Files.createDirectory(Paths.get(interpreterDir.toString(), interpreterName));
    DependencyResolver dependencyResolver =
        new DependencyResolver(localRepoDir.toString(), ZeppelinConfiguration.load());

    doNothing().when(mockInterpreterSettingManager).refreshInterpreterTemplates();

    interpreterService.downloadInterpreter(
        new InterpreterInstallationRequest(interpreterName, artifactName),
        dependencyResolver,
        specificInterpreterPath,
        new SimpleServiceCallback<String>() {
          @Override
          public void onStart(String message, ServiceContext context) {
            assertEquals("Starting to download " + interpreterName + " interpreter", message);
          }

          @Override
          public void onSuccess(String message, ServiceContext context) {
            assertEquals(interpreterName + " downloaded", message);
          }

          @Override
          public void onFailure(Exception ex, ServiceContext context) {
          fail(ex);
          }
        });

    verify(mockInterpreterSettingManager, times(1)).refreshInterpreterTemplates();
  }