Search in sources :

Example 6 with IBranchLayoutEntry

use of com.virtuslab.branchlayout.api.IBranchLayoutEntry in project git-machete-intellij-plugin by VirtusLab.

the class BranchLayoutTestSuite method withBranchSlideOut_givenNonRootExistingBranch_slidesOut.

@Test
public void withBranchSlideOut_givenNonRootExistingBranch_slidesOut() {
    // given
    String rootName = "root";
    String branchToSlideOutName = "parent";
    String childName0 = "child0";
    String childName1 = "child1";
    /*-
        root                          root
          parent       slide out
            child0      ----->          child0
            child1                      child1
    */
    List<IBranchLayoutEntry> childBranches = List.of(new BranchLayoutEntry(childName0, /* customAnnotation */
    null, List.empty()), new BranchLayoutEntry(childName1, /* customAnnotation */
    null, List.empty()));
    val entry = new BranchLayoutEntry(branchToSlideOutName, /* customAnnotation */
    null, childBranches);
    val rootEntry = new BranchLayoutEntry(rootName, /* customAnnotation */
    null, List.of(entry));
    val branchLayout = new BranchLayout(List.of(rootEntry));
    // when
    IBranchLayout result = branchLayout.slideOut(branchToSlideOutName);
    // then
    assertEquals(result.getRootEntries().size(), 1);
    assertEquals(result.getRootEntries().get(0).getName(), rootName);
    val children = result.getRootEntries().get(0).getChildren();
    assertEquals(children.size(), 2);
    assertEquals(children.get(0).getName(), childName0);
    assertEquals(children.get(1).getName(), childName1);
}
Also used : lombok.val(lombok.val) BranchLayout(com.virtuslab.branchlayout.api.BranchLayout) IBranchLayout(com.virtuslab.branchlayout.api.IBranchLayout) IBranchLayoutEntry(com.virtuslab.branchlayout.api.IBranchLayoutEntry) BranchLayoutEntry(com.virtuslab.branchlayout.api.BranchLayoutEntry) IBranchLayoutEntry(com.virtuslab.branchlayout.api.IBranchLayoutEntry) IBranchLayout(com.virtuslab.branchlayout.api.IBranchLayout) Test(org.junit.Test)

Aggregations

BranchLayoutEntry (com.virtuslab.branchlayout.api.BranchLayoutEntry)6 IBranchLayoutEntry (com.virtuslab.branchlayout.api.IBranchLayoutEntry)6 IBranchLayout (com.virtuslab.branchlayout.api.IBranchLayout)5 lombok.val (lombok.val)5 BranchLayout (com.virtuslab.branchlayout.api.BranchLayout)4 Test (org.junit.Test)4 EntryDoesNotExistException (com.virtuslab.branchlayout.api.EntryDoesNotExistException)1 EntryIsDescendantOfException (com.virtuslab.branchlayout.api.EntryIsDescendantOfException)1 GitVfsUtils.getMacheteFilePath (com.virtuslab.gitmachete.frontend.vfsutils.GitVfsUtils.getMacheteFilePath)1 UIThreadUnsafe (com.virtuslab.qual.guieffect.UIThreadUnsafe)1 Path (java.nio.file.Path)1