Search in sources :

Example 1 with ReadAttributesRequest

use of org.molgenis.api.metadata.v3.model.ReadAttributesRequest in project molgenis by molgenis.

the class MetadataApiControllerTest method testGetAttributes.

@Test
void testGetAttributes() {
    String entityTypeId = "MyEntityTypeId";
    Query query = mock(Query.class);
    Sort sort = mock(Sort.class);
    int size = 1;
    int page = 2;
    ReadAttributesRequest readAttributesRequest = new ReadAttributesRequest();
    readAttributesRequest.setQ(query);
    readAttributesRequest.setSort(sort);
    readAttributesRequest.setSize(size);
    readAttributesRequest.setPage(page);
    Attributes attributes = mock(Attributes.class);
    when(metadataApiService.findAttributes(entityTypeId, query, sort, size, page)).thenReturn(attributes);
    AttributesResponse attributesResponse = mock(AttributesResponse.class);
    when(attributeResponseMapper.toAttributesResponse(attributes, size, page)).thenReturn(attributesResponse);
    assertEquals(attributesResponse, metadataApiController.getAttributes(entityTypeId, readAttributesRequest));
}
Also used : AttributesResponse(org.molgenis.api.metadata.v3.model.AttributesResponse) Query(org.molgenis.api.model.Query) ReadAttributesRequest(org.molgenis.api.metadata.v3.model.ReadAttributesRequest) ServletRequestAttributes(org.springframework.web.context.request.ServletRequestAttributes) Sort(org.molgenis.api.model.Sort) Test(org.junit.jupiter.api.Test) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest)

Aggregations

Test (org.junit.jupiter.api.Test)1 AttributesResponse (org.molgenis.api.metadata.v3.model.AttributesResponse)1 ReadAttributesRequest (org.molgenis.api.metadata.v3.model.ReadAttributesRequest)1 Query (org.molgenis.api.model.Query)1 Sort (org.molgenis.api.model.Sort)1 AbstractMockitoTest (org.molgenis.test.AbstractMockitoTest)1 ServletRequestAttributes (org.springframework.web.context.request.ServletRequestAttributes)1