diff --git a/src/test/java/software/amazon/smithy/lsp/SmithyInterfaceTest.java b/src/test/java/software/amazon/smithy/lsp/SmithyInterfaceTest.java index 9db0e0d3..77fd2945 100644 --- a/src/test/java/software/amazon/smithy/lsp/SmithyInterfaceTest.java +++ b/src/test/java/software/amazon/smithy/lsp/SmithyInterfaceTest.java @@ -17,7 +17,6 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertEquals; import java.io.File; import java.nio.file.Path; @@ -25,6 +24,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; import org.eclipse.lsp4j.jsonrpc.messages.Either; import org.junit.Test; @@ -105,10 +105,16 @@ public void runValidators() throws Exception { assertTrue(result.isRight()); List validationEvents = result.getRight().getValidationEvents(); assertFalse(validationEvents.isEmpty()); - assertEquals( - "Proto index 1 is used muliple times in members name,age of shape (structure: `some.test#MyStruct`).", - validationEvents.get(0).getMessage() - ); + + String expectedMessage = "Proto index 1 is used muliple times in members name," + + "age of shape (structure: `some.test#MyStruct`)."; + Optional matchingEvent = validationEvents.stream() + .filter(ev ->ev.getMessage().equals(expectedMessage)).findFirst(); + + if (!matchingEvent.isPresent()) { + throw new AssertionError("Expected validation event with message `" + expectedMessage + + "`, but events were " + validationEvents); + } } private static List getFiles(String... filenames) throws Exception {