Search in sources :

Example 6 with BranchLayout

use of com.virtuslab.branchlayout.api.BranchLayout 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 7 with BranchLayout

use of com.virtuslab.branchlayout.api.BranchLayout 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)

Example 8 with BranchLayout

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

the class BranchLayoutTestSuite method withBranchSlideOut_givenTwoRootBranches_slidesOut.

@Test
public void withBranchSlideOut_givenTwoRootBranches_slidesOut() {
    // given
    val rootName = "root";
    val masterRootName = "master";
    /*-
            root        slide out      master
            master       ----->
    */
    val entry = new BranchLayoutEntry(rootName, /* customAnnotation */
    null, List.empty());
    val masterEntry = new BranchLayoutEntry(masterRootName, /* customAnnotation */
    null, List.empty());
    val branchLayout = new BranchLayout(List.of(entry, masterEntry));
    // when
    IBranchLayout result = branchLayout.slideOut(rootName);
    // then
    assertEquals(result.getRootEntries().size(), 1);
    assertEquals(result.getRootEntries().get(0).getName(), masterRootName);
}
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 9 with BranchLayout

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

the class BranchLayoutFileReaderTestSuite method read_givenEmptyFile_reads.

@Test
@SneakyThrows
public void read_givenEmptyFile_reads() {
    // given
    List<String> linesToReturn = List.empty();
    BranchLayoutFileReader reader = getBranchLayoutFileReaderForLines(linesToReturn, /* indentWidth */
    1);
    // when
    BranchLayout branchLayout = reader.read(path);
    // then no exception thrown
    Assert.assertEquals(0, branchLayout.getRootEntries().size());
}
Also used : BranchLayout(com.virtuslab.branchlayout.api.BranchLayout) BranchLayoutFileReader(com.virtuslab.branchlayout.impl.readwrite.BranchLayoutFileReader) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) SneakyThrows(lombok.SneakyThrows)

Example 10 with BranchLayout

use of com.virtuslab.branchlayout.api.BranchLayout 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

BranchLayout (com.virtuslab.branchlayout.api.BranchLayout)10 Test (org.junit.Test)10 IBranchLayout (com.virtuslab.branchlayout.api.IBranchLayout)7 lombok.val (lombok.val)7 BranchLayoutEntry (com.virtuslab.branchlayout.api.BranchLayoutEntry)6 IBranchLayoutEntry (com.virtuslab.branchlayout.api.IBranchLayoutEntry)6 BranchLayoutFileReader (com.virtuslab.branchlayout.impl.readwrite.BranchLayoutFileReader)3 SneakyThrows (lombok.SneakyThrows)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3