I have legacy code where is private enum which I need to construct another type for acceptance testing, but I'm stuck because this enum is private and it is not part of any class, looks like following:
enum Element {
ELEMENT1, ELEMENT2;
public static Element[] values() { /* compiled code */ }
public static Element valueOf(java.lang.String name) { /* compiled code */ }
private Element() { /* compiled code */ }
}
is there a way how to use this enum, expose it from legacy code, or maybe way how to mock it?
Update: I know I can read values enums by reflection, but I have another class which is public and I need to use enum value in its constructor, this class is in the same package like Element, its constructor is :
public class ElementProvider {
public ElementProvider(string name, Element element){ /*compiled code*/ }
}