Permalink
Browse files

Correct error message on XStreams failure due repeated column. fixes #…

  • Loading branch information...
mgurov committed Jan 11, 2014
1 parent 5df09f8 commit 7c7646a107e9a7fb505650fba38ec959ed9f6df6
@@ -107,6 +107,8 @@ public TableConverter(LocalizedXStreams.LocalizedXStream xStream, ParameterInfo
return Collections.unmodifiableList((List<T>) xStream.unmarshal(reader));
} catch (AbstractReflectionConverter.UnknownFieldException e) {
throw new CucumberException(e.getShortMessage());
+ } catch (AbstractReflectionConverter.DuplicateFieldException e) {
+ throw new CucumberException(e.getShortMessage());
} catch (ConversionException e) {
throw new CucumberException(String.format("Can't assign null value to one of the primitive fields in %s. Please use boxed types.", e.get("class")));
}
@@ -81,6 +81,20 @@ public void gives_a_nice_error_message_when_primitive_field_is_null() {
}
}
+ @Test
+ public void gives_a_meaningfull_error_message_when_field_is_repeated() {
+ try {
+ tc.toList(UserPojo.class, TableParser.parse("" +
+ "| credits | credits |\n" +
+ "| 5 | 5 |\n" +
+ "", PARAMETER_INFO)
+ );
+ fail();
+ } catch (CucumberException e) {
+ assertEquals("Duplicate field credits", e.getMessage());
+ }
+ }
+
@Test
public void converts_list_of_beans_to_table_with_explicit_columns() {
List<UserPojo> users = tc.toList(UserPojo.class, personTable());

0 comments on commit 7c7646a

Please sign in to comment.