DelayedMockspressoBuilder extends AbstractDelayedMockspresso implements Mockspresso.Builder { void setParent(@Nullable MockspressoConfigContainer parentConfig) { if (parentConfig == null) { setDelegate(null); } else { MockspressoBuilderImpl builder = mBuilder.deepCopy(); builder.setParent(parentConfig); setDelegate(builder.buildInternal()); } } DelayedMockspressoBuilder(Provider<MockspressoBuilderImpl> builderProvider); @NotNull @Override Builder plugin(@NotNull MockspressoPlugin plugin); @NotNull @Override Builder outerRule(@NotNull TestRule testRule); @NotNull @Override Builder outerRule(@NotNull MethodRule methodRule); @NotNull @Override Builder innerRule(@NotNull TestRule testRule); @NotNull @Override Builder innerRule(@NotNull MethodRule methodRule); @NotNull @Override Builder testResources(@NotNull Object objectWithResources); @NotNull @Override Builder testResourcesWithoutLifecycle(@NotNull Object objectWithResources); @NotNull @Override Builder mocker(@NotNull MockerConfig mockerConfig); @NotNull @Override Builder injector(@NotNull InjectionConfig injectionConfig); @NotNull @Override Builder specialObjectMaker(@NotNull SpecialObjectMaker specialObjectMaker); @NotNull @Override Builder dependency(@NotNull Class<T> clazz, V value); @NotNull @Override Builder dependency(@NotNull TypeToken<T> typeToken, V value); @NotNull @Override Builder dependency(@NotNull DependencyKey<T> key, V value); @NotNull @Override Builder dependencyProvider(@NotNull Class<T> clazz, @NotNull ObjectProvider<V> value); @NotNull @Override Builder dependencyProvider(@NotNull TypeToken<T> typeToken, @NotNull ObjectProvider<V> value); @NotNull @Override Builder dependencyProvider(@NotNull DependencyKey<T> key, @NotNull ObjectProvider<V> value); @NotNull @Override Builder realObject(@NotNull Class<T> objectClass); @NotNull @Override Builder realObject(@NotNull TypeToken<T> objectToken); @NotNull @Override Builder realObject(@NotNull DependencyKey<T> keyAndImplementation); @NotNull @Override Builder realObject(@NotNull DependencyKey<T> key, @NotNull Class<? extends T> implementationClass); @NotNull @Override Builder realObject(@NotNull DependencyKey<T> key, @NotNull TypeToken<? extends T> implementationToken); @NotNull @Override Mockspresso build(); @NotNull @Override Rule buildRule();  }
@Test public void testSetupAndTearDown() { mDelayedBuilder.setParent(mConfig); mDelayedBuilder.setParent(null); InOrder inOrder = Mockito.inOrder(mBackingBuilder, mConfig, mChildConfig); inOrder.verify(mBackingBuilder).deepCopy(); inOrder.verify(mBackingBuilder).setParent(mConfig); inOrder.verify(mBackingBuilder).buildInternal(); inOrder.verify(mChildConfig).setup(mChildMockspresso); inOrder.verify(mChildConfig).teardown(); verifyNoMoreInteractions(mBackingBuilder, mConfig, mChildConfig); }