use of sonia.scm.user.User in project scm-review-plugin by scm-manager.
the class CurrentUserResolver method getCurrentUserDisplayName.
public static String getCurrentUserDisplayName() {
PrincipalCollection principals = SecurityUtils.getSubject().getPrincipals();
String displayName = principals.getPrimaryPrincipal().toString();
User user = principals.oneByType(User.class);
if (user != null) {
displayName = user.getDisplayName();
if (Strings.isNullOrEmpty(displayName)) {
displayName = user.getName();
}
}
return displayName;
}
use of sonia.scm.user.User in project scm-review-plugin by scm-manager.
the class MergeService method appendSquashContributors.
private void appendSquashContributors(StringBuilder builder, PullRequest pullRequest, Set<Person> contributors) {
userDisplayManager.get(pullRequest.getAuthor()).ifPresent(prAuthor -> {
User currentUser = currentUser();
String committerMail = email.getMailOrFallback(currentUser);
builder.append("\nAuthor: ").append(prAuthor.getDisplayName()).append(" <").append(prAuthor.getMail()).append(">");
if (!prAuthor.getDisplayName().equals(currentUser.getDisplayName())) {
builder.append("\nCommitted-by: ").append(currentUser.getDisplayName());
builder.append(" <").append(committerMail).append(">");
}
appendCoAuthors(builder, contributors, prAuthor);
});
}
use of sonia.scm.user.User in project scm-review-plugin by scm-manager.
the class DefaultPullRequestService method computeSubscriberForNewPullRequest.
private void computeSubscriberForNewPullRequest(PullRequest pullRequest) {
User user = CurrentUserResolver.getCurrentUser();
Set<String> subscriber = new HashSet<>(pullRequest.getSubscriber());
subscriber.addAll(pullRequest.getReviewer().keySet());
subscriber.add(user.getId());
pullRequest.setSubscriber(subscriber);
}
use of sonia.scm.user.User in project scm-review-plugin by scm-manager.
the class MergeResourceTest method shouldCreateSquashCommitMessage.
@Test
void shouldCreateSquashCommitMessage() throws IOException, URISyntaxException {
when(mergeService.createCommitDefaults(any(), any(), eq(SQUASH))).thenReturn(new CommitDefaults("successful", DisplayUser.from(new User("Arthur Dent"))));
MockHttpRequest request = createHttpGetRequest(MERGE_URL + "/commit-message/?strategy=SQUASH");
MockHttpResponse response = new MockHttpResponse();
dispatcher.invoke(request, response);
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getContentAsString()).isEqualTo("successful");
}
use of sonia.scm.user.User in project scm-review-plugin by scm-manager.
the class PullRequestRootResourceTest method shouldReturnAlreadyExistsResult.
@Test
@SubjectAware(username = "dent")
public void shouldReturnAlreadyExistsResult() throws URISyntaxException, IOException {
mockLoggedInUser(new User("dent"));
mockLogCommandForPullRequestCheck(ImmutableList.of(new Changeset()));
PullRequest pullRequest = createPullRequest();
when(store.getAll()).thenReturn(ImmutableList.of(pullRequest));
MockHttpRequest request = MockHttpRequest.get("/" + PullRequestRootResource.PULL_REQUESTS_PATH_V2 + "/ns/repo/check?source=develop&target=master");
dispatcher.invoke(request, response);
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getContentAsString()).contains("\"status\":\"PR_ALREADY_EXISTS\"");
assertThat(response.getContentAsString()).contains("\"_links\":{\"self\":{\"href\":\"/v2/pull-requests/ns/repo/check?source=develop&target=master\"}}");
}
Aggregations