JobRequestHelper { public JobResult addBranch(final String jobId, final String spaceName, final String projectName, final String newBranchName, final String baseBranchName, final String userIdentifier) { JobResult result = new JobResult(); result.setJobId(jobId); final WorkspaceProject project = workspaceProjectService.resolveProject( spacesAPI.getSpace(spaceName), projectName); if (project == null) { result.setStatus(JobStatus.RESOURCE_NOT_EXIST); result.setResult("Project [" + projectName + "] does not exist"); return result; } try { workspaceProjectService.addBranch(newBranchName, baseBranchName, project, userIdentifier); result.setStatus(JobStatus.SUCCESS); } catch (FileAlreadyExistsException e) { result.setStatus(JobStatus.DUPLICATE_RESOURCE); result.setResult("Branch [" + newBranchName + "] already exists."); } catch (Exception e) { result.setStatus(JobStatus.FAIL); result.setResult(e.getMessage()); } return result; }  JobResult cloneProject(final String jobId,
                                  final String spaceName,
                                  final CloneProjectRequest cloneProjectRequest); JobResult createProject(final String jobId,
                                   final String spaceName,
                                   final String projectName,
                                   String projectGroupId,
                                   String projectVersion,
                                   String projectDescription); JobResult deleteProject(final String jobId,
                                   final String spaceName,
                                   final String projectName); JobResult compileProject(final String jobId,
                                    final String spaceName,
                                    final String projectName,
                                    final String branchName); JobResult installProject(final String jobId,
                                    final String spaceName,
                                    final String projectName,
                                    final String branchName); JobResult testProject(final String jobId,
                                 final String spaceName,
                                 final String projectName,
                                 final String branchName); JobResult deployProject(final String jobId,
                                   final String spaceName,
                                   final String projectName,
                                   final String branchName); JobResult removeSpace(final String jobId,
                                 final String spaceName); JobResult createSpace(final String jobId,
                                 final String spaceName,
                                 final String spaceDescription,
                                 final String spaceOwner,
                                 final String defaultGroupId); JobResult updateSpace(final String jobId,
                                 final String spaceName,
                                 final String spaceDescription,
                                 final String spaceOwner,
                                 final String defaultGroupId); JobResult addBranch(final String jobId,
                               final String spaceName,
                               final String projectName,
                               final String newBranchName,
                               final String baseBranchName,
                               final String userIdentifier); JobResult removeBranch(final String jobId,
                                  final String spaceName,
                                  final String projectName,
                                  final String branchName,
                                  final String userIdentifier); JobResult addProjectToSpace(final String jobId,
                                       final String spaceName,
                                       final String projectName);  }
@Test public void testAddBranchProjectDoesNotExists() { when(workspaceProjectService.resolveProject(eq(space), eq("project"))).thenReturn(null); JobResult jobResult = helper.addBranch(null, space.getName(), "project", "new-branch", "ref-branch", "user"); assertEquals(JobStatus.RESOURCE_NOT_EXIST, jobResult.getStatus()); }
@Test public void testAddBranchFail() { doThrow(Exception.class).when(workspaceProjectService).addBranch(any(), any(), any(), any()); JobResult jobResult = helper.addBranch(null, space.getName(), "project", "new-branch", "ref-branch", "user"); assertEquals(JobStatus.FAIL, jobResult.getStatus()); }
@Test public void testAddBranch() { JobResult jobResult = helper.addBranch(null, space.getName(), "project", "new-branch", "ref-branch", "user"); assertEquals(JobStatus.SUCCESS, jobResult.getStatus()); }