Skip to content

Commit 4b90761

Browse files
authored
[Communication] - Identity - Functions and objects renaming (Azure#19588)
* Renaming functions * Updated changelog * Renamed recorded files * Addressed comments
1 parent 58a6584 commit 4b90761

File tree

12 files changed

+57
-50
lines changed

12 files changed

+57
-50
lines changed

sdk/communication/azure-communication-identity/CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22

33
## 1.0.0-beta.6 (2021-03-09)
44
### Added
5-
- Added a retryPolicy() chain method to the `CommunicationIdentityClientBuilder`
5+
- Added a retryPolicy() chain method to the `CommunicationIdentityClientBuilder`.
6+
7+
### Breaking
8+
- `CommunicationIdentityClient.createUserWithToken` and `CommunicationIdentityAsyncClient.createUserWithToken` have been renamed to
9+
`CommunicationIdentityClient.createUserAndToken` and `CommunicationIdentityAsyncClient.createUserAndToken`.
10+
- `CommunicationIdentityClient.createUserWithTokenWithResponse` and `CommunicationIdentityAsyncClient.createUserWithTokenWithResponse` have been renamed to
11+
`CommunicationIdentityClient.createUserAndTokenWithResponse` and `CommunicationIdentityAsyncClient.createUserAndTokenWithResponse`.
12+
- `CommunicationUserIdentifierWithTokenResult` class has been renamed to `CommunicationUserIdentifierAndTokenResult`.
613

714
## 1.0.0-beta.5 (2021-03-02)
815
### Breaking

sdk/communication/azure-communication-identity/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ CommunicationUserIdentifier user = communicationIdentityClient.createUser();
9898
System.out.println("User id: " + user.getId());
9999
```
100100

101-
Alternatively, use the `createUserWithToken` function to create a new user and issue a token for it.
101+
Alternatively, use the `createUserAndToken` function to create a new user and issue a token for it.
102102
For this option, a list of communication tokens scopes must be defined.
103103
<!-- embedme ./src/samples/java/com/azure/communication/identity/ReadmeSamples.java#L101-L107 -->
104104
```java
105105
// Define a list of communication token scopes
106106
List<CommunicationTokenScope> scopes =
107107
new ArrayList<>(Arrays.asList(CommunicationTokenScope.CHAT));
108108

109-
CommunicationUserIdentifierWithTokenResult result = communicationIdentityClient.createUserWithToken(scopes);
109+
CommunicationUserIdentifierAndTokenResult result = communicationIdentityClient.createUserAndToken(scopes);
110110
System.out.println("User id: " + result.getUser().getId());
111111
System.out.println("User token value: " + result.getUserToken().getToken());
112112
```

sdk/communication/azure-communication-identity/src/main/java/com/azure/communication/identity/CommunicationIdentityAsyncClient.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import com.azure.communication.identity.implementation.models.CommunicationIdentityAccessTokenResult;
1111
import com.azure.communication.identity.implementation.models.CommunicationIdentityCreateRequest;
1212
import com.azure.communication.identity.models.CommunicationTokenScope;
13-
import com.azure.communication.identity.models.CommunicationUserIdentifierWithTokenResult;
13+
import com.azure.communication.identity.models.CommunicationUserIdentifierAndTokenResult;
1414
import com.azure.communication.common.CommunicationUserIdentifier;
1515
import com.azure.core.annotation.ReturnType;
1616
import com.azure.core.annotation.ServiceClient;
@@ -90,8 +90,8 @@ public Mono<Response<CommunicationUserIdentifier>> createUserWithResponse() {
9090
* @return the result with created communication user and token.
9191
*/
9292
@ServiceMethod(returns = ReturnType.SINGLE)
93-
public Mono<CommunicationUserIdentifierWithTokenResult>
94-
createUserWithToken(Iterable<CommunicationTokenScope> scopes) {
93+
public Mono<CommunicationUserIdentifierAndTokenResult>
94+
createUserAndToken(Iterable<CommunicationTokenScope> scopes) {
9595
try {
9696
Objects.requireNonNull(scopes);
9797
final List<CommunicationTokenScope> scopesInput = StreamSupport.stream(scopes.spliterator(), false).collect(Collectors.toList());
@@ -112,16 +112,16 @@ public Mono<Response<CommunicationUserIdentifier>> createUserWithResponse() {
112112
* @return the result with created communication user and token with response.
113113
*/
114114
@ServiceMethod(returns = ReturnType.SINGLE)
115-
public Mono<Response<CommunicationUserIdentifierWithTokenResult>>
116-
createUserWithTokenWithResponse(Iterable<CommunicationTokenScope> scopes) {
115+
public Mono<Response<CommunicationUserIdentifierAndTokenResult>>
116+
createUserAndTokenWithResponse(Iterable<CommunicationTokenScope> scopes) {
117117
try {
118118
Objects.requireNonNull(scopes);
119119
final List<CommunicationTokenScope> scopesInput = StreamSupport.stream(scopes.spliterator(), false).collect(Collectors.toList());
120120
return client.createWithResponseAsync(
121121
new CommunicationIdentityCreateRequest().setCreateTokenWithScopes(scopesInput))
122122
.flatMap(
123123
(Response<CommunicationIdentityAccessTokenResult> response) -> {
124-
return Mono.just(new SimpleResponse<CommunicationUserIdentifierWithTokenResult>(response,
124+
return Mono.just(new SimpleResponse<CommunicationUserIdentifierAndTokenResult>(response,
125125
userWithAccessTokenResultConverter(response.getValue())));
126126
});
127127
} catch (RuntimeException ex) {
@@ -245,18 +245,18 @@ public Mono<Response<AccessToken>> getTokenWithResponse(CommunicationUserIdentif
245245
}
246246

247247
/**
248-
* Converts CommunicationIdentityAccessTokenResult to CommunicationUserIdentifierWithTokenResult
248+
* Converts CommunicationIdentityAccessTokenResult to CommunicationUserIdentifierAndTokenResult
249249
*
250250
* @param identityAccessTokenResult The result input.
251-
* @return the result converted to CommunicationUserIdentifierWithTokenResult type
251+
* @return the result converted to CommunicationUserIdentifierAndTokenResult type
252252
*/
253-
private CommunicationUserIdentifierWithTokenResult userWithAccessTokenResultConverter(
253+
private CommunicationUserIdentifierAndTokenResult userWithAccessTokenResultConverter(
254254
CommunicationIdentityAccessTokenResult identityAccessTokenResult) {
255255
CommunicationUserIdentifier user =
256256
new CommunicationUserIdentifier(identityAccessTokenResult.getIdentity().getId());
257257
AccessToken token = new AccessToken(
258258
identityAccessTokenResult.getAccessToken().getToken(),
259259
identityAccessTokenResult.getAccessToken().getExpiresOn());
260-
return new CommunicationUserIdentifierWithTokenResult(user, token);
260+
return new CommunicationUserIdentifierAndTokenResult(user, token);
261261
}
262262
}

sdk/communication/azure-communication-identity/src/main/java/com/azure/communication/identity/CommunicationIdentityClient.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import com.azure.communication.identity.implementation.models.CommunicationIdentityAccessTokenResult;
1616
import com.azure.communication.identity.implementation.models.CommunicationIdentityCreateRequest;
1717
import com.azure.communication.identity.models.CommunicationTokenScope;
18-
import com.azure.communication.identity.models.CommunicationUserIdentifierWithTokenResult;
18+
import com.azure.communication.identity.models.CommunicationUserIdentifierAndTokenResult;
1919
import com.azure.communication.common.CommunicationUserIdentifier;
2020
import com.azure.core.annotation.ReturnType;
2121
import com.azure.core.annotation.ServiceClient;
@@ -79,7 +79,7 @@ public Response<CommunicationUserIdentifier> createUserWithResponse(Context cont
7979
* @return the result with created communication user and token
8080
*/
8181
@ServiceMethod(returns = ReturnType.SINGLE)
82-
public CommunicationUserIdentifierWithTokenResult createUserWithToken(
82+
public CommunicationUserIdentifierAndTokenResult createUserAndToken(
8383
Iterable<CommunicationTokenScope> scopes) {
8484
Objects.requireNonNull(scopes);
8585
final List<CommunicationTokenScope> scopesInput = StreamSupport.stream(scopes.spliterator(), false).collect(Collectors.toList());
@@ -96,7 +96,7 @@ public CommunicationUserIdentifierWithTokenResult createUserWithToken(
9696
* @return the result with created communication user and token
9797
*/
9898
@ServiceMethod(returns = ReturnType.SINGLE)
99-
public Response<CommunicationUserIdentifierWithTokenResult> createUserWithTokenWithResponse(
99+
public Response<CommunicationUserIdentifierAndTokenResult> createUserAndTokenWithResponse(
100100
Iterable<CommunicationTokenScope> scopes, Context context) {
101101
Objects.requireNonNull(scopes);
102102
context = context == null ? Context.NONE : context;
@@ -107,7 +107,7 @@ public Response<CommunicationUserIdentifierWithTokenResult> createUserWithTokenW
107107
if (response == null || response.getValue() == null) {
108108
throw logger.logExceptionAsError(new IllegalStateException("Service failed to return a response or expected value."));
109109
}
110-
return new SimpleResponse<CommunicationUserIdentifierWithTokenResult>(
110+
return new SimpleResponse<CommunicationUserIdentifierAndTokenResult>(
111111
response,
112112
userWithAccessTokenResultConverter(response.getValue()));
113113
}
@@ -215,14 +215,14 @@ public Response<AccessToken> getTokenWithResponse(CommunicationUserIdentifier co
215215
new AccessToken(response.getValue().getToken(), response.getValue().getExpiresOn()));
216216
}
217217

218-
private CommunicationUserIdentifierWithTokenResult userWithAccessTokenResultConverter(
218+
private CommunicationUserIdentifierAndTokenResult userWithAccessTokenResultConverter(
219219
CommunicationIdentityAccessTokenResult identityAccessTokenResult) {
220220
CommunicationUserIdentifier user =
221221
new CommunicationUserIdentifier(identityAccessTokenResult.getIdentity().getId());
222222
AccessToken token = new AccessToken(
223223
identityAccessTokenResult.getAccessToken().getToken(),
224224
identityAccessTokenResult.getAccessToken().getExpiresOn());
225-
return new CommunicationUserIdentifierWithTokenResult(user, token);
225+
return new CommunicationUserIdentifierAndTokenResult(user, token);
226226

227227
}
228228
}

sdk/communication/azure-communication-identity/src/main/java/com/azure/communication/identity/models/CommunicationUserIdentifierWithTokenResult.java renamed to sdk/communication/azure-communication-identity/src/main/java/com/azure/communication/identity/models/CommunicationUserIdentifierAndTokenResult.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66
import com.azure.core.credential.AccessToken;
77

88
/** The CommunicationUserIdentifierWithAccessTokenResult model. */
9-
public final class CommunicationUserIdentifierWithTokenResult {
9+
public final class CommunicationUserIdentifierAndTokenResult {
1010

1111
private final CommunicationUserIdentifier communicationUser;
1212
private final AccessToken userToken;
1313

1414
/**
15-
* Creates a CommunicationUserIdentifierWithTokenResult object
15+
* Creates a CommunicationUserIdentifierAndTokenResult object
1616
*
1717
* @param communicationUser the communication user identifier
1818
* @param userToken the user token of the communication user
1919
* @throws IllegalArgumentException thrown if id parameter fail the validation.
2020
*/
21-
public CommunicationUserIdentifierWithTokenResult(CommunicationUserIdentifier communicationUser,
21+
public CommunicationUserIdentifierAndTokenResult(CommunicationUserIdentifier communicationUser,
2222
AccessToken userToken) {
2323
this.communicationUser = communicationUser;
2424
this.userToken = userToken;

sdk/communication/azure-communication-identity/src/samples/java/com/azure/communication/identity/ReadmeSamples.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import com.azure.communication.common.CommunicationUserIdentifier;
1010
import com.azure.communication.identity.models.CommunicationTokenScope;
11-
import com.azure.communication.identity.models.CommunicationUserIdentifierWithTokenResult;
11+
import com.azure.communication.identity.models.CommunicationUserIdentifierAndTokenResult;
1212
import com.azure.core.credential.AccessToken;
1313
import com.azure.core.credential.AzureKeyCredential;
1414
import com.azure.core.http.HttpClient;
@@ -96,13 +96,13 @@ public CommunicationUserIdentifier createNewUser() {
9696
*
9797
* @return the result with the created user and token
9898
*/
99-
public CommunicationUserIdentifierWithTokenResult createNewUserWithToken() {
99+
public CommunicationUserIdentifierAndTokenResult createNewUserAndToken() {
100100
CommunicationIdentityClient communicationIdentityClient = createCommunicationIdentityClient();
101101
// Define a list of communication token scopes
102102
List<CommunicationTokenScope> scopes =
103103
new ArrayList<>(Arrays.asList(CommunicationTokenScope.CHAT));
104104

105-
CommunicationUserIdentifierWithTokenResult result = communicationIdentityClient.createUserWithToken(scopes);
105+
CommunicationUserIdentifierAndTokenResult result = communicationIdentityClient.createUserAndToken(scopes);
106106
System.out.println("User id: " + result.getUser().getId());
107107
System.out.println("User token value: " + result.getUserToken().getToken());
108108
return result;

sdk/communication/azure-communication-identity/src/test/java/com/azure/communication/identity/CommunicationIdentityAsyncTests.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import com.azure.communication.common.CommunicationUserIdentifier;
1313
import com.azure.communication.identity.models.CommunicationTokenScope;
14-
import com.azure.communication.identity.models.CommunicationUserIdentifierWithTokenResult;
14+
import com.azure.communication.identity.models.CommunicationUserIdentifierAndTokenResult;
1515
import com.azure.core.credential.AccessToken;
1616
import com.azure.core.http.HttpClient;
1717
import com.azure.core.http.rest.Response;
@@ -102,15 +102,15 @@ public void createUserWithResponse(HttpClient httpClient) {
102102

103103
@ParameterizedTest
104104
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
105-
public void createUserWithToken(HttpClient httpClient) {
105+
public void createUserAndToken(HttpClient httpClient) {
106106
// Arrange
107107
CommunicationIdentityClientBuilder builder = getCommunicationIdentityClient(httpClient);
108-
asyncClient = setupAsyncClient(builder, "createUserWithToken");
108+
asyncClient = setupAsyncClient(builder, "createUserAndToken");
109109
List<CommunicationTokenScope> scopes = Arrays.asList(CommunicationTokenScope.CHAT);
110110

111111
// Action & Assert
112-
Mono<CommunicationUserIdentifierWithTokenResult> createUserWithToken = asyncClient.createUserWithToken(scopes);
113-
StepVerifier.create(createUserWithToken)
112+
Mono<CommunicationUserIdentifierAndTokenResult> createUserAndToken = asyncClient.createUserAndToken(scopes);
113+
StepVerifier.create(createUserAndToken)
114114
.assertNext(result -> {
115115
assertNotNull(result.getUserToken());
116116
assertNotNull(result.getUser());
@@ -120,16 +120,16 @@ public void createUserWithToken(HttpClient httpClient) {
120120

121121
@ParameterizedTest
122122
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
123-
public void createUserWithTokenWithResponse(HttpClient httpClient) {
123+
public void createUserAndTokenWithResponse(HttpClient httpClient) {
124124
// Arrange
125125
CommunicationIdentityClientBuilder builder = getCommunicationIdentityClient(httpClient);
126-
asyncClient = setupAsyncClient(builder, "createUserWithTokenWithResponse");
126+
asyncClient = setupAsyncClient(builder, "createUserAndTokenWithResponse");
127127
List<CommunicationTokenScope> scopes = Arrays.asList(CommunicationTokenScope.CHAT);
128128

129129
// Action & Assert
130-
Mono<Response<CommunicationUserIdentifierWithTokenResult>> createUserWithToken =
131-
asyncClient.createUserWithTokenWithResponse(scopes);
132-
StepVerifier.create(createUserWithToken)
130+
Mono<Response<CommunicationUserIdentifierAndTokenResult>> createUserAndToken =
131+
asyncClient.createUserAndTokenWithResponse(scopes);
132+
StepVerifier.create(createUserAndToken)
133133
.assertNext(result -> {
134134
assertEquals(201, result.getStatusCode());
135135
assertNotNull(result.getValue().getUserToken());
@@ -140,27 +140,27 @@ public void createUserWithTokenWithResponse(HttpClient httpClient) {
140140

141141
@ParameterizedTest
142142
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
143-
public void createUserWithTokenNullScopes(HttpClient httpClient) {
143+
public void createUserAndTokenNullScopes(HttpClient httpClient) {
144144
// Arrange
145145
CommunicationIdentityClientBuilder builder = getCommunicationIdentityClient(httpClient);
146-
asyncClient = setupAsyncClient(builder, "createUserWithTokenNullScopes");
146+
asyncClient = setupAsyncClient(builder, "createUserAndTokenNullScopes");
147147

148148
// Action & Assert
149149
StepVerifier.create(
150-
asyncClient.createUserWithToken(null))
150+
asyncClient.createUserAndToken(null))
151151
.verifyError(NullPointerException.class);
152152
}
153153

154154
@ParameterizedTest
155155
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
156-
public void createUserWithTokenWithResponseNullScopes(HttpClient httpClient) {
156+
public void createUserAndTokenWithResponseNullScopes(HttpClient httpClient) {
157157
// Arrange
158158
CommunicationIdentityClientBuilder builder = getCommunicationIdentityClient(httpClient);
159-
asyncClient = setupAsyncClient(builder, "createUserWithTokenWithResponseNullScopes");
159+
asyncClient = setupAsyncClient(builder, "createUserAndTokenWithResponseNullScopes");
160160

161161
// Action & Assert
162162
StepVerifier.create(
163-
asyncClient.createUserWithTokenWithResponse(null))
163+
asyncClient.createUserAndTokenWithResponse(null))
164164
.verifyError(NullPointerException.class);
165165
}
166166

sdk/communication/azure-communication-identity/src/test/java/com/azure/communication/identity/CommunicationIdentityTests.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import com.azure.communication.common.CommunicationUserIdentifier;
1313
import com.azure.communication.identity.models.CommunicationTokenScope;
14-
import com.azure.communication.identity.models.CommunicationUserIdentifierWithTokenResult;
14+
import com.azure.communication.identity.models.CommunicationUserIdentifierAndTokenResult;
1515
import com.azure.core.credential.AccessToken;
1616
import com.azure.core.http.HttpClient;
1717
import com.azure.core.http.rest.Response;
@@ -86,30 +86,30 @@ public void createUserWithResponse(HttpClient httpClient) {
8686

8787
@ParameterizedTest
8888
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
89-
public void createUserWithToken(HttpClient httpClient) {
89+
public void createUserAndToken(HttpClient httpClient) {
9090
// Arrange
9191
CommunicationIdentityClientBuilder builder = getCommunicationIdentityClient(httpClient);
92-
client = setupClient(builder, "createUserWithTokenSync");
92+
client = setupClient(builder, "createUserAndTokenSync");
9393
List<CommunicationTokenScope> scopes = Arrays.asList(CommunicationTokenScope.CHAT);
9494

9595
// Action & Assert
96-
CommunicationUserIdentifierWithTokenResult result = client.createUserWithToken(scopes);
96+
CommunicationUserIdentifierAndTokenResult result = client.createUserAndToken(scopes);
9797
assertNotNull(result.getUser().getId());
9898
assertNotNull(result.getUserToken());
9999
assertFalse(result.getUser().getId().isEmpty());
100100
}
101101

102102
@ParameterizedTest
103103
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
104-
public void createUserWithTokenWithResponse(HttpClient httpClient) {
104+
public void createUserAndTokenWithResponse(HttpClient httpClient) {
105105
// Arrange
106106
CommunicationIdentityClientBuilder builder = getCommunicationIdentityClient(httpClient);
107-
client = setupClient(builder, "createUserWithTokenWithResponseSync");
107+
client = setupClient(builder, "createUserAndTokenWithResponseSync");
108108
List<CommunicationTokenScope> scopes = Arrays.asList(CommunicationTokenScope.CHAT);
109109
// Action & Assert
110-
Response<CommunicationUserIdentifierWithTokenResult> response =
111-
client.createUserWithTokenWithResponse(scopes, Context.NONE);
112-
CommunicationUserIdentifierWithTokenResult result = response.getValue();
110+
Response<CommunicationUserIdentifierAndTokenResult> response =
111+
client.createUserAndTokenWithResponse(scopes, Context.NONE);
112+
CommunicationUserIdentifierAndTokenResult result = response.getValue();
113113
assertEquals(201, response.getStatusCode());
114114
assertNotNull(result.getUser().getId());
115115
assertNotNull(result.getUserToken());

sdk/communication/azure-communication-identity/src/test/resources/session-records/createUserWithToken.json renamed to sdk/communication/azure-communication-identity/src/test/resources/session-records/createUserAndToken.json

File renamed without changes.

sdk/communication/azure-communication-identity/src/test/resources/session-records/createUserWithTokenNullScopes.json renamed to sdk/communication/azure-communication-identity/src/test/resources/session-records/createUserAndTokenNullScopes.json

File renamed without changes.

0 commit comments

Comments
 (0)