Search in sources :

Example 1 with SearchRequestV2_1

use of nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.SearchRequestV2_1 in project timbuctoo by HuygensING.

the class ListFacetDescriptionTest method filterAddsNoFilterIfTheFacetValueIsNotAListFacetValue.

@Test
public void filterAddsNoFilterIfTheFacetValueIsNotAListFacetValue() {
    String value1 = "value1";
    List<FacetValue> facetValues = Lists.newArrayList((FacetValue) () -> FACET_NAME);
    SearchRequestV2_1 searchRequest = new SearchRequestV2_1();
    searchRequest.setFacetValues(facetValues);
    GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(v -> v.withProperty(PROPERTY, value1).withTimId("1")).withVertex(v -> v.withProperty(PROPERTY, "value2").withTimId("2")).build().traversal().V();
    instance.filter(traversal, facetValues);
    assertThat(traversal.toList(), containsInAnyOrder(VertexMatcher.likeVertex().withTimId("1"), VertexMatcher.likeVertex().withTimId("2")));
}
Also used : VertexMatcher(nl.knaw.huygens.timbuctoo.util.VertexMatcher) Test(org.junit.Test) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) GraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal) ListFacetValue(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.ListFacetValue) SearchRequestV2_1(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.SearchRequestV2_1) Mockito.verify(org.mockito.Mockito.verify) PropertyParser(nl.knaw.huygens.timbuctoo.search.description.PropertyParser) FacetValue(nl.knaw.huygens.timbuctoo.search.FacetValue) List(java.util.List) Lists(com.google.common.collect.Lists) Matchers.contains(org.hamcrest.Matchers.contains) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) BDDMockito.given(org.mockito.BDDMockito.given) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) Before(org.junit.Before) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Mockito.mock(org.mockito.Mockito.mock) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) ListFacetValue(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.ListFacetValue) FacetValue(nl.knaw.huygens.timbuctoo.search.FacetValue) SearchRequestV2_1(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.SearchRequestV2_1) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 2 with SearchRequestV2_1

use of nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.SearchRequestV2_1 in project timbuctoo by HuygensING.

the class ListFacetDescriptionTest method filterAddsNoFilterIfTheFacetValuesIsEmpty.

@Test
public void filterAddsNoFilterIfTheFacetValuesIsEmpty() {
    String value1 = "value1";
    List<FacetValue> facetValues = Lists.newArrayList(new ListFacetValue(FACET_NAME, Lists.newArrayList()));
    SearchRequestV2_1 searchRequest = new SearchRequestV2_1();
    searchRequest.setFacetValues(facetValues);
    GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(v -> v.withProperty(PROPERTY, value1).withTimId("1")).withVertex(v -> v.withProperty(PROPERTY, "value2").withTimId("2")).build().traversal().V();
    instance.filter(traversal, facetValues);
    assertThat(traversal.toList(), containsInAnyOrder(VertexMatcher.likeVertex().withTimId("1"), VertexMatcher.likeVertex().withTimId("2")));
}
Also used : VertexMatcher(nl.knaw.huygens.timbuctoo.util.VertexMatcher) Test(org.junit.Test) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) GraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal) ListFacetValue(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.ListFacetValue) SearchRequestV2_1(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.SearchRequestV2_1) Mockito.verify(org.mockito.Mockito.verify) PropertyParser(nl.knaw.huygens.timbuctoo.search.description.PropertyParser) FacetValue(nl.knaw.huygens.timbuctoo.search.FacetValue) List(java.util.List) Lists(com.google.common.collect.Lists) Matchers.contains(org.hamcrest.Matchers.contains) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) BDDMockito.given(org.mockito.BDDMockito.given) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) Before(org.junit.Before) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Mockito.mock(org.mockito.Mockito.mock) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) ListFacetValue(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.ListFacetValue) FacetValue(nl.knaw.huygens.timbuctoo.search.FacetValue) ListFacetValue(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.ListFacetValue) SearchRequestV2_1(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.SearchRequestV2_1) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 3 with SearchRequestV2_1

use of nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.SearchRequestV2_1 in project timbuctoo by HuygensING.

the class EdgeListFacetDescriptionTest method filterAddsNoFilterIfTheFacetValuesIsEmpty.

@Test
public void filterAddsNoFilterIfTheFacetValuesIsEmpty() {
    List<FacetValue> facetValues = Lists.newArrayList(new ListFacetValue(FACET_NAME, Lists.newArrayList()));
    SearchRequestV2_1 searchRequest = new SearchRequestV2_1();
    searchRequest.setFacetValues(facetValues);
    GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(v -> v.withTimId("1")).withVertex(v -> v.withTimId("2")).build().traversal().V();
    instance.filter(traversal, facetValues);
    assertThat(traversal.toList(), containsInAnyOrder(VertexMatcher.likeVertex().withTimId("1"), VertexMatcher.likeVertex().withTimId("2")));
}
Also used : VertexMatcher(nl.knaw.huygens.timbuctoo.util.VertexMatcher) Test(org.junit.Test) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) GraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal) ListFacetValue(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.ListFacetValue) SearchRequestV2_1(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.SearchRequestV2_1) FacetValue(nl.knaw.huygens.timbuctoo.search.FacetValue) List(java.util.List) Lists(com.google.common.collect.Lists) Matchers.contains(org.hamcrest.Matchers.contains) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Matchers.equalTo(org.hamcrest.Matchers.equalTo) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Collections(java.util.Collections) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) Before(org.junit.Before) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) ListFacetValue(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.ListFacetValue) FacetValue(nl.knaw.huygens.timbuctoo.search.FacetValue) ListFacetValue(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.ListFacetValue) SearchRequestV2_1(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.SearchRequestV2_1) Test(org.junit.Test)

