@Test @DisplayName("validate createWithAadAccessTokenAuthentication throws IllegalArgumentException exception when missing or invalid parameters") void createWithAadAccessTokenAuthentication(){ Assertions.assertThrows(IllegalArgumentException.class, () -> ConnectionStringBuilder .createWithAadAccessTokenAuthentication(null, "token")); Assertions.assertThrows(IllegalArgumentException.class, () -> ConnectionStringBuilder .createWithAadAccessTokenAuthentication("","token")); Assertions.assertThrows(IllegalArgumentException.class, () -> ConnectionStringBuilder .createWithAadAccessTokenAuthentication("resource.uri", null)); Assertions.assertThrows(IllegalArgumentException.class, () -> ConnectionStringBuilder .createWithAadAccessTokenAuthentication("resource.uri","")); Assertions.assertDoesNotThrow( () -> ConnectionStringBuilder .createWithAadAccessTokenAuthentication("resource.uri","token")); }
public static ConnectionStringBuilder createWithAadAccessTokenAuthentication(String resourceUri, String token) { if (StringUtils.isEmpty(resourceUri)) { throw new IllegalArgumentException("resourceUri cannot be null or empty"); } if (StringUtils.isEmpty(token)) { throw new IllegalArgumentException("token cannot be null or empty"); } ConnectionStringBuilder csb = new ConnectionStringBuilder(resourceUri); csb.accessToken = token; return csb; }
ConnectionStringBuilder { public static ConnectionStringBuilder createWithAadAccessTokenAuthentication(String resourceUri, String token) { if (StringUtils.isEmpty(resourceUri)) { throw new IllegalArgumentException("resourceUri cannot be null or empty"); } if (StringUtils.isEmpty(token)) { throw new IllegalArgumentException("token cannot be null or empty"); } ConnectionStringBuilder csb = new ConnectionStringBuilder(resourceUri); csb.accessToken = token; return csb; } }
ConnectionStringBuilder { public static ConnectionStringBuilder createWithAadAccessTokenAuthentication(String resourceUri, String token) { if (StringUtils.isEmpty(resourceUri)) { throw new IllegalArgumentException("resourceUri cannot be null or empty"); } if (StringUtils.isEmpty(token)) { throw new IllegalArgumentException("token cannot be null or empty"); } ConnectionStringBuilder csb = new ConnectionStringBuilder(resourceUri); csb.accessToken = token; return csb; } private  ConnectionStringBuilder(String resourceUri); }
ConnectionStringBuilder { public static ConnectionStringBuilder createWithAadAccessTokenAuthentication(String resourceUri, String token) { if (StringUtils.isEmpty(resourceUri)) { throw new IllegalArgumentException("resourceUri cannot be null or empty"); } if (StringUtils.isEmpty(token)) { throw new IllegalArgumentException("token cannot be null or empty"); } ConnectionStringBuilder csb = new ConnectionStringBuilder(resourceUri); csb.accessToken = token; return csb; } private  ConnectionStringBuilder(String resourceUri); String getClusterUrl(); void setApplicationNameForTracing(String applicationNameForTracing); void setClientVersionForTracing(String clientVersionForTracing); Callable<String> getTokenProvider(); static ConnectionStringBuilder createWithAadUserCredentials(String resourceUri,
                                                                       String username,
                                                                       String password,
                                                                       String authorityId); static ConnectionStringBuilder createWithAadUserCredentials(String resourceUri,
                                                                       String username,
                                                                       String password); static ConnectionStringBuilder createWithAadApplicationCredentials(String resourceUri,
                                                                              String applicationClientId,
                                                                              String applicationKey,
                                                                              String authorityId); static ConnectionStringBuilder createWithAadApplicationCredentials(String resourceUri,
                                                                              String applicationClientId,
                                                                              String applicationKey); static ConnectionStringBuilder createWithDeviceCodeCredentials(String resourceUri, String authorityId); static ConnectionStringBuilder createWithDeviceCodeCredentials(String resourceUri); static ConnectionStringBuilder createWithAadApplicationCertificate(String resourceUri,
                                                                              String applicationClientId,
                                                                              X509Certificate x509Certificate,
                                                                              PrivateKey privateKey); static ConnectionStringBuilder createWithAadApplicationCertificate(String resourceUri,
                                                                              String applicationClientId,
                                                                              X509Certificate x509Certificate,
                                                                              PrivateKey privateKey,
                                                                              String authorityId); static ConnectionStringBuilder createWithAadAccessTokenAuthentication(String resourceUri, String token); static ConnectionStringBuilder createWithAadTokenProviderAuthentication(String resourceUri, Callable<String> tokenProviderCallable); }
ConnectionStringBuilder { public static ConnectionStringBuilder createWithAadAccessTokenAuthentication(String resourceUri, String token) { if (StringUtils.isEmpty(resourceUri)) { throw new IllegalArgumentException("resourceUri cannot be null or empty"); } if (StringUtils.isEmpty(token)) { throw new IllegalArgumentException("token cannot be null or empty"); } ConnectionStringBuilder csb = new ConnectionStringBuilder(resourceUri); csb.accessToken = token; return csb; } private  ConnectionStringBuilder(String resourceUri); String getClusterUrl(); void setApplicationNameForTracing(String applicationNameForTracing); void setClientVersionForTracing(String clientVersionForTracing); Callable<String> getTokenProvider(); static ConnectionStringBuilder createWithAadUserCredentials(String resourceUri,
                                                                       String username,
                                                                       String password,
                                                                       String authorityId); static ConnectionStringBuilder createWithAadUserCredentials(String resourceUri,
                                                                       String username,
                                                                       String password); static ConnectionStringBuilder createWithAadApplicationCredentials(String resourceUri,
                                                                              String applicationClientId,
                                                                              String applicationKey,
                                                                              String authorityId); static ConnectionStringBuilder createWithAadApplicationCredentials(String resourceUri,
                                                                              String applicationClientId,
                                                                              String applicationKey); static ConnectionStringBuilder createWithDeviceCodeCredentials(String resourceUri, String authorityId); static ConnectionStringBuilder createWithDeviceCodeCredentials(String resourceUri); static ConnectionStringBuilder createWithAadApplicationCertificate(String resourceUri,
                                                                              String applicationClientId,
                                                                              X509Certificate x509Certificate,
                                                                              PrivateKey privateKey); static ConnectionStringBuilder createWithAadApplicationCertificate(String resourceUri,
                                                                              String applicationClientId,
                                                                              X509Certificate x509Certificate,
                                                                              PrivateKey privateKey,
                                                                              String authorityId); static ConnectionStringBuilder createWithAadAccessTokenAuthentication(String resourceUri, String token); static ConnectionStringBuilder createWithAadTokenProviderAuthentication(String resourceUri, Callable<String> tokenProviderCallable);  }