private void setMockRuntimeMemoryInfoAccessor(IMap map, final long totalMemoryMB, final long freeMemoryMB, final long maxMemoryMB) {
final MapProxyImpl mapProxy = (MapProxyImpl) map;
final MapService mapService = (MapService) mapProxy.getService();
final MapServiceContext mapServiceContext = mapService.getMapServiceContext();
final DefaultMapServiceContext defaultMapServiceContext = (DefaultMapServiceContext) mapServiceContext;
final EvictionOperator evictionOperator = EvictionOperator.create(new MemoryInfoAccessor() {
@Override
public long getTotalMemory() {
return convertMegaBytesToBytes(totalMemoryMB);
}
@Override
public long getFreeMemory() {
return convertMegaBytesToBytes(freeMemoryMB);
}
@Override
public long getMaxMemory() {
return convertMegaBytesToBytes(maxMemoryMB);
}
}, mapServiceContext);
defaultMapServiceContext.setEvictionOperator(evictionOperator);
}