本文整理汇总了Java中org.jbehave.core.model.Meta类的典型用法代码示例。如果您正苦于以下问题:Java Meta类的具体用法?Java Meta怎么用?Java Meta使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Meta类属于org.jbehave.core.model包,在下文中一共展示了Meta类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runScenariosParametrisedByExamples
import org.jbehave.core.model.Meta; //导入依赖的package包/类
private void runScenariosParametrisedByExamples(RunContext context, Scenario scenario, Meta storyAndScenarioMeta)
throws Throwable {
ExamplesTable table = scenario.getExamplesTable();
reporter.get().beforeExamples(scenario.getSteps(), table);
Keywords keywords = context.configuration().keywords();
for (Map<String, String> scenarioParameters : table.getRows()) {
Meta parameterMeta = parameterMeta(keywords, scenarioParameters);
if ( !parameterMeta.isEmpty() && !context.filter.allow(parameterMeta) ){
continue;
}
reporter.get().example(scenarioParameters);
if (context.configuration().storyControls().resetStateBeforeScenario()) {
context.resetState();
}
runBeforeOrAfterScenarioSteps(context, scenario, storyAndScenarioMeta, Stage.BEFORE, ScenarioType.EXAMPLE);
addMetaParameters(scenarioParameters, storyAndScenarioMeta);
runGivenStories(scenario.getGivenStories(), scenarioParameters, context);
runScenarioSteps(context, scenario, scenarioParameters);
runBeforeOrAfterScenarioSteps(context, scenario, storyAndScenarioMeta, Stage.AFTER, ScenarioType.EXAMPLE);
}
reporter.get().afterExamples();
}
示例2: map
import org.jbehave.core.model.Meta; //导入依赖的package包/类
/**
* Maps a story if it is allowed by the meta filter
*
* @param story
* the Story
* @param metaFilter
* the meta filter
*/
public void map(Story story, MetaFilter metaFilter) {
if (metaFilter.allow(story.getMeta())) {
boolean allowed = false;
for (Scenario scenario : story.getScenarios()) {
// scenario also inherits meta from story
Meta inherited = scenario.getMeta().inheritFrom(story.getMeta());
if (metaFilter.allow(inherited)) {
allowed = true;
break;
}
}
if (allowed) {
add(metaFilter.asString(), story);
}
}
}
示例3: match
import org.jbehave.core.model.Meta; //导入依赖的package包/类
private boolean match(Properties properties, Meta meta) {
boolean matches = false;
for (Object key : properties.keySet()) {
String property = (String) properties.get(key);
for (String metaName : meta.getPropertyNames()) {
if (key.equals(metaName)) {
String value = meta.getProperty(metaName);
if (StringUtils.isBlank(value)) {
matches = true;
} else if (property.contains("*")) {
matches = value.matches(property.replace("*", ".*"));
} else {
matches = properties.get(key).equals(value);
}
}
if (matches) {
break;
}
}
}
return matches;
}
示例4: parseScenario
import org.jbehave.core.model.Meta; //导入依赖的package包/类
private Scenario parseScenario(String scenarioAsText) {
String title = findScenarioTitle(scenarioAsText);
String scenarioWithoutKeyword = removeStart(scenarioAsText, keywords.scenario()).trim();
String scenarioWithoutTitle = removeStart(scenarioWithoutKeyword, title);
if ( !scenarioWithoutTitle.startsWith("\n") ){ // always ensure scenario starts with newline
scenarioWithoutTitle = "\n" + scenarioWithoutTitle;
}
Meta meta = findScenarioMeta(scenarioWithoutTitle);
ExamplesTable examplesTable = findExamplesTable(scenarioWithoutTitle);
GivenStories givenStories = findScenarioGivenStories(scenarioWithoutTitle);
if (givenStories.requireParameters()) {
givenStories.useExamplesTable(examplesTable);
}
List<String> steps = findSteps(scenarioWithoutTitle);
return new Scenario(title, meta, givenStories, examplesTable, steps);
}
示例5: shouldHandleTargetInvocationFailureInBeforeOrAfterStep
import org.jbehave.core.model.Meta; //导入依赖的package包/类
@Test
public void shouldHandleTargetInvocationFailureInBeforeOrAfterStep() throws IntrospectionException {
// Given
SomeSteps stepsInstance = new SomeSteps();
MostUsefulConfiguration configuration = new MostUsefulConfiguration();
InjectableStepsFactory stepsFactory = new InstanceStepsFactory(configuration, stepsInstance);
StepCreator stepCreator = new StepCreator(stepsInstance.getClass(), stepsFactory,
configuration.parameterConverters(), new ParameterControls(), null, new SilentStepMonitor());
// When
Method method = SomeSteps.methodFor("aFailingBeforeScenarioMethod");
StepResult stepResult = stepCreator.createBeforeOrAfterStep(method, Meta.EMPTY).perform(null);
// Then
assertThat(stepResult, instanceOf(Failed.class));
assertThat(stepResult.getFailure(), instanceOf(UUIDExceptionWrapper.class));
Throwable cause = stepResult.getFailure().getCause();
assertThat(cause, instanceOf(BeforeOrAfterFailed.class));
assertThat(
cause.getMessage(),
org.hamcrest.Matchers
.equalTo("Method aFailingBeforeScenarioMethod (annotated with @BeforeScenario in class org.jbehave.core.steps.SomeSteps) failed: java.lang.RuntimeException"));
}
示例6: shouldInvokeBeforeOrAfterStepMethodWithExpectedParametersFromMeta
import org.jbehave.core.model.Meta; //导入依赖的package包/类
@Test
public void shouldInvokeBeforeOrAfterStepMethodWithExpectedParametersFromMeta() throws Exception {
// Given
SomeSteps stepsInstance = new SomeSteps();
StepCreator stepCreator = stepCreatorUsing(stepsInstance, mock(StepMatcher.class), new ParameterControls());
Properties properties = new Properties();
properties.put("theme", "shopping cart");
properties.put("variant", "book");
// When
Step stepWithMeta = stepCreator.createBeforeOrAfterStep(SomeSteps.methodFor("aMethodWithANamedParameter"),
new Meta(properties));
StepResult stepResult = stepWithMeta.perform(null);
// Then
assertThat(stepResult, instanceOf(Skipped.class));
assertThat(stepsInstance.args, instanceOf(Map.class));
@SuppressWarnings("unchecked")
Map<String, String> methodArgs = (Map<String, String>) stepsInstance.args;
assertThat(methodArgs.get("variant"), is("book"));
assertThat(methodArgs.get("theme"), is("shopping cart"));
}
示例7: shouldInvokeBeforeOrAfterStepMethodWithMetaUsingParanamer
import org.jbehave.core.model.Meta; //导入依赖的package包/类
@Test
public void shouldInvokeBeforeOrAfterStepMethodWithMetaUsingParanamer() throws Exception {
// Given
SomeSteps stepsInstance = new SomeSteps();
StepCreator stepCreator = stepCreatorUsing(stepsInstance, mock(StepMatcher.class), new ParameterControls());
stepCreator.useParanamer(new CachingParanamer(new BytecodeReadingParanamer()));
Properties properties = new Properties();
properties.put("theme", "shopping cart");
// When
Step stepWithMeta = stepCreator.createBeforeOrAfterStep(SomeSteps.methodFor("aMethodWithoutNamedAnnotation"),
new Meta(properties));
StepResult stepResult = stepWithMeta.perform(null);
// Then
assertThat(stepResult, instanceOf(Skipped.class));
assertThat((String) stepsInstance.args, is("shopping cart"));
}
示例8: shouldInvokeAfterStepUponAnyOutcomeMethodWithExpectedParametersFromMeta
import org.jbehave.core.model.Meta; //导入依赖的package包/类
@Test
public void shouldInvokeAfterStepUponAnyOutcomeMethodWithExpectedParametersFromMeta() throws Exception {
// Given
SomeSteps stepsInstance = new SomeSteps();
StepCreator stepCreator = stepCreatorUsing(stepsInstance, mock(StepMatcher.class), new ParameterControls());
Properties properties = new Properties();
properties.put("theme", "shopping cart");
properties.put("variant", "book");
// When
Step stepWithMeta = stepCreator.createAfterStepUponOutcome(SomeSteps.methodFor("aMethodWithANamedParameter"),
AfterScenario.Outcome.ANY, new Meta(properties));
StepResult stepResult = stepWithMeta.perform(null);
// Then
assertThat(stepResult, instanceOf(Skipped.class));
assertThat(stepsInstance.args, instanceOf(Map.class));
@SuppressWarnings("unchecked")
Map<String, String> methodArgs = (Map<String, String>) stepsInstance.args;
assertThat(methodArgs.get("variant"), is("book"));
assertThat(methodArgs.get("theme"), is("shopping cart"));
}
示例9: shouldInvokeAfterStepUponSuccessOutcomeMethodIfNoFailureOccurred
import org.jbehave.core.model.Meta; //导入依赖的package包/类
@Test
public void shouldInvokeAfterStepUponSuccessOutcomeMethodIfNoFailureOccurred() throws Exception {
// Given
SomeSteps stepsInstance = new SomeSteps();
StepCreator stepCreator = stepCreatorUsing(stepsInstance, mock(StepMatcher.class), new ParameterControls());
Properties properties = new Properties();
properties.put("theme", "shopping cart");
properties.put("variant", "book");
// When
Step stepWithMeta = stepCreator.createAfterStepUponOutcome(SomeSteps.methodFor("aMethodWithANamedParameter"),
AfterScenario.Outcome.SUCCESS, new Meta(properties));
StepResult stepResult = stepWithMeta.perform(null);
// Then
assertThat(stepResult, instanceOf(Skipped.class));
assertThat(stepsInstance.args, instanceOf(Map.class));
@SuppressWarnings("unchecked")
Map<String, String> methodArgs = (Map<String, String>) stepsInstance.args;
assertThat(methodArgs.get("variant"), is("book"));
assertThat(methodArgs.get("theme"), is("shopping cart"));
}
示例10: shouldInvokeAfterStepUponFailureOutcomeMethodIfFailureOccurred
import org.jbehave.core.model.Meta; //导入依赖的package包/类
@Test
public void shouldInvokeAfterStepUponFailureOutcomeMethodIfFailureOccurred() throws Exception {
// Given
SomeSteps stepsInstance = new SomeSteps();
StepCreator stepCreator = stepCreatorUsing(stepsInstance, mock(StepMatcher.class), new ParameterControls());
Properties properties = new Properties();
properties.put("theme", "shopping cart");
properties.put("variant", "book");
// When
Step stepWithMeta = stepCreator.createAfterStepUponOutcome(SomeSteps.methodFor("aMethodWithANamedParameter"),
AfterScenario.Outcome.FAILURE, new Meta(properties));
StepResult stepResult = stepWithMeta.doNotPerform(null);
// Then
assertThat(stepResult, instanceOf(Skipped.class));
assertThat(stepsInstance.args, instanceOf(Map.class));
@SuppressWarnings("unchecked")
Map<String, String> methodArgs = (Map<String, String>) stepsInstance.args;
assertThat(methodArgs.get("variant"), is("book"));
assertThat(methodArgs.get("theme"), is("shopping cart"));
}
示例11: shouldInvokeBeforeOrAfterStepMethodWithExpectedConvertedParametersFromMeta
import org.jbehave.core.model.Meta; //导入依赖的package包/类
@Test
public void shouldInvokeBeforeOrAfterStepMethodWithExpectedConvertedParametersFromMeta() throws Exception {
// Given
SomeSteps stepsInstance = new SomeSteps();
StepCreator stepCreator = stepCreatorUsing(stepsInstance, mock(StepMatcher.class), new ParameterControls());
stepCreator.useParanamer(new CachingParanamer(new BytecodeReadingParanamer()));
// When
Date aDate = new Date();
when(parameterConverters.convert(anyString(), eq(Date.class))).thenReturn(aDate);
Step stepWithMeta = stepCreator.createBeforeOrAfterStep(SomeSteps.methodFor("aMethodWithDate"), new Meta());
StepResult stepResult = stepWithMeta.perform(null);
// Then
assertThat(stepResult, instanceOf(Skipped.class));
assertThat((Date) stepsInstance.args, is(aDate));
}
示例12: shouldInjectExceptionThatHappenedIfTargetMethodExpectsIt
import org.jbehave.core.model.Meta; //导入依赖的package包/类
@Test
public void shouldInjectExceptionThatHappenedIfTargetMethodExpectsIt() throws Exception {
// Given
SomeSteps stepsInstance = new SomeSteps();
parameterConverters = new ParameterConverters();
StepCreator stepCreator = stepCreatorUsing(stepsInstance, mock(StepMatcher.class), new ParameterControls());
// When
Step stepWithMeta = stepCreator.createBeforeOrAfterStep(
SomeSteps.methodFor("aMethodThatExpectsUUIDExceptionWrapper"), mock(Meta.class));
UUIDExceptionWrapper occurredFailure = new UUIDExceptionWrapper();
StepResult stepResult = stepWithMeta.perform(occurredFailure);
// Then
assertThat(stepResult, instanceOf(Skipped.class));
assertThat((UUIDExceptionWrapper) stepsInstance.args, is(occurredFailure));
}
示例13: shouldInjectNoFailureIfNoExceptionHappenedAndTargetMethodExpectsIt
import org.jbehave.core.model.Meta; //导入依赖的package包/类
@Test
public void shouldInjectNoFailureIfNoExceptionHappenedAndTargetMethodExpectsIt() throws Exception {
// Given
SomeSteps stepsInstance = new SomeSteps();
parameterConverters = new ParameterConverters();
StepCreator stepCreator = stepCreatorUsing(stepsInstance, mock(StepMatcher.class), new ParameterControls());
// When
Step stepWithMeta = stepCreator.createBeforeOrAfterStep(
SomeSteps.methodFor("aMethodThatExpectsUUIDExceptionWrapper"), mock(Meta.class));
UUIDExceptionWrapper occurredFailure = new UUIDExceptionWrapper();
StepResult stepResult = stepWithMeta.perform(occurredFailure);
// Then
assertThat(stepResult, instanceOf(Skipped.class));
assertThat((UUIDExceptionWrapper) stepsInstance.args, is(occurredFailure));
}
示例14: shouldProvideStepsToBePerformedBeforeAndAfterScenariosWithFailureOccuring
import org.jbehave.core.model.Meta; //导入依赖的package包/类
@Test
public void shouldProvideStepsToBePerformedBeforeAndAfterScenariosWithFailureOccuring() {
MultipleAliasesSteps steps = new MultipleAliasesSteps();
ScenarioType scenarioType = ScenarioType.NORMAL;
List<BeforeOrAfterStep> beforeAfterScenario = steps.listBeforeOrAfterScenario(scenarioType);
assertThat(beforeAfterScenario.size(), equalTo(4));
beforeAfterScenario.get(0).createStep().perform(null);
assertThat(steps.beforeScenario, is(true));
Meta storyAndScenarioMeta = null;
// uponOutcome=ANY
beforeAfterScenario.get(1).createStepUponOutcome(storyAndScenarioMeta).perform(null);
assertThat(steps.afterAnyScenario, is(true));
// uponOutcome=SUCCESS
beforeAfterScenario.get(2).createStepUponOutcome(storyAndScenarioMeta).doNotPerform(null);
assertThat(steps.afterSuccessfulScenario, is(false));
// uponOutcome=FAILURE
beforeAfterScenario.get(3).createStepUponOutcome(storyAndScenarioMeta).doNotPerform(null);
assertThat(steps.afterFailedScenario, is(true));
}
示例15: shouldProvideStepsToBePerformedBeforeAndAfterScenariosWithNoFailureOccuring
import org.jbehave.core.model.Meta; //导入依赖的package包/类
@Test
public void shouldProvideStepsToBePerformedBeforeAndAfterScenariosWithNoFailureOccuring() {
MultipleAliasesSteps steps = new MultipleAliasesSteps();
ScenarioType scenarioType = ScenarioType.NORMAL;
List<BeforeOrAfterStep> beforeAfterScenario = steps.listBeforeOrAfterScenario(scenarioType);
assertThat(beforeAfterScenario.size(), equalTo(4));
beforeAfterScenario.get(0).createStep().perform(null);
assertThat(steps.beforeScenario, is(true));
Meta storyAndScenarioMeta = null;
// uponOutcome=ANY
beforeAfterScenario.get(1).createStepUponOutcome(storyAndScenarioMeta).perform(null);
assertThat(steps.afterAnyScenario, is(true));
// uponOutcome=SUCCESS
beforeAfterScenario.get(2).createStepUponOutcome(storyAndScenarioMeta).perform(null);
assertThat(steps.afterSuccessfulScenario, is(true));
// uponOutcome=FAILURE
beforeAfterScenario.get(3).createStepUponOutcome(storyAndScenarioMeta).perform(null);
assertThat(steps.afterFailedScenario, is(false));
}