use of io.cucumber.messages.types.Envelope in project cucumber-jvm by cucumber.
the class TestStep method emitTestStepFinished.
private void emitTestStepFinished(TestCase testCase, EventBus bus, UUID textExecutionId, Instant stopTime, Duration duration, Result result) {
bus.send(new TestStepFinished(stopTime, testCase, this, result));
TestStepResult testStepResult = new TestStepResult();
if (result.getError() != null) {
testStepResult.setMessage(extractStackTrace(result.getError()));
}
testStepResult.setStatus(from(result.getStatus()));
testStepResult.setDuration(javaDurationToDuration(duration));
Envelope envelope = new Envelope();
envelope.setTestStepFinished(new io.cucumber.messages.types.TestStepFinished(textExecutionId.toString(), id.toString(), testStepResult, javaInstantToTimestamp(stopTime)));
bus.send(envelope);
}
use of io.cucumber.messages.types.Envelope in project cucumber-jvm by cucumber.
the class CachingGlue method emitStepDefined.
private void emitStepDefined(CoreStepDefinition coreStepDefinition) {
bus.send(new StepDefinedEvent(bus.getInstant(), new io.cucumber.plugin.event.StepDefinition(coreStepDefinition.getStepDefinition().getLocation(), coreStepDefinition.getExpression().getSource())));
io.cucumber.messages.types.StepDefinition messagesStepDefinition = new io.cucumber.messages.types.StepDefinition();
messagesStepDefinition.setId(coreStepDefinition.getId().toString());
messagesStepDefinition.setPattern(new StepDefinitionPattern(coreStepDefinition.getExpression().getSource(), getExpressionType(coreStepDefinition)));
coreStepDefinition.getDefinitionLocation().ifPresent(reference -> messagesStepDefinition.setSourceReference(createSourceReference(reference)));
Envelope envelope = new Envelope();
envelope.setStepDefinition(messagesStepDefinition);
bus.send(envelope);
}
use of io.cucumber.messages.types.Envelope in project cucumber-jvm by cucumber.
the class CachingGlue method emitParameterTypeDefined.
private void emitParameterTypeDefined(ParameterType<?> parameterType) {
io.cucumber.messages.types.ParameterType messagesParameterType = new io.cucumber.messages.types.ParameterType();
messagesParameterType.setId(bus.generateId().toString());
messagesParameterType.setName(parameterType.getName());
messagesParameterType.setRegularExpressions(parameterType.getRegexps());
messagesParameterType.setPreferForRegularExpressionMatch(parameterType.preferForRegexpMatch());
messagesParameterType.setUseForSnippets(parameterType.useForSnippets());
Envelope envelope = new Envelope();
envelope.setParameterType(messagesParameterType);
bus.send(envelope);
}
use of io.cucumber.messages.types.Envelope in project cucumber-jvm by cucumber.
the class TestSourcesModel method parseGherkinSource.
private void parseGherkinSource(URI path) {
if (!pathToReadEventMap.containsKey(path)) {
return;
}
String source = pathToReadEventMap.get(path).getSource();
List<Envelope> sources = singletonList(makeSourceEnvelope(source, path.toString()));
List<Envelope> envelopes = Gherkin.fromSources(sources, true, true, true, () -> String.valueOf(UUID.randomUUID())).collect(toList());
GherkinDocument gherkinDocument = envelopes.stream().map(Envelope::getGherkinDocument).filter(Objects::nonNull).findFirst().orElse(null);
pathToAstMap.put(path, gherkinDocument);
Map<Long, AstNode> nodeMap = new HashMap<>();
AstNode currentParent = new AstNode(gherkinDocument.getFeature(), null);
for (FeatureChild child : gherkinDocument.getFeature().getChildren()) {
processFeatureDefinition(nodeMap, child, currentParent);
}
pathToNodeMap.put(path, nodeMap);
}
use of io.cucumber.messages.types.Envelope in project cucumber-jvm by cucumber.
the class TestCaseState method createEnvelope.
private Envelope createEnvelope(Attachment attachment) {
Envelope envelope = new Envelope();
envelope.setAttachment(attachment);
return envelope;
}
Aggregations