Search in sources :

Example 1 with OIndexUnique

use of com.orientechnologies.orient.core.index.OIndexUnique in project orientdb by orientechnologies.

the class OChainedIndexProxyFindBestIndexTest method testPriorityHashOverNonHash.

@Test
public void testPriorityHashOverNonHash() throws Exception {
    final OIndexUnique expectedResult = mockUniqueHashIndex();
    final List<OIndex<?>> indexes = Arrays.<OIndex<?>>asList(mockUniqueIndex(), mockUniqueCompositeIndex(), expectedResult, mockUniqueIndex(), mockUniqueCompositeIndex());
    final OIndex<?> result = OChainedIndexProxy.findBestIndex(indexes);
    Assert.assertSame(result, expectedResult);
}
Also used : OIndexUnique(com.orientechnologies.orient.core.index.OIndexUnique) OIndex(com.orientechnologies.orient.core.index.OIndex) Test(org.testng.annotations.Test)

Example 2 with OIndexUnique

use of com.orientechnologies.orient.core.index.OIndexUnique in project orientdb by orientechnologies.

the class OChainedIndexProxyFindBestIndexTest method mockUniqueCompositeHashIndexWithNullSupport.

private OIndexUnique mockUniqueCompositeHashIndexWithNullSupport() {
    final OIndexUnique uniqueIndex = mock(OIndexUnique.class);
    when(uniqueIndex.getInternal()).thenReturn(uniqueIndex);
    final OIndexDefinition definition = mock(OIndexDefinition.class);
    when(definition.getParamCount()).thenReturn(2);
    when(uniqueIndex.getDefinition()).thenReturn(definition);
    when(uniqueIndex.getType()).thenReturn(OClass.INDEX_TYPE.UNIQUE_HASH_INDEX.toString());
    when(uniqueIndex.getMetadata()).thenReturn(new ODocument().field("ignoreNullValues", false));
    return uniqueIndex;
}
Also used : OIndexDefinition(com.orientechnologies.orient.core.index.OIndexDefinition) OIndexUnique(com.orientechnologies.orient.core.index.OIndexUnique) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 3 with OIndexUnique

use of com.orientechnologies.orient.core.index.OIndexUnique in project orientdb by orientechnologies.

the class OChainedIndexProxyFindBestIndexTest method mockUniqueIndex.

private OIndexUnique mockUniqueIndex() {
    final OIndexUnique uniqueIndex = mock(OIndexUnique.class);
    when(uniqueIndex.getInternal()).thenReturn(uniqueIndex);
    final OIndexDefinition definition = mock(OIndexDefinition.class);
    when(definition.getParamCount()).thenReturn(1);
    when(uniqueIndex.getDefinition()).thenReturn(definition);
    when(uniqueIndex.getType()).thenReturn(OClass.INDEX_TYPE.UNIQUE.toString());
    return uniqueIndex;
}
Also used : OIndexDefinition(com.orientechnologies.orient.core.index.OIndexDefinition) OIndexUnique(com.orientechnologies.orient.core.index.OIndexUnique)

Example 4 with OIndexUnique

use of com.orientechnologies.orient.core.index.OIndexUnique in project orientdb by orientechnologies.

the class OChainedIndexProxyFindBestIndexTest method testDoNotUseCompositeHashIndex.

@Test
public void testDoNotUseCompositeHashIndex() throws Exception {
    final OIndexUnique expectedResult = mockUniqueIndex();
    final List<OIndex<?>> indexes = Arrays.<OIndex<?>>asList(mockUniqueCompositeHashIndexWithNullSupport(), expectedResult, mockUniqueCompositeHashIndexWithNullSupport());
    final OIndex<?> result = OChainedIndexProxy.findBestIndex(indexes);
    Assert.assertSame(result, expectedResult);
}
Also used : OIndexUnique(com.orientechnologies.orient.core.index.OIndexUnique) OIndex(com.orientechnologies.orient.core.index.OIndex) Test(org.testng.annotations.Test)

Example 5 with OIndexUnique

use of com.orientechnologies.orient.core.index.OIndexUnique in project orientdb by orientechnologies.

the class OChainedIndexProxyFindBestIndexTest method testPriorityNonCompositeOverComposite.

@Test
public void testPriorityNonCompositeOverComposite() throws Exception {
    final OIndexUnique expectedResult = mockUniqueIndex();
    final List<OIndex<?>> indexes = Arrays.<OIndex<?>>asList(mockUniqueCompositeIndexWithNullSupport(), mockUniqueCompositeHashIndexWithNullSupport(), expectedResult, mockUniqueCompositeIndexWithNullSupport(), mockUniqueCompositeHashIndexWithNullSupport());
    final OIndex<?> result = OChainedIndexProxy.findBestIndex(indexes);
    Assert.assertSame(result, expectedResult);
}
Also used : OIndexUnique(com.orientechnologies.orient.core.index.OIndexUnique) OIndex(com.orientechnologies.orient.core.index.OIndex) Test(org.testng.annotations.Test)

Aggregations

OIndexUnique (com.orientechnologies.orient.core.index.OIndexUnique)11 OIndexDefinition (com.orientechnologies.orient.core.index.OIndexDefinition)6 OIndex (com.orientechnologies.orient.core.index.OIndex)5 Test (org.testng.annotations.Test)5 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)2