use of com.azure.android.communication.chat.implementation.models.CommunicationIdentifierModel in project azure-sdk-for-android by Azure.
the class CommunicationIdentifierConverterTests method deserializerMicrosoftTeamsUser.
@ParameterizedTest
@ValueSource(booleans = { true, false })
public void deserializerMicrosoftTeamsUser(boolean isAnonymous) {
MicrosoftTeamsUserIdentifier identifier = (MicrosoftTeamsUserIdentifier) CommunicationIdentifierConverter.convert(new CommunicationIdentifierModel().setRawId(rawId).setMicrosoftTeamsUser(new MicrosoftTeamsUserIdentifierModel().setUserId(teamsUserId).setIsAnonymous(isAnonymous).setCloud(CommunicationCloudEnvironmentModel.GCCH)), logger);
assertEquals(MicrosoftTeamsUserIdentifier.class, identifier.getClass());
assertEquals(teamsUserId, identifier.getUserId());
assertEquals(rawId, identifier.getRawId());
assertEquals(CommunicationCloudEnvironment.GCCH, identifier.getCloudEnvironment());
assertEquals(isAnonymous, identifier.isAnonymous());
}
use of com.azure.android.communication.chat.implementation.models.CommunicationIdentifierModel 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.CommunicationIdentifierModel in project azure-sdk-for-android by Azure.
the class CommunicationIdentifierConverterTests method serializePhoneNumber.
@Test
public void serializePhoneNumber() {
final String phoneNumber = "+12223334444";
CommunicationIdentifierModel model = CommunicationIdentifierConverter.convert(new PhoneNumberIdentifier(phoneNumber).setRawId(rawId), logger);
assertNotNull(model.getPhoneNumber());
assertEquals(phoneNumber, model.getPhoneNumber().getValue());
assertEquals(rawId, model.getRawId());
}
use of com.azure.android.communication.chat.implementation.models.CommunicationIdentifierModel in project azure-sdk-for-android by Azure.
the class CommunicationIdentifierConverterTests method deserializePhoneNumber.
@Test
public void deserializePhoneNumber() {
CommunicationIdentifier identifier = CommunicationIdentifierConverter.convert(new CommunicationIdentifierModel().setRawId(rawId).setPhoneNumber(new PhoneNumberIdentifierModel().setValue(testPhoneNumber)), logger);
assertEquals(PhoneNumberIdentifier.class, identifier.getClass());
assertEquals(testPhoneNumber, ((PhoneNumberIdentifier) identifier).getPhoneNumber());
assertEquals(rawId, ((PhoneNumberIdentifier) identifier).getRawId());
}
use of com.azure.android.communication.chat.implementation.models.CommunicationIdentifierModel 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);
});
});
}
Aggregations