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;
}
Aggregations