diff --git a/javatests/dagger/internal/codegen/DaggerSuperficialValidationTest.java b/javatests/dagger/internal/codegen/DaggerSuperficialValidationTest.java index 7092047a856..94db789822e 100644 --- a/javatests/dagger/internal/codegen/DaggerSuperficialValidationTest.java +++ b/javatests/dagger/internal/codegen/DaggerSuperficialValidationTest.java @@ -467,18 +467,17 @@ public void invalidAnnotationValue() { () -> superficialValidation.validateElement(testClassElement)); // TODO(b/248552462): Javac and KSP should match once this bug is fixed. boolean isJavac = processingEnv.getBackend() == XProcessingEnv.Backend.JAVAC; - assertThat(exception) - .hasMessageThat() - .contains( - String.format( - NEW_LINES.join( - "Validation trace:", - " => element (CLASS): test.Outer.TestClass", - " => annotation type: test.Outer.TestAnnotation", - " => annotation: @test.Outer.TestAnnotation(classes={<%1$s>})", - " => annotation value (TYPE_ARRAY): classes={<%1$s>}", - " => annotation value (TYPE): classes=<%1$s>"), - isJavac ? "error" : "Error")); + String expectedMessage = + String.format( + NEW_LINES.join( + "Validation trace:", + " => element (CLASS): test.Outer.TestClass", + " => annotation type: test.Outer.TestAnnotation", + " => annotation: @test.Outer.TestAnnotation(classes={<%1$s>})", + " => annotation value (TYPE_ARRAY): classes={<%1$s>}", + " => annotation value (TYPE): classes=<%1$s>"), + isJavac ? "error" : "Error"); + assertThat(exception).hasMessageThat().contains(expectedMessage); }); } @@ -527,20 +526,19 @@ public void invalidAnnotationValueOnParameter() { () -> superficialValidation.validateElement(parameter)); // TODO(b/248552462): Javac and KSP should match once this bug is fixed. boolean isJavac = processingEnv.getBackend() == XProcessingEnv.Backend.JAVAC; - assertThat(exception) - .hasMessageThat() - .contains( - String.format( - NEW_LINES.join( - "Validation trace:", - " => element (CLASS): test.Outer.TestClass", - " => element (CONSTRUCTOR): TestClass(java.lang.String)", - " => element (PARAMETER): strParam", - " => annotation type: test.Outer.TestAnnotation", - " => annotation: @test.Outer.TestAnnotation(classes={<%1$s>})", - " => annotation value (TYPE_ARRAY): classes={<%1$s>}", - " => annotation value (TYPE): classes=<%1$s>"), - isJavac ? "error" : "Error")); + String expectedMessage = + String.format( + NEW_LINES.join( + "Validation trace:", + " => element (CLASS): test.Outer.TestClass", + " => element (CONSTRUCTOR): TestClass(java.lang.String)", + " => element (PARAMETER): strParam", + " => annotation type: test.Outer.TestAnnotation", + " => annotation: @test.Outer.TestAnnotation(classes={<%1$s>})", + " => annotation value (TYPE_ARRAY): classes={<%1$s>}", + " => annotation value (TYPE): classes=<%1$s>"), + isJavac ? "error" : "Error"); + assertThat(exception).hasMessageThat().contains(expectedMessage); }); }