I have an interface that has a default method overload that can transform an instance of any sort of bar (in this case, message format) into a canonical format for processing.
interface Foo {
void doThing(SpecificType bar);
default void doThing(SuperType bar) {
doThing(new SpecificType(bar));
}
}
I want to test that when I call Foo#doThing with a SomeOtherBar, the message gets correctly transformed and sent out the SpecificType overload. However, Spock's Mock() intercepts all methods, including default methods.
Since one main purpose of default methods is to support adaptation onto legacy APIs, this behavior will prevent backwards-compatibility bridges from working if a provider API is upgraded. Instead, it should be possible to either by default (my preference) or explicitly exclude default interface methods from being implemented by the mock proxy.
I have an interface that has a default method overload that can transform an instance of any sort of
bar(in this case, message format) into a canonical format for processing.I want to test that when I call
Foo#doThingwith aSomeOtherBar, the message gets correctly transformed and sent out theSpecificTypeoverload. However, Spock'sMock()intercepts all methods, including default methods.Since one main purpose of default methods is to support adaptation onto legacy APIs, this behavior will prevent backwards-compatibility bridges from working if a provider API is upgraded. Instead, it should be possible to either by default (my preference) or explicitly exclude default interface methods from being implemented by the mock proxy.