@Test void testMapUnknownAttribute() { SortMapper sortMapper = new SortMapper(); Sort sort = Sort.create(singletonList(Order.create("attr1"))); EntityType entityType = mock(EntityType.class); assertThrows(UnknownSortAttributeException.class, () -> 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);  }