Search in sources :

Example 1 with IGitCoreCommit

use of com.virtuslab.gitcore.api.IGitCoreCommit 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());
}
Also used : IGitCoreCommit(com.virtuslab.gitcore.api.IGitCoreCommit) IGitCoreLocalBranchSnapshot(com.virtuslab.gitcore.api.IGitCoreLocalBranchSnapshot) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 2 with IGitCoreCommit

use of com.virtuslab.gitcore.api.IGitCoreCommit 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);
}
Also used : TestGitCoreReflogEntry(com.virtuslab.gitmachete.backend.unit.UnitTestUtils.TestGitCoreReflogEntry) IGitCoreCommit(com.virtuslab.gitcore.api.IGitCoreCommit) SyncToParentStatus(com.virtuslab.gitmachete.backend.api.SyncToParentStatus) IGitCoreLocalBranchSnapshot(com.virtuslab.gitcore.api.IGitCoreLocalBranchSnapshot) Test(org.junit.Test)

Example 3 with IGitCoreCommit

use of com.virtuslab.gitcore.api.IGitCoreCommit 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);
}
Also used : IGitCoreCommit(com.virtuslab.gitcore.api.IGitCoreCommit) SyncToParentStatus(com.virtuslab.gitmachete.backend.api.SyncToParentStatus) IGitCoreLocalBranchSnapshot(com.virtuslab.gitcore.api.IGitCoreLocalBranchSnapshot) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 4 with IGitCoreCommit

use of com.virtuslab.gitcore.api.IGitCoreCommit 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);
}
Also used : IGitCoreCommit(com.virtuslab.gitcore.api.IGitCoreCommit) SyncToParentStatus(com.virtuslab.gitmachete.backend.api.SyncToParentStatus) IGitCoreLocalBranchSnapshot(com.virtuslab.gitcore.api.IGitCoreLocalBranchSnapshot) Test(org.junit.Test)

Example 5 with IGitCoreCommit

use of com.virtuslab.gitcore.api.IGitCoreCommit in project git-machete-intellij-plugin by VirtusLab.

the class GitMacheteRepository_deriveParentAwareForkPointUnitTestSuite method parentAgnosticForkPointIsMissingAndParentIsNotAncestorOfChild.

@Test
@SneakyThrows
public void parentAgnosticForkPointIsMissingAndParentIsNotAncestorOfChild() {
    // given
    IGitCoreCommit childCommit = createGitCoreCommit();
    IGitCoreCommit parentCommit = createGitCoreCommit();
    IGitCoreLocalBranchSnapshot childBranch = createGitCoreLocalBranch(childCommit);
    IGitCoreLocalBranchSnapshot parentBranch = createGitCoreLocalBranch(parentCommit);
    PowerMockito.doReturn(Stream.empty()).when(gitCoreRepository).ancestorsOf(childCommit);
    PowerMockito.doReturn(false).when(gitCoreRepository).isAncestorOrEqual(parentCommit, childCommit);
    // when
    Option<IGitCoreCommit> result = invokeDeriveParentAwareForkPoint(childBranch, parentBranch);
    // then
    Assert.assertTrue(result.isEmpty());
}
Also used : IGitCoreCommit(com.virtuslab.gitcore.api.IGitCoreCommit) IGitCoreLocalBranchSnapshot(com.virtuslab.gitcore.api.IGitCoreLocalBranchSnapshot) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Aggregations

IGitCoreCommit (com.virtuslab.gitcore.api.IGitCoreCommit)10 IGitCoreLocalBranchSnapshot (com.virtuslab.gitcore.api.IGitCoreLocalBranchSnapshot)9 Test (org.junit.Test)9 SneakyThrows (lombok.SneakyThrows)7 SyncToParentStatus (com.virtuslab.gitmachete.backend.api.SyncToParentStatus)6 GitCoreException (com.virtuslab.gitcore.api.GitCoreException)1 TestGitCoreReflogEntry (com.virtuslab.gitmachete.backend.unit.UnitTestUtils.TestGitCoreReflogEntry)1 ObjectId (org.eclipse.jgit.lib.ObjectId)1 RevWalk (org.eclipse.jgit.revwalk.RevWalk)1