Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renaming methods/classes based on review. #24474

Merged
merged 12 commits into from
Oct 4, 2021
Prev Previous commit
Next Next commit
Adding back test for fullyQualifiedNamespace.
  • Loading branch information
conniey committed Sep 30, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 9b48f9eb00331900c3be6ab549a04c51c6db6cab
Original file line number Diff line number Diff line change
@@ -238,15 +238,22 @@ public SchemaRegistryClientBuilder addPolicy(HttpPipelinePolicy policy) {
* If {@link #pipeline(HttpPipeline) pipeline} is set, then all HTTP pipeline related settings are ignored.
*
* @return A {@link SchemaRegistryAsyncClient} with the options set from the builder.
* @throws NullPointerException if {@link #fullyQualifiedNamespace(String) endpoint} and {@link #credential(TokenCredential)
* credential} are not set.
* @throws NullPointerException if {@link #fullyQualifiedNamespace(String) fullyQualifiedNamespace} and
* {@link #credential(TokenCredential) credential} are not set.
* @throws IllegalArgumentException if {@link #fullyQualifiedNamespace(String) fullyQualifiedNamespace} is an empty
* string.
*/
public SchemaRegistryAsyncClient buildAsyncClient() {
Objects.requireNonNull(credential,
"'credential' cannot be null and must be set via builder.credential(TokenCredential)");
Objects.requireNonNull(fullyQualifiedNamespace,
"'fullyQualifiedNamespace' cannot be null and must be set via builder.fullyQualifiedNamespace(String)");

if (CoreUtils.isNullOrEmpty(fullyQualifiedNamespace)) {
throw logger.logExceptionAsError(new IllegalArgumentException(
"'fullyQualifiedNamespace' cannot be an empty string."));
}

Configuration buildConfiguration = (configuration == null)
? Configuration.getGlobalConfiguration()
: configuration;
Original file line number Diff line number Diff line change
@@ -3,11 +3,14 @@

package com.azure.data.schemaregistry;

import com.azure.core.credential.TokenCredential;
import com.azure.identity.ClientSecretCredential;
import com.azure.identity.ClientSecretCredentialBuilder;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import static org.mockito.Mockito.mock;

/**
* Unit tests for {@link SchemaRegistryClientBuilder}.
*/
@@ -31,6 +34,19 @@ public void testNullEndpoint() {
.buildAsyncClient());
}

@Test
public void testInvalidEndpoint() {
// Arrange
final TokenCredential credential = mock(TokenCredential.class);

// Act & Assert
Assertions.assertThrows(IllegalArgumentException.class,
() -> new SchemaRegistryClientBuilder()
.credential(credential)
.fullyQualifiedNamespace("")
.buildAsyncClient());
}

@Test
public void testSchemaRegistryClientCreation() {