MvvmActivity extends AppCompatActivity implements MvvmView<T, S>, ActivityDelegateCallback<T, S> { @NonNull public S getViewModel() { if (viewModel == null) { throw new IllegalStateException("You can't call getViewModel() before activity creating."); } return viewModel; }  @Override Object onRetainCustomNonConfigurationInstance(); @NonNull @Override MvvmView<T, S> getMvvmView(); @NonNull T getBinding(); @Override @CallSuper void setBinding(@NonNull T binding); @NonNull S getViewModel(); @Override @CallSuper void setViewModel(@NonNull S viewModel);  }
@Test(expected = IllegalStateException.class) public void testAvoidViewModelUsageBeforeInitialization() { activity.getViewModel(); }