Search in sources :

Example 31 with IndexStatistics

use of org.apache.geode.cache.query.IndexStatistics in project geode by apache.

the class ListIndexFunctionJUnitTest method createMockIndex.

private Index createMockIndex(final IndexDetails indexDetails) {
    final Index mockIndex = mockContext.mock(Index.class, "Index " + indexDetails.getIndexName() + " " + mockCounter.getAndIncrement());
    final Region mockRegion = mockContext.mock(Region.class, "Region " + indexDetails.getRegionPath() + " " + mockCounter.getAndIncrement());
    mockContext.checking(new Expectations() {

        {
            oneOf(mockIndex).getFromClause();
            will(returnValue(indexDetails.getFromClause()));
            oneOf(mockIndex).getIndexedExpression();
            will(returnValue(indexDetails.getIndexedExpression()));
            oneOf(mockIndex).getName();
            will(returnValue(indexDetails.getIndexName()));
            oneOf(mockIndex).getProjectionAttributes();
            will(returnValue(indexDetails.getProjectionAttributes()));
            exactly(2).of(mockIndex).getRegion();
            will(returnValue(mockRegion));
            oneOf(mockIndex).getType();
            will(returnValue(getIndexType(indexDetails.getIndexType())));
            oneOf(mockRegion).getName();
            will(returnValue(indexDetails.getRegionName()));
            oneOf(mockRegion).getFullPath();
            will(returnValue(indexDetails.getRegionPath()));
        }
    });
    if (indexDetails.getIndexStatisticsDetails() != null) {
        final IndexStatistics mockIndexStatistics = mockContext.mock(IndexStatistics.class, "IndexStatistics " + indexDetails.getIndexName() + " " + mockCounter.getAndIncrement());
        mockContext.checking(new Expectations() {

            {
                exactly(2).of(mockIndex).getStatistics();
                will(returnValue(mockIndexStatistics));
                oneOf(mockIndexStatistics).getNumUpdates();
                will(returnValue(indexDetails.getIndexStatisticsDetails().getNumberOfUpdates()));
                oneOf(mockIndexStatistics).getNumberOfKeys();
                will(returnValue(indexDetails.getIndexStatisticsDetails().getNumberOfKeys()));
                oneOf(mockIndexStatistics).getNumberOfValues();
                will(returnValue(indexDetails.getIndexStatisticsDetails().getNumberOfValues()));
                oneOf(mockIndexStatistics).getTotalUpdateTime();
                will(returnValue(indexDetails.getIndexStatisticsDetails().getTotalUpdateTime()));
                oneOf(mockIndexStatistics).getTotalUses();
                will(returnValue(indexDetails.getIndexStatisticsDetails().getTotalUses()));
            }
        });
    } else {
        mockContext.checking(new Expectations() {

            {
                oneOf(mockIndex).getStatistics();
                will(returnValue(null));
            }
        });
    }
    return mockIndex;
}
Also used : Expectations(org.jmock.Expectations) IndexStatistics(org.apache.geode.cache.query.IndexStatistics) Region(org.apache.geode.cache.Region) Index(org.apache.geode.cache.query.Index)

Aggregations

IndexStatistics (org.apache.geode.cache.query.IndexStatistics)31 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)24 Test (org.junit.Test)24 Portfolio (org.apache.geode.cache.query.data.Portfolio)23 Query (org.apache.geode.cache.query.Query)19 PartitionedIndex (org.apache.geode.cache.query.internal.index.PartitionedIndex)8 SelectResults (org.apache.geode.cache.query.SelectResults)6 BucketRegion (org.apache.geode.internal.cache.BucketRegion)4 Region (org.apache.geode.cache.Region)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Cache (org.apache.geode.cache.Cache)2 Index (org.apache.geode.cache.query.Index)2 InternalIndexStatistics (org.apache.geode.cache.query.internal.index.AbstractIndex.InternalIndexStatistics)2 File (java.io.File)1 Properties (java.util.Properties)1 QueryService (org.apache.geode.cache.query.QueryService)1 Numbers (org.apache.geode.cache.query.data.Numbers)1 DefaultQueryService (org.apache.geode.cache.query.internal.DefaultQueryService)1 DistributedSystem (org.apache.geode.distributed.DistributedSystem)1