### Question:
BindingAttributeResolver { public ViewResolutionResult resolve(PendingAttributesForView pendingAttributesForView) { List<ViewAttributeBinder> resolvedViewAttributes = Lists.newArrayList(); Iterable<ByBindingAttributeMappingsResolver> resolvers = byBindingAttributeMappingsResolverFinder.findCandidates( pendingAttributesForView.getView()); for (ByBindingAttributeMappingsResolver resolver : resolvers) { Collection<ViewAttributeBinder> newResolvedViewAttributes = resolver.resolve(pendingAttributesForView); resolvedViewAttributes.addAll(newResolvedViewAttributes); if (pendingAttributesForView.isEmpty()) break; } ViewResolutionErrors errors = pendingAttributesForView.getResolutionErrors(); ResolvedBindingAttributesForView resolvedBindingAttributes = new ResolvedBindingAttributesForView(pendingAttributesForView.getView(), resolvedViewAttributes); return new ViewResolutionResult(resolvedBindingAttributes, errors); } BindingAttributeResolver(ByBindingAttributeMappingsResolverFinder byBindingAttributeMappingsResolverFinder); ViewResolutionResult resolve(PendingAttributesForView pendingAttributesForView);  }### Answer:
@Test public void givenTwoCandidateResolvers_whenResolve_thenBothResolversShouldInvolveResolving() { ByBindingAttributeMappingsResolver candidateResolver1 = mock(ByBindingAttributeMappingsResolver.class); ByBindingAttributeMappingsResolver candidateResolver2 = mock(ByBindingAttributeMappingsResolver.class); when(byBindingAttributeMappingsResolverFinder.findCandidates(any(View.class))).thenReturn(newArrayList(candidateResolver1, candidateResolver2)); BindingAttributeResolver bindingAttributeResolver = new BindingAttributeResolver(byBindingAttributeMappingsResolverFinder); PendingAttributesForView pendingAttributesForView = mock(PendingAttributesForView.class); when(pendingAttributesForView.isEmpty()).thenReturn(false); bindingAttributeResolver.resolve(pendingAttributesForView); verify(candidateResolver1).resolve(pendingAttributesForView); verify(candidateResolver2).resolve(pendingAttributesForView); }
@Test public void givenTwoCandidateResolvers_whenResolveCompletedAtFirstResolver_thenSecondResolverShouldBeSkipped() { ByBindingAttributeMappingsResolver candidateResolver1 = mock(ByBindingAttributeMappingsResolver.class); ByBindingAttributeMappingsResolver candidateResolver2 = mock(ByBindingAttributeMappingsResolver.class); when(byBindingAttributeMappingsResolverFinder.findCandidates(any(View.class))).thenReturn(newArrayList(candidateResolver1, candidateResolver2)); BindingAttributeResolver bindingAttributeResolver = new BindingAttributeResolver(byBindingAttributeMappingsResolverFinder); PendingAttributesForView pendingAttributesForView = mock(PendingAttributesForView.class); when(pendingAttributesForView.isEmpty()).thenReturn(true); bindingAttributeResolver.resolve(pendingAttributesForView); verify(candidateResolver1).resolve(pendingAttributesForView); verify(candidateResolver2, never()).resolve(pendingAttributesForView); }