Search in sources :

Example 1 with IBranchLayout

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

the class BranchLayoutTestSuite method withBranchSlideOut_givenRootBranchWithChildren_slidesOut.

@Test
public void withBranchSlideOut_givenRootBranchWithChildren_slidesOut() {
    // given
    String rootName = "root";
    String childName0 = "child0";
    String childName1 = "child1";
    /*-
            root          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(rootName, /* customAnnotation */
    null, childBranches);
    val branchLayout = new BranchLayout(List.of(entry));
    // when
    IBranchLayout result = branchLayout.slideOut(rootName);
    // then
    assertEquals(result.getRootEntries().size(), 2);
    assertEquals(result.getRootEntries().get(0).getName(), childName0);
    assertEquals(result.getRootEntries().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)

Example 2 with IBranchLayout

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

the class BranchLayoutTestSuite method withBranchSlideOut_givenSingleRootBranch_slidesOut.

@Test
public void withBranchSlideOut_givenSingleRootBranch_slidesOut() {
    // given
    val rootName = "root";
    /*-
            root       slide out
                        ----->
    */
    val entry = new BranchLayoutEntry(rootName, /* customAnnotation */
    null, List.empty());
    val branchLayout = new BranchLayout(List.of(entry));
    // when
    IBranchLayout result = branchLayout.slideOut(rootName);
    // then
    assertEquals(result.getRootEntries().size(), 0);
}
Also used : lombok.val(lombok.val) BranchLayout(com.virtuslab.branchlayout.api.BranchLayout) IBranchLayout(com.virtuslab.branchlayout.api.IBranchLayout) BranchLayoutEntry(com.virtuslab.branchlayout.api.BranchLayoutEntry) IBranchLayoutEntry(com.virtuslab.branchlayout.api.IBranchLayoutEntry) IBranchLayout(com.virtuslab.branchlayout.api.IBranchLayout) Test(org.junit.Test)

Example 3 with IBranchLayout

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

the class BranchLayoutTestSuite method withBranchSlideOut_givenNonExistingBranch_noExceptionThrown.

@Test
public void withBranchSlideOut_givenNonExistingBranch_noExceptionThrown() {
    // given
    val branchToSlideOutName = "branch";
    val branchLayout = new BranchLayout(List.empty());
    // when
    IBranchLayout result = branchLayout.slideOut(branchToSlideOutName);
    // then no exception thrown
    Assert.assertTrue(result.getRootEntries().isEmpty());
}
Also used : lombok.val(lombok.val) BranchLayout(com.virtuslab.branchlayout.api.BranchLayout) IBranchLayout(com.virtuslab.branchlayout.api.IBranchLayout) IBranchLayout(com.virtuslab.branchlayout.api.IBranchLayout) Test(org.junit.Test)

Example 4 with IBranchLayout

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

the class BranchLayoutTestSuite method withBranchSlideOut_givenDuplicatedBranch_slidesOut.

@Test
public void withBranchSlideOut_givenDuplicatedBranch_slidesOut() {
    // given
    String rootName = "root";
    String branchToSlideOutName = "child";
    /*-
        root                        root
          child      slide out
          child       ----->
    */
    List<IBranchLayoutEntry> childBranches = List.of(new BranchLayoutEntry(branchToSlideOutName, /* customAnnotation */
    null, List.empty()), new BranchLayoutEntry(branchToSlideOutName, /* customAnnotation */
    null, List.empty()));
    val rootEntry = new BranchLayoutEntry(rootName, /* customAnnotation */
    null, childBranches);
    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(), 0);
}
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)

Example 5 with IBranchLayout

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

the class BranchLayoutTestSuite method withBranchSlideOut_givenDuplicatedBranchUnderItself_slidesOut.

@Test
public void withBranchSlideOut_givenDuplicatedBranchUnderItself_slidesOut() {
    // given
    String rootName = "root";
    String childName = "child";
    /*-
            root           slide out      root
              child         ----->
                child
    */
    val childBranchEntry = new BranchLayoutEntry(childName, /* customAnnotation */
    null, List.empty());
    List<IBranchLayoutEntry> childBranches = List.of(new BranchLayoutEntry(childName, /* customAnnotation */
    null, List.of(childBranchEntry)));
    val entry = new BranchLayoutEntry(rootName, /* customAnnotation */
    null, childBranches);
    val branchLayout = new BranchLayout(List.of(entry));
    // when
    IBranchLayout result = branchLayout.slideOut(childName);
    // then
    assertEquals(result.getRootEntries().size(), 1);
    assertEquals(result.getRootEntries().get(0).getName(), rootName);
    assertEquals(result.getRootEntries().get(0).getChildren().size(), 0);
}
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

IBranchLayout (com.virtuslab.branchlayout.api.IBranchLayout)11 lombok.val (lombok.val)8 Test (org.junit.Test)8 BranchLayout (com.virtuslab.branchlayout.api.BranchLayout)7 BranchLayoutEntry (com.virtuslab.branchlayout.api.BranchLayoutEntry)7 IBranchLayoutEntry (com.virtuslab.branchlayout.api.IBranchLayoutEntry)7 GitVfsUtils.getMacheteFilePath (com.virtuslab.gitmachete.frontend.vfsutils.GitVfsUtils.getMacheteFilePath)3 Path (java.nio.file.Path)3 BranchLayoutException (com.virtuslab.branchlayout.api.BranchLayoutException)1 EntryDoesNotExistException (com.virtuslab.branchlayout.api.EntryDoesNotExistException)1 EntryIsDescendantOfException (com.virtuslab.branchlayout.api.EntryIsDescendantOfException)1 GitMacheteBundle.getString (com.virtuslab.gitmachete.frontend.resourcebundles.GitMacheteBundle.getString)1 GitVfsUtils.getGitDirectoryPath (com.virtuslab.gitmachete.frontend.vfsutils.GitVfsUtils.getGitDirectoryPath)1 GitVfsUtils.getMainDirectoryPath (com.virtuslab.gitmachete.frontend.vfsutils.GitVfsUtils.getMainDirectoryPath)1 UIThreadUnsafe (com.virtuslab.qual.guieffect.UIThreadUnsafe)1 SneakyThrows (lombok.SneakyThrows)1