How to use getStepType method of net.serenitybdd.jbehave.SerenityStepCandidate class

Best Serenity jBehave code snippet using net.serenitybdd.jbehave.SerenityStepCandidate.getStepType

Run Serenity jBehave automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

copy
1package net.serenitybdd.jbehave;
2
3import net.serenitybdd.jbehave.reflection.Extract;
4import org.jbehave.core.configuration.Keywords;
5import org.jbehave.core.parsers.RegexPrefixCapturingPatternParser;
6import org.jbehave.core.steps.InjectableStepsFactory;
7import org.jbehave.core.steps.ParameterControls;
8import org.jbehave.core.steps.ParameterConverters;
9import org.jbehave.core.steps.Step;
10import org.jbehave.core.steps.StepCandidate;
11import org.jbehave.core.steps.StepType;
12import org.jbehave.core.steps.context.StepsContext;
13
14import java.lang.reflect.Method;
15import java.util.List;
16import java.util.Map;
17
18public class SerenityStepCandidate extends StepCandidate {
19
20    private final StepCandidate stepCandidate;
21
22    public SerenityStepCandidate(StepCandidate stepCandidate) {
23
24        super(stepCandidate.getPatternAsString(),
25                stepCandidate.getPriority(),
26                stepCandidate.getStepType(),
27                stepCandidate.getMethod(),
28                (Class<?>) Extract.field("stepsType").from(stepCandidate),
29                (InjectableStepsFactory) Extract.field("stepsFactory").from(stepCandidate),
30                new StepsContext(),
31                (Keywords) Extract.field("keywords").from(stepCandidate),
32                new RegexPrefixCapturingPatternParser(),
33                new ParameterConverters(),
34                new ParameterControls());
35        this.composedOf(stepCandidate.composedSteps());
36        this.stepCandidate = stepCandidate;
37    }
38
39    @Override
40    public Method getMethod() {
41        return stepCandidate.getMethod();
42    }
43
44    @Override
45    public Integer getPriority() {
46        return stepCandidate.getPriority();
47    }
48
49    @Override
50    public String getPatternAsString() {
51        return stepCandidate.getPatternAsString();
52    }
53
54    @Override
55    public StepType getStepType() {
56        return stepCandidate.getStepType();
57    }
58
59    @Override
60    public String getStartingWord() {
61        return stepCandidate.getStartingWord();
62    }
63
64    @Override
65    public boolean isComposite() {
66        return stepCandidate.isComposite();
67    }
68
69    @Override
70    public String[] composedSteps() {
71        return stepCandidate.composedSteps();
72    }
73
74    @Override
75    public boolean ignore(String stepAsString) {
76        return stepCandidate.ignore(stepAsString);
77    }
78
79    @Override
80    public boolean isPending() {
81        return stepCandidate.isPending();
82    }
83
84    @Override
85    public boolean matches(String stepAsString) {
86        return stepCandidate.matches(stepAsString);
87    }
88
89    @Override
90    public boolean matches(String step, String previousNonAndStep) {
91        return stepCandidate.matches(step, previousNonAndStep);
92    }
93
94    @Override
95    public Step createMatchedStep(String stepAsString, Map<String, String> namedParameters, List<Step> composedSteps) {
96        return stepCandidate.createMatchedStep(stepAsString, namedParameters, composedSteps);
97    }
98
99    @Override
100    public String toString() {
101        return stepCandidate.toString();
102    }
103}
104
Full Screen
copy
1/*
2 * Copyright 2018 Alfresco, Inc. and/or its affiliates.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *       http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.activiti.cloud.acc.shared.serenity;
18
19import java.util.Map;
20
21import net.serenitybdd.jbehave.SerenityStepCandidate;
22import org.jbehave.core.configuration.Configuration;
23import org.jbehave.core.configuration.Keywords;
24import org.jbehave.core.parsers.RegexPrefixCapturingPatternParser;
25import org.jbehave.core.parsers.StepMatcher;
26import org.jbehave.core.steps.InjectableStepsFactory;
27import org.jbehave.core.steps.Step;
28import org.jbehave.core.steps.StepCandidate;
29import org.jbehave.core.steps.StepCreator;
30
31/**
32 * Extended SerenityStepCandidate
33 */
34public class ExtendedSerenityStepCandidate extends SerenityStepCandidate {
35
36    private StepCreator stepCreator;
37
38    private Keywords keywords;
39
40    public ExtendedSerenityStepCandidate(StepCandidate stepCandidate,
41                                         Configuration configuration,
42                                         InjectableStepsFactory stepsFactory) {
43        super(stepCandidate);
44
45        keywords = configuration.keywords();
46
47        StepMatcher stepMatcher = new RegexPrefixCapturingPatternParser()
48                .parseStep(getStepType(),
49                           stepCandidate.getPatternAsString());
50        this.stepCreator = new ExtendedStepCreator(getStepsType(),
51                                                   stepsFactory,
52                                                   configuration.stepsContext(),
53                                                   configuration.parameterConverters(),
54                                                   configuration.parameterControls(),
55                                                   stepMatcher,
56                                                   configuration.stepMonitor(),
57                                                   keywords);
58    }
59
60    @Override
61    public Step createMatchedStep(String stepAsString,
62                                  Map<String, String> namedParameters) {
63
64        String stepWithoutStartingWord = keywords.stepWithoutStartingWord(stepAsString,
65                                                                          getStepType());
66        return stepCreator.createParametrisedStep(getMethod(),
67                                                  stepAsString,
68                                                  stepWithoutStartingWord,
69                                                  namedParameters);
70    }
71
72    protected StepCreator getStepCreator() {
73        return stepCreator;
74    }
75}
76
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Trigger getStepType code on LambdaTest Cloud Grid

Execute automation tests with getStepType on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)