Search in sources :

Example 11 with PropertyParser

use of nl.knaw.huygens.timbuctoo.search.description.PropertyParser in project timbuctoo by HuygensING.

the class ListFacetDescriptionTest method filterLetsTheParserParseEachDatabaseValue.

@Test
public void filterLetsTheParserParseEachDatabaseValue() {
    String value1 = "value1";
    List<FacetValue> facetValues = Lists.newArrayList(new ListFacetValue(FACET_NAME, Lists.newArrayList(value1)));
    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);
    // needed to verify the parser
    traversal.toList();
    verify(propertyParser).parse("value1");
    verify(propertyParser).parse("value2");
}
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) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 12 with PropertyParser

use of nl.knaw.huygens.timbuctoo.search.description.PropertyParser in project timbuctoo by HuygensING.

the class PropertyDescriptorFactoryTest method getLocalWithPropertyNameAndParserReturnsALocalPropertyDescriptor.

@Test
public void getLocalWithPropertyNameAndParserReturnsALocalPropertyDescriptor() {
    PropertyParser parser = mock(PropertyParser.class);
    PropertyDescriptor descriptor = instance.getLocal("propertyName", parser);
    assertThat(descriptor, is(instanceOf(LocalPropertyDescriptor.class)));
}
Also used : PropertyDescriptor(nl.knaw.huygens.timbuctoo.search.description.PropertyDescriptor) PropertyParser(nl.knaw.huygens.timbuctoo.search.description.PropertyParser) Test(org.junit.Test)

Example 13 with PropertyParser

use of nl.knaw.huygens.timbuctoo.search.description.PropertyParser in project timbuctoo by HuygensING.

the class AbstractPropertyParserTest method namesReturnsTheDefaultValueIfTheInputValueIsNull.

@Test
public void namesReturnsTheDefaultValueIfTheInputValueIsNull() {
    String nullString = null;
    PropertyParser instance = getInstance();
    Object result = instance.parseForSort(nullString);
    assertThat(result, is(nullValue()));
}
Also used : PropertyParser(nl.knaw.huygens.timbuctoo.search.description.PropertyParser) Test(org.junit.Test)

Example 14 with PropertyParser

use of nl.knaw.huygens.timbuctoo.search.description.PropertyParser in project timbuctoo by HuygensING.

the class PropertyParserFactoryTest method getParserReturnsAChangeDatePropertyParserForChange.

@Test
public void getParserReturnsAChangeDatePropertyParserForChange() {
    PropertyParser parser = instance.getParser(Change.class);
    assertThat(parser, is(instanceOf(ChangeDatePropertyParser.class)));
}
Also used : PropertyParser(nl.knaw.huygens.timbuctoo.search.description.PropertyParser) Test(org.junit.Test)

Example 15 with PropertyParser

use of nl.knaw.huygens.timbuctoo.search.description.PropertyParser in project timbuctoo by HuygensING.

the class PropertyParserFactoryTest method getParserReturnsADatableFromYearPropertyParserForDatable.

@Test
public void getParserReturnsADatableFromYearPropertyParserForDatable() {
    PropertyParser parser = instance.getParser(Datable.class);
    assertThat(parser, is(instanceOf(DatableFromYearPropertyParser.class)));
}
Also used : PropertyParser(nl.knaw.huygens.timbuctoo.search.description.PropertyParser) Test(org.junit.Test)

Aggregations

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