### Question:
OnlineIIRSinglechannelSampleFilter extends AbstractIIRSinglechannelSampleFilter { protected double[] getUnfilteredSamplesCache(int newSamples) { int unfilteredSamplesNeeded = newSamples + filterOrder; int zeroPaddingSize = 0; double[] unfilteredSamplesCache = new double[unfilteredSamplesNeeded]; if (unfilteredSamplesNeeded > source.getSampleCount()) { zeroPaddingSize = unfilteredSamplesNeeded - source.getSampleCount(); } for (int i = 0; i < zeroPaddingSize; i++) { unfilteredSamplesCache[i] = 0.0; } source.getSamples(unfilteredSamplesCache, source.getSampleCount() - unfilteredSamplesNeeded + zeroPaddingSize, unfilteredSamplesNeeded - zeroPaddingSize, zeroPaddingSize); return unfilteredSamplesCache; } 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 testGetUnfilteredSamplesCache() { coefficients = new FilterCoefficients(new double[] {1.0,0.0,0.0,0.0}, new double[] {1.0,0.0,0.0,0.0}); engine = getEngine(source, coefficients); float[] samples = new float[TEST_SAMPLE_COUNT]; for (int i = 0; i < TEST_SAMPLE_COUNT; i++) { samples[i] = (float) Math.random(); } for (int i = 0; i < TEST_SAMPLE_COUNT; i++) source.addSamples(new float[] {samples[i]}); double[] uCache = engine.getUnfilteredSamplesCache(source.getSampleCount(0)); for (int i = 0; i < TEST_SAMPLE_COUNT; i++) { if (samples.length - i - 1 >= 0) assertEquals(uCache[uCache.length - i - 1], samples[samples.length - i - 1], 0.000001); else assertEquals(uCache[uCache.length - i], 0.0, 0.00000001); } float[] newSamples = new float[] {(float) Math.random(), (float) Math.random()}; source.addSamples(new float[] {newSamples[0]}); source.addSamples(new float[] {newSamples[1]}); uCache = engine.getUnfilteredSamplesCache(2); assertEquals(uCache[0], samples[samples.length-3], 0.00001); assertEquals(uCache[1], samples[samples.length-2], 0.00001); assertEquals(uCache[2], samples[samples.length-1], 0.00001); assertEquals(uCache[3], newSamples[0], 0.00001); assertEquals(uCache[4], newSamples[1], 0.00001); float[] newNewSamples = new float[] {(float) Math.random()}; source.addSamples(newNewSamples); uCache = engine.getUnfilteredSamplesCache(1); assertEquals(uCache[0], samples[samples.length - 1], 0.00001); assertEquals(uCache[1], newSamples[0], 0.00001); assertEquals(uCache[2], newSamples[1], 0.00001); assertEquals(uCache[3], newNewSamples[0], 0.00001); }