### Question:
OwnerFieldClass { public ExecutableElement getSetter(String propertyName) throws UnableToCompleteException { if (ambiguousSetters != null && ambiguousSetters.contains(propertyName)) { logger.die( "Ambiguous setter requested: " + AptUtil.asQualifiedNameable(rawType).getQualifiedName() .toString() + "." + propertyName); } return setters.get(propertyName); } OwnerFieldClass(TypeMirror forType, MortalLogger logger, UiBinderContext context); static OwnerFieldClass getFieldClass(TypeMirror forType, MortalLogger logger,
      UiBinderContext context); TypeMirror getRawType(); ExecutableElement getSetter(String propertyName); Map<String, SimpleEntry<ExecutableElement, Integer>> getUiChildMethods(); ExecutableElement getUiConstructor();  }### Answer:
@Test public void nonAmbiguousSetter(Elements elements) throws Exception { TypeElement typeElement = elements.getTypeElement(AmbiguousSetterExample.class.getName()); OwnerFieldClass cut = new OwnerFieldClass(typeElement.asType(), mockLogger, mockContext); ExecutableElement setter = cut.getSetter("text"); assertNotNull(setter); verifyNoMoreInteractions(mockLogger, mockContext); }
@Test public void ambiguousSetter(Elements elements) throws Exception { TypeElement typeElement = elements.getTypeElement(AmbiguousSetterExample.class.getName()); OwnerFieldClass cut = new OwnerFieldClass(typeElement.asType(), mockLogger, mockContext); ExecutableElement setter = cut.getSetter("number"); assertNull(setter); ArgumentCaptor<String> messageCaptor = ArgumentCaptor.forClass(String.class); verify(mockLogger) .die(messageCaptor.capture()); assertTrue(messageCaptor.getValue().startsWith("Ambiguous setter")); verifyNoMoreInteractions(mockLogger, mockContext); }
@Test public void nonAmbiguousSetterInParentChild(Elements elements) throws Exception { TypeElement typeElement = elements.getTypeElement(ChildClass.class.getName()); OwnerFieldClass cut = new OwnerFieldClass(typeElement.asType(), mockLogger, mockContext); ExecutableElement setter = cut.getSetter("text"); assertNotNull(setter); verifyNoMoreInteractions(mockLogger, mockContext); }
@Test public void ambiguousSetterInParentChild(Elements elements) throws Exception { TypeElement typeElement = elements.getTypeElement(ChildClass.class.getName()); OwnerFieldClass cut = new OwnerFieldClass(typeElement.asType(), mockLogger, mockContext); ExecutableElement setter = cut.getSetter("number"); assertNull(setter); ArgumentCaptor<String> messageCaptor = ArgumentCaptor.forClass(String.class); verify(mockLogger) .die(messageCaptor.capture()); assertTrue(messageCaptor.getValue().startsWith("Ambiguous setter")); verifyNoMoreInteractions(mockLogger, mockContext); }
@Test public void nonAmbiguousGenericsSetter(Elements elements) throws Exception { TypeElement typeElement = elements.getTypeElement(ChildClass.class.getName()); OwnerFieldClass cut = new OwnerFieldClass(typeElement.asType(), mockLogger, mockContext); ExecutableElement setter = cut.getSetter("data"); assertNotNull(setter); verifyNoMoreInteractions(mockLogger, mockContext); }