  @Test
  public void annotateStatement() {

    testHelper.getPsiClass(
        psiClasses -> {
          assertEquals(2, psiClasses.size());

          PsiClass underTest = psiClasses.get(0);
          PsiClass component = psiClasses.get(1);

          // For testing environment
          Function<PsiMethodCallExpression, PsiClass> resolver =
              psiMethodCallExpression -> component;
          RequiredPropAnnotator annotator = new RequiredPropAnnotator(resolver);
          TestHolder holder = new TestHolder();
          Collection<PsiStatement> statements =
              PsiTreeUtil.findChildrenOfAnyType(underTest, PsiStatement.class);
          // Simulates IDE behavior of traversing Psi elements
          for (PsiStatement statement : statements) {
            annotator.annotate(statement, holder);
          }

          assertEquals(3, holder.errorMessages.size());
          for (String errorMessage : holder.errorMessages) {
            assertEquals(
                "The following props are not "
                    + "marked as optional and were not supplied: testRequiredPropName",
                errorMessage);
          }
          assertEquals(3, holder.errorElements.size());
          for (PsiElement errorElement : holder.errorElements) {
            assertEquals("RequiredPropAnnotatorComponent.create", errorElement.getText());
          }
          return true;
        },
        "RequiredPropAnnotatorTest.java",
        "RequiredPropAnnotatorComponent.java");
  }