Search in sources :

Example 1 with PropertyParser

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

the class FacetDescriptionFactoryTest method createListFacetDescriptionWithARelationCreatesADerivedListFacetDescription.

@Test
public void createListFacetDescriptionWithARelationCreatesADerivedListFacetDescription() {
    PropertyParser parser = mock(PropertyParser.class);
    FacetDescription description = instance.createListFacetDescription("facetName", parser, "propertyName", "relation");
    assertThat(description, is(instanceOf(RelatedListFacetDescription.class)));
}
Also used : PropertyParser(nl.knaw.huygens.timbuctoo.search.description.PropertyParser) FacetDescription(nl.knaw.huygens.timbuctoo.search.description.FacetDescription) Test(org.junit.Test)

Example 2 with PropertyParser

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

the class LocalPropertyDescriptorTest method getReturnsValueFromParserParseIfTheVertexDoesContainTheProperty.

@Test
public void getReturnsValueFromParserParseIfTheVertexDoesContainTheProperty() {
    String propertyName = "propName";
    String expectedValue = "a string";
    PropertyParser parser = mock(PropertyParser.class);
    given(parser.parse(anyString())).willReturn(expectedValue);
    Vertex vertex = vertex().withProperty(propertyName, "a string 2").build();
    LocalPropertyDescriptor instance = new LocalPropertyDescriptor(propertyName, parser);
    String value = instance.get(vertex);
    assertThat(value, is(equalTo(expectedValue)));
    verify(parser).parse(anyString());
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) PropertyParser(nl.knaw.huygens.timbuctoo.search.description.PropertyParser) Test(org.junit.Test)

Example 3 with PropertyParser

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

the class LocalPropertyDescriptorTest method getReturnsTheValueWithAPrefixAndAPostfixIfTheyAreConfigured.

@Test
public void getReturnsTheValueWithAPrefixAndAPostfixIfTheyAreConfigured() {
    String propertyName = "propName";
    String expectedValue = "a string";
    String prefix = "[";
    String postfix = "]";
    PropertyParser parser = mock(PropertyParser.class);
    given(parser.parse(anyString())).willReturn(expectedValue);
    Vertex vertex = vertex().withProperty(propertyName, "a string 2").build();
    LocalPropertyDescriptor instance = new LocalPropertyDescriptor(propertyName, parser, prefix, postfix);
    String value = instance.get(vertex);
    assertThat(value, allOf(startsWith(prefix), endsWith(postfix)));
    verify(parser).parse(anyString());
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) PropertyParser(nl.knaw.huygens.timbuctoo.search.description.PropertyParser) Test(org.junit.Test)

Example 4 with PropertyParser

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

the class LocalPropertyDescriptorTest method getReturnsNullIfTheParserReturnsNull.

@Test
public void getReturnsNullIfTheParserReturnsNull() {
    String propertyName = "propName";
    String prefix = "[";
    String postfix = "]";
    PropertyParser parser = mock(PropertyParser.class);
    given(parser.parse(anyString())).willReturn(null);
    Vertex vertex = vertex().withProperty(propertyName, "a string 2").build();
    LocalPropertyDescriptor instance = new LocalPropertyDescriptor(propertyName, parser, prefix, postfix);
    String value = instance.get(vertex);
    assertThat(value, is(nullValue()));
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) PropertyParser(nl.knaw.huygens.timbuctoo.search.description.PropertyParser) Test(org.junit.Test)

Example 5 with PropertyParser

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

the class PropertyDescriptorFactoryTest method getLocalWithPrefixAndPostfixReturnsLocalPropertyDescriptor.

@Test
public void getLocalWithPrefixAndPostfixReturnsLocalPropertyDescriptor() {
    PropertyParser parser = mock(PropertyParser.class);
    PropertyDescriptor descriptor = instance.getLocal("propertyName", parser, "prefix", "postfix");
    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)

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