Lets say you have a class that has the responsibility producing a set of finished data, but the method of producing that data is intentionally an implementation detail and as such should be left inaccessible to clients. How do you unit test such an API, knowing as the implementor that the data will change over time? Ideally you'd want to mock the underlying dataset, but the fact that it's an implementation detail means the dataset is not exposed and should not be. The client application should never have any reason to change the underlying data access methods, but the test still has need to mock it.
For a simple example, lets say you have two APIs. The first returns a set of integers that form a data set. The second API is a subset of that, representing integers that need to be filtered out of the first set. Your function has the responsibility of returning the final set of integers, but the fact that it makes API calls internally is an implementation detail that there is otherwise no reason to expose to the outside. Following principles of good class design, the only method that should be visible from the outside is the one function that returns the set of integers, but in order to unit test it you would need to override those internal API calls to provide consistent controlled data. I want to be able to unit test this function to make sure it return that right data, but by all rights I shouldn't expose any of the necessary components that are purely implementation details.
Is there a way to have the best of both worlds? Are there better design principles that I'm unaware of that describe how to break down a problem of this style?