Search in sources :

Example 1 with CommunicationIdentifierModel

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());
}
Also used : MicrosoftTeamsUserIdentifier(com.azure.android.communication.common.MicrosoftTeamsUserIdentifier) MicrosoftTeamsUserIdentifierModel(com.azure.android.communication.chat.implementation.models.MicrosoftTeamsUserIdentifierModel) CommunicationIdentifierModel(com.azure.android.communication.chat.implementation.models.CommunicationIdentifierModel) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with CommunicationIdentifierModel

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());
}
Also used : CommunicationUserIdentifierModel(com.azure.android.communication.chat.implementation.models.CommunicationUserIdentifierModel) CommunicationIdentifier(com.azure.android.communication.common.CommunicationIdentifier) CommunicationIdentifierModel(com.azure.android.communication.chat.implementation.models.CommunicationIdentifierModel) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with CommunicationIdentifierModel

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());
}
Also used : PhoneNumberIdentifier(com.azure.android.communication.common.PhoneNumberIdentifier) CommunicationIdentifierModel(com.azure.android.communication.chat.implementation.models.CommunicationIdentifierModel) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with CommunicationIdentifierModel

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());
}
Also used : CommunicationIdentifier(com.azure.android.communication.common.CommunicationIdentifier) PhoneNumberIdentifierModel(com.azure.android.communication.chat.implementation.models.PhoneNumberIdentifierModel) CommunicationIdentifierModel(com.azure.android.communication.chat.implementation.models.CommunicationIdentifierModel) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with CommunicationIdentifierModel

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);
        });
    });
}
Also used : CommunicationUserIdentifierModel(com.azure.android.communication.chat.implementation.models.CommunicationUserIdentifierModel) PhoneNumberIdentifierModel(com.azure.android.communication.chat.implementation.models.PhoneNumberIdentifierModel) MicrosoftTeamsUserIdentifierModel(com.azure.android.communication.chat.implementation.models.MicrosoftTeamsUserIdentifierModel) CommunicationIdentifierModel(com.azure.android.communication.chat.implementation.models.CommunicationIdentifierModel) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

CommunicationIdentifierModel (com.azure.android.communication.chat.implementation.models.CommunicationIdentifierModel)11 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)10 Test (org.junit.jupiter.api.Test)8 CommunicationUserIdentifierModel (com.azure.android.communication.chat.implementation.models.CommunicationUserIdentifierModel)4 MicrosoftTeamsUserIdentifierModel (com.azure.android.communication.chat.implementation.models.MicrosoftTeamsUserIdentifierModel)3 PhoneNumberIdentifierModel (com.azure.android.communication.chat.implementation.models.PhoneNumberIdentifierModel)3 CommunicationIdentifier (com.azure.android.communication.common.CommunicationIdentifier)3 MicrosoftTeamsUserIdentifier (com.azure.android.communication.common.MicrosoftTeamsUserIdentifier)2 ValueSource (org.junit.jupiter.params.provider.ValueSource)2 ChatParticipant (com.azure.android.communication.chat.implementation.models.ChatParticipant)1 CommunicationUserIdentifier (com.azure.android.communication.common.CommunicationUserIdentifier)1 PhoneNumberIdentifier (com.azure.android.communication.common.PhoneNumberIdentifier)1 UnknownIdentifier (com.azure.android.communication.common.UnknownIdentifier)1