Search in sources :

Example 11 with PropertyDescriptor

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

the class AppenderPropertyDescriptorTest method getReturnAppendsTheValuesOfThePropertyDescriptorsSeparatedByTheSeparator.

@Test
public void getReturnAppendsTheValuesOfThePropertyDescriptorsSeparatedByTheSeparator() {
    PropertyDescriptor propertyDescriptor1 = propertyDescriptorThatReturns("value1");
    PropertyDescriptor propertyDescriptor2 = propertyDescriptorThatReturns("value2");
    String separator = " ";
    AppenderPropertyDescriptor instance = new AppenderPropertyDescriptor(propertyDescriptor1, propertyDescriptor2, separator);
    Vertex vertex = vertex().build();
    String value = instance.get(vertex);
    assertThat(value, is("value1 value2"));
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) PropertyDescriptor(nl.knaw.huygens.timbuctoo.search.description.PropertyDescriptor) Test(org.junit.Test)

Example 12 with PropertyDescriptor

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

the class AppenderPropertyDescriptorTest method getReturnsOnlyTheValueOfTheSecondDescriptorIfTheFirstReturnsNull.

@Test
public void getReturnsOnlyTheValueOfTheSecondDescriptorIfTheFirstReturnsNull() {
    PropertyDescriptor propertyDescriptor1 = propertyDescriptorThatReturns(null);
    PropertyDescriptor propertyDescriptor2 = propertyDescriptorThatReturns("value2");
    String separator = " ";
    AppenderPropertyDescriptor instance = new AppenderPropertyDescriptor(propertyDescriptor1, propertyDescriptor2, separator);
    Vertex vertex = vertex().build();
    String value = instance.get(vertex);
    assertThat(value, is("value2"));
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) PropertyDescriptor(nl.knaw.huygens.timbuctoo.search.description.PropertyDescriptor) Test(org.junit.Test)

Example 13 with PropertyDescriptor

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

the class CompositePropertyDescriptorTest method getReturnsTheValueOfTheSecondPropDescriptionIfTheValueOfTheFirstOneIsAnEmptyString.

@Test
public void getReturnsTheValueOfTheSecondPropDescriptionIfTheValueOfTheFirstOneIsAnEmptyString() {
    PropertyDescriptor propertyDescriptor1 = mock(PropertyDescriptor.class);
    given(propertyDescriptor1.get(any(Vertex.class))).willReturn("");
    PropertyDescriptor propertyDescriptor2 = mock(PropertyDescriptor.class);
    String valueOfDesc2 = "notNull";
    given(propertyDescriptor2.get(any(Vertex.class))).willReturn(valueOfDesc2);
    CompositePropertyDescriptor instance = new CompositePropertyDescriptor(propertyDescriptor1, propertyDescriptor2);
    String value = instance.get(mock(Vertex.class));
    assertThat(value, is(valueOfDesc2));
    verify(propertyDescriptor1).get(any(Vertex.class));
    verify(propertyDescriptor2).get(any(Vertex.class));
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) PropertyDescriptor(nl.knaw.huygens.timbuctoo.search.description.PropertyDescriptor) Test(org.junit.Test)

Example 14 with PropertyDescriptor

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

the class CompositePropertyDescriptorTest method getReturnsTheValueOfTheFirstPropDescription.

@Test
public void getReturnsTheValueOfTheFirstPropDescription() {
    PropertyDescriptor propertyDescriptor1 = mock(PropertyDescriptor.class);
    String valueOfDesc1 = "notNull";
    given(propertyDescriptor1.get(any(Vertex.class))).willReturn(valueOfDesc1);
    PropertyDescriptor propertyDescriptor2 = mock(PropertyDescriptor.class);
    CompositePropertyDescriptor instance = new CompositePropertyDescriptor(propertyDescriptor1, propertyDescriptor2);
    String value = instance.get(mock(Vertex.class));
    assertThat(value, is(valueOfDesc1));
    verify(propertyDescriptor1).get(any(Vertex.class));
    verifyZeroInteractions(propertyDescriptor2);
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) PropertyDescriptor(nl.knaw.huygens.timbuctoo.search.description.PropertyDescriptor) Test(org.junit.Test)

Example 15 with PropertyDescriptor

use of nl.knaw.huygens.timbuctoo.search.description.PropertyDescriptor 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)

Aggregations

PropertyDescriptor (nl.knaw.huygens.timbuctoo.search.description.PropertyDescriptor)15 Test (org.junit.Test)11 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)7 PropertyParser (nl.knaw.huygens.timbuctoo.search.description.PropertyParser)3 PersonNames (nl.knaw.huygens.timbuctoo.model.PersonNames)1 ElementValidationResult (nl.knaw.huygens.timbuctoo.server.healthchecks.ElementValidationResult)1 Transaction (org.apache.tinkerpop.gremlin.structure.Transaction)1 Node (org.neo4j.graphdb.Node)1 IndexManager (org.neo4j.graphdb.index.IndexManager)1