use of sonia.scm.repository.Branches in project scm-review-plugin by scm-manager.
the class BranchRevisionResolverTest method setUpBranches.
private void setUpBranches(String... names) throws IOException {
when(repositoryService.getBranchesCommand()).thenReturn(branchesCommandBuilder);
List<Branch> branches = Arrays.stream(names).map(name -> Branch.normalBranch(name, name)).collect(Collectors.toList());
when(branchesCommandBuilder.getBranches()).thenReturn(new Branches(branches));
}
use of sonia.scm.repository.Branches in project scm-review-plugin by scm-manager.
the class PullRequestInformationHook method checkIfMultipleBranchesExist.
private boolean checkIfMultipleBranchesExist(RepositoryService repositoryService) {
try {
Branches branches = repositoryService.getBranchesCommand().getBranches();
int branchCount = branches.getBranches().size();
return branchCount > 1;
} catch (IOException ex) {
LOG.warn("could not read branches for repository {}, assuming only one branch exists", repositoryService.getRepository());
return false;
}
}
use of sonia.scm.repository.Branches in project scm-review-plugin by scm-manager.
the class PullRequestInformationHookTest method init.
@Before
public void init() throws IOException {
hook = new PullRequestInformationHook(pullRequestService, serviceFactory, messageSenderFactory);
when(event.getContext()).thenReturn(context);
when(event.getRepository()).thenReturn(REPOSITORY);
when(context.getBranchProvider()).thenReturn(branchProvider);
when(context.getMessageProvider()).thenReturn(messageProvider);
when(context.isFeatureSupported(MESSAGE_PROVIDER)).thenReturn(true);
when(branchProvider.getCreatedOrModified()).thenReturn(Collections.emptyList());
when(serviceFactory.create(REPOSITORY)).thenReturn(service);
when(service.isSupported(Command.MERGE)).thenReturn(true);
when(configuration.getBaseUrl()).thenReturn("http://example.com");
when(pullRequestService.getAll("space", "X")).thenReturn(asList(OPEN_PULL_REQUEST, MERGED_PULL_REQUEST));
doNothing().when(messageProvider).sendMessage(messageCaptor.capture());
when(service.getBranchesCommand()).thenReturn(branchesCommand);
Branches branches = new Branches(Branch.defaultBranch("main", "", 0L), Branch.normalBranch("x", "", 0L));
when(branchesCommand.getBranches()).thenReturn(branches);
}
use of sonia.scm.repository.Branches in project scm-review-plugin by scm-manager.
the class PullRequestInformationHookTest method shouldSendMessageWithoutCreateLinks.
@Test
@SubjectAware(username = "dent")
public void shouldSendMessageWithoutCreateLinks() throws Exception {
when(branchProvider.getCreatedOrModified()).thenReturn(singletonList("branch_1"));
when(service.getBranchesCommand()).thenReturn(branchesCommand);
Branches branches = new Branches(Branch.defaultBranch("main", "", 0L));
when(branchesCommand.getBranches()).thenReturn(branches);
hook.checkForInformation(event);
List<String> sentMessages = messageCaptor.getAllValues();
assertThat(sentMessages).filteredOn(s -> s.length() > 0).isEmpty();
}
use of sonia.scm.repository.Branches in project scm-review-plugin by scm-manager.
the class MergeServiceTest method mocksForPullRequestUpdate.
private void mocksForPullRequestUpdate(String branchName) throws IOException {
lenient().when(repositoryService.isSupported(Command.BRANCH)).thenReturn(true);
lenient().when(repositoryService.isSupported(Command.BRANCHES)).thenReturn(true);
when(mergeCommandBuilder.isSupported(MergeStrategy.MERGE_COMMIT)).thenReturn(true);
when(mergeCommandBuilder.executeMerge()).thenReturn(MergeCommandResult.success("1", "2", "123"));
when(repositoryService.getBranchCommand()).thenReturn(branchCommandBuilder);
Branches branches = new Branches();
branches.setBranches(ImmutableList.of(Branch.normalBranch(branchName, "123")));
when(branchesCommandBuilder.getBranches()).thenReturn(branches);
}
Aggregations