OCompositeIndexDefinition extends ODocumentWrapperNoClass implements OIndexDefinition { public Object createValue(final List<?> params) { int currentParamIndex = 0; final OCompositeKey firstKey = new OCompositeKey(); final List<OCompositeKey> compositeKeys = new ArrayList<OCompositeKey>(10); compositeKeys.add(firstKey); boolean containsCollection = false; for (final OIndexDefinition indexDefinition : indexDefinitions) { if (currentParamIndex + 1 > params.size()) break; final int endIndex; if (currentParamIndex + indexDefinition.getParamCount() > params.size()) endIndex = params.size(); else endIndex = currentParamIndex + indexDefinition.getParamCount(); final List<?> indexParams = params.subList(currentParamIndex, endIndex); currentParamIndex += indexDefinition.getParamCount(); final Object keyValue = indexDefinition.createValue(indexParams); if (keyValue == null) return null; containsCollection = addKey(firstKey, compositeKeys, containsCollection, keyValue); } if (!containsCollection) return firstKey; return compositeKeys; } OCompositeIndexDefinition();  OCompositeIndexDefinition(final String iClassName);  OCompositeIndexDefinition(final String iClassName, final List<? extends OIndexDefinition> iIndexes); String getClassName(); void addIndex(final OIndexDefinition indexDefinition); List<String> getFields(); List<String> getFieldsToIndex(); Object getDocumentValueToIndex(final ODocument iDocument); int getMultiValueDefinitionIndex(); String getMultiValueField(); Object createValue(final List<?> params); OIndexDefinitionMultiValue getMultiValueDefinition(); OCompositeKey createSingleValue(final List<?> params); Object createValue(final Object... params); void processChangeEvent(OMultiValueChangeEvent<?, ?> changeEvent, Map<OCompositeKey, Integer> keysToAdd,
      Map<OCompositeKey, Integer> keysToRemove, Object... params); int getParamCount(); OType[] getTypes(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); @Override ODocument toStream(); String toCreateIndexDDL(final String indexName, final String indexType);  }
@Test public void testCreateValueSuccessful() { final Object result = compositeIndex.createValue(Arrays.asList("12", "test")); Assert.assertEquals(result, new OCompositeKey(Arrays.asList(12, "test"))); }
@Test public void testCreateValueWrongParam() { final Object result = compositeIndex.createValue(Arrays.asList("1t2", "test")); Assert.assertNull(result); }
@Test public void testCreateValueSuccessfulArrayParams() { final Object result = compositeIndex.createValue("12", "test"); Assert.assertEquals(result, new OCompositeKey(Arrays.asList(12, "test"))); }
@Test public void testCreateValueWrongParamArrayParams() { final Object result = compositeIndex.createValue("1t2", "test"); Assert.assertNull(result); }