@Test public void testMultiValue() throws Exception { TypeManager typeManager = mock(TypeManager.class); when(typeManager.getValueType("STRING")).thenReturn(new StringValueType()); ValueType valueType = new ListValueType(typeManager, "STRING"); FieldType fieldType = mock(FieldType.class); when(fieldType.getValueType()).thenReturn(valueType); HierarchicalFacetPrefixFormatter formatter = new HierarchicalFacetPrefixFormatter(); List<String> result = formatter.format(Lists.newArrayList( new IndexValue(null, fieldType, "foo/bar"), new IndexValue(null, fieldType, "bar/foo")), null); assertEquals(4, result.size()); assertEquals("0/foo", result.get(0)); assertEquals("1/foo/bar", result.get(1)); assertEquals("0/bar", result.get(2)); assertEquals("1/bar/foo", result.get(3)); }
@Override public List<String> format(List<IndexValue> indexValues, LRepository repository) throws InterruptedException { List<String> result = new ArrayList<String>(); for (IndexValue indexValue : indexValues) { ValueType valueType = indexValue.fieldType.getValueType(); if (valueType.getBaseName().equals("LIST")) { valueType = valueType.getNestedValueType(); } if (!valueType.getName().equals("STRING")) { throw new RuntimeException(this.getClass().getSimpleName() + " only supports string values, but got: " + valueType.getName()); } processPath((String)indexValue.value, result); } return result; }
HierarchicalFacetPrefixFormatter implements Formatter { @Override public List<String> format(List<IndexValue> indexValues, LRepository repository) throws InterruptedException { List<String> result = new ArrayList<String>(); for (IndexValue indexValue : indexValues) { ValueType valueType = indexValue.fieldType.getValueType(); if (valueType.getBaseName().equals("LIST")) { valueType = valueType.getNestedValueType(); } if (!valueType.getName().equals("STRING")) { throw new RuntimeException(this.getClass().getSimpleName() + " only supports string values, but got: " + valueType.getName()); } processPath((String)indexValue.value, result); } return result; } }
HierarchicalFacetPrefixFormatter implements Formatter { @Override public List<String> format(List<IndexValue> indexValues, LRepository repository) throws InterruptedException { List<String> result = new ArrayList<String>(); for (IndexValue indexValue : indexValues) { ValueType valueType = indexValue.fieldType.getValueType(); if (valueType.getBaseName().equals("LIST")) { valueType = valueType.getNestedValueType(); } if (!valueType.getName().equals("STRING")) { throw new RuntimeException(this.getClass().getSimpleName() + " only supports string values, but got: " + valueType.getName()); } processPath((String)indexValue.value, result); } return result; }  }
HierarchicalFacetPrefixFormatter implements Formatter { @Override public List<String> format(List<IndexValue> indexValues, LRepository repository) throws InterruptedException { List<String> result = new ArrayList<String>(); for (IndexValue indexValue : indexValues) { ValueType valueType = indexValue.fieldType.getValueType(); if (valueType.getBaseName().equals("LIST")) { valueType = valueType.getNestedValueType(); } if (!valueType.getName().equals("STRING")) { throw new RuntimeException(this.getClass().getSimpleName() + " only supports string values, but got: " + valueType.getName()); } processPath((String)indexValue.value, result); } return result; }  @Override List<String> format(List<IndexValue> indexValues, LRepository repository); }
HierarchicalFacetPrefixFormatter implements Formatter { @Override public List<String> format(List<IndexValue> indexValues, LRepository repository) throws InterruptedException { List<String> result = new ArrayList<String>(); for (IndexValue indexValue : indexValues) { ValueType valueType = indexValue.fieldType.getValueType(); if (valueType.getBaseName().equals("LIST")) { valueType = valueType.getNestedValueType(); } if (!valueType.getName().equals("STRING")) { throw new RuntimeException(this.getClass().getSimpleName() + " only supports string values, but got: " + valueType.getName()); } processPath((String)indexValue.value, result); } return result; }  @Override List<String> format(List<IndexValue> indexValues, LRepository repository);  }