@Test public void retrieveNonIndexedChat_ShouldAddNewIndexEntryAfterRetrievalAttempt() { FolderIndexMock folderIndex = new FolderIndexMock(); IndexedSkypeMailFolder indexedGmailFolder_SUBJECT = createIndexedSkypeMailFolder(folderIndex); SkypeChat nonIndexedSkypeChat = SkypeApiMock.produceChatMock("#is-not-indexed", "not", "indexed"); Assert.assertNull(folderIndex.getSignatureFor("#is-not-indexed")); indexedGmailFolder_SUBJECT.retrieveMessageEntryFor(nonIndexedSkypeChat); String sig = folderIndex.getSignatureFor("#is-not-indexed"); Assert.assertEquals(nonIndexedSkypeChat.getBodySignature(), sig); }
@Test public void testMergeWithTwoEquivalentMessages() { SkypeChatBuilderHelper chatHelper = new SkypeChatBuilderHelper() { @Override public void addChatMessages() { addMessage("joe", "m1", "21/03 15:15:18"); addMessage("joe", "m2", "21/03 15:17:18"); addMessage("foo", "C", "21/03 15:24:18"); addMessage("joe", "m6", "22/03 15:24:18"); addMessage("foo", "D", "22/03 16:24:18"); addMessage("moe", "m9", "22/03 16:25:20"); } }; SkypeChat chatA = chatHelper.getChat("toUpdate", "FOO"); SkypeChatBuilderHelper chatFromOtherSource = new SkypeChatBuilderHelper() { @Override public void addChatMessages() { addMessage("moe", "m5", "22/03 15:16:20"); addMessage("foo", "C", "22/03 15:24:18"); addMessage("moe", "m7", "22/03 15:30:22"); addMessage("foo", "D", "23/03 16:24:18"); addMessage("moe", "m10", "23/03 16:25:20"); } }; SkypeChat chatB = chatFromOtherSource.getChat("toUpdate", "FOO"); String expected = "[2011/03/21 15:15:18] JOE: m1\n" + "[2011/03/21 15:16:20] MOE: m5\n" + "[2011/03/21 15:17:18] JOE: m2\n" + "[2011/03/21 15:24:18] FOO: C\n" + "[2011/03/21 15:30:22] MOE: m7\n" + "[2011/03/22 15:24:18] JOE: m6\n" + "[2011/03/22 16:24:18] FOO: D\n" + "[2011/03/22 16:25:20] MOE: m9\n" + "[2011/03/23 16:25:20] MOE: m10"; assertMergeEnsuringCommutativeProperty( chatA.getChatMessages(), chatB.getChatMessages(), expected); }
@Test public void testMergeListWithoutCommonMessages() { SkypeChatBuilderHelper chatHelper = new SkypeChatBuilderHelper() { @Override public void addChatMessages() { addMessage("joe", "m1", "21/03 15:15:18"); addMessage("moe", "m2", "21/03 15:24:18"); addMessage("joe", "m3", "22/03 15:24:18"); } }; SkypeChat chatA = chatHelper.getChat("toUpdate", "FOO"); SkypeChatBuilderHelper chatFromOtherSource = new SkypeChatBuilderHelper() { @Override public void addChatMessages() { addMessage("cloe", "m1.5", "21/03 15:15:19"); addMessage("joe", "m5", "22/03 15:24:20"); addMessage("moe", "m6", "22/03 15:24:22"); } }; SkypeChat chatB = chatFromOtherSource.getChat("toUpdate", "FOO"); String expected = "[2011/03/21 15:15:18] JOE: m1\n" + "[2011/03/21 15:15:19] CLOE: m1.5\n" + "[2011/03/21 15:24:18] MOE: m2\n" + "[2011/03/22 15:24:18] JOE: m3\n" + "[2011/03/22 15:24:20] JOE: m5\n" + "[2011/03/22 15:24:22] MOE: m6"; assertMergeEnsuringCommutativeProperty( chatA.getChatMessages(), chatB.getChatMessages(), expected); }
public FileSystemStorageEntry(SkypeChat chat, File basedir) { this.chat = chat; String preparedFileName = getFilenameFor(chat.getId()); this.entryFile = new File(basedir, preparedFileName); }