Search in sources :

Example 1 with DisplayedUserDto

use of com.cloudogu.scm.review.pullrequest.dto.DisplayedUserDto in project scm-review-plugin by scm-manager.

the class HitEnricher method appendEmbeddedUserForAuthor.

private void appendEmbeddedUserForAuthor(HalAppender appender, Hit hit) {
    Hit.Field author = hit.getFields().get("author");
    Optional<DisplayUser> displayUser = userDisplayManager.get(((Hit.ValueField) author).getValue().toString());
    if (displayUser.isPresent()) {
        DisplayUser user = displayUser.get();
        appender.appendEmbedded("user", new DisplayedUserDto(user.getId(), user.getDisplayName(), user.getMail()));
    }
}
Also used : Hit(sonia.scm.search.Hit) DisplayUser(sonia.scm.user.DisplayUser) DisplayedUserDto(com.cloudogu.scm.review.pullrequest.dto.DisplayedUserDto)

Example 2 with DisplayedUserDto

use of com.cloudogu.scm.review.pullrequest.dto.DisplayedUserDto in project scm-review-plugin by scm-manager.

the class HitEnricherTest method shouldEnrichHitWithDisplayUser.

@Test
void shouldEnrichHitWithDisplayUser() {
    mockHit(ImmutableMap.of("author", new Hit.ValueField("trillian"), "pullRequestId", new Hit.ValueField("1")));
    when(userDisplayManager.get("trillian")).thenReturn(Optional.of(DisplayUser.from(new User("trillian", "Tricia McMillan", "trillian@hitchhiker.org"))));
    enricher.enrich(context, appender);
    verify(appender, times(1)).appendEmbedded(eq("user"), (DisplayedUserDto) argThat(user -> {
        assertThat(((DisplayedUserDto) user).getDisplayName()).isEqualTo("Tricia McMillan");
        return true;
    }));
}
Also used : User(sonia.scm.user.User) DisplayUser(sonia.scm.user.DisplayUser) DisplayedUserDto(com.cloudogu.scm.review.pullrequest.dto.DisplayedUserDto) Test(org.junit.jupiter.api.Test)

Aggregations

DisplayedUserDto (com.cloudogu.scm.review.pullrequest.dto.DisplayedUserDto)2 DisplayUser (sonia.scm.user.DisplayUser)2 Test (org.junit.jupiter.api.Test)1 Hit (sonia.scm.search.Hit)1 User (sonia.scm.user.User)1