Search in sources :

Example 1 with DiscussionTopic

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

the class DiscussionEntryTest method initTest_UnreadChildrenOne.

@Test
public void initTest_UnreadChildrenOne() throws Exception {
    long id = 7L;
    ArrayList<Long> unreadEntries = new ArrayList<>();
    DiscussionTopic topic = new DiscussionTopic();
    DiscussionEntry parent = new DiscussionEntry();
    DiscussionEntry entry = new DiscussionEntry();
    DiscussionEntry reply = new DiscussionEntry();
    reply.setId(id);
    unreadEntries.add(id);
    topic.setUnreadEntries(unreadEntries);
    entry.addReply(reply);
    entry.init(topic, parent);
    assertEquals(1, entry.getUnreadChildren());
}
Also used : ArrayList(java.util.ArrayList) DiscussionEntry(com.instructure.canvasapi2.models.DiscussionEntry) DiscussionTopic(com.instructure.canvasapi2.models.DiscussionTopic) Test(org.junit.Test)

Example 2 with DiscussionTopic

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

the class DiscussionEntryTest method initTest_TotalChildrenZero.

@Test
public void initTest_TotalChildrenZero() throws Exception {
    DiscussionTopic topic = new DiscussionTopic();
    DiscussionEntry parent = new DiscussionEntry();
    DiscussionEntry entry = new DiscussionEntry();
    entry.init(topic, parent);
    assertEquals(0, entry.getTotalChildren());
}
Also used : DiscussionEntry(com.instructure.canvasapi2.models.DiscussionEntry) DiscussionTopic(com.instructure.canvasapi2.models.DiscussionTopic) Test(org.junit.Test)

Example 3 with DiscussionTopic

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

the class DiscussionEntryTest method initTest_TotalChildrenOne.

@Test
public void initTest_TotalChildrenOne() throws Exception {
    DiscussionTopic topic = new DiscussionTopic();
    DiscussionEntry parent = new DiscussionEntry();
    DiscussionEntry entry = new DiscussionEntry();
    DiscussionEntry reply = new DiscussionEntry();
    entry.addReply(reply);
    entry.init(topic, parent);
    assertEquals(1, entry.getTotalChildren());
}
Also used : DiscussionEntry(com.instructure.canvasapi2.models.DiscussionEntry) DiscussionTopic(com.instructure.canvasapi2.models.DiscussionTopic) Test(org.junit.Test)

Example 4 with DiscussionTopic

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

the class DiscussionTopicTest method getUnreadEntriesMap_Content.

@Test
public void getUnreadEntriesMap_Content() throws Exception {
    long id = 8L;
    DiscussionTopic topic = new DiscussionTopic();
    ArrayList<Long> unreadList = new ArrayList<>();
    unreadList.add(id);
    topic.setUnreadEntries(unreadList);
    assertEquals(id, topic.getUnreadEntriesMap().keySet().toArray()[0]);
}
Also used : ArrayList(java.util.ArrayList) DiscussionTopic(com.instructure.canvasapi2.models.DiscussionTopic) Test(org.junit.Test)

Example 5 with DiscussionTopic

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

the class DiscussionTopicTest method getUnreadEntriesMap_Size.

@Test
public void getUnreadEntriesMap_Size() throws Exception {
    DiscussionTopic topic = new DiscussionTopic();
    ArrayList<Long> unreadList = new ArrayList<>();
    unreadList.add(8L);
    unreadList.add(13435L);
    topic.setUnreadEntries(unreadList);
    assertEquals(2, topic.getUnreadEntriesMap().size());
}
Also used : ArrayList(java.util.ArrayList) DiscussionTopic(com.instructure.canvasapi2.models.DiscussionTopic) Test(org.junit.Test)

Aggregations

DiscussionTopic (com.instructure.canvasapi2.models.DiscussionTopic)8 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)5 DiscussionEntry (com.instructure.canvasapi2.models.DiscussionEntry)4 DiscussionParticipant (com.instructure.canvasapi2.models.DiscussionParticipant)2 RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)1 RestParams (com.instructure.canvasapi2.builders.RestParams)1