jparams / to-string-verifier

To String Verifier provides an easy and convenient way to test the toString method on your class.
MIT License
33 stars 6 forks source link

Failed String Comparisons for List of Strings while attempting to upgrade to 1.4.8 #62

Open Carlos-Alonzo opened 12 months ago

Carlos-Alonzo commented 12 months ago

As stated on the title we are seeing failures on the comparison of Lists of String objects, in our case, due to omission of double quotes. We tried to pass in a String formatter to add the double quotes but issue remains. We think this stems from this fix https://github.com/jparams/to-string-verifier/issues/24. Here is how to replicate it:

@Test void testListOfStrings() { ToStringVerifier.forClass(HasListField.class) .withPreset(Presets.APACHE_TO_STRING_BUILDER_JSON_STYLE) .verify(); }

class HasListField{ private List strings;

public HasListField(List<String> strings) {
  this.strings = strings;
}

public List<String> getStrings() {
  return strings;
}

@Override
public String toString() {
  return new Gson().toJson(this);
}

}