Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CI for 1.44.0 bump #142

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

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;
import java.nio.file.Paths;
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;
Expand Down Expand Up @@ -105,10 +105,16 @@ public void runValidators() throws Exception {
assertTrue(result.isRight());
List<ValidationEvent> 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," +
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, there is a typo on "muliple" and a missing white space after the comma.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, that's just the message the validator produces, which lives in a jar in test resources. I don't remember where exactly it came from

"age of shape (structure: `some.test#MyStruct`).";
Optional<ValidationEvent> matchingEvent = validationEvents.stream()
.filter(ev ->ev.getMessage().equals(expectedMessage)).findFirst();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think you could a hamcrest matcher (or orElseThrow) to make this a little cleaner

assertThat(validationEvents, hasItem(hasProperty("message", equals(expectedMessage)))

or

.orElseThrow(() -> new AssertionError(...))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would if we used hamcrest in the language server. Will be adding it in the future though.


if (!matchingEvent.isPresent()) {
throw new AssertionError("Expected validation event with message `" + expectedMessage
+ "`, but events were " + validationEvents);
}
}

private static List<File> getFiles(String... filenames) throws Exception {
Expand Down
Loading