Search in sources :

Example 1 with Order

use of org.molgenis.data.Sort.Order in project molgenis by molgenis.

the class SortTest method sortMultipleAttrAsc.

@Test
void sortMultipleAttrAsc() {
    Sort sort = new Sort(Arrays.asList(new Sort.Order("attr0", Sort.Direction.ASC), new Sort.Order("attr1", Sort.Direction.ASC)));
    Iterator<Sort.Order> it = sort.iterator();
    assertEquals(new Order("attr0", ASC), it.next());
    assertEquals(new Order("attr1", ASC), it.next());
}
Also used : Order(org.molgenis.data.Sort.Order) Test(org.junit.jupiter.api.Test)

Example 2 with Order

use of org.molgenis.data.Sort.Order in project molgenis by molgenis.

the class SortTest method sortMultipleAttrDefault.

@Test
void sortMultipleAttrDefault() {
    Sort sort = new Sort(Arrays.asList(new Sort.Order("attr0"), new Sort.Order("attr1")));
    Iterator<Sort.Order> it = sort.iterator();
    assertEquals(new Order("attr0"), it.next());
    assertEquals(new Order("attr1"), it.next());
}
Also used : Order(org.molgenis.data.Sort.Order) Test(org.junit.jupiter.api.Test)

Example 3 with Order

use of org.molgenis.data.Sort.Order in project molgenis by molgenis.

the class SortTest method sortMultipleAttrBuilderAscAndDesc.

@Test
void sortMultipleAttrBuilderAscAndDesc() {
    Sort sort = new Sort().on("attr0", Sort.Direction.ASC).on("attr1", Sort.Direction.DESC);
    Iterator<Sort.Order> it = sort.iterator();
    assertEquals(new Order("attr0", ASC), it.next());
    assertEquals(new Order("attr1", DESC), it.next());
}
Also used : Order(org.molgenis.data.Sort.Order) Test(org.junit.jupiter.api.Test)

Example 4 with Order

use of org.molgenis.data.Sort.Order in project molgenis by molgenis.

the class AttributeResponseMapperImpl method map.

private List<org.molgenis.api.model.Sort> map(Attribute attr) {
    List<org.molgenis.api.model.Sort> orders;
    Sort sort = attr.getOrderBy();
    if (sort == null) {
        orders = emptyList();
    } else {
        orders = new ArrayList<>(Iterables.size(sort));
        for (Order order : sort) {
            orders.add(org.molgenis.api.model.Sort.create(order.getAttr(), Direction.valueOf(order.getDirection().name())));
        }
    }
    return orders;
}
Also used : Order(org.molgenis.data.Sort.Order) Sort(org.molgenis.data.Sort)

Example 5 with Order

use of org.molgenis.data.Sort.Order in project molgenis by molgenis.

the class SortTest method sortMultipleAttrDesc.

@Test
void sortMultipleAttrDesc() {
    Sort sort = new Sort(Arrays.asList(new Sort.Order("attr0", Sort.Direction.DESC), new Sort.Order("attr1", Sort.Direction.DESC)));
    Iterator<Sort.Order> it = sort.iterator();
    assertEquals(new Order("attr0", DESC), it.next());
    assertEquals(new Order("attr1", DESC), it.next());
}
Also used : Order(org.molgenis.data.Sort.Order) Test(org.junit.jupiter.api.Test)

Aggregations

Order (org.molgenis.data.Sort.Order)9 Test (org.junit.jupiter.api.Test)8 Sort (org.molgenis.data.Sort)1