Search in sources :

Example 6 with Change

use of org.eclipse.egit.core.synchronize.GitCommitsModelCache.Change in project egit by eclipse.

the class GitModelCacheFileTest method createCacheFile.

private GitModelCacheFile createCacheFile(ObjectId repoId, ObjectId cacheId, IPath location) throws Exception {
    Change change = mock(Change.class);
    when(change.getObjectId()).thenReturn(AbbreviatedObjectId.fromObjectId(cacheId));
    when(change.getRemoteObjectId()).thenReturn(AbbreviatedObjectId.fromObjectId(repoId));
    return new GitModelCacheFile(createModelCommit(), lookupRepository(leftRepoFile), change, location);
}
Also used : Change(org.eclipse.egit.core.synchronize.GitCommitsModelCache.Change)

Example 7 with Change

use of org.eclipse.egit.core.synchronize.GitCommitsModelCache.Change in project egit by eclipse.

the class ChangeTest method shouldBeEqualWhenBothObjectIdsAreTheSame.

@Test
public void shouldBeEqualWhenBothObjectIdsAreTheSame() {
    // given
    Change c1 = new Change();
    Change c2 = new Change();
    c1.objectId = c2.objectId = MISC_ID;
    // when
    boolean result = c1.equals(c2);
    // then
    assertTrue(result);
    assertEquals(c1.hashCode(), c2.hashCode());
}
Also used : Change(org.eclipse.egit.core.synchronize.GitCommitsModelCache.Change) Test(org.junit.Test)

Example 8 with Change

use of org.eclipse.egit.core.synchronize.GitCommitsModelCache.Change in project egit by eclipse.

the class ChangeTest method shouldNotBeEqualWhenObjectIdsAreDifferent.

@Test
public void shouldNotBeEqualWhenObjectIdsAreDifferent() {
    // given
    Change c1 = new Change();
    Change c2 = new Change();
    c1.objectId = ZERO_ID;
    c2.objectId = MISC_ID;
    // when
    boolean result = c1.equals(c2);
    // then
    assertFalse(result);
    assertFalse(c1.hashCode() == c2.hashCode());
}
Also used : Change(org.eclipse.egit.core.synchronize.GitCommitsModelCache.Change) Test(org.junit.Test)

Example 9 with Change

use of org.eclipse.egit.core.synchronize.GitCommitsModelCache.Change in project egit by eclipse.

the class ChangeTest method shouldNotBeEqualWithDifferentType.

@Test
public void shouldNotBeEqualWithDifferentType() {
    // given
    Change change = new Change();
    // when
    boolean result = change.equals(new Object());
    // then
    assertFalse(result);
}
Also used : Change(org.eclipse.egit.core.synchronize.GitCommitsModelCache.Change) Test(org.junit.Test)

Example 10 with Change

use of org.eclipse.egit.core.synchronize.GitCommitsModelCache.Change in project egit by eclipse.

the class ChangeTest method shouldNotBeEqualWhenOneObjectIdIsNull.

@Test
public void shouldNotBeEqualWhenOneObjectIdIsNull() {
    // given
    Change change = new Change();
    change.objectId = ZERO_ID;
    // when
    boolean result = change.equals(new Change());
    // then
    assertFalse(result);
}
Also used : Change(org.eclipse.egit.core.synchronize.GitCommitsModelCache.Change) Test(org.junit.Test)

Aggregations

Change (org.eclipse.egit.core.synchronize.GitCommitsModelCache.Change)35 Test (org.junit.Test)29 Git (org.eclipse.jgit.api.Git)21 HashMap (java.util.HashMap)3 Repository (org.eclipse.jgit.lib.Repository)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 IPath (org.eclipse.core.runtime.IPath)2 DirCacheIterator (org.eclipse.jgit.dircache.DirCacheIterator)2 MutableObjectId (org.eclipse.jgit.lib.MutableObjectId)2 TreeWalk (org.eclipse.jgit.treewalk.TreeWalk)2 Map (java.util.Map)1 Path (org.eclipse.core.runtime.Path)1 FileModelFactory (org.eclipse.egit.ui.internal.synchronize.model.TreeBuilder.FileModelFactory)1 TreeModelFactory (org.eclipse.egit.ui.internal.synchronize.model.TreeBuilder.TreeModelFactory)1 AbbreviatedObjectId (org.eclipse.jgit.lib.AbbreviatedObjectId)1 ObjectId (org.eclipse.jgit.lib.ObjectId)1 RevCommit (org.eclipse.jgit.revwalk.RevCommit)1 RevWalk (org.eclipse.jgit.revwalk.RevWalk)1 EmptyTreeIterator (org.eclipse.jgit.treewalk.EmptyTreeIterator)1