SonarConnectionFactory { public SonarConnection create(String url, String login, String password) { Preconditions.checkNotNull(url, "url is mandatory"); SonarConnection sonarConnection = new SonarConnection(); sonarConnection.connect(url, login, password); return sonarConnection; }  SonarConnection create(String url, String login, String password);  }
@Test(expected = NullPointerException.class) public void can_t_pass_null_to_create_method() { sonarConnectionFactory.create(null, "", ""); }
@Test public void should_create_sonar_connection() { SonarConnection connection = sonarConnectionFactory.create("http: assertFalse(connection.isClosed()); }