Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for properties with SortedSet and other collection datatype #60

Closed
paulovitor opened this issue Jul 25, 2014 · 5 comments
Closed

Comments

@paulovitor
Copy link

When execute fixture, following exception is displayed:

target = {java.lang.ClassCastException@1827}"java.lang.ClassCastException: Cannot cast java.util.HashSet to java.util.SortedSet"

public class Father {
    private SortedSet<Son> children = new TreeSet<>();
}
Fixture.of(Father.class).addTemplate("valid", new Rule() {
            {
                add("children", has(1).of(Son.class, "valid"));
            }
        });

Is it can add support for other collection beyond Set?

protected TransformerChain buildTransformerChain(Transformer transformer) {
        TransformerChain transformerChain = new TransformerChain(transformer);

        transformerChain.add(new CalendarTransformer());
        transformerChain.add(new SetTransformer());
        transformerChain.add(new PrimitiveTransformer());
        transformerChain.add(new WrapperTransformer());

        return transformerChain;
    }

Or get implementation class from Set interface, instead of create HashSet:

public <T> T transform(Object value, Class<T> type) {
        return type.cast(new HashSet((Collection) value));
    }
@paulovitor paulovitor changed the title adding support for properties with SortedSet and other collection datatype add support for properties with SortedSet and other collection datatype Jul 25, 2014
maurcarvalho added a commit to maurcarvalho/fixture-factory that referenced this issue Feb 20, 2016
@maurcarvalho
Copy link
Contributor

maurcarvalho commented Feb 22, 2016

@paulovitor I fixed it here f1d4dab.
Any instance of Set should transformable. Let's wait code review and merge.

@paulovitor
Copy link
Author

Ok Mauricio, thanks! ;)

@maurcarvalho
Copy link
Contributor

@ahirata @aparra @nykolaslima Hello guys, any chance to have it reviewed soon?

@maurcarvalho
Copy link
Contributor

Fixed at f1d4dab and merged.
@ahirata or @paulovitor, could you please close this issue?
Thank you.

@paulovitor
Copy link
Author

Fixed at f1d4dab and merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants