jeudi 5 mars 2015

Get parameters values of enum constructors in Java

I have enum which I cannot initialize during the testing (staticMethod() fails) and it is impossible for me to mock that call. Is there a way to get values of parameters passed to constructors via reflection (in this case I want to know that "Monday" and "Sunday" are passed)?



public enum Day {
SATURDAY ("Monday"),
SUNDAY ("Sunday");

private final String day;

private Day(String day) {
this.day = day;
StaticClass.someMethod();
}
}





Aucun commentaire:

Enregistrer un commentaire