Skip to Content
1
Former Member
May 15, 2017 at 04:37 PM

BUG: Orika copying subclasses of objects in DefaultFacetSearchConfigService fails

201 Views

In the DefaultFacetSearchConfigService.getConfiguration(String) it copies the FacetSearchConfig object using the 3rd party Orika (https://github.com/orika-mapper/orika) before returning it. If it tries to copy a collection with subclasses, it has issues.

In the following unit test, I am copying the IndexedProperty using the orika-mapper in the same way as the DefaultFacetSearchConfigService. I extended AbstractSolrFacetVisibilityRuleData and added that to the list of the IndexedProperty's facetVisibilityRules. After copying, the copied IndexedProperty's facetVisibilityRules are not the extended class, but it is the AbstractSolrFacetVisibilityRuleData.

This will cause issues when creating your implementation of SolrFacetVisibilityRulePlugin to evaluate the visibility rules.

 @Test
 public void testCopying() throws Exception
 {
     IndexedProperty indexedProperty = new IndexedProperty();
     indexedProperty.setFacetVisibilityRules(Collections.singletonList(new OtherFacetSelectedSolrFacetVisibilityRuleData()));
 
     ConfigurableMapper facetSearchConfigMapper = new ConfigurableMapper();
     IndexedProperty copiedIndexedProperty = facetSearchConfigMapper.map(indexedProperty, IndexedProperty.class);
 
     AbstractSolrFacetVisibilityRuleData copiedVisibilityRuleData = copiedIndexedProperty.getFacetVisibilityRules().iterator().next();
     Assert.assertTrue(OtherFacetSelectedSolrFacetVisibilityRuleData.class.isInstance(copiedVisibilityRuleData));
 }