use of org.molgenis.data.rest.v2.EntityAggregatesResponse.AggregateResultResponse in project molgenis by molgenis.
the class EntityAggregatesResponseTest method testAggregateResultResponseToResponseAggregateResult.
// regression test for https://github.com/molgenis/molgenis/issues/6581
@Test
public void testAggregateResultResponseToResponseAggregateResult() {
EntityType entityType = mock(EntityType.class);
Attribute longAttribute = when(mock(Attribute.class).getDataType()).thenReturn(LONG).getMock();
when(longAttribute.getName()).thenReturn("longAttribute");
Iterable<Attribute> attributes = singletonList(longAttribute);
when(entityType.getAtomicAttributes()).thenReturn(attributes);
Entity entity = mock(Entity.class);
when(entity.get("longAttribute")).thenReturn(123L);
when(entity.getEntityType()).thenReturn(entityType);
List<List<Long>> matrix = emptyList();
List<Object> xLabels = Collections.singletonList(entity);
List<Object> yLabels = emptyList();
AggregateResult aggregateResult = mock(AggregateResult.class);
when(aggregateResult.getMatrix()).thenReturn(matrix);
when(aggregateResult.getxLabels()).thenReturn(xLabels);
when(aggregateResult.getyLabels()).thenReturn(yLabels);
AggregateResultResponse aggregateResultResponse = AggregateResultResponse.toResponse(aggregateResult);
assertEquals(aggregateResultResponse.getMatrix(), matrix);
assertEquals(aggregateResultResponse.getxLabels(), singletonList(singletonMap("longAttribute", "123")));
assertEquals(aggregateResultResponse.getyLabels(), emptyList());
}
Aggregations