### Question:
BoundPropertyAnnotationReader { public static BoundProperty getBoundProperty(AnnotatedElement annotatedElement) { return findBoundProperty(annotatedElement) .orElseThrow(() -> new IllegalArgumentException( String.format("%s has no annotation that defines a %s. You can call " + BoundPropertyAnnotationReader.class.getSimpleName() + "#isBoundPropertyPresent(AnnotatedElement) to safeguard against this.", annotatedElement, BoundPropertyCreator.class.getName()))); } private  BoundPropertyAnnotationReader(); static boolean isBoundPropertyPresent(AnnotatedElement annotatedElement); static BoundProperty getBoundProperty(AnnotatedElement annotatedElement); static Optional<BoundProperty> findBoundProperty(AnnotatedElement annotatedElement); static BoundProperty getBoundProperty(A annotation,
            AnnotatedElement annotatedElement);  }### Answer:
@Test public void testGetBoundProperty_FailsIfNoBoundPropertyAnnotationPresent() throws Exception { try { BoundPropertyAnnotationReader.getBoundProperty(BoundPropertyAnnotationReaderTest.class.getField("foo")); fail("expected an " + IllegalArgumentException.class.getSimpleName()); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), containsString(BoundPropertyAnnotationReaderTest.class.getSimpleName())); assertThat(e.getMessage(), containsString("foo")); assertThat(e.getMessage(), containsString("isBoundPropertyPresent")); } }
@Test public void testGetBoundProperty_FailsWithMultipleBoundProperties() { Assertions.assertThrows(IllegalArgumentException.class, () -> { BoundPropertyAnnotationReader.getBoundProperty(ClassWithBoundPropertyAnnotations.class .getField("componentWithMultipleBoundProperties")); }); }
@Test public void testGetBoundProperty_multipleSameBoundProperties() throws Exception { BoundPropertyAnnotationReader.getBoundProperty(ClassWithBoundPropertyAnnotations.class .getField("componentWithMultipleSameBoundProperties")); }
@Test public void testGetBoundProperty_FailsIfCreatorCantBeCreated() { Assertions.assertThrows(IllegalArgumentException.class, () -> { BoundPropertyAnnotationReader.getBoundProperty(ClassWithBoundPropertyAnnotations.class .getField("componentWithUninstatiableBoundPropertyCreator")); }); }
@Test public void testGetBoundProperty_PropagatesExceptionFromCreator() { Assertions.assertThrows(IllegalStateException.class, () -> { BoundPropertyAnnotationReader.getBoundProperty(ClassWithBoundPropertyAnnotations.class .getField("componentWithDefectBoundPropertyCreator")); }); }
@Test public void testGetBoundProperty() throws Exception { BoundProperty boundProperty = BoundPropertyAnnotationReader .getBoundProperty(ClassWithBoundPropertyAnnotations.class .getField("component")); assertThat(boundProperty.getPmoProperty(), is("foo")); }