use of org.molgenis.api.data.v3.model.ReadEntitiesRequest in project molgenis by molgenis.
the class EntityControllerTest method testGetEntities.
@Test
void testGetEntities() {
String entityTypeId = "MyEntityTypeId";
Selection filter = Selection.FULL_SELECTION;
Selection expand = Selection.FULL_SELECTION;
Query query = Query.builder().setOperator(Operator.MATCHES).setValue("value").build();
Sort sort = Sort.create("field", Direction.ASC);
ReadEntitiesRequest entityRequest = new ReadEntitiesRequest();
entityRequest.setEntityTypeId(entityTypeId);
entityRequest.setQ(query);
entityRequest.setSort(sort);
entityRequest.setFilter(filter);
entityRequest.setExpand(expand);
entityRequest.setSize(10);
entityRequest.setPage(2);
Entities entities = Entities.create(emptyList(), 30);
when(dataServiceV3.findAll(entityTypeId, query, filter, expand, sort, 10, 2)).thenReturn(entities);
EntityCollection entityCollection = EntityCollection.builder().setEntityTypeId(entityTypeId).setEntities(emptyList()).setPage(Page.builder().setOffset(20).setPageSize(10).setTotal(30).build()).build();
EntitiesResponse entitiesResponse = mock(EntitiesResponse.class);
when(entityMapper.map(entityCollection, filter, expand, 10, 2, 30)).thenReturn(entitiesResponse);
assertEquals(entitiesResponse, entityController.getEntities(entityRequest));
}
Aggregations