@Test void testMapNoOrder() { Attribute attr1 = mock(Attribute.class); EntityType entityType = mock(EntityType.class); doReturn(attr1).when(entityType).getAttribute("attr1"); SortMapper sortMapper = new SortMapper(); Sort sort = Sort.create(singletonList(Order.create("attr1"))); org.molgenis.data.Sort expected = new org.molgenis.data.Sort().on("attr1", org.molgenis.data.Sort.Direction.ASC); assertEquals(expected, sortMapper.map(sort, entityType)); }
public Sort map(org.molgenis.api.model.Sort sort, EntityType entityType) { Sort newSort = new Sort(); sort.getOrders() .forEach( order -> { String attributeName = order.getId(); if (entityType.getAttribute(attributeName) == null) { throw new UnknownSortAttributeException(entityType, attributeName); } Order.Direction direction = order.getDirection(); newSort.on( attributeName, direction != null ? Direction.valueOf(direction.name()) : Direction.ASC); }); return newSort; }
SortMapper { public Sort map(org.molgenis.api.model.Sort sort, EntityType entityType) { Sort newSort = new Sort(); sort.getOrders() .forEach( order -> { String attributeName = order.getId(); if (entityType.getAttribute(attributeName) == null) { throw new UnknownSortAttributeException(entityType, attributeName); } Order.Direction direction = order.getDirection(); newSort.on( attributeName, direction != null ? Direction.valueOf(direction.name()) : Direction.ASC); }); return newSort; } }
SortMapper { public Sort map(org.molgenis.api.model.Sort sort, EntityType entityType) { Sort newSort = new Sort(); sort.getOrders() .forEach( order -> { String attributeName = order.getId(); if (entityType.getAttribute(attributeName) == null) { throw new UnknownSortAttributeException(entityType, attributeName); } Order.Direction direction = order.getDirection(); newSort.on( attributeName, direction != null ? Direction.valueOf(direction.name()) : Direction.ASC); }); return newSort; } SortMapper(); }
SortMapper { public Sort map(org.molgenis.api.model.Sort sort, EntityType entityType) { Sort newSort = new Sort(); sort.getOrders() .forEach( order -> { String attributeName = order.getId(); if (entityType.getAttribute(attributeName) == null) { throw new UnknownSortAttributeException(entityType, attributeName); } Order.Direction direction = order.getDirection(); newSort.on( attributeName, direction != null ? Direction.valueOf(direction.name()) : Direction.ASC); }); return newSort; } SortMapper(); Sort map(org.molgenis.api.model.Sort sort, EntityType entityType); }
SortMapper { public Sort map(org.molgenis.api.model.Sort sort, EntityType entityType) { Sort newSort = new Sort(); sort.getOrders() .forEach( order -> { String attributeName = order.getId(); if (entityType.getAttribute(attributeName) == null) { throw new UnknownSortAttributeException(entityType, attributeName); } Order.Direction direction = order.getDirection(); newSort.on( attributeName, direction != null ? Direction.valueOf(direction.name()) : Direction.ASC); }); return newSort; } SortMapper(); Sort map(org.molgenis.api.model.Sort sort, EntityType entityType);  }