Search in sources :

Example 6 with CommunicationIdentifierModel

use of com.azure.android.communication.chat.implementation.models.CommunicationIdentifierModel in project azure-sdk-for-android by Azure.

the class CommunicationIdentifierConverterTests method serializeUnknown.

@Test
public void serializeUnknown() {
    CommunicationIdentifierModel model = CommunicationIdentifierConverter.convert(new UnknownIdentifier(someId), logger);
    assertEquals(someId, model.getRawId());
}
Also used : UnknownIdentifier(com.azure.android.communication.common.UnknownIdentifier) CommunicationIdentifierModel(com.azure.android.communication.chat.implementation.models.CommunicationIdentifierModel) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with CommunicationIdentifierModel

use of com.azure.android.communication.chat.implementation.models.CommunicationIdentifierModel in project azure-sdk-for-android by Azure.

the class CommunicationIdentifierConverterTests method serializeCommunicationUser.

@Test
public void serializeCommunicationUser() {
    CommunicationIdentifierModel model = CommunicationIdentifierConverter.convert(new CommunicationUserIdentifier(someId), logger);
    assertNotNull(model.getCommunicationUser());
    assertEquals(someId, model.getCommunicationUser().getId());
}
Also used : CommunicationIdentifierModel(com.azure.android.communication.chat.implementation.models.CommunicationIdentifierModel) CommunicationUserIdentifier(com.azure.android.communication.common.CommunicationUserIdentifier) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 8 with CommunicationIdentifierModel

use of com.azure.android.communication.chat.implementation.models.CommunicationIdentifierModel in project azure-sdk-for-android by Azure.

the class CommunicationIdentifierConverterTests method deserializeUnknown.

@Test
public void deserializeUnknown() {
    CommunicationIdentifier unknownIdentifier = CommunicationIdentifierConverter.convert(new CommunicationIdentifierModel().setRawId(rawId), logger);
    assertEquals(UnknownIdentifier.class, unknownIdentifier.getClass());
    assertEquals(rawId, ((UnknownIdentifier) unknownIdentifier).getId());
}
Also used : 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 9 with CommunicationIdentifierModel

use of com.azure.android.communication.chat.implementation.models.CommunicationIdentifierModel in project azure-sdk-for-android by Azure.

the class CommunicationIdentifierConverterTests method serializeMicrosoftTeamsUser.

@ParameterizedTest
@ValueSource(booleans = { true, false })
public void serializeMicrosoftTeamsUser(boolean isAnonymous) {
    CommunicationIdentifierModel model = CommunicationIdentifierConverter.convert(new MicrosoftTeamsUserIdentifier(teamsUserId, isAnonymous).setRawId(rawId).setCloudEnvironment(CommunicationCloudEnvironment.DOD), logger);
    assertNotNull(model.getMicrosoftTeamsUser());
    assertEquals(teamsUserId, model.getMicrosoftTeamsUser().getUserId());
    assertEquals(rawId, model.getRawId());
    assertEquals(CommunicationCloudEnvironmentModel.DOD, model.getMicrosoftTeamsUser().getCloud());
    assertEquals(isAnonymous, model.getMicrosoftTeamsUser().isAnonymous());
}
Also used : MicrosoftTeamsUserIdentifier(com.azure.android.communication.common.MicrosoftTeamsUserIdentifier) CommunicationIdentifierModel(com.azure.android.communication.chat.implementation.models.CommunicationIdentifierModel) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 10 with CommunicationIdentifierModel

use of com.azure.android.communication.chat.implementation.models.CommunicationIdentifierModel 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);
        });
    });
}
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