Search in sources :

Example 6 with FacetDescription

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

the class FacetDescriptionFactoryTest method createChangeRangeFacetDescriptionCreatesAChangeRangeFacetDescriptionIfTheTypeIsChange.

@Test
public void createChangeRangeFacetDescriptionCreatesAChangeRangeFacetDescriptionIfTheTypeIsChange() {
    FacetDescription facetDescription = instance.createChangeRangeFacetDescription("facetName", "propertyName");
    assertThat(facetDescription, is(instanceOf(ChangeRangeFacetDescription.class)));
}
Also used : FacetDescription(nl.knaw.huygens.timbuctoo.search.description.FacetDescription) Test(org.junit.Test)

Example 7 with FacetDescription

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

the class AbstractFacetDescriptionTest method getFacetInvokesTheFacetGetterToReturnTheFacet.

@Test
public void getFacetInvokesTheFacetGetterToReturnTheFacet() {
    PropertyValueGetter propertyValueGetter = mock(PropertyValueGetter.class);
    FacetGetter facetGetter = mock(FacetGetter.class);
    Facet mockFacet = mock(Facet.class);
    given(facetGetter.getFacet(any(), any())).willReturn(mockFacet);
    FacetDescription instance = new FacetDescriptionImpl(FACET_NAME, PROPERTY_NAME, facetGetter, propertyValueGetter);
    Map<String, Set<Vertex>> facetCounts = new HashMap<>();
    facetCounts.put(PROP_VAL, Sets.newHashSet());
    Facet result = instance.getFacet(facetCounts);
    ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
    assertEquals(result, mockFacet);
    ArgumentCaptor<HashMap> captor1 = ArgumentCaptor.forClass(HashMap.class);
    verify(facetGetter, times(1)).getFacet(captor.capture(), captor1.capture());
    assertThat(captor.getValue(), equalTo(FACET_NAME));
    assertThat(captor1.getValue(), equalTo(facetCounts));
}
Also used : Set(java.util.Set) HashMap(java.util.HashMap) FacetDescription(nl.knaw.huygens.timbuctoo.search.description.FacetDescription) Test(org.junit.Test)

Example 8 with FacetDescription

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

the class AbstractFacetDescriptionTest method getNameReturnsTheFacetName.

@Test
public void getNameReturnsTheFacetName() {
    PropertyValueGetter propertyValueGetter = mock(PropertyValueGetter.class);
    FacetGetter facetGetter = mock(FacetGetter.class);
    FacetDescription instance = new FacetDescriptionImpl(FACET_NAME, PROPERTY_NAME, facetGetter, propertyValueGetter);
    assertThat(instance.getName(), equalTo(FACET_NAME));
}
Also used : FacetDescription(nl.knaw.huygens.timbuctoo.search.description.FacetDescription) Test(org.junit.Test)

Example 9 with FacetDescription

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

the class AbstractFacetDescriptionTest method getValuesInvokesThePropertyValueGetterToReturnThePropertyValues.

@Test
public void getValuesInvokesThePropertyValueGetterToReturnThePropertyValues() {
    PropertyValueGetter propertyValueGetter = mock(PropertyValueGetter.class);
    FacetGetter facetGetter = mock(FacetGetter.class);
    List<String> mockValues = mock(List.class);
    Vertex vertex = mock(Vertex.class);
    given(propertyValueGetter.getValues(any(), any())).willReturn(mockValues);
    FacetDescription instance = new FacetDescriptionImpl(FACET_NAME, PROPERTY_NAME, facetGetter, propertyValueGetter);
    List<String> result = instance.getValues(vertex);
    assertEquals(result, mockValues);
    ArgumentCaptor<Vertex> captor = ArgumentCaptor.forClass(Vertex.class);
    ArgumentCaptor<String> captor1 = ArgumentCaptor.forClass(String.class);
    verify(propertyValueGetter, times(1)).getValues(captor.capture(), captor1.capture());
    assertThat(captor.getValue(), equalTo(vertex));
    assertThat(captor1.getValue(), equalTo(PROPERTY_NAME));
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) FacetDescription(nl.knaw.huygens.timbuctoo.search.description.FacetDescription) Test(org.junit.Test)

Example 10 with FacetDescription

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

the class FacetDescriptionFactoryTest method createMultiValueFacetDescriptionWithARelationCreatesADerivedMultiValueFacetDescription.

@Test
public void createMultiValueFacetDescriptionWithARelationCreatesADerivedMultiValueFacetDescription() {
    FacetDescription description = instance.createMultiValueListFacetDescription("facetName", "propertyName", "relationName");
    assertThat(description, is(instanceOf(RelatedMultiValueListFacetDescription.class)));
}
Also used : FacetDescription(nl.knaw.huygens.timbuctoo.search.description.FacetDescription) Test(org.junit.Test)

Aggregations

FacetDescription (nl.knaw.huygens.timbuctoo.search.description.FacetDescription)15 Test (org.junit.Test)15 PropertyParser (nl.knaw.huygens.timbuctoo.search.description.PropertyParser)3 HashMap (java.util.HashMap)1 Set (java.util.Set)1 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)1