use of com.virtuslab.gitcore.api.IGitCoreLocalBranchSnapshot in project git-machete-intellij-plugin by VirtusLab.
the class GitMacheteRepository_deriveParentAwareForkPointUnitTestSuite method parentIsNotAncestorOfForkPointAndParentIsAncestorOfChild.
@Test
@SneakyThrows
public void parentIsNotAncestorOfForkPointAndParentIsAncestorOfChild() {
// given
IGitCoreCommit forkPointCommit = createGitCoreCommit();
IGitCoreCommit parentCommit = createGitCoreCommit();
IGitCoreCommit childCommit = createGitCoreCommit();
IGitCoreLocalBranchSnapshot parentBranch = createGitCoreLocalBranch(parentCommit);
IGitCoreLocalBranchSnapshot childBranch = createGitCoreLocalBranch(childCommit);
PowerMockito.doReturn(Stream.of(forkPointCommit)).when(gitCoreRepository).ancestorsOf(childCommit);
PowerMockito.doReturn(false).when(gitCoreRepository).isAncestorOrEqual(parentCommit, forkPointCommit);
PowerMockito.doReturn(true).when(gitCoreRepository).isAncestorOrEqual(parentCommit, childCommit);
// when
Option<IGitCoreCommit> result = invokeDeriveParentAwareForkPoint(childBranch, parentBranch);
// then
Assert.assertTrue(result.isDefined());
Assert.assertEquals(parentCommit, result.get());
}
use of com.virtuslab.gitcore.api.IGitCoreLocalBranchSnapshot in project git-machete-intellij-plugin by VirtusLab.
the class GitMacheteRepository_deriveSyncToParentStatusUnitTestSuite method branchAndParentPointingSameCommitAndBranchNotJustCreated_merged.
@Test
public void branchAndParentPointingSameCommitAndBranchNotJustCreated_merged() {
// given
IGitCoreCommit commit = createGitCoreCommit();
IGitCoreLocalBranchSnapshot parentBranch = createGitCoreLocalBranch(commit);
IGitCoreLocalBranchSnapshot childBranch = createGitCoreLocalBranch(commit, new TestGitCoreReflogEntry());
// when
SyncToParentStatus syncToParentStatus = invokeDeriveSyncToParentStatus(childBranch, parentBranch, MISSING_FORK_POINT);
// then
Assert.assertEquals(SyncToParentStatus.MergedToParent, syncToParentStatus);
}
use of com.virtuslab.gitcore.api.IGitCoreLocalBranchSnapshot in project git-machete-intellij-plugin by VirtusLab.
the class GitMacheteRepository_deriveSyncToParentStatusUnitTestSuite method branchPointedCommitIsAncestorOfParentPointedCommit_merged.
@Test
@SneakyThrows
public void branchPointedCommitIsAncestorOfParentPointedCommit_merged() {
// given
IGitCoreCommit childCommit = createGitCoreCommit();
IGitCoreCommit parentCommit = createGitCoreCommit();
IGitCoreLocalBranchSnapshot childBranch = createGitCoreLocalBranch(childCommit);
IGitCoreLocalBranchSnapshot parentBranch = createGitCoreLocalBranch(parentCommit);
PowerMockito.doReturn(false).when(gitCoreRepository).isAncestorOrEqual(parentCommit, childCommit);
PowerMockito.doReturn(true).when(gitCoreRepository).isAncestorOrEqual(childCommit, parentCommit);
// when
SyncToParentStatus syncToParentStatus = invokeDeriveSyncToParentStatus(childBranch, parentBranch, MISSING_FORK_POINT);
// then
Assert.assertEquals(SyncToParentStatus.OutOfSync, syncToParentStatus);
}
use of com.virtuslab.gitcore.api.IGitCoreLocalBranchSnapshot in project git-machete-intellij-plugin by VirtusLab.
the class GitMacheteRepository_deriveSyncToParentStatusUnitTestSuite method branchAndParentPointingSameCommitAndBranchJustCreated_inSync.
@Test
public void branchAndParentPointingSameCommitAndBranchJustCreated_inSync() {
// given
IGitCoreCommit commit = createGitCoreCommit();
IGitCoreLocalBranchSnapshot parentBranch = createGitCoreLocalBranch(commit);
IGitCoreLocalBranchSnapshot childBranch = createGitCoreLocalBranch(commit);
// when
SyncToParentStatus syncToParentStatus = invokeDeriveSyncToParentStatus(childBranch, parentBranch, MISSING_FORK_POINT);
// then
Assert.assertEquals(SyncToParentStatus.InSync, syncToParentStatus);
}
use of com.virtuslab.gitcore.api.IGitCoreLocalBranchSnapshot in project git-machete-intellij-plugin by VirtusLab.
the class UnitTestUtils method createGitCoreLocalBranch.
@SneakyThrows
static IGitCoreLocalBranchSnapshot createGitCoreLocalBranch(IGitCoreCommit pointedCommit, IGitCoreReflogEntry... reflogEntries) {
IGitCoreLocalBranchSnapshot mock = PowerMockito.mock(IGitCoreLocalBranchSnapshot.class);
PowerMockito.doReturn(String.valueOf(counter.incrementAndGet())).when(mock).getFullName();
PowerMockito.doReturn(pointedCommit).when(mock).getPointedCommit();
PowerMockito.doReturn(List.ofAll(Stream.of(reflogEntries))).when(mock).getReflogFromMostRecent();
PowerMockito.doReturn(Option.none()).when(mock).getRemoteTrackingBranch();
return mock;
}
Aggregations