title: Mock testing clarification
body: <p>I need a clarification about mocking tests. In my particular scenario, I have to test a service, that has the dependency on the connecting module, the connector. Basically what connector does, is that it creates an instance of the service call that has to be made. I will demonstrate on the example.</p>
  
  <pre><code>public DataService(Connector connector) {
      this.connector = connector;
  }
  
  @Override
  public ServiceData getWeatherData(String dataId) throws ServiceCommunicatonException {
  
      try {
  
          return connector.newGetWeatherDataCall().call(
                  WeatherData.builder().withId(dataId).build());
  
      } catch (Exception e) {
          throw new ServiceCommunicatonException(ERR_MSG);
      }
  
  }
  </code></pre>
  
  <p>So the <code>connector.newGetWeatherDataCall()</code> returns the instance of the type <code>WeatherData</code>.</p>
  
  <p>Now, in order to test the <code>Service</code>, I guess I would need to mock the <code>Connector</code>. Mocking the <code>Service</code> is probably pointless, because then I am not really testing it, right?</p>
  
  <p>I tried mocking the <code>Connector</code> with something like this:</p>
  
  <pre><code>@Before
  public void setUp() {
      connector = mock(Connector.class);
  }
  
  @Test
  public void getDataTest() {
      assertNotNull(service.getData("123"));
  }
  </code></pre>
  
  <p>However, this is obviously wrong, because this gave ma <code>NullPointerException</code> because <code>WeatherDataCall</code> from this line: return </p>
  
  <pre><code>connector.newGetWeatherDataCall().call(
                      WeatherData.builder().withId(dataId).build()); was null. 
  </code></pre>
  
  <p>So how should this be properly tested/mocked? It would be great with some code examples.</p>