コード例 #1
1
  public void testRestoreFromBundleTooManyConversationId() {
    Bundle bundle = new Bundle();

    ArrayList<Conversation> conversations = new ArrayList<Conversation>(TWELVE);
    ArrayList<ConversationId> conversationIds = new ArrayList<ConversationId>(TWELVE + 1);

    bundle.putParcelableArrayList(CONVERSATION_ID, conversationIds);
    bundle.putParcelableArrayList(CONVERSATION, conversations);

    mDialogueData.restoreFromBundle(bundle);

    // nothing should happen
  }
コード例 #2
0
  public void testDeleteAll() {
    Contact contact1 = Mockito.mock(Contact.class);
    Contact contact2 = Mockito.mock(Contact.class);

    mDialogueData.createOrGetConversation(contact1);
    mDialogueData.createOrGetConversation(contact2);

    assertFalse(0 == mDialogueData.getConversations().size());

    mDialogueData.removeAllConversations();

    assertTrue(0 == mDialogueData.getConversations().size());
  }
コード例 #3
0
 public void testRestoreFromNullBundle() {
   try {
     mDialogueData.restoreFromBundle(null);
     fail("NullArgumentException expected");
   } catch (NullArgumentException e) {
     // all good :)
   }
 }
コード例 #4
0
 public void testRemoveNullListener() {
   try {
     mDialogueData.removeListener(null);
     fail("NullArgumentException expected");
   } catch (NullArgumentException e) {
     // all good :)
   }
 }
コード例 #5
0
 public void testAddNullMessageToConversation() {
   try {
     mDialogueData.addMessageToConversation(null);
     fail("NullArgumentException expected");
   } catch (NullArgumentException e) {
     // all good :)
   }
 }
コード例 #6
0
 public void testGetNullConversation() {
   try {
     mDialogueData.getConversation(null);
     fail("NullArgumentException expected");
   } catch (NullArgumentException e) {
     // all good :)
   }
 }
コード例 #7
0
  public void testUpdateConversation() {
    Contact contact1 = Mockito.mock(Contact.class);

    Conversation conversationBefore = mDialogueData.createOrGetConversation(contact1);
    assertNull(conversationBefore.getChannel());

    conversationBefore.setChannel(ChannelType.SMS);

    mDialogueData.updateConversation(conversationBefore);

    Conversation conversationAfter = mDialogueData.createOrGetConversation(contact1);
    assertNotNull(conversationAfter.getChannel());
    assertEquals(ChannelType.SMS, conversationAfter.getChannel());

    mDialogueData.removeConversation(conversationBefore.getId());
    mDialogueData.removeConversation(conversationAfter.getId());
  }
コード例 #8
0
 public void testUpdateConversationNull() {
   try {
     mDialogueData.updateConversation(null);
     fail();
   } catch (NullArgumentException e) {
     // OK
   }
 }
コード例 #9
0
  public void testRestoreFromBundleNullConversationId() {
    Bundle bundle = new Bundle();

    bundle.putParcelableArrayList(CONVERSATION_ID, null);

    mDialogueData.restoreFromBundle(bundle);

    // nothing should happen
  }
コード例 #10
0
  public void testRemoveNonAddedListener() {
    mDialogueData.removeListener(
        new DialogueDataListener() {
          @Override
          public void onDialogueDataChanged() {
            // we don't care :)
          }
        });

    // nothing should happen :)
  }