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);
}
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);
}
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);
}
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());
}
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);
}
Aggregations