title: NullPointerException when running JUnit tests, saying interface is null
body: <p>I'm trying to write a java program that allows the user to input a series of data values then for the program to sort through finding the mean and the median of that series, using an interface to "treat" different objects as if they were the same.  However when I run my JUnit test, it keeps saying my interface is null.</p>
  
  <p>NoiseFilter.java</p>
  
  <pre><code>package noisefilter.model;
  
  import java.util.ArrayList;
  
  public interface NoiseFilter {
  
  public double getBestMesurement(ArrayList&lt;Double&gt; samples);
  
  }
  </code></pre>
  
  <p>AveragingFilter.java</p>
  
  <pre><code>package noisefilter.model;
  
  import java.util.ArrayList;
  
  public class AveragingFilter implements NoiseFilter {
  
  @Override
  /**
   * The method getBestMeasurement takes an array list of type double and returns a
   */
  public double getBestMesurement(ArrayList&lt;Double&gt; samples) {
      // TODO Auto-generated method stub
  
      if (samples.equals(null)) {
          throw new IllegalArgumentException("The Samples cannot be null");
      }
      if (samples.size() &lt; 3) {
          throw new IllegalArgumentException("The Sample size must have 3");
      }
      double sum = 0.0;
      for (Double number : samples) {
          sum += number;
      }
  
      return (sum / samples.size());
  }
  
  }
  </code></pre>
  
  <p>SensorData.java</p>
  
  <pre><code>package noisefilter.model;
  
  import java.util.ArrayList;
  
  public class SensorData implements NoiseFilter {
  
  ArrayList&lt;Double&gt; data;
  NoiseFilter filter;
  
  public SensorData() {
      this.data = new ArrayList&lt;Double&gt;();
      this.filter = null;
  }
  
  public void addSample(double sample) {
      data.add(sample);
  }
  
  public void setFilter(NoiseFilter filterVar) {
      this.filter = filterVar;
  }
  
  public double getFilteredResult() {
      if (filter.equals(null)) {
          throw new IllegalStateException("The filter cannot be left null");
      }
      return filter.getBestMesurement(data);
  }
  
  @Override
  public double getBestMesurement(ArrayList&lt;Double&gt; samples) {
  
      samples = this.data;
      return 0;
  }
  </code></pre>
  
  <p>WhenAveragingFilter.java (JUnit Test)</p>
  
  <pre><code>package noisefilter.tests;
  
  import static org.junit.Assert.*;
  
  import org.junit.Before;
  import org.junit.Test;
  
  import noisefilter.model.NoiseFilter;
  import noisefilter.model.SensorData;
  
  public class WhenAverageFiltering {
  
  NoiseFilter filter;
  SensorData dataSet;
  
  
  @Before
  public void setUp() throws Exception {
      this.dataSet = new SensorData();
      dataSet.setFilter(filter);
  }
  
  @Test
  public void averageOfThree100sShouldBe100() {
      dataSet.addSample(100);
      dataSet.addSample(100);
      dataSet.addSample(100);
  
      assertTrue(dataSet.getFilteredResult() == 100);
  }
  
  @Test
  public void averageOfThreeDifferent() {
      dataSet.addSample(120);
      dataSet.addSample(140);
      dataSet.addSample(130);
  
      assertTrue(dataSet.getFilteredResult() == 130);
  }
  
  @Test
  public void averageOfFiveDifferent() {
      dataSet.addSample(10);
      dataSet.addSample(50);
      dataSet.addSample(60);
  
      assertTrue(dataSet.getFilteredResult() == 40);
  }
  
  }
  </code></pre>
  
  <p>Here's the errors that I get when I run the JUnit Test.</p>
  
  <pre><code>java.lang.NullPointerException
  at noisefilter.model.SensorData.getFilteredResult(SensorData.java:24)
  at     noisefilter.tests.WhenAverageFiltering.averageOfFiveDifferent(WhenAverageFiltering.java:47)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  at java.lang.reflect.Method.invoke(Unknown Source)
  at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
  at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
  at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
  at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
  at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
  at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
  at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
  at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
  </code></pre>