class JobRequestHelper {

    public JobResult testProject(final String jobId,
                                 final String spaceName,
                                 final String projectName,
                                 final String branchName) {

        final JobResult result = new JobResult();
        result.setJobId(jobId);

        final WorkspaceProject workspaceProject = workspaceProjectService.resolveProject(
                spacesAPI.getSpace(spaceName),
                projectName,
                branchName);

        if (workspaceProject == null) {
            return projectDoesNotExistError(jobId, projectName);
        }

        final Module module = workspaceProject.getMainModule();

        if (module == null) {
            if (branchName == null) {
                return projectHasNoMainModuleError(jobId, projectName);
            }
            return projectHasNoModuleError(jobId, projectName, branchName);
        }

        testService.runAllTests("JobRequestHelper",
                                module.getPomXMLPath(),
                                getCustomTestResultEvent(result));

        return result;
    }

}