use of nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.SortParameter in project timbuctoo by HuygensING.
the class SortDescriptionTest method sortAddsASortParametersThatSortsTheVertices.
@Test
@SuppressWarnings("unchecked")
public void sortAddsASortParametersThatSortsTheVertices() {
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(v -> v.withTimId("id1").withProperty(PROPERTY_1, "value1.2")).withVertex(v -> v.withTimId("id2").withProperty(PROPERTY_1, "value1.1")).withVertex(v -> v.withTimId("id3").withProperty(PROPERTY_1, "value1")).build().traversal().V();
List<SortParameter> sortParameters = Lists.newArrayList(new SortParameter(SORT_FIELD_1, asc));
instance.sort(traversal, sortParameters);
List<Vertex> actual = traversal.toList();
assertThat(actual, contains(likeVertex().withTimId("id3"), likeVertex().withTimId("id2"), likeVertex().withTimId("id1")));
}
use of nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.SortParameter in project timbuctoo by HuygensING.
the class SortDescriptionTest method sortAddsASortParameterToTheSearchResultsForEachOfTheSortParameters.
@Test
@SuppressWarnings("unchecked")
public void sortAddsASortParameterToTheSearchResultsForEachOfTheSortParameters() {
GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(v -> v.withTimId("id1").withProperty(PROPERTY_1, "value1.2").withProperty(PROPERTY_2, "value2")).withVertex(v -> v.withTimId("id2").withProperty(PROPERTY_1, "value1").withProperty(PROPERTY_2, "value2.1")).withVertex(v -> v.withTimId("id3").withProperty(PROPERTY_1, "value1").withProperty(PROPERTY_2, "value2")).build().traversal().V();
List<SortParameter> sortParameters = Lists.newArrayList(new SortParameter(SORT_FIELD_1, asc), new SortParameter(SORT_FIELD_2, asc));
instance.sort(traversal, sortParameters);
List<Vertex> actual = traversal.toList();
assertThat(actual, contains(likeVertex().withTimId("id3"), likeVertex().withTimId("id2"), likeVertex().withTimId("id1")));
}
use of nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.SortParameter in project timbuctoo by HuygensING.
the class SortDescriptionTest method sortIgnoresUnknownSortParameters.
@Test
@SuppressWarnings("unchecked")
public void sortIgnoresUnknownSortParameters() {
GraphTraversal<Vertex, Vertex> traversal = mock(GraphTraversal.class);
List<SortParameter> sortParameters = Lists.newArrayList(new SortParameter("unknownField", asc));
instance.sort(traversal, sortParameters);
verifyZeroInteractions(traversal);
}
Aggregations