Search in sources :

Example 1 with BranchLayout

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

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

the class BranchLayoutFileReaderTestSuite method read_givenCorrectFile_reads.

@Test
@SneakyThrows
public void read_givenCorrectFile_reads() {
    // given
    List<String> linesToReturn = List.of(" ", "A", " B", "C", "");
    BranchLayoutFileReader reader = getBranchLayoutFileReaderForLines(linesToReturn, /* indentWidth */
    1);
    // when
    BranchLayout branchLayout = reader.read(path);
    // then
    Assert.assertTrue(branchLayout.findEntryByName("A").isDefined());
    Assert.assertTrue(branchLayout.findEntryByName("B").isDefined());
    Assert.assertTrue(branchLayout.findEntryByName("C").isDefined());
    Assert.assertEquals(2, 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 3 with BranchLayout

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

the class BranchLayoutFileReaderTestSuite method read_givenCorrectFileWithRootsOnly_reads.

@Test
@SneakyThrows
public void read_givenCorrectFileWithRootsOnly_reads() {
    // given
    List<String> linesToReturn = List.of("A", " ", "B");
    BranchLayoutFileReader reader = getBranchLayoutFileReaderForLines(linesToReturn, /* indentWidth */
    1);
    // when
    BranchLayout branchLayout = reader.read(path);
    // then
    Assert.assertTrue(branchLayout.findEntryByName("A").isDefined());
    Assert.assertTrue(branchLayout.findEntryByName("B").isDefined());
    Assert.assertEquals(2, 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 4 with BranchLayout

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

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

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