ResourceLifecycleFieldManager implements ResourcesLifecycleComponent { @Override public void setup(Mockspresso mockspresso) { for (TestResource resource : mTestResources) { Object o = resource.getObjectWithResources(); mFieldImporter.importAnnotatedFields(o); mRealObjectFieldTracker.scanNullRealObjectFields(o); } Set<DependencyKey> intersectionSet = new HashSet<>(mDependencyMap.keySet()); intersectionSet.retainAll(mRealObjectMapping.keySet()); if (!intersectionSet.isEmpty()) { throw new RepeatedDependencyDefinedException(intersectionSet.iterator().next()); } mRealObjectFieldTracker.applyValuesToFields(); } ResourceLifecycleFieldManager(
      Collection<TestResource> testResources,
      DependencyMap dependencyMap,
      RealObjectMapping realObjectMapping, FieldImporter fieldImporter,
      RealObjectFieldTracker realObjectFieldTracker); @Override void setup(Mockspresso mockspresso); @Override void teardown();  }
@Test public void testSetup() { mResourceLifecycleFieldManager.setup(mMockspresso); InOrder inOrder = Mockito.inOrder(mDependencyMap, mRealObjectMapping, mFieldImporter, mRealObjectFieldTracker); for (TestResource resource : mTestResources) { inOrder.verify(mFieldImporter).importAnnotatedFields(resource.getObjectWithResources()); inOrder.verify(mRealObjectFieldTracker).scanNullRealObjectFields(resource.getObjectWithResources()); } inOrder.verify(mDependencyMap).keySet(); inOrder.verify(mRealObjectMapping).keySet(); inOrder.verify(mRealObjectFieldTracker).applyValuesToFields(); verifyNoMoreInteractions(mDependencyMap, mRealObjectMapping, mFieldImporter, mRealObjectFieldTracker); }
@Test(expected = RepeatedDependencyDefinedException.class) public void testRepeatedDependencyBetweenDepAndRealObjMapping() { Set<DependencyKey> dependencyMapKeys = new HashSet<>(); dependencyMapKeys.add(DependencyKey.of(String.class)); Set<DependencyKey> realObjectMapKeys = new HashSet<>(); realObjectMapKeys.add(DependencyKey.of(String.class)); when(mDependencyMap.keySet()).thenReturn(dependencyMapKeys); when(mRealObjectMapping.keySet()).thenReturn(realObjectMapKeys); mResourceLifecycleFieldManager.setup(mMockspresso); }