@Test
  public void executeFunctionOnLonerWithPartitionedRegionShouldNotThrowClassCastException() {
    Region<String, String> region = cache
        .<String, String>createRegionFactory(PARTITION)
        .create("region");

    populateRegion(region);

    ResultCollector<Collection<String>, Collection<String>> resultCollector = TypedFunctionService
        .<Void, Collection<String>, Collection<String>>onRegion(region)
        .withFilter(keysForGet)
        .execute(new TestFunction(DataSetSupplier.PARTITIONED));

    assertThat(resultCollector.getResult())
        .containsExactlyInAnyOrder(expectedValues.toArray(new String[0]));
  }
This tests make sure that, in case of LonerDistributedSystem we don't get ClassCast Exception.
Just making sure that the function executed on lonerDistributedSystem.

<p>
Regression test for bug: If invoked from LonerDistributedSystem, FunctionService.onMembers()
throws ClassCastException
geode-core/src/integrationTest/java/org/apache/geode/internal/cache/execute/FunctionExecutionOnLonerRegressionTest.java