Example #1
0
 private String getAuthenticationToken() {
   User user = EnvironmentContext.getCurrent().getUser();
   if (user != null) {
     return user.getToken();
   }
   return null;
 }
  /**
   * Creates a task for given set of user, workspace, project's name
   *
   * @return the created mock object
   */
  private RunQueueTask createTask(User user, String workspace, String projectName)
      throws NotFoundException, RunnerException {
    RunQueueTask runQueueTask = mock(RunQueueTask.class);
    RunRequest runRequest = mock(RunRequest.class);
    doReturn(runRequest).when(runQueueTask).getRequest();
    doReturn(user.getId()).when(runRequest).getUserId();
    doReturn(workspace).when(runRequest).getWorkspace();
    doReturn(projectName).when(runRequest).getProject();

    ApplicationProcessDescriptor descriptor = mock(ApplicationProcessDescriptor.class);
    doReturn(descriptor).when(runQueueTask).getDescriptor();
    doReturn(workspace).when(descriptor).getWorkspace();
    doReturn(projectName).when(descriptor).getProject();

    return runQueueTask;
  }