Search in sources :

Example 1 with CommunicationIdentifier

use of com.azure.android.communication.common.CommunicationIdentifier 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 2 with CommunicationIdentifier

use of com.azure.android.communication.common.CommunicationIdentifier 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 3 with CommunicationIdentifier

use of com.azure.android.communication.common.CommunicationIdentifier in project azure-sdk-for-android by Azure.

the class NotificationUtilsTest method canParseTeamsPublicUserRawId.

@Test
public void canParseTeamsPublicUserRawId() {
    final String teamsPublicUserRawId = "8:orgid:" + USER_ID;
    CommunicationIdentifier communicationIdentifier = NotificationUtils.getCommunicationIdentifier(teamsPublicUserRawId);
    assertNotNull(communicationIdentifier);
    assertTrue(communicationIdentifier instanceof MicrosoftTeamsUserIdentifier);
    MicrosoftTeamsUserIdentifier microsoftTeamsUserIdentifier = (MicrosoftTeamsUserIdentifier) communicationIdentifier;
    assertEquals(CommunicationCloudEnvironment.PUBLIC, microsoftTeamsUserIdentifier.getCloudEnvironment());
    assertEquals(false, microsoftTeamsUserIdentifier.isAnonymous());
    assertEquals(USER_ID, microsoftTeamsUserIdentifier.getUserId());
    assertEquals(teamsPublicUserRawId, microsoftTeamsUserIdentifier.getRawId());
}
Also used : MicrosoftTeamsUserIdentifier(com.azure.android.communication.common.MicrosoftTeamsUserIdentifier) CommunicationIdentifier(com.azure.android.communication.common.CommunicationIdentifier) Test(org.junit.jupiter.api.Test)

Example 4 with CommunicationIdentifier

use of com.azure.android.communication.common.CommunicationIdentifier in project azure-sdk-for-android by Azure.

the class NotificationUtilsTest method canParseAcsGcchUserRawId.

@Test
public void canParseAcsGcchUserRawId() {
    final String acsUserRawId = "8:gcch-acs:" + USER_ID;
    CommunicationIdentifier communicationIdentifier = NotificationUtils.getCommunicationIdentifier(acsUserRawId);
    assertNotNull(communicationIdentifier);
    assertTrue(communicationIdentifier instanceof CommunicationUserIdentifier);
    CommunicationUserIdentifier communicationUserIdentifier = (CommunicationUserIdentifier) communicationIdentifier;
    assertEquals(acsUserRawId, communicationUserIdentifier.getId());
}
Also used : CommunicationIdentifier(com.azure.android.communication.common.CommunicationIdentifier) CommunicationUserIdentifier(com.azure.android.communication.common.CommunicationUserIdentifier) Test(org.junit.jupiter.api.Test)

Example 5 with CommunicationIdentifier

use of com.azure.android.communication.common.CommunicationIdentifier in project azure-sdk-for-android by Azure.

the class NotificationUtilsTest method canParseSpoolUserRawId.

@Test
public void canParseSpoolUserRawId() {
    final String spoolUserRawId = "8:spool:" + USER_ID;
    CommunicationIdentifier communicationIdentifier = NotificationUtils.getCommunicationIdentifier(spoolUserRawId);
    assertNotNull(communicationIdentifier);
    assertTrue(communicationIdentifier instanceof CommunicationUserIdentifier);
    CommunicationUserIdentifier communicationUserIdentifier = (CommunicationUserIdentifier) communicationIdentifier;
    assertEquals(spoolUserRawId, communicationUserIdentifier.getId());
}
Also used : CommunicationIdentifier(com.azure.android.communication.common.CommunicationIdentifier) CommunicationUserIdentifier(com.azure.android.communication.common.CommunicationUserIdentifier) Test(org.junit.jupiter.api.Test)

Aggregations

CommunicationIdentifier (com.azure.android.communication.common.CommunicationIdentifier)21 Test (org.junit.jupiter.api.Test)13 JSONException (org.json.JSONException)8 JSONObject (org.json.JSONObject)8 CommunicationUserIdentifier (com.azure.android.communication.common.CommunicationUserIdentifier)4 MicrosoftTeamsUserIdentifier (com.azure.android.communication.common.MicrosoftTeamsUserIdentifier)4 CommunicationIdentifierModel (com.azure.android.communication.chat.implementation.models.CommunicationIdentifierModel)3 JSONArray (org.json.JSONArray)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 CommunicationUserIdentifierModel (com.azure.android.communication.chat.implementation.models.CommunicationUserIdentifierModel)1 PhoneNumberIdentifierModel (com.azure.android.communication.chat.implementation.models.PhoneNumberIdentifierModel)1 PhoneNumberIdentifier (com.azure.android.communication.common.PhoneNumberIdentifier)1 UnknownIdentifier (com.azure.android.communication.common.UnknownIdentifier)1