Class MockInstantiator

  • All Implemented Interfaces:
    com.vaadin.flow.di.Instantiator , java.io.Serializable

    @Deprecated(message = "Wrapping the instantiator of the mocked environment has no effect; use that instantiator directly. Scheduled for removal.") 
    public class MockInstantiator
     implements Instantiator
                        

    An Instantiator wrapping the one the mocked environment provides.

    The wrapper does not mock anything any more: the getOrCreate special cases it was written for are long gone, so every member simply forwards to delegate. The mocked services therefore use the environment's own instantiator directly, and this class is kept for source compatibility only.

    The forwarding is spelled out by hand on purpose: Kotlin interface delegation only generates forwarders for the abstract members of Instantiator, so a method Flow declares as a Java default would otherwise resolve to that default implementation and never reach the delegate — which is how a Spring PageTitleGenerator bean used to be dropped in browserless tests. Since a wrapper can always fall behind a method added to Instantiator later, create hands back the delegate itself instead of wrapping it.

    The list of forwarders below is deliberately not guarded by a test: pinning it would fail the build whenever Flow adds a method to Instantiator, which is not worth it for a class scheduled for removal and used by nothing here. A method missing from the list is therefore silently dropped for callers who construct this class themselves — one more reason not to.