Package 

Class MockStateHolder


  • 
    public final class MockStateHolder
    
                        

    Used to mock the initial state value of a viewmodel.

    • Constructor Detail

      • MockStateHolder

        MockStateHolder()
    • Method Detail

      • clearMock

         final Unit clearMock(MockableMavericksView view)

        Clear the stored mock info for the given view. This should be called after the view is done initializing itself with the mock. This should be done to prevent leaking references to the view and its mocks.

      • getMockedState

         final <S extends MavericksState> S getMockedState(MockableMavericksView view, KProperty<?> viewModelProperty, Boolean existingViewModel, Class<S> stateClass, Boolean forceMockExistingViewModel)

        Get the mocked state for the viewmodel on the given view. Returns null if no mocked state has been set - this is valid if a view under mock contains nested views that are not under mock.

        The mock state is not cleared after being retrieved because if the view has multiple viewmodels they will each need to access this separately.

        If null is returned it means that the view should be initialized from its arguments. This will only happen if this is not an "existing" view model.

        Parameters:
        forceMockExistingViewModel - If true, and if existingViewModel is true, then we expect that no mock state has been set for this viewmodel and we should instead manually retrieve the default mock state from the View and force that as the mock state to use.