Fix unit test

This commit is contained in:
René Pfeuffer
2018-06-25 09:37:25 +02:00
parent c847f3d437
commit 51b2407ac4
2 changed files with 5 additions and 9 deletions

View File

@@ -23,19 +23,15 @@ import static sonia.scm.api.v2.resources.ResourceLinks.userCollection;
public class UserCollectionToDtoMapper {
@Inject
private UserToUserDtoMapper userToDtoMapper;
@Inject
private UriInfoStore uriInfoStore;
private final UserToUserDtoMapper userToDtoMapper;
private final UriInfoStore uriInfoStore;
@Inject
public UserCollectionToDtoMapper(UserToUserDtoMapper userToDtoMapper, UriInfoStore uriInfoStore) {
this.userToDtoMapper = userToDtoMapper;
this.uriInfoStore = uriInfoStore;
}
public UserCollectionToDtoMapper() {
}
public UserCollectionDto map(int pageNumber, int pageSize, PageResult<User> pageResult) {
NumberedPaging paging = zeroBasedNumberedPaging(pageNumber, pageSize, pageResult.getOverallCount());
List<UserDto> dtos = pageResult.getEntities().stream().map(userToDtoMapper::map).collect(toList());

View File

@@ -70,8 +70,8 @@ public class GroupCollectionToDtoMapperTest {
@Test
public void shouldCreateNextPageLink_whenHasMore() {
PageResult<Group> pageResult = createPage(createGroups("nobodies", "bosses"), 0, 1);
GroupCollectionDto groupCollectionDto = mapper.map(1, 1, pageResult);
assertTrue(groupCollectionDto.getLinks().getLinkBy("next").get().getHref().contains("page=2"));
GroupCollectionDto groupCollectionDto = mapper.map(0, 1, pageResult);
assertTrue(groupCollectionDto.getLinks().getLinkBy("next").get().getHref().contains("page=1"));
}
@Test