+ Start a Discussion

Apex test data setup with valid restricted picklist values and controlling field

We have recently setup a couple picklists on an object that are restricted values one is a controlling field for the other!
The object does not support record types (OrderItems) so there is no restriction based on record type.
I would like to setup my test data to query the fields to get valid values so that the tests do not rely on specific values which could be changed by an Admin!

I'm stuck at the point where I can describe the field but not sure how to get the picklist values or the dependencies??
Schema.DescribeFieldResult dfr = Schema.sObjectType.OrderItem.fields.field1__c;
Schema.DescribeFieldResult dfr = Schema.sObjectType.OrderItem.fields.field2__c;

Looking for tips to find a valid value for field1 and based on the value find valid value on field2 which is controlled by field1.

Any pointer to general reference for this would get me pointed in the right direction or if you have it handy code examples are welcome too!

Update to my question - did determine this schema method would return picklist values but still stumped on finding controlling field valid value combinations!
List<Schema.PicklistEntry> ple = dfr.getPicklistValues();