Package org.jbehave.core.steps.ParameterConverters

Examples of org.jbehave.core.steps.ParameterConverters.MethodReturningConverter


    @Test
    public void shouldConvertParameterValuesOfTableRow() throws Exception {
        // Given
        ParameterConverters parameterConverters = new ParameterConverters();
        parameterConverters.addConverters(new MethodReturningConverter(methodFor("convertDate"), this));
        ExamplesTableFactory factory = new ExamplesTableFactory(parameterConverters);

        // When
        String tableAsString = "|one|two|\n|11|22|\n|1/1/2010|2/2/2010|";
        ExamplesTable examplesTable = factory.createExamplesTable(tableAsString);
View Full Code Here


    @Test
    public void shouldConvertParameterValuesOfTableRowWithDefaults() throws Exception {
        // Given
        ParameterConverters parameterConverters = new ParameterConverters();
        parameterConverters.addConverters(new MethodReturningConverter(methodFor("convertDate"), this));
        ExamplesTableFactory factory = new ExamplesTableFactory(parameterConverters);

        // When
        String tableDefaultsAsString = "|three|\n|99|";
        ExamplesTable defaultsTable = factory.createExamplesTable(tableDefaultsAsString);
View Full Code Here

     */
    private List<ParameterConverter> methodReturningConverters(final Class<?> type) {
        final List<ParameterConverter> converters = new ArrayList<ParameterConverter>();
        for (final Method method : type.getMethods()) {
            if (method.isAnnotationPresent(AsParameterConverter.class)) {
                converters.add(new MethodReturningConverter(method, type, this));
            }
        }
        return converters;
    }
View Full Code Here

  private List<ParameterConverter> methodReturningConverters(Class<?> type) {
    List<ParameterConverter> converters = new ArrayList<ParameterConverter>();

    for (Method method : type.getMethods()) {
      if (method.isAnnotationPresent(AsParameterConverter.class)) {
        converters.add(new MethodReturningConverter(method, type, this));
      }
    }

    return converters;
  }
View Full Code Here

  private List<ParameterConverter> methodReturningConverters(Object instance) {
    List<ParameterConverter> converters = new ArrayList<ParameterConverter>();

    for (Method method : instance.getClass().getMethods()) {
      if (method.isAnnotationPresent(AsParameterConverter.class)) {
        converters.add(new MethodReturningConverter(method, instance));
      }
    }

    return converters;
  }
View Full Code Here

    }

    @Test
    public void shouldConvertParameterFromMethodReturningValue() throws ParseException, IntrospectionException {
        Method method = SomeSteps.methodFor("aMethodReturningExamplesTable");
        ParameterConverter converter = new MethodReturningConverter(method, new SomeSteps());
        assertThat(converter.accept(method.getReturnType()), is(true));
        assertThat(converter.accept(WrongType.class), is(false));
        assertThat(converter.accept(mock(Type.class)), is(false));
        String value = "|col1|col2|\n|row11|row12|\n|row21|row22|\n";
        ExamplesTable table = (ExamplesTable) converter.convertValue(value, ExamplesTable.class);
        assertThat(table.getRowCount(), equalTo(2));
        Map<String, String> row1 = table.getRow(0);
        assertThat(row1.get("col1"), equalTo("row11"));
        assertThat(row1.get("col2"), equalTo("row12"));
        Map<String, String> row2 = table.getRow(1);
View Full Code Here

    @Test(expected = ParameterConvertionFailed.class)
    public void shouldFailToConvertParameterFromFailingMethodReturningValue() throws ParseException,
            IntrospectionException {
        Method method = SomeSteps.methodFor("aFailingMethodReturningExamplesTable");
        ParameterConverter converter = new MethodReturningConverter(method, new SomeSteps());
        String value = "|col1|col2|\n|row11|row12|\n|row21|row22|\n";
        converter.convertValue(value, ExamplesTable.class);
    }
View Full Code Here

TOP

Related Classes of org.jbehave.core.steps.ParameterConverters.MethodReturningConverter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.