use of com.azure.android.communication.chat.implementation.models.CommunicationUserIdentifierModel in project azure-sdk-for-android by Azure.
the class CommunicationIdentifierConverter method assertSingleType.
private static void assertSingleType(CommunicationIdentifierModel identifier) {
CommunicationUserIdentifierModel communicationUser = identifier.getCommunicationUser();
PhoneNumberIdentifierModel phoneNumber = identifier.getPhoneNumber();
MicrosoftTeamsUserIdentifierModel microsoftTeamsUser = identifier.getMicrosoftTeamsUser();
ArrayList<String> presentProperties = new ArrayList<String>();
if (communicationUser != null) {
presentProperties.add(communicationUser.getClass().getName());
}
if (phoneNumber != null) {
presentProperties.add(phoneNumber.getClass().getName());
}
if (microsoftTeamsUser != null) {
presentProperties.add(microsoftTeamsUser.getClass().getName());
}
if (presentProperties.size() > 1) {
throw new IllegalArgumentException(String.format("Only one of the identifier models in %s should be present.", TextUtils.join(", ", presentProperties)));
}
}
use of com.azure.android.communication.chat.implementation.models.CommunicationUserIdentifierModel in project azure-sdk-for-android by Azure.
the class CommunicationIdentifierConverterTests method deserializeCommunicationUser.
@Test
public void deserializeCommunicationUser() {
CommunicationIdentifier identifier = CommunicationIdentifierConverter.convert(new CommunicationIdentifierModel().setCommunicationUser(new CommunicationUserIdentifierModel().setId(someId)), logger);
assertEquals(identifier.getClass(), CommunicationUserIdentifier.class);
assertEquals(someId, ((CommunicationUserIdentifier) identifier).getId());
}
use of com.azure.android.communication.chat.implementation.models.CommunicationUserIdentifierModel in project azure-sdk-for-android by Azure.
the class CommunicationIdentifierConverterTests method deserializerThrowsWhenMissingProperty.
@Test
public void deserializerThrowsWhenMissingProperty() {
CommunicationIdentifierModel[] modelsWithMissingMandatoryProperty = new CommunicationIdentifierModel[] { // Missing RawId
new CommunicationIdentifierModel(), // Missing Id
new CommunicationIdentifierModel().setRawId(rawId).setCommunicationUser(new CommunicationUserIdentifierModel()), // Missing PhoneNumber
new CommunicationIdentifierModel().setRawId(rawId).setPhoneNumber(new PhoneNumberIdentifierModel()), new CommunicationIdentifierModel().setRawId(rawId).setMicrosoftTeamsUser(// Missing userId
new MicrosoftTeamsUserIdentifierModel().setCloud(CommunicationCloudEnvironmentModel.PUBLIC)), new CommunicationIdentifierModel().setRawId(rawId).setMicrosoftTeamsUser(// Missing UserId
new MicrosoftTeamsUserIdentifierModel().setIsAnonymous(true).setCloud(CommunicationCloudEnvironmentModel.DOD)), new CommunicationIdentifierModel().setRawId(rawId).setMicrosoftTeamsUser(new MicrosoftTeamsUserIdentifierModel().setUserId(teamsUserId).setIsAnonymous(true)) };
Arrays.stream(modelsWithMissingMandatoryProperty).forEach(identifierModel -> {
assertThrows(NullPointerException.class, () -> {
CommunicationIdentifierConverter.convert(identifierModel, logger);
});
});
}
use of com.azure.android.communication.chat.implementation.models.CommunicationUserIdentifierModel in project azure-sdk-for-android by Azure.
the class CommunicationIdentifierConverterTests method deserializerThrowsWhenMoreThanOneNestedObjectsSet.
@Test
public void deserializerThrowsWhenMoreThanOneNestedObjectsSet() {
CommunicationIdentifierModel[] modelsWithTooManyNestedObjects = new CommunicationIdentifierModel[] { new CommunicationIdentifierModel().setRawId(rawId).setCommunicationUser(new CommunicationUserIdentifierModel().setId(someId)).setPhoneNumber(new PhoneNumberIdentifierModel().setValue(testPhoneNumber)), new CommunicationIdentifierModel().setRawId(rawId).setCommunicationUser(new CommunicationUserIdentifierModel().setId(someId)).setMicrosoftTeamsUser(new MicrosoftTeamsUserIdentifierModel().setUserId(teamsUserId).setIsAnonymous(true).setCloud(CommunicationCloudEnvironmentModel.PUBLIC)), new CommunicationIdentifierModel().setRawId(rawId).setPhoneNumber(new PhoneNumberIdentifierModel().setValue(testPhoneNumber)).setMicrosoftTeamsUser(new MicrosoftTeamsUserIdentifierModel().setUserId(teamsUserId).setIsAnonymous(true).setCloud(CommunicationCloudEnvironmentModel.PUBLIC)) };
Arrays.stream(modelsWithTooManyNestedObjects).forEach(identifierModel -> {
assertThrows(IllegalArgumentException.class, () -> {
CommunicationIdentifierConverter.convert(identifierModel, logger);
});
});
}
use of com.azure.android.communication.chat.implementation.models.CommunicationUserIdentifierModel in project azure-sdk-for-android by Azure.
the class ChatImplClientTestBase method generateParticipant.
private static ChatParticipant generateParticipant(String id, String displayName) {
ChatParticipant chatParticipant = new ChatParticipant();
chatParticipant.setCommunicationIdentifier(new CommunicationIdentifierModel().setCommunicationUser(new CommunicationUserIdentifierModel().setId(id)));
chatParticipant.setDisplayName(displayName);
return chatParticipant;
}
Aggregations