Example 4 with SearchRequestV2_1

use of nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.SearchRequestV2_1 in project timbuctoo by HuygensING.

the class EdgeListFacetDescriptionTest method filterAddsAFilterToFilterOutTheNonMatchingVertices.

@Test
public void filterAddsAFilterToFilterOutTheNonMatchingVertices() {
    List<FacetValue> facetValues = Lists.newArrayList(new ListFacetValue(FACET_NAME, Lists.newArrayList(RELATION_NAME)));
    SearchRequestV2_1 searchRequest = new SearchRequestV2_1();
    searchRequest.setFacetValues(facetValues);
    GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex("v1", v -> v.withTimId("1")).withVertex("v2", v -> v.withTimId("2").withOutgoingRelation(RELATION_NAME, "v1")).build().traversal().V();
    instance.filter(traversal, facetValues);
    assertThat(traversal.toList(), contains(VertexMatcher.likeVertex().withTimId("1")));
}
Also used : VertexMatcher(nl.knaw.huygens.timbuctoo.util.VertexMatcher) Test(org.junit.Test) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) GraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal) ListFacetValue(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.ListFacetValue) SearchRequestV2_1(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.SearchRequestV2_1) FacetValue(nl.knaw.huygens.timbuctoo.search.FacetValue) List(java.util.List) Lists(com.google.common.collect.Lists) Matchers.contains(org.hamcrest.Matchers.contains) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Matchers.equalTo(org.hamcrest.Matchers.equalTo) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Collections(java.util.Collections) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) Before(org.junit.Before) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) ListFacetValue(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.ListFacetValue) FacetValue(nl.knaw.huygens.timbuctoo.search.FacetValue) ListFacetValue(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.ListFacetValue) SearchRequestV2_1(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.SearchRequestV2_1) Test(org.junit.Test)

Example 5 with SearchRequestV2_1

use of nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.SearchRequestV2_1 in project timbuctoo by HuygensING.

the class ListFacetDescriptionTest method filterAddsAFilterToFilterOutTheNonMatchingVertices.

@Test
public void filterAddsAFilterToFilterOutTheNonMatchingVertices() {
    String value1 = "value1";
    List<FacetValue> facetValues = Lists.newArrayList(new ListFacetValue(FACET_NAME, Lists.newArrayList(value1)));
    SearchRequestV2_1 searchRequest = new SearchRequestV2_1();
    searchRequest.setFacetValues(facetValues);
    GraphTraversal<Vertex, Vertex> traversal = newGraph().withVertex(v -> v.withProperty(PROPERTY, value1).withTimId("1")).withVertex(v -> v.withProperty(PROPERTY, "value2").withTimId("2")).build().traversal().V();
    instance.filter(traversal, facetValues);
    assertThat(traversal.toList(), contains(VertexMatcher.likeVertex().withTimId("1")));
}
Also used : VertexMatcher(nl.knaw.huygens.timbuctoo.util.VertexMatcher) Test(org.junit.Test) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) GraphTraversal(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal) ListFacetValue(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.ListFacetValue) SearchRequestV2_1(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.SearchRequestV2_1) Mockito.verify(org.mockito.Mockito.verify) PropertyParser(nl.knaw.huygens.timbuctoo.search.description.PropertyParser) FacetValue(nl.knaw.huygens.timbuctoo.search.FacetValue) List(java.util.List) Lists(com.google.common.collect.Lists) Matchers.contains(org.hamcrest.Matchers.contains) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) BDDMockito.given(org.mockito.BDDMockito.given) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) Before(org.junit.Before) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Mockito.mock(org.mockito.Mockito.mock) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) ListFacetValue(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.ListFacetValue) FacetValue(nl.knaw.huygens.timbuctoo.search.FacetValue) ListFacetValue(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.ListFacetValue) SearchRequestV2_1(nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.SearchRequestV2_1) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Aggregations

Lists (com.google.common.collect.Lists)5 List (java.util.List)5 FacetValue (nl.knaw.huygens.timbuctoo.search.FacetValue)5 ListFacetValue (nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.ListFacetValue)5 SearchRequestV2_1 (nl.knaw.huygens.timbuctoo.server.mediatypes.v2.search.SearchRequestV2_1)5 TestGraphBuilder.newGraph (nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph)5 VertexMatcher (nl.knaw.huygens.timbuctoo.util.VertexMatcher)5 GraphTraversal (org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal)5 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)5 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)5 Matchers.contains (org.hamcrest.Matchers.contains)5 Matchers.containsInAnyOrder (org.hamcrest.Matchers.containsInAnyOrder)5 Before (org.junit.Before)5 Test (org.junit.Test)5 PropertyParser (nl.knaw.huygens.timbuctoo.search.description.PropertyParser)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 BDDMockito.given (org.mockito.BDDMockito.given)3 Mockito.mock (org.mockito.Mockito.mock)3 Mockito.verify (org.mockito.Mockito.verify)3 Collections (java.util.Collections)2