Conversation extends ConversationHistory { public void addTextMessage(TextMessage txt) { if (mVisible) { txt.read(); } if (txt.getConversation() == null) { Log.e(TAG, "Error in conversation class... No conversation is attached to this interaction"); } if (txt.getContact() == null) { txt.setContact(getContact()); } mHistory.put(txt.getTimestamp(), txt); mDirty = true; mAggregateHistory.add(txt); updatedElementSubject.onNext(new Tuple<>(txt, ElementStatus.ADD)); } Conversation(String accountId, CallContact contact); Conference getConference(String id); void composingStatusChanged(CallContact contact, Account.ComposingStatus composing); Observable<Tuple<Interaction, ElementStatus>> getUpdatedElements(); Observable<Interaction> getLastDisplayed(); Observable<List<Interaction>> getCleared(); Observable<List<Conference>> getCalls(); Observable<Account.ComposingStatus> getComposingStatus(); void addConference(final Conference conference); void removeConference(Conference c); boolean isVisible(); void setLoaded(Single<Conversation> loaded); Single<Conversation> getLoaded(); void setVisible(boolean visible); CallContact getContact(); void addCall(SipCall call); void addTextMessage(TextMessage txt); void addRequestEvent(TrustRequest request); void addContactEvent(); void addContactEvent(ContactEvent contactEvent); void addFileTransfer(DataTransfer dataTransfer); void updateTextMessage(TextMessage text); ArrayList<Interaction> getAggregateHistory(); void sortHistory(); Single<List<Interaction>> getSortedHistory(); Interaction getLastEvent(); Conference getCurrentCall(); ArrayList<Conference> getCurrentCalls(); Collection<SipCall> getCallHistory(); TreeMap<Long, TextMessage> getUnreadTextMessages(); NavigableMap<Long, Interaction> getRawHistory(); void clearHistory(boolean delete); void setHistory(List<Interaction> loadedConversation); void addElement(Interaction interaction); void updateFileTransfer(DataTransfer transfer, Interaction.InteractionStatus eventCode); void removeInteraction(Interaction interaction); void removeAll(); void setColor(int c); Observable<Integer> getColor(); String getAccountId();  }
@Test public void addTextMessage() throws Exception { int oldSize = conversation.getAggregateHistory().size(); conversation.addTextMessage(new TextMessage(true, "Coucou", new Uri("ring:test"), "1", "Toi")); int newSize = conversation.getAggregateHistory().size(); assertEquals(0, oldSize); assertEquals(oldSize, newSize - 1); }