Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions sdk/communication/azure-communication-administration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
<properties>
<src.dir>src/main</src.dir>
<test.dir>src/test</test.dir>
<jacoco.min.branchcoverage>0.10</jacoco.min.branchcoverage>
<jacoco.min.linecoverage>0.10</jacoco.min.linecoverage>
<jacoco.min.linecoverage>0.85</jacoco.min.linecoverage>
<jacoco.min.branchcoverage>0.70</jacoco.min.branchcoverage>
</properties>

<dependencies>
Expand Down Expand Up @@ -122,8 +122,8 @@
<version>0.8.5</version> <!-- {x-version-update;org.jacoco:jacoco-maven-plugin;external_dependency} -->
<configuration>
<excludes>
<exclude>com/azure/communication/administration/models/**/*</exclude>
<exclude>com/azure/communication/administration/implementation/**/*</exclude>
<exclude>com/azure/communication/**/models/**/*</exclude>
<exclude>com/azure/communication/**/implementation/**/*</exclude>
</excludes>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import java.time.OffsetDateTime;
import java.util.List;
import java.util.Objects;

import reactor.core.publisher.Mono;

import static com.azure.core.util.FluxUtil.monoError;
Expand Down Expand Up @@ -103,6 +105,7 @@ public Mono<Response<CommunicationUser>> createUser(Context context) {
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Void> deleteUser(CommunicationUser communicationUser) {
try {
Objects.requireNonNull(communicationUser);
return withContext(context -> deleteUser(communicationUser, context)
.flatMap(
(Response<Void> res) -> {
Expand All @@ -122,6 +125,7 @@ public Mono<Void> deleteUser(CommunicationUser communicationUser) {
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Void>> deleteUserWithResponse(CommunicationUser communicationUser) {
try {
Objects.requireNonNull(communicationUser);
return withContext(context -> deleteUser(communicationUser, context));
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand Down Expand Up @@ -151,6 +155,7 @@ public Mono<Response<Void>> deleteUser(CommunicationUser communicationUser, Cont
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Void> revokeTokens(CommunicationUser communicationUser, OffsetDateTime issuedBefore) {
try {
Objects.requireNonNull(communicationUser);
return withContext(context -> revokeTokens(communicationUser, issuedBefore, context)
.flatMap(
(Response<Void> res) -> {
Expand All @@ -172,6 +177,7 @@ public Mono<Void> revokeTokens(CommunicationUser communicationUser, OffsetDateTi
public Mono<Response<Void>> revokeTokensWithResponse(
CommunicationUser communicationUser, OffsetDateTime issuedBefore) {
try {
Objects.requireNonNull(communicationUser);
return withContext(context -> revokeTokens(communicationUser, issuedBefore, context));
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand Down Expand Up @@ -208,6 +214,8 @@ public Mono<Response<Void>> revokeTokens(
public Mono<CommunicationUserToken> issueToken(
CommunicationUser communicationUser, List<String> scopes) {
try {
Objects.requireNonNull(communicationUser);
Objects.requireNonNull(scopes);
return withContext(context -> issueToken(communicationUser, scopes, context)
.flatMap(
(Response<CommunicationUserToken> res) -> {
Expand All @@ -232,6 +240,8 @@ public Mono<CommunicationUserToken> issueToken(
public Mono<Response<CommunicationUserToken>> issueTokenWithResponse(
CommunicationUser communicationUser, List<String> scopes) {
try {
Objects.requireNonNull(communicationUser);
Objects.requireNonNull(scopes);
return withContext(context -> issueToken(communicationUser, scopes, context));
} catch (RuntimeException ex) {
return monoError(logger, ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ public Mono<Response<AreaCodes>> getAllAreaCodesWithResponse(
Mono<Response<AreaCodes>> getAllAreaCodesWithResponse(
String locationType, String countryCode, String phonePlanId, List<LocationOptionsQuery> locationOptions,
Context context) {
Objects.requireNonNull(locationType, "'locationType' cannot be null.");
Objects.requireNonNull(countryCode, "'countryCode' cannot be null.");
Objects.requireNonNull(phonePlanId, "'phonePlanId' cannot be null.");

LocationOptionsQueries locationOptionsQueries = new LocationOptionsQueries();
locationOptionsQueries.setLocationOptions(locationOptions);

try {
Objects.requireNonNull(locationType, "'locationType' cannot be null.");
Objects.requireNonNull(countryCode, "'countryCode' cannot be null.");
Objects.requireNonNull(phonePlanId, "'phonePlanId' cannot be null.");
if (context == null) {
return phoneNumberAdministrations.getAllAreaCodesWithResponseAsync(
locationType, countryCode, phonePlanId, locationOptionsQueries);
Expand Down Expand Up @@ -173,9 +173,8 @@ public Mono<Response<UpdatePhoneNumberCapabilitiesResponse>> getCapabilitiesUpda

Mono<Response<UpdatePhoneNumberCapabilitiesResponse>> getCapabilitiesUpdateWithResponse(
String capabilitiesId, Context context) {
Objects.requireNonNull(capabilitiesId, "'capabilitiesId' cannot be null.");

try {
Objects.requireNonNull(capabilitiesId, "'capabilitiesId' cannot be null.");
if (context == null) {
return phoneNumberAdministrations.getCapabilitiesUpdateWithResponseAsync(capabilitiesId);
} else {
Expand Down Expand Up @@ -214,17 +213,15 @@ public Mono<Response<UpdateNumberCapabilitiesResponse>> updateCapabilitiesWithRe

Mono<Response<UpdateNumberCapabilitiesResponse>> updateCapabilitiesWithResponse(
Map<PhoneNumber, NumberUpdateCapabilities> phoneNumberCapabilitiesUpdate, Context context) {
Objects.requireNonNull(phoneNumberCapabilitiesUpdate, "'phoneNumberCapabilitiesUpdate' cannot be null.");

Map<String, NumberUpdateCapabilities> capabilitiesMap = new HashMap<>();
for (Map.Entry<PhoneNumber, NumberUpdateCapabilities> entry : phoneNumberCapabilitiesUpdate.entrySet()) {
capabilitiesMap.put(entry.getKey().getValue(), entry.getValue());
}

UpdateNumberCapabilitiesRequest updateNumberCapabilitiesRequest = new UpdateNumberCapabilitiesRequest();
updateNumberCapabilitiesRequest.setPhoneNumberCapabilitiesUpdate(capabilitiesMap);

try {
Objects.requireNonNull(phoneNumberCapabilitiesUpdate, "'phoneNumberCapabilitiesUpdate' cannot be null.");
Map<String, NumberUpdateCapabilities> capabilitiesMap = new HashMap<>();
for (Map.Entry<PhoneNumber, NumberUpdateCapabilities> entry : phoneNumberCapabilitiesUpdate.entrySet()) {
capabilitiesMap.put(entry.getKey().getValue(), entry.getValue());
}
UpdateNumberCapabilitiesRequest updateNumberCapabilitiesRequest = new UpdateNumberCapabilitiesRequest();
updateNumberCapabilitiesRequest.setPhoneNumberCapabilitiesUpdate(capabilitiesMap);

if (context == null) {
return phoneNumberAdministrations.updateCapabilitiesWithResponseAsync(
updateNumberCapabilitiesRequest);
Expand Down Expand Up @@ -285,12 +282,11 @@ public Mono<Response<NumberConfigurationResponse>> getNumberConfigurationWithRes

Mono<Response<NumberConfigurationResponse>> getNumberConfigurationWithResponse(
PhoneNumber phoneNumber, Context context) {
Objects.requireNonNull(phoneNumber, "'phoneNumber' cannot be null.");

NumberConfigurationPhoneNumber configurationPhoneNumber = new NumberConfigurationPhoneNumber();
configurationPhoneNumber.setPhoneNumber(phoneNumber.getValue());

try {
Objects.requireNonNull(phoneNumber, "'phoneNumber' cannot be null.");
NumberConfigurationPhoneNumber configurationPhoneNumber = new NumberConfigurationPhoneNumber();
configurationPhoneNumber.setPhoneNumber(phoneNumber.getValue());

if (context == null) {
return phoneNumberAdministrations.getNumberConfigurationWithResponseAsync(
configurationPhoneNumber);
Expand Down Expand Up @@ -330,13 +326,13 @@ public Mono<Response<Void>> configureNumberWithResponse(

Mono<Response<Void>> configureNumberWithResponse(
PhoneNumber phoneNumber, PstnConfiguration pstnConfiguration, Context context) {
Objects.requireNonNull(phoneNumber, "'phoneNumber' cannot be null.");
Objects.requireNonNull(pstnConfiguration, "'pstnConfiguration' cannot be null.");

NumberConfiguration numberConfiguration = new NumberConfiguration();
numberConfiguration.setPhoneNumber(phoneNumber.getValue()).setPstnConfiguration(pstnConfiguration);

try {
Objects.requireNonNull(phoneNumber, "'phoneNumber' cannot be null.");
Objects.requireNonNull(pstnConfiguration, "'pstnConfiguration' cannot be null.");

NumberConfiguration numberConfiguration = new NumberConfiguration();
numberConfiguration.setPhoneNumber(phoneNumber.getValue()).setPstnConfiguration(pstnConfiguration);

if (context == null) {
return phoneNumberAdministrations.configureNumberWithResponseAsync(numberConfiguration);
} else {
Expand Down Expand Up @@ -370,11 +366,11 @@ public Mono<Response<Void>> unconfigureNumberWithResponse(PhoneNumber phoneNumbe
}

Mono<Response<Void>> unconfigureNumberWithResponse(PhoneNumber phoneNumber, Context context) {
Objects.requireNonNull(phoneNumber, "'phoneNumber' cannot be null.");
NumberConfigurationPhoneNumber configurationPhoneNumber = new NumberConfigurationPhoneNumber();
configurationPhoneNumber.setPhoneNumber(phoneNumber.getValue());

try {
Objects.requireNonNull(phoneNumber, "'phoneNumber' cannot be null.");
NumberConfigurationPhoneNumber configurationPhoneNumber = new NumberConfigurationPhoneNumber();
configurationPhoneNumber.setPhoneNumber(phoneNumber.getValue());

if (context == null) {
return phoneNumberAdministrations.unconfigureNumberWithResponseAsync(configurationPhoneNumber);
} else {
Expand All @@ -401,9 +397,8 @@ public PagedFlux<PhonePlanGroup> listPhonePlanGroups(

PagedFlux<PhonePlanGroup> listPhonePlanGroups(
String countryCode, String locale, Boolean includeRateInformation, Context context) {
Objects.requireNonNull(countryCode, "'countryCode' cannot be null.");

try {
Objects.requireNonNull(countryCode, "'countryCode' cannot be null.");
if (context == null) {
return phoneNumberAdministrations.getPhonePlanGroupsAsync(
countryCode, locale, includeRateInformation, null, null);
Expand All @@ -430,10 +425,9 @@ public PagedFlux<PhonePlan> listPhonePlans(String countryCode, String phonePlanG
}

PagedFlux<PhonePlan> listPhonePlans(String countryCode, String phonePlanGroupId, String locale, Context context) {
Objects.requireNonNull(countryCode, "'countryCode' cannot be null.");
Objects.requireNonNull(phonePlanGroupId, "'phonePlanGroupId' cannot be null.");

try {
Objects.requireNonNull(countryCode, "'countryCode' cannot be null.");
Objects.requireNonNull(phonePlanGroupId, "'phonePlanGroupId' cannot be null.");
if (context == null) {
return phoneNumberAdministrations.getPhonePlansAsync(
countryCode, phonePlanGroupId, locale, null, null);
Expand Down Expand Up @@ -481,11 +475,11 @@ public Mono<Response<LocationOptionsResponse>> getPhonePlanLocationOptionsWithRe

Mono<Response<LocationOptionsResponse>> getPhonePlanLocationOptionsWithResponse(
String countryCode, String phonePlanGroupId, String phonePlanId, String locale, Context context) {
Objects.requireNonNull(countryCode, "'countryCode' cannot be null.");
Objects.requireNonNull(phonePlanGroupId, "'phonePlanGroupId' cannot be null.");
Objects.requireNonNull(phonePlanId, "'phonePlanId' cannot be null.");

try {
Objects.requireNonNull(countryCode, "'countryCode' cannot be null.");
Objects.requireNonNull(phonePlanGroupId, "'phonePlanGroupId' cannot be null.");
Objects.requireNonNull(phonePlanId, "'phonePlanId' cannot be null.");

if (context == null) {
return phoneNumberAdministrations.getPhonePlanLocationOptionsWithResponseAsync(
countryCode, phonePlanGroupId, phonePlanId, locale);
Expand Down Expand Up @@ -522,9 +516,8 @@ public Mono<Response<PhoneNumberRelease>> getReleaseByIdWithResponse(String rele
}

Mono<Response<PhoneNumberRelease>> getReleaseByIdWithResponse(String releaseId, Context context) {
Objects.requireNonNull(releaseId, "'releaseId' cannot be null.");

try {
Objects.requireNonNull(releaseId, "'releaseId' cannot be null.");
if (context == null) {
return phoneNumberAdministrations.getReleaseByIdWithResponseAsync(releaseId);
} else {
Expand Down Expand Up @@ -621,9 +614,8 @@ public Mono<Response<PhoneNumberReservation>> getReservationByIdWithResponse(Str
}

Mono<Response<PhoneNumberReservation>> getReservationByIdWithResponse(String reservationId, Context context) {
Objects.requireNonNull(reservationId, "'ReservationId' cannot be null.");

try {
Objects.requireNonNull(reservationId, "'reservationId' cannot be null.");
if (context == null) {
return phoneNumberAdministrations.getSearchByIdWithResponseAsync(reservationId);
} else {
Expand Down Expand Up @@ -658,9 +650,9 @@ private Mono<Response<CreateReservationResponse>> createReservationWithResponse(

private Mono<Response<CreateReservationResponse>> createReservationWithResponse(
CreateReservationOptions reservationOptions, Context context) {
Objects.requireNonNull(reservationOptions, "'reservationOptions' cannot be null.");

try {
Objects.requireNonNull(reservationOptions, "'reservationOptions' cannot be null.");

if (context == null) {
return phoneNumberAdministrations.createSearchWithResponseAsync(reservationOptions);
} else {
Expand Down Expand Up @@ -716,9 +708,9 @@ public Mono<Response<Void>> cancelReservationWithResponse(String reservationId)
}

Mono<Response<Void>> cancelReservationWithResponse(String reservationId, Context context) {
Objects.requireNonNull(reservationId, "'ReservationId' cannot be null.");

try {
Objects.requireNonNull(reservationId, "'ReservationId' cannot be null.");

if (context == null) {
return phoneNumberAdministrations.cancelSearchWithResponseAsync(reservationId);
} else {
Expand Down Expand Up @@ -750,9 +742,8 @@ private Mono<Response<Void>> purchaseReservationWithResponse(String reservationI
}

private Mono<Response<Void>> purchaseReservationWithResponse(String reservationId, Context context) {
Objects.requireNonNull(reservationId, "'reservationId' cannot be null.");

try {
Objects.requireNonNull(reservationId, "'reservationId' cannot be null.");
if (context == null) {
return phoneNumberAdministrations.purchaseSearchWithResponseAsync(reservationId);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,30 @@ public void deleteUserWithResponse(HttpClient httpClient) {
.verifyComplete();
}

@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
public void deleteUserWithNullUser(HttpClient httpClient) {
// Arrange
asyncClient = getCommunicationIdentityClient(httpClient).buildAsyncClient();

// Action & Assert
StepVerifier.create(
asyncClient.deleteUser(null))
.verifyError(NullPointerException.class);
}

@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
public void deleteUserWithResponseWithNullUser(HttpClient httpClient) {
// Arrange
asyncClient = getCommunicationIdentityClient(httpClient).buildAsyncClient();

// Action & Assert
StepVerifier.create(
asyncClient.deleteUserWithResponse(null))
.verifyError(NullPointerException.class);
}

@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
public void revokeToken(HttpClient httpClient) {
Expand Down Expand Up @@ -171,6 +195,31 @@ public void revokeTokenWithResponse(HttpClient httpClient) {
.verifyComplete();
}

@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
public void revokeTokenWithNullUser(HttpClient httpClient) {
// Arrange
asyncClient = getCommunicationIdentityClient(httpClient).buildAsyncClient();

// Action & Assert
StepVerifier.create(
asyncClient.revokeTokens(null, null))
.verifyError(NullPointerException.class);
}

@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
public void revokeTokenWithResponseWithNullUser(HttpClient httpClient) {
// Arrange
asyncClient = getCommunicationIdentityClient(httpClient).buildAsyncClient();

// Action & Assert
StepVerifier.create(
asyncClient.revokeTokensWithResponse(null, null))
.verifyError(NullPointerException.class);
}


@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
public void issueToken(HttpClient httpClient) {
Expand Down Expand Up @@ -216,4 +265,41 @@ public void issueTokenWithResponse(HttpClient httpClient) {
})
.verifyComplete();
}

@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
public void issueTokenWithNullUser(HttpClient httpClient) {
// Arrange
asyncClient = getCommunicationIdentityClient(httpClient).buildAsyncClient();
List<String> scopes = new ArrayList<>(Arrays.asList("chat"));

// Action & Assert
StepVerifier.create(
asyncClient.issueToken(null, scopes))
.verifyError(NullPointerException.class);
}

@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
public void issueTokenWithNullScope(HttpClient httpClient) {
// Arrange
asyncClient = getCommunicationIdentityClient(httpClient).buildAsyncClient();

// Action & Assert
StepVerifier.create(asyncClient.issueToken(new CommunicationUser("testUser"), null))
.verifyError(NullPointerException.class);
}

@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
public void issueTokenWithResponseWithNullUser(HttpClient httpClient) {
// Arrange
asyncClient = getCommunicationIdentityClient(httpClient).buildAsyncClient();
List<String> scopes = new ArrayList<>(Arrays.asList("chat"));

// Action & Assert
StepVerifier.create(
asyncClient.issueTokenWithResponse(null, scopes))
.verifyError(NullPointerException.class);
}
}
Loading