ThunderClientBuilder { public ThunderClient build() { Objects.requireNonNull(endpoint, "You must provide an endpoint with the ThunderClientBuilder.endpoint() method" + " in order to build a ThunderClient."); Objects.requireNonNull(httpClient, "You must provide an authentication mechanism with the" + " ThunderClientBuilder.authentication() method in order to build a ThunderClient."); var retrofit = new Retrofit.Builder() .baseUrl(endpoint) .addConverterFactory(JacksonConverterFactory.create()) .client(httpClient) .build(); return retrofit.create(ThunderClient.class); } ThunderClientBuilder(); ThunderClientBuilder endpoint(String endpoint); ThunderClientBuilder authentication(String apiUser, String apiSecret); ThunderClient build();  }
@Test void buildShouldThrowWithoutSettingEndpoint() { NullPointerException e = assertThrows(NullPointerException.class, () -> new ThunderClientBuilder().build()); assertTrue(e.getMessage().startsWith("You must provide an endpoint")); }