Search in sources :

Example 11 with Recipient

use of com.instructure.canvasapi2.models.Recipient in project instructure-android by instructure.

the class ChooseMessageRecipientRecyclerAdapterTest method testAreContentsTheSame_DifferentName.

@Test
public void testAreContentsTheSame_DifferentName() {
    Recipient recipient1 = new Recipient("", "name", 0, 0, 0);
    Recipient recipient2 = new Recipient("", "hodor", 0, 0, 0);
    assertFalse(mAdapter.getItemCallback().areContentsTheSame(recipient1, recipient2));
}
Also used : Recipient(com.instructure.canvasapi2.models.Recipient) Test(org.junit.Test)

Example 12 with Recipient

use of com.instructure.canvasapi2.models.Recipient in project instructure-android by instructure.

the class RecipientManager method searchAllRecipients.

public static void searchAllRecipients(final boolean forceNetwork, String searchQuery, String context, StatusCallback<List<Recipient>> callback) {
    if (isTesting() || mTesting) {
    // TODO...
    } else {
        final RestBuilder adapter = new RestBuilder(callback);
        StatusCallback<List<Recipient>> depaginatedCallback = new ExhaustiveListCallback<Recipient>(callback) {

            @Override
            public void getNextPage(@NonNull StatusCallback<List<Recipient>> callback, @NonNull String nextUrl, boolean isCached) {
                RecipientAPI.getNextPageRecipients(forceNetwork, nextUrl, adapter, callback);
            }
        };
        adapter.setStatusCallback(depaginatedCallback);
        RecipientAPI.getFirstPageRecipients(forceNetwork, searchQuery, context, adapter, depaginatedCallback);
    }
}
Also used : NonNull(android.support.annotation.NonNull) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) List(java.util.List) StatusCallback(com.instructure.canvasapi2.StatusCallback) Recipient(com.instructure.canvasapi2.models.Recipient) ExhaustiveListCallback(com.instructure.canvasapi2.utils.ExhaustiveListCallback)

Example 13 with Recipient

use of com.instructure.canvasapi2.models.Recipient in project instructure-android by instructure.

the class RecipientTest method getRecipientTypeTest_Person.

@Test
public void getRecipientTypeTest_Person() throws Exception {
    Recipient recipient = new Recipient();
    recipient.setStringId("1234567");
    assertEquals(Recipient.Type.person, recipient.getRecipientType());
}
Also used : Recipient(com.instructure.canvasapi2.models.Recipient) Test(org.junit.Test)

Example 14 with Recipient

use of com.instructure.canvasapi2.models.Recipient in project instructure-android by instructure.

the class RecipientTest method getIdAsLongTest_Number.

@Test
public void getIdAsLongTest_Number() throws Exception {
    Recipient recipient = new Recipient();
    recipient.setStringId("123456789");
    assertEquals(123456789, recipient.getIdAsLong());
}
Also used : Recipient(com.instructure.canvasapi2.models.Recipient) Test(org.junit.Test)

Example 15 with Recipient

use of com.instructure.canvasapi2.models.Recipient in project instructure-android by instructure.

the class RecipientTest method getRecipientTypeTest_MetaGroup.

@Test
public void getRecipientTypeTest_MetaGroup() throws Exception {
    Recipient recipient = new Recipient();
    recipient.setStringId("not_a_person_or_group");
    recipient.setUserCount(0);
    assertEquals(Recipient.Type.metagroup, recipient.getRecipientType());
}
Also used : Recipient(com.instructure.canvasapi2.models.Recipient) Test(org.junit.Test)

Aggregations

Recipient (com.instructure.canvasapi2.models.Recipient)14 Test (org.junit.Test)9 RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)7 RestParams (com.instructure.canvasapi2.builders.RestParams)4 NonNull (android.support.annotation.NonNull)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 RecipientEntry (com.android.ex.chips.RecipientEntry)2 StatusCallback (com.instructure.canvasapi2.StatusCallback)2 ExhaustiveListCallback (com.instructure.canvasapi2.utils.ExhaustiveListCallback)2 Context (android.content.Context)1 Resources (android.content.res.Resources)1 Bitmap (android.graphics.Bitmap)1 Paint (android.graphics.Paint)1 Rfc822Tokenizer (android.text.util.Rfc822Tokenizer)1 CanvasContext (com.instructure.canvasapi2.models.CanvasContext)1 Enrollment (com.instructure.canvasapi2.models.Enrollment)1 User (com.instructure.canvasapi2.models.User)1 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)1 RecipientAdapter (com.instructure.teacher.adapters.RecipientAdapter)1