@Test @DisplayName("validate createWithAadTokenProviderAuthentication throws IllegalArgumentException exception when missing or invalid parameters") void createWithAadTokenProviderAuthentication(){ Assertions.assertThrows(IllegalArgumentException.class, () -> ConnectionStringBuilder .createWithAadTokenProviderAuthentication(null, () -> "token")); Assertions.assertThrows(IllegalArgumentException.class, () -> ConnectionStringBuilder .createWithAadTokenProviderAuthentication("", () -> "token")); Assertions.assertThrows(IllegalArgumentException.class, () -> ConnectionStringBuilder .createWithAadTokenProviderAuthentication("resource.uri", null)); Assertions.assertDoesNotThrow( () -> ConnectionStringBuilder .createWithAadTokenProviderAuthentication("resource.uri", () -> "token")); }
public static ConnectionStringBuilder createWithAadTokenProviderAuthentication(String resourceUri, Callable<String> tokenProviderCallable) { if (StringUtils.isEmpty(resourceUri)) { throw new IllegalArgumentException("resourceUri cannot be null or empty"); } if (tokenProviderCallable == null) { throw new IllegalArgumentException("tokenProviderCallback cannot be null"); } ConnectionStringBuilder csb = new ConnectionStringBuilder(resourceUri); csb.tokenProvider = tokenProviderCallable; return csb; }
ConnectionStringBuilder { public static ConnectionStringBuilder createWithAadTokenProviderAuthentication(String resourceUri, Callable<String> tokenProviderCallable) { if (StringUtils.isEmpty(resourceUri)) { throw new IllegalArgumentException("resourceUri cannot be null or empty"); } if (tokenProviderCallable == null) { throw new IllegalArgumentException("tokenProviderCallback cannot be null"); } ConnectionStringBuilder csb = new ConnectionStringBuilder(resourceUri); csb.tokenProvider = tokenProviderCallable; return csb; } }
ConnectionStringBuilder { public static ConnectionStringBuilder createWithAadTokenProviderAuthentication(String resourceUri, Callable<String> tokenProviderCallable) { if (StringUtils.isEmpty(resourceUri)) { throw new IllegalArgumentException("resourceUri cannot be null or empty"); } if (tokenProviderCallable == null) { throw new IllegalArgumentException("tokenProviderCallback cannot be null"); } ConnectionStringBuilder csb = new ConnectionStringBuilder(resourceUri); csb.tokenProvider = tokenProviderCallable; return csb; } private  ConnectionStringBuilder(String resourceUri); }
ConnectionStringBuilder { public static ConnectionStringBuilder createWithAadTokenProviderAuthentication(String resourceUri, Callable<String> tokenProviderCallable) { if (StringUtils.isEmpty(resourceUri)) { throw new IllegalArgumentException("resourceUri cannot be null or empty"); } if (tokenProviderCallable == null) { throw new IllegalArgumentException("tokenProviderCallback cannot be null"); } ConnectionStringBuilder csb = new ConnectionStringBuilder(resourceUri); csb.tokenProvider = tokenProviderCallable; 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 createWithAadTokenProviderAuthentication(String resourceUri, Callable<String> tokenProviderCallable) { if (StringUtils.isEmpty(resourceUri)) { throw new IllegalArgumentException("resourceUri cannot be null or empty"); } if (tokenProviderCallable == null) { throw new IllegalArgumentException("tokenProviderCallback cannot be null"); } ConnectionStringBuilder csb = new ConnectionStringBuilder(resourceUri); csb.tokenProvider = tokenProviderCallable; 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);  }