### Question:
MasterSelection implements OptimalMaster { public int findOptimalMaster(IfgStack[] ifgStack) { orbitNumber = ifgStack[0].master.orbitNumber; modeledCoherence = ifgStack[0].meanCoherence; int index = 0; int i = 0; for (IfgStack anIfgStack : ifgStack) { long orbit = anIfgStack.master.orbitNumber; float coherence = anIfgStack.meanCoherence; if (coherence > modeledCoherence) { modeledCoherence = coherence; orbitNumber = orbit; index = i; } ++i; } return index; } MasterSelection(); void setInput(SLCImage[] slcImages, Orbit[] orbits); long getOrbitNumber(); float getModeledCoherence(); int findOptimalMaster(IfgStack[] ifgStack); IfgStack[] getCoherenceScores(final ProgressMonitor pm); int estimateOptimalMaster(final ProgressMonitor pm); static Product findOptimalMasterProduct(final Product[] srcProducts);  }### Answer:
@Test public void testFindOptimalMaster() throws Exception { final MasterSelection dataStack = new MasterSelection(); dataStack.setInput(slcImages, orbits); dataStack.estimateOptimalMaster(ProgressMonitor.NULL); float modeledCoherence_ACTUAL = dataStack.getModeledCoherence(); long optimalMaster_ACTUAL = dataStack.getOrbitNumber(); assertEquals(modeledCoherence_EXPECTED, modeledCoherence_ACTUAL , 1e-3); assertEquals(optimalMaster_EXPECTED, optimalMaster_EXPECTED); }