### Question:
OnlineIIRSinglechannelSampleFilter extends AbstractIIRSinglechannelSampleFilter { protected double[] calculateNewFilteredSamples(double[] unfilteredSamplesCache, double[] filteredSamplesCache, int newSamples) { return calculateNewFilteredSamples(bCoefficients, aCoefficients, filterOrder, unfilteredSamplesCache, filteredSamplesCache, newSamples); } OnlineIIRSinglechannelSampleFilter(SampleSource source, TimeDomainSampleFilter definition);  OnlineIIRSinglechannelSampleFilter(SampleSource source, TimeDomainSampleFilter definition, FilterCoefficients coefficients);  OnlineIIRSinglechannelSampleFilter(SampleSource source, FilterCoefficients coefficients); static double[] filterUsingCache(double[] bCoefficients, double[] aCoefficients, double[] input); synchronized void updateCache(int newSamples); @Override synchronized void getSamples(double[] target, int signalOffset, int count, int arrayOffset);  }### Answer:
@Test public void testCalculateNewFilteredSamples() { coefficients = new FilterCoefficients(new double[] {1.0, 0.0, 0.0}, new double[] {1.0, 0.0, 0.0}); engine = getEngine(source, coefficients); double[] samples = new double[TEST_SAMPLE_COUNT]; for (int i = 0; i < TEST_SAMPLE_COUNT; i++) { samples[i] = Math.random(); source.addSamples(new float[] {(float) samples[i]}); } double[] uCache = engine.getUnfilteredSamplesCache(source.getSampleCount(0)); double[] fCache = engine.getFilteredSamplesCache(source.getSampleCount(0)); double[] newFiltered = engine.calculateNewFilteredSamples(uCache, fCache, TEST_SAMPLE_COUNT); for (int i = 0; i < newFiltered.length; i++) assertEquals(newFiltered[i], samples[i], 0.0001); double[] newSamples1 = new double[] {Math.random(), Math.random()}; source.addSamples(new float[] {(float) newSamples1[0]}); source.addSamples(new float[] {(float) newSamples1[1]}); uCache = engine.getUnfilteredSamplesCache(2); fCache = engine.getFilteredSamplesCache(2); newFiltered = engine.calculateNewFilteredSamples(uCache, fCache, 2); assertEquals(newFiltered[0], newSamples1[0], 0.00001); assertEquals(newFiltered[1], newSamples1[1], 0.000001); }