use of io.cucumber.plugin.event.Location in project cucumber-jvm by cucumber.
the class Runner method emitSnippetSuggestedEvent.
private void emitSnippetSuggestedEvent(Pickle pickle, Step step) {
List<String> snippets = generateSnippetsForStep(step);
if (snippets.isEmpty()) {
return;
}
Suggestion suggestion = new Suggestion(step.getText(), snippets);
Location scenarioLocation = pickle.getLocation();
Location stepLocation = step.getLocation();
SnippetsSuggestedEvent event = new SnippetsSuggestedEvent(bus.getInstant(), pickle.getUri(), scenarioLocation, stepLocation, suggestion);
bus.send(event);
}
use of io.cucumber.plugin.event.Location in project cucumber-jvm by cucumber.
the class PickleOrderTest method reverse_lexical_uri_order.
@Test
void reverse_lexical_uri_order() {
when(firstPickle.getUri()).thenReturn(URI.create("file:com/example/a.feature"));
when(firstPickle.getLocation()).thenReturn(new Location(2, -1));
when(secondPickle.getUri()).thenReturn(URI.create("file:com/example/a.feature"));
when(secondPickle.getLocation()).thenReturn(new Location(3, -1));
when(thirdPickle.getUri()).thenReturn(URI.create("file:com/example/b.feature"));
PickleOrder order = StandardPickleOrders.reverseLexicalUriOrder();
List<Pickle> pickles = order.orderPickles(Arrays.asList(secondPickle, thirdPickle, firstPickle));
assertThat(pickles, contains(thirdPickle, secondPickle, firstPickle));
}
use of io.cucumber.plugin.event.Location in project cucumber-jvm by cucumber.
the class PickleOrderTest method lexical_uri_order.
@Test
void lexical_uri_order() {
when(firstPickle.getUri()).thenReturn(URI.create("file:com/example/a.feature"));
when(firstPickle.getLocation()).thenReturn(new Location(2, -1));
when(secondPickle.getUri()).thenReturn(URI.create("file:com/example/a.feature"));
when(secondPickle.getLocation()).thenReturn(new Location(3, -1));
when(thirdPickle.getUri()).thenReturn(URI.create("file:com/example/b.feature"));
PickleOrder order = StandardPickleOrders.lexicalUriOrder();
List<Pickle> pickles = order.orderPickles(Arrays.asList(thirdPickle, secondPickle, firstPickle));
assertThat(pickles, contains(firstPickle, secondPickle, thirdPickle));
}
use of io.cucumber.plugin.event.Location in project cucumber-jvm by cucumber.
the class TeamCityPlugin method getSnippets.
private String getSnippets(TestCase testCase) {
URI uri = testCase.getUri();
Location location = testCase.getLocation();
List<Suggestion> suggestionForTestCase = suggestions.stream().filter(suggestion -> suggestion.getUri().equals(uri) && suggestion.getTestCaseLocation().equals(location)).map(SnippetsSuggestedEvent::getSuggestion).collect(Collectors.toList());
return createMessage(suggestionForTestCase);
}
use of io.cucumber.plugin.event.Location in project cucumber-jvm by cucumber.
the class TimelineFormatter method findRootNodeName.
private String findRootNodeName(TestCase testCase) {
Location location = testCase.getLocation();
Predicate<Node> withLocation = candidate -> candidate.getLocation().equals(location);
return parsedTestSources.get(testCase.getUri()).stream().map(node -> node.findPathTo(withLocation)).filter(Optional::isPresent).map(Optional::get).findFirst().map(nodes -> nodes.get(0)).flatMap(Node::getName).orElse("Unknown");
}
Aggregations