I have a class which exposes a set of apis as below
class MyDataProcessor{
private int M;
private double[] data;
public MyDataProcessor(int N,int M){
this.M = M;
this.data = new double[M];
for(int i=0;i<M;i++){
int randomX = //get a random value
double v = processValue(randomX);
this.data[i] = v;
}
private static double processValue(int randomX){
//do some work on randomX and return a double value
}
private double mean(double[] a){
double meanValue = //find mean of a
return meanValue;
}
private double stddev(double[] a){
double stdDevValue = //find stddev of a
return stdDevValue;
}
public double lowerBoundConf(){
double mean = mean(this.data);
double sd = stddev(this.data);
double lb = mean + (1.96*stddev)/Math.sqrt(this.M);
return lb;
}
}
Here,I have to unit test the method lowerBoundConf
.I cannot provide a double[] array to this method(that would have made it simple).The array has to come from inside the constructor.I cannot figure out how I can write tests for this.Can someone help?