Search in sources :

Example 6 with DisplayUser

use of sonia.scm.user.DisplayUser in project scm-review-plugin by scm-manager.

the class MentionMapperTest method shouldAppendMentionForMentionedUser.

@Test
void shouldAppendMentionForMentionedUser() {
    DisplayUser user = setupExistingUserMock("dent", "Arthur Dent", "dent@hitchhiker.org");
    Set<String> userIds = ImmutableSet.of("dent");
    Set<DisplayUser> mentions = mentionMapper.mapMentions(userIds);
    assertThat(mentions.iterator().next()).isEqualTo(user);
}
Also used : DisplayUser(sonia.scm.user.DisplayUser) Test(org.junit.jupiter.api.Test)

Example 7 with DisplayUser

use of sonia.scm.user.DisplayUser in project scm-review-plugin by scm-manager.

the class MergeServiceTest method shouldCreateCommitMessageForSquashWithAuthorFromPullRequest.

@Test
void shouldCreateCommitMessageForSquashWithAuthorFromPullRequest() throws IOException {
    User user = mockUser("Phil", "Phil Groundhog", "phil@groundhog.com");
    when(email.getMailOrFallback(user)).thenReturn("phil@groundhog.com");
    DisplayUser currentUser = DisplayUser.from(new User("zaphod", "Zaphod Beeblebrox", "zaphod@hitchhiker.com"));
    when(userDisplayManager.get("zaphod")).thenReturn(of(currentUser));
    when(subject.isPermitted("repository:read:" + REPOSITORY.getId())).thenReturn(true);
    when(repositoryService.isSupported(Command.LOG)).thenReturn(true);
    PullRequest pullRequest = createPullRequest();
    pullRequest.setAuthor("zaphod");
    when(pullRequestService.get(REPOSITORY.getNamespace(), REPOSITORY.getName(), "1")).thenReturn(pullRequest);
    when(userDisplayManager.get("zaphod")).thenReturn(Optional.of(currentUser));
    Person author = new Person("Zaphod Beeblebrox", "zaphod@hitchhiker.com");
    ChangesetPagingResult changesets = new ChangesetPagingResult(3, asList(new Changeset("1", 1L, author, "first commit"), new Changeset("2", 2L, author, "second commit\nwith multiple lines"), new Changeset("3", 3L, new Person("Arthur", "dent@hitchhiker.com"), "third commit")));
    when(logCommandBuilder.getChangesets()).thenReturn(changesets);
    CommitDefaults commitDefaults = service.createCommitDefaults(REPOSITORY.getNamespaceAndName(), "1", MergeStrategy.SQUASH);
    assertThat(commitDefaults.getCommitMessage()).isEqualTo("Squash commits of branch squash:\n" + "\n" + "- first commit\n" + "\n" + "- second commit\n" + "with multiple lines\n" + "\n" + "- third commit\n" + "\n" + "\n" + "Author: Zaphod Beeblebrox <zaphod@hitchhiker.com>" + "\nCommitted-by: Phil Groundhog <phil@groundhog.com>" + "\nCo-authored-by: Arthur <dent@hitchhiker.com>");
    assertThat(commitDefaults.getCommitAuthor()).usingRecursiveComparison().isEqualTo(currentUser);
}
Also used : ChangesetPagingResult(sonia.scm.repository.ChangesetPagingResult) DisplayUser(sonia.scm.user.DisplayUser) User(sonia.scm.user.User) DisplayUser(sonia.scm.user.DisplayUser) CommitDefaults(com.cloudogu.scm.review.pullrequest.service.MergeService.CommitDefaults) Person(sonia.scm.repository.Person) Changeset(sonia.scm.repository.Changeset) Test(org.junit.jupiter.api.Test)

Aggregations

DisplayUser (sonia.scm.user.DisplayUser)7 Test (org.junit.jupiter.api.Test)3 BasicComment (com.cloudogu.scm.review.comment.service.BasicComment)1 DisplayedUserDto (com.cloudogu.scm.review.pullrequest.dto.DisplayedUserDto)1 MergeStrategyInfoDto (com.cloudogu.scm.review.pullrequest.dto.MergeStrategyInfoDto)1 MergeService (com.cloudogu.scm.review.pullrequest.service.MergeService)1 CommitDefaults (com.cloudogu.scm.review.pullrequest.service.MergeService.CommitDefaults)1 Operation (io.swagger.v3.oas.annotations.Operation)1 ApiResponse (io.swagger.v3.oas.annotations.responses.ApiResponse)1 HashSet (java.util.HashSet)1 Matcher (java.util.regex.Matcher)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Changeset (sonia.scm.repository.Changeset)1 ChangesetPagingResult (sonia.scm.repository.ChangesetPagingResult)1 NamespaceAndName (sonia.scm.repository.NamespaceAndName)1 Person (sonia.scm.repository.Person)1 Hit (sonia.scm.search.Hit)1 User (sonia.scm.user.User)1