Search in sources :

Example 1 with FileEntry

use of com.intellij.history.core.tree.FileEntry in project intellij-community by JetBrains.

the class StreamTest method testDirectoryEntryWithChildren.

@Test
public void testDirectoryEntryWithChildren() throws IOException {
    Entry dir = new DirectoryEntry("");
    Entry subDir = new DirectoryEntry("");
    dir.addChild(subDir);
    subDir.addChild(new FileEntry("a", new StoredContent(333), -1, false));
    subDir.addChild(new FileEntry("b", new StoredContent(333), -1, false));
    StreamUtil.writeEntry(os, dir);
    Entry result = StreamUtil.readEntry(is);
    List<Entry> children = result.getChildren();
    assertEquals(1, children.size());
    Entry e = children.get(0);
    assertEquals(DirectoryEntry.class, e.getClass());
    assertSame(result, e.getParent());
    children = e.getChildren();
    assertEquals(2, children.size());
    assertEquals(FileEntry.class, children.get(0).getClass());
    assertSame(e, children.get(0).getParent());
    assertEquals(FileEntry.class, children.get(1).getClass());
    assertSame(e, children.get(1).getParent());
}
Also used : DirectoryEntry(com.intellij.history.core.tree.DirectoryEntry) Entry(com.intellij.history.core.tree.Entry) RootEntry(com.intellij.history.core.tree.RootEntry) FileEntry(com.intellij.history.core.tree.FileEntry) FileEntry(com.intellij.history.core.tree.FileEntry) StoredContent(com.intellij.history.core.StoredContent) DirectoryEntry(com.intellij.history.core.tree.DirectoryEntry) Test(org.junit.Test)

Example 2 with FileEntry

use of com.intellij.history.core.tree.FileEntry in project intellij-community by JetBrains.

the class StreamTest method testDeleteChange.

@Test
public void testDeleteChange() throws IOException {
    DirectoryEntry dir = new DirectoryEntry("dir");
    dir.addChild(new FileEntry("file", new StoredContent(333), -1, false));
    dir.addChild(new DirectoryEntry("subDir"));
    Change c = new DeleteChange(nextId(), "entry", dir);
    StreamUtil.writeChange(os, c);
    Change read = StreamUtil.readChange(is);
    assertEquals(DeleteChange.class, read.getClass());
    DeleteChange result = (DeleteChange) read;
    assertEquals("entry", result.getPath());
    Entry e = result.getDeletedEntry();
    assertEquals(DirectoryEntry.class, e.getClass());
    assertEquals("dir", e.getName());
    assertEquals(2, e.getChildren().size());
    assertEquals("dir/file", e.getChildren().get(0).getPath());
    assertEquals("dir/subDir", e.getChildren().get(1).getPath());
}
Also used : DirectoryEntry(com.intellij.history.core.tree.DirectoryEntry) Entry(com.intellij.history.core.tree.Entry) RootEntry(com.intellij.history.core.tree.RootEntry) FileEntry(com.intellij.history.core.tree.FileEntry) FileEntry(com.intellij.history.core.tree.FileEntry) StoredContent(com.intellij.history.core.StoredContent) DirectoryEntry(com.intellij.history.core.tree.DirectoryEntry) Test(org.junit.Test)

Example 3 with FileEntry

use of com.intellij.history.core.tree.FileEntry in project intellij-community by JetBrains.

the class StreamTest method testDoesNotWriteEntryParent.

@Test
public void testDoesNotWriteEntryParent() throws IOException {
    Entry parent = new DirectoryEntry("");
    Entry e = new FileEntry("", new StoredContent(333), -1, false);
    parent.addChild(e);
    StreamUtil.writeEntry(os, e);
    assertNull(StreamUtil.readEntry(is).getParent());
}
Also used : DirectoryEntry(com.intellij.history.core.tree.DirectoryEntry) Entry(com.intellij.history.core.tree.Entry) RootEntry(com.intellij.history.core.tree.RootEntry) FileEntry(com.intellij.history.core.tree.FileEntry) FileEntry(com.intellij.history.core.tree.FileEntry) StoredContent(com.intellij.history.core.StoredContent) DirectoryEntry(com.intellij.history.core.tree.DirectoryEntry) Test(org.junit.Test)

Example 4 with FileEntry

use of com.intellij.history.core.tree.FileEntry in project intellij-community by JetBrains.

the class StreamTest method testFileEntry.

@Test
public void testFileEntry() throws Exception {
    Entry e = new FileEntry("file", new StoredContent(333), 123L, true);
    StreamUtil.writeEntry(os, e);
    Entry result = StreamUtil.readEntry(is);
    assertEquals(FileEntry.class, result.getClass());
    assertEquals("file", result.getName());
    assertEquals(333, ((StoredContent) result.getContent()).getContentId());
    assertEquals(123L, result.getTimestamp());
    assertTrue(result.isReadOnly());
}
Also used : DirectoryEntry(com.intellij.history.core.tree.DirectoryEntry) Entry(com.intellij.history.core.tree.Entry) RootEntry(com.intellij.history.core.tree.RootEntry) FileEntry(com.intellij.history.core.tree.FileEntry) FileEntry(com.intellij.history.core.tree.FileEntry) StoredContent(com.intellij.history.core.StoredContent) Test(org.junit.Test)

Aggregations

StoredContent (com.intellij.history.core.StoredContent)4 DirectoryEntry (com.intellij.history.core.tree.DirectoryEntry)4 Entry (com.intellij.history.core.tree.Entry)4 FileEntry (com.intellij.history.core.tree.FileEntry)4 RootEntry (com.intellij.history.core.tree.RootEntry)4 Test (org.junit.Test)4