### Question:
MultichannelSampleFilter extends MultichannelSampleProcessor { public void addFilter(SinglechannelSampleFilterEngine filter) { int cnt = chains.size(); LinkedList<SinglechannelSampleFilterEngine> chain; for (int i=0; i<cnt; i++) { chain = chains.get(i); chain.add(filter); } } MultichannelSampleFilter(MultichannelSampleSource source);  MultichannelSampleFilter(MultichannelSampleSource source, OriginalMultichannelSampleSource originalSource); @Override synchronized void getSamples(int channel, double[] target, int signalOffset, int count, int arrayOffset); void addFilter(SinglechannelSampleFilterEngine filter); void addFilter(SinglechannelSampleFilterEngine filter, int[] channels); void addFilter(SinglechannelSampleFilterEngine filter, int channel); @Override void propertyChange(PropertyChangeEvent evt); void reinitFilterChains(); Montage getCurrentMontage(); void setCurrentMontage(Montage currentMontage);  }### Answer:
@Test public void testAddFilterAllChannels() { TimeDomainSampleFilter definition = new TimeDomainSampleFilter(FilterType.LOWPASS, ApproximationFunctionType.BUTTERWORTH, new double[] {20, 0}, new double[] {40, 0}, 3.0, 20.0); definition.setSamplingFrequency(128.0); AbstractIIRSinglechannelSampleFilter filterEngine = new OfflineIIRSinglechannelSampleFilter(new ChannelSelectorSampleSource(source,0), definition); int i, j; for (i = 0; i < 4; i++) { for (j = 0; j < TEST_CHANNEL_COUNT; j++) assertEquals(mfilter.chains.elementAt(j).size(), i); mfilter.addFilter(filterEngine); } }
@Test public void testAddFilterForSpecifiedChannels() { TimeDomainSampleFilter definition = new TimeDomainSampleFilter(FilterType.LOWPASS, ApproximationFunctionType.BUTTERWORTH, new double[] {20, 0}, new double[] {30, 8}, 5.0, 20.0); definition.setSamplingFrequency(128.0); AbstractIIRSinglechannelSampleFilter filterEngine = new OfflineIIRSinglechannelSampleFilter(new ChannelSelectorSampleSource(source,0), definition); int i, j; for (j = 0; j < TEST_CHANNEL_COUNT; j++) assertEquals(mfilter.chains.elementAt(j).size(), 0); mfilter.addFilter(filterEngine, new int[] {2, 3}); for (j = 0; j < TEST_CHANNEL_COUNT; j++) { if (j == 2 || j == 3) assertEquals(mfilter.chains.elementAt(j).size(), 1); else assertEquals(mfilter.chains.elementAt(j).size(), 0); } mfilter.addFilter(filterEngine, new int[] {3, 4, 5}); for (j = 0; j < TEST_CHANNEL_COUNT; j++) { if (j == 2 || j == 4 || j == 5) assertEquals(mfilter.chains.elementAt(j).size(), 1); else if (j == 3) assertEquals(mfilter.chains.elementAt(j).size(), 2); else assertEquals(mfilter.chains.elementAt(j).size(), 0); } }