vendredi 31 juillet 2015

How can I test specific field of entity by JUnit if using validator?

I have some entity which stored in db.
For example:

@Pattern(regexp = "male|female")
@Column(name = "sex")
private String sex;


Now I have some JUnit test codebut its test all fields.

Set<ConstraintViolation<Candidate>> violations = this.validator.validate(this.validCandidate, Candidate.class);
assertTrue(violations.isEmpty());

How can I test only sex for example?

Aucun commentaire:

Enregistrer un commentaire