VoicePrint implements Serializable { double getDistance(DistanceCalculator calculator, VoicePrint voicePrint) { r.lock(); try { return calculator.getDistance(this.features, voicePrint.features); } finally { r.unlock(); } } VoicePrint();   VoicePrint(double[] features);   VoicePrint(VoicePrint print); @Override String toString();  }
@Test public void getDistanceDelegatesToDistanceCalculator(@Injectable final VoicePrint vp) { final double d = 100; double distance = voicePrint.getDistance(new DistanceCalculator() { @Override public double getDistance(double[] features1, double[] features2) { return d; } }, vp); assertThat(distance, is(equalTo(d))); }