Search in sources :

Example 1 with LinksResponse

use of org.molgenis.api.model.response.LinksResponse in project molgenis by molgenis.

the class EntityMapperImpl method map.

@Override
public EntitiesResponse map(EntityCollection entityCollection, Selection filter, Selection expand, int size, int number, int total) {
    EntitiesResponse.Builder builder = mapRecursive(entityCollection, filter, expand, 0);
    LinksResponse linksResponse = LinksUtils.createLinksResponse(number, size, total);
    setPageResponse(entityCollection, builder);
    return builder.setLinks(linksResponse).build();
}
Also used : Builder(org.molgenis.api.data.v3.model.EntitiesResponse.Builder) LinksResponse(org.molgenis.api.model.response.LinksResponse) EntitiesResponse(org.molgenis.api.data.v3.model.EntitiesResponse)

Example 2 with LinksResponse

use of org.molgenis.api.model.response.LinksResponse in project molgenis by molgenis.

the class LinksUtilsTest method createLinksResponseOnePage.

@Test
void createLinksResponseOnePage() throws URISyntaxException {
    request.setQueryString("page=0");
    LinksResponse linksResponse = LinksResponse.builder().setSelf(new URI("http://localhost?page=0")).build();
    assertEquals(linksResponse, LinksUtils.createLinksResponse(0, 10, 10));
}
Also used : LinksResponse(org.molgenis.api.model.response.LinksResponse) URI(java.net.URI) Test(org.junit.jupiter.api.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Example 3 with LinksResponse

use of org.molgenis.api.model.response.LinksResponse in project molgenis by molgenis.

the class LinksUtilsTest method createLinksResponseLastPage.

@Test
void createLinksResponseLastPage() throws URISyntaxException {
    request.setQueryString("page=2");
    LinksResponse linksResponse = LinksResponse.builder().setPrevious(new URI("http://localhost?page=1")).setSelf(new URI("http://localhost?page=2")).build();
    assertEquals(linksResponse, LinksUtils.createLinksResponse(2, 10, 30));
}
Also used : LinksResponse(org.molgenis.api.model.response.LinksResponse) URI(java.net.URI) Test(org.junit.jupiter.api.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Example 4 with LinksResponse

use of org.molgenis.api.model.response.LinksResponse in project molgenis by molgenis.

the class LinksUtilsTest method createLinksResponseOutOfRangePageZeroTotalElements.

@Test
void createLinksResponseOutOfRangePageZeroTotalElements() throws URISyntaxException {
    request.setQueryString("page=100");
    LinksResponse linksResponse = LinksResponse.builder().setSelf(new URI("http://localhost?page=100")).build();
    assertEquals(linksResponse, LinksUtils.createLinksResponse(100, 10, 0));
}
Also used : LinksResponse(org.molgenis.api.model.response.LinksResponse) URI(java.net.URI) Test(org.junit.jupiter.api.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Example 5 with LinksResponse

use of org.molgenis.api.model.response.LinksResponse in project molgenis by molgenis.

the class LinksUtilsTest method createLinksResponseOutOfRangePage.

@Test
void createLinksResponseOutOfRangePage() throws URISyntaxException {
    request.setQueryString("page=100");
    LinksResponse linksResponse = LinksResponse.builder().setPrevious(new URI("http://localhost?page=2")).setSelf(new URI("http://localhost?page=100")).build();
    assertEquals(linksResponse, LinksUtils.createLinksResponse(100, 10, 30));
}
Also used : LinksResponse(org.molgenis.api.model.response.LinksResponse) URI(java.net.URI) Test(org.junit.jupiter.api.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Aggregations

LinksResponse (org.molgenis.api.model.response.LinksResponse)8 URI (java.net.URI)6 Test (org.junit.jupiter.api.Test)6 AbstractMockitoTest (org.molgenis.test.AbstractMockitoTest)6 EntitiesResponse (org.molgenis.api.data.v3.model.EntitiesResponse)1 Builder (org.molgenis.api.data.v3.model.EntitiesResponse.Builder)1 PageResponse (org.molgenis.api.model.response.PageResponse)1